preston-footprint opened a new issue, #2961:
URL: https://github.com/apache/datafusion-sqlparser-rs/issues/2961

   Postgres-family lexers never let `--` or `/*` be part of an operator; the 
operator ends there and a comment starts. sqlparser lexes `#-` (and `|/`, 
`||/`) as one token first, which leaves the rest of the comment marker behind.
   
   ```sql
   select 2 #--'
    3, pg_backend_pid() --'
   ```
   
   - sqlparser 0.64.0: `HashMinus`, `Minus`, then the string `'\n 3, 
pg_backend_pid() --'`; parses as `SELECT 2 #- -'...'`.
   - Redshift: two columns, `1` (that is, `2 # 3`) and `1073905994`.
   
   The same happens with `/*`: `select 9 |/*'*/ 2, pg_backend_pid() --'` 
returns `11` and the pid on Redshift, while sqlparser lexes `PGSquareRoot`, 
`Mul`, a string, and fails to parse.
   
   Postgres documents the rule under "Operators" 
(https://www.postgresql.org/docs/8.0/sql-syntax.html#SQL-SYNTAX-OPERATORS): 
"`--` and `/*` cannot appear anywhere in an operator name, since they will be 
taken as the start of a comment." Postgres's own dialect in sqlparser likely 
has the same gap.
   


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