zvonimir-dd opened a new issue, #2624:
URL: https://github.com/apache/datafusion-sqlparser-rs/issues/2624

   ### Summary
   
   PostgreSQL's `INSERT` accepts `OVERRIDING { SYSTEM | USER } VALUE` between 
the column list and the source (it controls whether supplied values or the 
sequence are used for identity columns). sqlparser rejects it, in both the 
PostgreSQL and the generic dialect.
   
   ### Reproduction (sqlparser 0.63.0)
   
   ```rust
   use sqlparser::{dialect::PostgreSqlDialect, parser::Parser};
   
   let sql = "INSERT INTO t (id, a) OVERRIDING SYSTEM VALUE VALUES (1, 'x')";
   Parser::parse_sql(&PostgreSqlDialect {}, sql).unwrap();
   ```
   
   ```
   sql parser error: Expected: SELECT, VALUES, or a subquery in the query body, 
found: OVERRIDING at Line: 1, Column: 23
   ```
   
   `OVERRIDING USER VALUE` fails the same way. Both statements run on 
PostgreSQL (checked on 16.15):
   
   ```sql
   CREATE TABLE t (id int GENERATED ALWAYS AS IDENTITY, a text);
   INSERT INTO t (id, a) OVERRIDING SYSTEM VALUE VALUES (1, 'x');
   INSERT INTO t (id, a) OVERRIDING USER VALUE VALUES (1, 'x');
   ```
   
   ### Grammar
   
   From https://www.postgresql.org/docs/current/sql-insert.html:
   
   ```
   INSERT INTO table_name [ AS alias ] [ ( column_name [, ...] ) ]
       [ OVERRIDING { SYSTEM | USER } VALUE ]
       { DEFAULT VALUES | VALUES ( { expression | DEFAULT } [, ...] ) [, ...] | 
query }
       [ ON CONFLICT [ conflict_target ] conflict_action ]
       [ RETURNING ... ]
   ```
   
   ### Proposed change
   
   A new `OVERRIDING` keyword and an optional field on `Insert`, for example
   
   ```rust
   /// PostgreSQL `OVERRIDING { SYSTEM | USER } VALUE`
   pub overriding: Option<InsertOverriding>, // enum InsertOverriding { System, 
User }
   ```
   
   parsed right after the column list and printed in the same position, so the 
statement round-trips. I'm happy to send a PR.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to