sql-parser icon indicating copy to clipboard operation
sql-parser copied to clipboard

INSERT multiple rows is not supported

Open cdmh opened this issue 4 years ago • 4 comments

A SQL statement to insert multiple rows into a table fails parsing

INSERT INTO links (url, name) VALUES ('https://www.google.com','Google'), ('https://www.yahoo.com','Yahoo'),('https://www.bing.com','Bing');

Produces an error at the end of the first pair of parentheses in the VALUES clause hsql::SQLParserResult::errorColumn_ == 73 hsql::SQLParserResult::errorMsg_ == "syntax error, unexpected ',', expecting end of file"

cdmh avatar Oct 21 '20 17:10 cdmh

I can only confirm this. The insert_statement does not support multiple values:

https://github.com/hyrise/sql-parser/blob/33c00133f26792d6ec3ef08a29e754e749e384ff/src/parser/bison_parser.y#L632-L638

To our defense, this is not supported by SQL-92, which we use as orientation, either:

         <insert columns and source> ::=
                [ <left paren> <insert column list> <right paren> ]
              <query expression>
              | DEFAULT VALUES

         2) An <insert columns and source> that specifies DEFAULT VALUES is
            equivalent to an <insert columns and source> that specifies a
            <query expression> of the form

              VALUES (DEFAULT, . . . )

            where the number of "DEFAULT" entries is equal to the number of
            columns of T.

That being said, this is a valuable suggestion and I would support adding it. Due to a lack of resources, adding this might take us a while. External contributions are of course welcomed.

mrks avatar Oct 21 '20 18:10 mrks

Thanks for the quick response! I’m not familiar with the standards, so didn’t appreciate this is an extension, although widely supported.

I don’t have experience with parsers, but maybe I’ll give it a go and see if I can work out how to support this.

cdmh avatar Oct 21 '20 19:10 cdmh

It might have come in with a newer SQL standard. SQL-92 is just the one that is sufficient for our purposes. I do wish we could upgrade to a more comprehensive support of a newer version.

mrks avatar Oct 21 '20 19:10 mrks

I also hope hyrise has this feature, it is usefull.

fowuyu avatar Nov 13 '20 01:11 fowuyu