Skip to content

Commit

Permalink
fix(parser): REGCLASS and REGPROC shouldn't be keyword (#16933)
Browse files Browse the repository at this point in the history
Signed-off-by: TennyZhuang <[email protected]>
  • Loading branch information
TennyZhuang authored May 24, 2024
1 parent c40e4f8 commit 6b362ad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
2 changes: 0 additions & 2 deletions src/sqlparser/src/keywords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,7 @@ define_keywords!(
REFERENCES,
REFERENCING,
REFRESH,
REGCLASS,
REGISTRY,
REGPROC,
REGR_AVGX,
REGR_AVGY,
REGR_COUNT,
Expand Down
19 changes: 9 additions & 10 deletions src/sqlparser/src/parser_v2/data_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,6 @@ where
Keyword::TIME => with_time_zone().map(DataType::Time),
// TODO: Support complex interval type parsing.
Keyword::INTERVAL => empty.value(DataType::Interval),
Keyword::REGCLASS => empty.value(DataType::Regclass),
Keyword::REGPROC => empty.value(DataType::Regproc),
Keyword::TEXT => empty.value(DataType::Text),
Keyword::STRUCT => cut_err(struct_data_type).map(DataType::Struct),
Keyword::BYTEA => empty.value(DataType::Bytea),
Expand All @@ -216,14 +214,15 @@ where
keywords,
trace(
"non_keyword_data_type",
object_name.map(|name| {
if name.to_string().eq_ignore_ascii_case("jsonb") {
// JSONB is not a keyword
DataType::Jsonb
} else {
DataType::Custom(name)
}
}),
object_name.map(
|name| match name.to_string().to_ascii_lowercase().as_str() {
// PostgreSQL built-in data types that are not keywords.
"jsonb" => DataType::Jsonb,
"regclass" => DataType::Regclass,
"regproc" => DataType::Regproc,
_ => DataType::Custom(name),
},
),
),
)),
)
Expand Down

0 comments on commit 6b362ad

Please sign in to comment.