anubhavlal07 opened a new pull request, #2987: URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2987
Dialects: Redshift, PostgreSQL Fixes #2958 With `RedshiftSqlDialect`, a `--` comment did not end at a lone `\r`, so `SELECT 1 AS a --\r, 2` parsed as `SELECT 1 AS a`. The tokenizer stopped at `\r` only for `PostgreSqlDialect`. Redshift is based on PostgreSQL 8.0.2 ([Amazon Redshift and PostgreSQL](https://docs.aws.amazon.com/redshift/latest/dg/c_redshift-and-postgres-sql.html)), and the PostgreSQL lexer ends `--` comments at either `\n` or `\r` ([scan.l](https://github.com/postgres/postgres/blob/master/src/backend/parser/scan.l)). This replaces the `dialect_of!(self is PostgreSqlDialect)` check with a new `Dialect::single_line_comment_ends_at_carriage_return` method, which defaults to `false` and returns `true` for PostgreSQL and Redshift. PostgreSQL behaves as before. The new test in `tests/sqlparser_redshift.rs` checks that dialects which enable the method parse two projections, and that the others still treat the rest of the line as a comment. I also added the fuzz seed `fuzz/fuzz_seeds/redshift_2958_comment_cr.sql`. I wrote this with AI assistance, then reviewed the diff and description myself. -- 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]
