-
Notifications
You must be signed in to change notification settings - Fork 102
fix: support create type
#118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,25 +191,57 @@ pub static STATEMENT_START_TOKEN_MAPS: LazyLock<Vec<HashMap<SyntaxKind, Vec<Toke | |
], | ||
)); | ||
|
||
// CREATE [ OR REPLACE ] OPERATOR | ||
// CREATE OPERATOR | ||
m.push(( | ||
SyntaxKind::DefineStmt, | ||
&[ | ||
SyntaxToken::Required(SyntaxKind::Create), | ||
SyntaxToken::Optional(SyntaxKind::Or), | ||
SyntaxToken::Optional(SyntaxKind::Replace), | ||
SyntaxToken::Required(SyntaxKind::Operator), | ||
], | ||
)); | ||
|
||
// CREATE [ OR REPLACE ] TYPE | ||
// CREATE TYPE name | ||
m.push(( | ||
SyntaxKind::DefineStmt, | ||
&[ | ||
SyntaxToken::Required(SyntaxKind::Create), | ||
SyntaxToken::Optional(SyntaxKind::Or), | ||
SyntaxToken::Optional(SyntaxKind::Replace), | ||
SyntaxToken::Required(SyntaxKind::TypeP), | ||
SyntaxToken::Required(SyntaxKind::Ident), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
], | ||
)); | ||
|
||
// CREATE TYPE name AS | ||
m.push(( | ||
SyntaxKind::CompositeTypeStmt, | ||
&[ | ||
SyntaxToken::Required(SyntaxKind::Create), | ||
SyntaxToken::Required(SyntaxKind::TypeP), | ||
SyntaxToken::Required(SyntaxKind::Ident), | ||
SyntaxToken::Required(SyntaxKind::As), | ||
], | ||
)); | ||
|
||
// CREATE TYPE name AS ENUM | ||
m.push(( | ||
SyntaxKind::CreateEnumStmt, | ||
&[ | ||
SyntaxToken::Required(SyntaxKind::Create), | ||
SyntaxToken::Required(SyntaxKind::TypeP), | ||
SyntaxToken::Required(SyntaxKind::Ident), | ||
SyntaxToken::Required(SyntaxKind::As), | ||
SyntaxToken::Required(SyntaxKind::EnumP), | ||
], | ||
)); | ||
|
||
// CREATE TYPE name AS RANGE | ||
m.push(( | ||
SyntaxKind::CreateRangeStmt, | ||
&[ | ||
SyntaxToken::Required(SyntaxKind::Create), | ||
SyntaxToken::Required(SyntaxKind::TypeP), | ||
SyntaxToken::Required(SyntaxKind::Ident), | ||
SyntaxToken::Required(SyntaxKind::As), | ||
SyntaxToken::Required(SyntaxKind::Range), | ||
], | ||
)); | ||
|
||
|
@@ -622,28 +654,6 @@ pub static STATEMENT_START_TOKEN_MAPS: LazyLock<Vec<HashMap<SyntaxKind, Vec<Toke | |
], | ||
)); | ||
|
||
m.push(( | ||
SyntaxKind::CreateEnumStmt, | ||
&[ | ||
SyntaxToken::Required(SyntaxKind::Create), | ||
SyntaxToken::Required(SyntaxKind::TypeP), | ||
SyntaxToken::Required(SyntaxKind::Ident), | ||
SyntaxToken::Required(SyntaxKind::As), | ||
SyntaxToken::Required(SyntaxKind::EnumP), | ||
], | ||
)); | ||
|
||
m.push(( | ||
SyntaxKind::CreateRangeStmt, | ||
&[ | ||
SyntaxToken::Required(SyntaxKind::Create), | ||
SyntaxToken::Required(SyntaxKind::TypeP), | ||
SyntaxToken::Required(SyntaxKind::Ident), | ||
SyntaxToken::Required(SyntaxKind::As), | ||
SyntaxToken::Required(SyntaxKind::Range), | ||
], | ||
)); | ||
|
||
m.push(( | ||
SyntaxKind::CreateFdwStmt, | ||
&[ | ||
|
@@ -956,7 +966,6 @@ pub static STATEMENT_START_TOKEN_MAPS: LazyLock<Vec<HashMap<SyntaxKind, Vec<Toke | |
// AlterObjectDependsStmt, | ||
// AlterObjectSchemaStmt, | ||
// AlterOwnerStmt, | ||
// CompositeTypeStmt, | ||
// AlterEnumStmt, | ||
// AlterTsdictionaryStmt, | ||
// AlterTsconfigurationStmt, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
CREATE TYPE type1; | ||
CREATE TYPE type1 AS (attr1 int4, attr2 bool); | ||
CREATE TYPE type1 AS (attr1 int4 COLLATE collation1, attr2 bool); | ||
/* TODO: CREATE TYPE type1 AS (attr1 int4 COLLATE collation1, attr2 bool); */ SELECT 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can't get it is obfuscated in the macro stack but we have a hint that it panics in |
||
CREATE TYPE type1 AS ENUM ('value1', 'value2', 'value3'); | ||
CREATE TYPE type1 AS RANGE (subtype = int4); | ||
CREATE TYPE type1 AS RANGE (subtype = int4, receive = receive_func, passedbyvalue); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,39 @@ description: CREATE TYPE type1; | |
--- | ||
Parse { | ||
cst: SourceFile@0..18 | ||
Create@0..6 "CREATE" | ||
Whitespace@6..7 " " | ||
TypeP@7..11 "TYPE" | ||
Whitespace@11..12 " " | ||
Ident@12..17 "type1" | ||
Ascii59@17..18 ";" | ||
DefineStmt@0..18 | ||
Create@0..6 "CREATE" | ||
Whitespace@6..7 " " | ||
TypeP@7..11 "TYPE" | ||
Whitespace@11..12 " " | ||
Ident@12..17 "type1" | ||
Ascii59@17..18 ";" | ||
, | ||
errors: [], | ||
stmts: [], | ||
stmts: [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎉 |
||
RawStmt { | ||
stmt: DefineStmt( | ||
DefineStmt { | ||
kind: ObjectType, | ||
oldstyle: false, | ||
defnames: [ | ||
Node { | ||
node: Some( | ||
String( | ||
String { | ||
sval: "type1", | ||
}, | ||
), | ||
), | ||
}, | ||
], | ||
args: [], | ||
definition: [], | ||
if_not_exists: false, | ||
replace: false, | ||
}, | ||
), | ||
range: 0..17, | ||
}, | ||
], | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE:
create type as
constitute a composite type