Skip to content

Commit

Permalink
Support MySQL UNION option for CREATE TABLE
Browse files Browse the repository at this point in the history
  • Loading branch information
nene committed Jan 13, 2024
1 parent c9001ea commit 64f4cd8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/cst/CreateTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ type TableOptionNameMysql =
| Keyword<"STATS_PERSISTENT">
| Keyword<"STATS_SAMPLE_PAGES">
| Keyword<"TABLESPACE">
| Keyword<"STORAGE">;
| Keyword<"STORAGE">
| Keyword<"UNION">;

type TableOptionValueMysql = Keyword<
| "DEFAULT"
Expand Down
2 changes: 2 additions & 0 deletions src/parser.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -3622,11 +3622,13 @@ mysql_table_opt_name
/ STATS_SAMPLE_PAGES
/ TABLESPACE
/ STORAGE
/ UNION

mysql_table_opt_value
= string_literal
/ number_literal
/ ident
/ paren$list$entity_name // for UNION
/ DEFAULT
/ DYNAMIC / FIXED / COMPRESSED / REDUNDANT / COMPACT // for ROW_FORMAT
/ NO / FIRST / LAST // for INSERT_METHOD
Expand Down
1 change: 1 addition & 0 deletions test/ddl/create_table_mysql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe("create table (MySQL)", () => {
// The STORAGE option is linked to TABLESPACE option before it according to MySQL docs,
// but really the syntax seems to allow any order, including separating them with commas.
["STORAGE", ["DISK", "MEMORY"]],
["UNION", ["(t1, t2, my_schema.t3)"]],
] as [string, string[]][]
).forEach(([name, values]) => {
values.forEach((value) => {
Expand Down

0 comments on commit 64f4cd8

Please sign in to comment.