Skip to content

Commit 286e10c

Browse files
authored
Parse more functionality of the CREATE TABLE statement (m-novikov#70)
* Add `create unlogged table` * Add: `create table as select` * include generated files * Add `create table ... on commit` * fix: either `table_definition` or `as select` * add autogenerated files * create as select with two choices * removed `on commit` for now * Default values in Column Definitions (m-novikov#73) * Add: column definitions with default values * Add more options to default expressions * update _column_constraints * include generated files * bump generated files * update parser.c after rebase
1 parent bb58ae1 commit 286e10c

File tree

5 files changed

+91543
-90656
lines changed

5 files changed

+91543
-90656
lines changed

grammar.js

+27-3
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ module.exports = grammar({
115115
keyword_owner: _ => make_keyword("owner"),
116116
keyword_temp: _ => make_keyword("temp"),
117117
keyword_temporary: _ => make_keyword("temporary"),
118+
keyword_unlogged: _ => make_keyword("unlogged"),
118119
keyword_union: _ => make_keyword("union"),
119120
keyword_all: _ => make_keyword("all"),
120121
keyword_except: _ => make_keyword("except"),
@@ -152,6 +153,7 @@ module.exports = grammar({
152153
keyword_brin: _ => make_keyword("brin"),
153154
keyword_like: _ => choice(make_keyword("like"),make_keyword("ilike")),
154155
keyword_similar: _ => make_keyword("similar"),
156+
keyword_preserve: _ => make_keyword("preserve"),
155157

156158
// Operators
157159
is_not: $ => prec.left(seq($.keyword_is, $.keyword_not)),
@@ -514,12 +516,34 @@ module.exports = grammar({
514516

515517
create_table: $ => seq(
516518
$.keyword_create,
517-
optional($._temporary),
519+
optional(
520+
choice(
521+
$._temporary,
522+
$.keyword_unlogged
523+
)
524+
),
518525
$.keyword_table,
519526
optional($._if_not_exists),
520527
$.table_reference,
521-
$.column_definitions,
522-
optional($.table_options),
528+
choice(
529+
seq(
530+
$.column_definitions,
531+
optional($.table_options),
532+
optional(
533+
seq(
534+
$.keyword_as,
535+
$._select_statement,
536+
),
537+
)
538+
),
539+
seq(
540+
optional($.table_options),
541+
seq(
542+
$.keyword_as,
543+
$._select_statement,
544+
),
545+
),
546+
)
523547
),
524548

525549
create_view: $ => seq(

src/grammar.json

+87-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/node-types.json

+37-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)