grammar: add many values to insert into
This commit is contained in:
parent
e577e230b1
commit
2479108e10
7 changed files with 57451 additions and 56755 deletions
1095
grammar.js
1095
grammar.js
File diff suppressed because it is too large
Load diff
|
@ -748,9 +748,14 @@
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
|
"type": "ALIAS",
|
||||||
|
"content": {
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "_list_of_identifiers"
|
"name": "_list_of_identifiers"
|
||||||
},
|
},
|
||||||
|
"named": true,
|
||||||
|
"value": "columns"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "BLANK"
|
"type": "BLANK"
|
||||||
}
|
}
|
||||||
|
@ -836,6 +841,54 @@
|
||||||
"named": false,
|
"named": false,
|
||||||
"value": "values"
|
"value": "values"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "insert_values"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "REPEAT",
|
||||||
|
"content": {
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": ","
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "insert_values"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "select_statement"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "("
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "select_statement"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": ")"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"insert_values": {
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "STRING",
|
||||||
"value": "("
|
"value": "("
|
||||||
|
@ -879,29 +932,6 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "select_statement"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "SEQ",
|
|
||||||
"members": [
|
|
||||||
{
|
|
||||||
"type": "STRING",
|
|
||||||
"value": "("
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "select_statement"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "STRING",
|
|
||||||
"value": ")"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"insert_item": {
|
"insert_item": {
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
"members": [
|
"members": [
|
||||||
|
|
|
@ -665,6 +665,21 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "columns",
|
||||||
|
"named": true,
|
||||||
|
"fields": {},
|
||||||
|
"children": {
|
||||||
|
"multiple": true,
|
||||||
|
"required": false,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "identifier",
|
||||||
|
"named": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "comparison_kw",
|
"type": "comparison_kw",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
@ -2294,7 +2309,7 @@
|
||||||
"required": false,
|
"required": false,
|
||||||
"types": [
|
"types": [
|
||||||
{
|
{
|
||||||
"type": "insert_item",
|
"type": "insert_values",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -2316,6 +2331,10 @@
|
||||||
"type": "as",
|
"type": "as",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "columns",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "identifier",
|
"type": "identifier",
|
||||||
"named": true
|
"named": true
|
||||||
|
@ -2343,6 +2362,21 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "insert_values",
|
||||||
|
"named": true,
|
||||||
|
"fields": {},
|
||||||
|
"children": {
|
||||||
|
"multiple": true,
|
||||||
|
"required": false,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "insert_item",
|
||||||
|
"named": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "into",
|
"type": "into",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
|
112120
src/parser.c
112120
src/parser.c
File diff suppressed because it is too large
Load diff
|
@ -8,11 +8,77 @@ insert into my_table values(1);
|
||||||
(insert_statement
|
(insert_statement
|
||||||
(identifier)
|
(identifier)
|
||||||
(insert_items
|
(insert_items
|
||||||
(insert_item
|
(insert_values
|
||||||
(number)))))
|
(insert_item (number))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
alias
|
insert into table by specified columns
|
||||||
|
================================================================================
|
||||||
|
insert into my_table (name, email, display_name) values
|
||||||
|
('foo', 'bar@biz.baz', 'Foo bar');
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(insert_statement
|
||||||
|
(identifier)
|
||||||
|
(columns
|
||||||
|
(identifier)
|
||||||
|
(identifier)
|
||||||
|
(identifier)
|
||||||
|
)
|
||||||
|
(insert_items
|
||||||
|
(insert_values
|
||||||
|
(insert_item (string))
|
||||||
|
(insert_item (string))
|
||||||
|
(insert_item (string))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
insert into table by specified columns with many values
|
||||||
|
================================================================================
|
||||||
|
insert into my_table (name, email, display_name) values
|
||||||
|
('foo', 'bar@biz.baz', 'Foo bar'),
|
||||||
|
('foo', 'bar@biz.baz', 'Foo bar'),
|
||||||
|
('foo', 'bar@biz.baz', 'Foo bar');
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(insert_statement
|
||||||
|
(identifier)
|
||||||
|
(columns
|
||||||
|
(identifier)
|
||||||
|
(identifier)
|
||||||
|
(identifier)
|
||||||
|
)
|
||||||
|
(insert_items
|
||||||
|
(insert_values
|
||||||
|
(insert_item (string))
|
||||||
|
(insert_item (string))
|
||||||
|
(insert_item (string))
|
||||||
|
)
|
||||||
|
(insert_values
|
||||||
|
(insert_item (string))
|
||||||
|
(insert_item (string))
|
||||||
|
(insert_item (string))
|
||||||
|
)
|
||||||
|
(insert_values
|
||||||
|
(insert_item (string))
|
||||||
|
(insert_item (string))
|
||||||
|
(insert_item (string))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
insert into table with alias
|
||||||
================================================================================
|
================================================================================
|
||||||
insert into foo.my_table as alias values(1);
|
insert into foo.my_table as alias values(1);
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
@ -20,14 +86,17 @@ insert into foo.my_table as alias values(1);
|
||||||
(source_file
|
(source_file
|
||||||
(insert_statement
|
(insert_statement
|
||||||
(identifier)
|
(identifier)
|
||||||
(as
|
(as (identifier))
|
||||||
(identifier))
|
|
||||||
(insert_items
|
(insert_items
|
||||||
(insert_item
|
(insert_values
|
||||||
(number)))))
|
(insert_item (number))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
default values
|
insert into default values
|
||||||
================================================================================
|
================================================================================
|
||||||
insert into foo.my_table default values;
|
insert into foo.my_table default values;
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
@ -35,10 +104,12 @@ insert into foo.my_table default values;
|
||||||
(source_file
|
(source_file
|
||||||
(insert_statement
|
(insert_statement
|
||||||
(identifier)
|
(identifier)
|
||||||
(insert_items)))
|
(insert_items)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
many values
|
insert into with many value items
|
||||||
================================================================================
|
================================================================================
|
||||||
insert into foo.my_table values (1, 2);
|
insert into foo.my_table values (1, 2);
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
@ -47,13 +118,16 @@ insert into foo.my_table values(1, 2);
|
||||||
(insert_statement
|
(insert_statement
|
||||||
(identifier)
|
(identifier)
|
||||||
(insert_items
|
(insert_items
|
||||||
(insert_item
|
(insert_values
|
||||||
(number))
|
(insert_item (number))
|
||||||
(insert_item
|
(insert_item (number))
|
||||||
(number)))))
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
different kind of values
|
insert into with different kind of value items
|
||||||
================================================================================
|
================================================================================
|
||||||
insert into foo.my_table values (1, DEFAULT, (select 1, 2));
|
insert into foo.my_table values (1, DEFAULT, (select 1, 2));
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
@ -62,18 +136,22 @@ insert into foo.my_table values(1, DEFAULT, (select 1, 2));
|
||||||
(insert_statement
|
(insert_statement
|
||||||
(identifier)
|
(identifier)
|
||||||
(insert_items
|
(insert_items
|
||||||
(insert_item
|
(insert_values
|
||||||
(number))
|
(insert_item (number))
|
||||||
(insert_item)
|
(insert_item)
|
||||||
(insert_item
|
(insert_item
|
||||||
(select_statement
|
(select_statement
|
||||||
(select_item
|
(select_item (number))
|
||||||
(number))
|
(select_item (number))
|
||||||
(select_item
|
)
|
||||||
(number)))))))
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
insert from select
|
insert into from select
|
||||||
================================================================================
|
================================================================================
|
||||||
insert into foo.my_table select column1 from foo bar;
|
insert into foo.my_table select column1 from foo bar;
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
@ -83,16 +161,22 @@ insert into foo.my_table select column1 from foo bar;
|
||||||
(identifier)
|
(identifier)
|
||||||
(insert_items
|
(insert_items
|
||||||
(select_statement
|
(select_statement
|
||||||
(select_item
|
(select_item (identifier))
|
||||||
(identifier))
|
|
||||||
(select_from
|
(select_from
|
||||||
(from_item
|
(from_item
|
||||||
(from_table
|
(from_table
|
||||||
(identifier)
|
(identifier)
|
||||||
(identifier))))))))
|
(identifier)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
insert from select(1)
|
insert into a table with the select enclosed in parentheses
|
||||||
================================================================================
|
================================================================================
|
||||||
insert into foo.my_table (select column1 from foo bar);
|
insert into foo.my_table (select column1 from foo bar);
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
@ -102,16 +186,22 @@ insert into foo.my_table (select column1 from foo bar);
|
||||||
(identifier)
|
(identifier)
|
||||||
(insert_items
|
(insert_items
|
||||||
(select_statement
|
(select_statement
|
||||||
(select_item
|
(select_item (identifier))
|
||||||
(identifier))
|
|
||||||
(select_from
|
(select_from
|
||||||
(from_item
|
(from_item
|
||||||
(from_table
|
(from_table
|
||||||
(identifier)
|
(identifier)
|
||||||
(identifier))))))))
|
(identifier)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
returning
|
insert into with returning clause
|
||||||
================================================================================
|
================================================================================
|
||||||
insert into foo values (1) returning *, 1;
|
insert into foo values (1) returning *, 1;
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
@ -120,16 +210,19 @@ insert into foo values(1) returning *, 1;
|
||||||
(insert_statement
|
(insert_statement
|
||||||
(identifier)
|
(identifier)
|
||||||
(insert_items
|
(insert_items
|
||||||
(insert_item
|
(insert_values
|
||||||
(number)))
|
(insert_item (number))
|
||||||
|
)
|
||||||
|
)
|
||||||
(returning
|
(returning
|
||||||
(select_item
|
(select_item (star))
|
||||||
(star))
|
(select_item (number))
|
||||||
(select_item
|
)
|
||||||
(number)))))
|
)
|
||||||
|
)
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
with cte
|
insert into using with clause
|
||||||
================================================================================
|
================================================================================
|
||||||
with foo as (select * from bar)
|
with foo as (select * from bar)
|
||||||
insert into my_table values (1);
|
insert into my_table values (1);
|
||||||
|
@ -141,19 +234,28 @@ insert into my_table values(1);
|
||||||
(with_query_item
|
(with_query_item
|
||||||
(identifier)
|
(identifier)
|
||||||
(select_statement
|
(select_statement
|
||||||
(select_item
|
(select_item (star))
|
||||||
(star))
|
|
||||||
(select_from
|
(select_from
|
||||||
(from_item
|
(from_item
|
||||||
(from_table
|
(from_table
|
||||||
(identifier)))))))
|
(identifier)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
(identifier)
|
(identifier)
|
||||||
(insert_items
|
(insert_items
|
||||||
(insert_item
|
(insert_values
|
||||||
(number)))))
|
(insert_item (number))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
returning into
|
insert into statement with returning into clause
|
||||||
================================================================================
|
================================================================================
|
||||||
insert into foo (bar, baz) select * from another
|
insert into foo (bar, baz) select * from another
|
||||||
returning id into _var;
|
returning id into _var;
|
||||||
|
@ -162,18 +264,25 @@ returning id into _var;
|
||||||
(source_file
|
(source_file
|
||||||
(insert_statement
|
(insert_statement
|
||||||
(identifier)
|
(identifier)
|
||||||
|
(columns
|
||||||
(identifier)
|
(identifier)
|
||||||
(identifier)
|
(identifier)
|
||||||
|
)
|
||||||
(insert_items
|
(insert_items
|
||||||
(select_statement
|
(select_statement
|
||||||
(select_item
|
(select_item (star))
|
||||||
(star))
|
|
||||||
(select_from
|
(select_from
|
||||||
(from_item
|
(from_item
|
||||||
(from_table
|
(from_table
|
||||||
(identifier))))))
|
(identifier)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
(returning
|
(returning
|
||||||
(select_item
|
(select_item (identifier))
|
||||||
(identifier)))
|
)
|
||||||
(into
|
(into (identifier))
|
||||||
(identifier))))
|
)
|
||||||
|
)
|
||||||
|
|
|
@ -119,7 +119,7 @@ with new as (delete from productes returning *) select 1;
|
||||||
(number))))
|
(number))))
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
with insert
|
select statement using with clause with insert into
|
||||||
================================================================================
|
================================================================================
|
||||||
with new as (insert into foo values(1)) select 1;
|
with new as (insert into foo values(1)) select 1;
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
@ -132,10 +132,16 @@ with new as (insert into foo values(1)) select 1;
|
||||||
(insert_statement
|
(insert_statement
|
||||||
(identifier)
|
(identifier)
|
||||||
(insert_items
|
(insert_items
|
||||||
(insert_item
|
(insert_values
|
||||||
(number))))))
|
(insert_item (number))
|
||||||
(select_item
|
)
|
||||||
(number))))
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(select_item (number))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
with update
|
with update
|
||||||
|
|
Binary file not shown.
Loading…
Reference in a new issue