Skip to content

PostgreSQL: Tokenize *= and @@@ as single operators - #3071

Open
ksaiharshavinay wants to merge 2 commits into
apache:mainfrom
ksaiharshavinay:fix/pg-operators-2809
Open

ksaiharshavinay wants to merge 2 commits into
apache:mainfrom
ksaiharshavinay:fix/pg-operators-2809

Conversation

@ksaiharshavinay

Copy link
Copy Markdown

Fixes #2809.

PostgreSqlDialect split *= into Mul + Eq and @@@ into AtAt + AtSign, so statements using them failed to parse or misparsed.

  • Tokenizer: when * is followed by =, <, or > in a dialect with custom operator parts (only PostgreSQL), scan the composite operator (*=, *<, *<=, *<>, *>, *>=) as one CustomBinaryOperator token. The scan stops before a trailing +/-, which PostgreSQL trims from such operators, so a*=-1 stays *= + Minus + 1.
  • The @@ arm now absorbs a third @ into CustomBinaryOperator("@@@"); plain @@ still returns AtAt, and other dialects are unchanged.
  • Tests: tokenizer tests for both operators and the trailing-sign cases, verified_stmt round-trips in sqlparser_postgres (including OPERATOR(pg_catalog.*=) and OPERATOR(pg_catalog.@@@)), plus fuzz seeds per AGENTS.md.

cargo test --all-features: 1984 passed. cargo fmt --check and clippy -D warnings clean.

Disclosure: prepared with AI assistance (Claude), including the review pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PostgreSqlDialect: *= and @@@ are split into two tokens,

1 participant