Skip to content

PostgreSQL: Render prefix @ operator with a space - #2531

Open
LucaCappelletti94 wants to merge 2 commits into
mainfrom
postgres-pgabs-display-space
Open

LucaCappelletti94 wants to merge 2 commits into
mainfrom
postgres-pgabs-display-space

Conversation

@LucaCappelletti94

Copy link
Copy Markdown
Contributor

SELECT @ -2 fails to round-trip on PostgreSQL. The prefix @ (UnaryOperator::PGAbs) renders with no space, so the AST displays as SELECT @-2 and re-parsing aborts in the tokenizer with Expected a valid binary operator after '@-', because @- is reserved as a geometric binary operator prefix. Found by the fuzz_parse_roundtrip target introduced in #2530.

PGAbs now renders with a trailing space, joining NOT, #, @-@, @@, ?- and ?|, which already use that arm for the same re-tokenization hazard, and matching the existing doc-comment example @ -9. The canonical output of SELECT @a becomes SELECT @ a.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant