LucaCappelletti94 opened a new pull request, #2968:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2968

   `SELECT CURRENT_USER, CURRENT_ROLE` parses `CURRENT_USER` as a 
[niladic](https://en.wiktionary.org/wiki/niladic) (fun word learned it today) 
`Expr::Function` and `CURRENT_ROLE` as an `Expr::Identifier`, and `SYSTEM_USER` 
and `CURRENT_SCHEMA` parse as identifiers too. PostgreSQL never reads any of 
the three as a column name. `CURRENT_ROLE` and `SYSTEM_USER` are reserved and 
`CURRENT_SCHEMA` can only be a type or function name ([keyword 
table](https://www.postgresql.org/docs/current/sql-keywords-appendix.html)), so 
`CREATE TABLE k (current_role int)` is a syntax error.
   
   All three are [session information 
functions](https://www.postgresql.org/docs/current/functions-info.html), and 
`pg_dump` writes them verbatim in defaults such as `DEFAULT CURRENT_ROLE`. With 
the current parse, code walking the AST cannot tell them apart from a column 
reference.
   
   This adds the three keywords that already builds the niladic function for 
`CURRENT_USER`, `SESSION_USER`, `USER` and `CURRENT_CATALOG`. PostgreSQL also 
has an ordinary `current_schema()` function, so `CURRENT_SCHEMA` followed by a 
parenthesis still parses as a regular call. A quoted `"current_role"` stays an 
identifier.


-- 
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]

  • [PR] PostgreSQL: Parse `CURRENT_... LucaCappelletti94 (via GitHub) via github

Reply via email to