diff --git a/ast/postgresql.ts b/ast/postgresql.ts index 6f44172c..4a3c1012 100644 --- a/ast/postgresql.ts +++ b/ast/postgresql.ts @@ -164,7 +164,7 @@ export interface create_table_stmt_node_like extends create_table_stmt_node_base like: create_like_table; } -export type create_table_stmt = AstStatement | AstStatement;; +export type create_table_stmt = AstStatement | AstStatement; export type create_sequence_stmt = { type: 'create', @@ -230,6 +230,46 @@ export type create_like_table_simple = { type: 'like'; table: table_ref_list; }; export type create_like_table = create_like_table_simple | create_like_table_simple & { parentheses?: boolean; }; + + + + + + +export type for_values_item = { + type: 'for_values_item'; + keyword: 'from'; + from: literal_string; + to: literal_string; + } | { + type: 'for_values_item'; + keyword: 'in'; + in: expr_list; + } | { + type: 'for_values_item'; + keyword: 'with'; + modulus: literal_numeric; + remainder: literal_numeric; + }; + + + +export type for_values = { + type: 'for_values'; + keyword: 'for values'; + expr: for_values_item; + }; + + + +export type create_table_partition_of = { + type: 'partition_of'; + keyword: 'partition of'; + table: table_name; + for_values: for_values; + tablespace: ident_without_kw_type | undefined; + }; + export type create_table_definition = create_definition[]; export type create_definition = create_column_definition | create_index_definition | create_fulltext_spatial_index_definition | create_constraint_definition; diff --git a/package-lock.json b/package-lock.json index 5827fbc4..4e366015 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,6 +36,7 @@ "mocha": "^10.0.0", "mochapack": "^2.0.3", "nyc": "15.1.0", + "pegjs": "^0.10.0", "pegjs-loader": "^0.5.6", "pre-commit": "^1.2.2", "rimraf": "^5.0.1", @@ -12155,7 +12156,6 @@ "resolved": "https://registry.npmjs.org/pegjs/-/pegjs-0.10.0.tgz", "integrity": "sha512-qI5+oFNEGi3L5HAxDwN2LA4Gg7irF70Zs25edhjld9QemOgp0CbvMtbFcMvFtEo1OityPrcCzkQFB8JP/hxgow==", "dev": true, - "peer": true, "bin": { "pegjs": "bin/pegjs" }, @@ -25767,8 +25767,7 @@ "version": "0.10.0", "resolved": "https://registry.npmjs.org/pegjs/-/pegjs-0.10.0.tgz", "integrity": "sha512-qI5+oFNEGi3L5HAxDwN2LA4Gg7irF70Zs25edhjld9QemOgp0CbvMtbFcMvFtEo1OityPrcCzkQFB8JP/hxgow==", - "dev": true, - "peer": true + "dev": true }, "pegjs-loader": { "version": "0.5.8", diff --git a/package.json b/package.json index 1624b22a..e9df8819 100644 --- a/package.json +++ b/package.json @@ -77,6 +77,7 @@ "mocha": "^10.0.0", "mochapack": "^2.0.3", "nyc": "15.1.0", + "pegjs": "^0.10.0", "pegjs-loader": "^0.5.6", "pre-commit": "^1.2.2", "rimraf": "^5.0.1", @@ -95,7 +96,7 @@ "sourceMap": false }, "dependencies": { - "big-integer": "^1.6.48", - "@types/pegjs": "^0.10.0" + "@types/pegjs": "^0.10.0", + "big-integer": "^1.6.48" } } diff --git a/pegjs/postgresql.pegjs b/pegjs/postgresql.pegjs index e3e5076b..dbc70b85 100644 --- a/pegjs/postgresql.pegjs +++ b/pegjs/postgresql.pegjs @@ -798,13 +798,7 @@ create_table_stmt ife:if_not_exists_stmt? __ t:table_ref_list __ po:create_table_partition_of { - /* - - export interface create_table_partition_of extends create_table_stmt_node_base { - partition_of: create_table_partition_of; - } - => AstStatement; - */ + // => AstStatement if(t) t.forEach(tt => tableList.add(`create::${tt.db}::${tt.table}`)); return { tableList: Array.from(tableList), @@ -876,7 +870,7 @@ create_table_stmt export interface create_table_stmt_node_like extends create_table_stmt_node_base{ like: create_like_table; } - => AstStatement; + => AstStatement */ if(t) t.forEach(tt => tableList.add(`create::${tt.db}::${tt.table}`)); return { @@ -1145,6 +1139,12 @@ create_like_table for_values_item = KW_FROM __ LPAREN __ f:literal_string __ RPAREN __ KW_TO __ LPAREN __ t:literal_string __ RPAREN { + /* => { + type: 'for_values_item'; + keyword: 'from'; + from: literal_string; + to: literal_string; + } */ return { type: 'for_values_item', keyword: 'from', @@ -1153,6 +1153,11 @@ for_values_item } } / KW_IN __ LPAREN __ e:expr_list __ RPAREN { + /* => { + type: 'for_values_item'; + keyword: 'in'; + in: expr_list; + } */ return { type: 'for_values_item', keyword: 'in', @@ -1160,6 +1165,12 @@ for_values_item } } / KW_WITH __ LPAREN __ 'MODULUS'i __ m:literal_numeric __ COMMA __ 'REMAINDER'i __ r:literal_numeric __ RPAREN { + /* => { + type: 'for_values_item'; + keyword: 'with'; + modulus: literal_numeric; + remainder: literal_numeric; + } */ return { type: 'for_values_item', keyword: 'with', @@ -1170,6 +1181,11 @@ for_values_item for_values = 'FOR'i __ KW_VALUES __ fvi:for_values_item { + /* => { + type: 'for_values'; + keyword: 'for values'; + expr: for_values_item; + } */ return { type: 'for_values', keyword: 'for values', @@ -1178,6 +1194,13 @@ for_values } create_table_partition_of = KW_PARTITION __ 'OF'i __ t:table_name __ fv:for_values __ ts:(KW_TABLESPACE __ ident_without_kw_type)? { + /* => { + type: 'partition_of'; + keyword: 'partition of'; + table: table_name; + for_values: for_values; + tablespace: ident_without_kw_type | undefined; + } */ return { type: 'partition_of', keyword: 'partition of',