Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser incorrectly parses queries with negative and zero values #243

Open
MGorkov opened this issue Apr 16, 2024 · 0 comments · May be fixed by #249
Open

Parser incorrectly parses queries with negative and zero values #243

MGorkov opened this issue Apr 16, 2024 · 0 comments · May be fixed by #249

Comments

@MGorkov
Copy link

MGorkov commented Apr 16, 2024

The following queries produces an invalid tree when run through the parser :
SELECT 0;
SELECT -1;

Parser output:
{ version: 160001, stmts: [ { stmt: { SelectStmt: { targetList: [ { ResTarget: { val: { A_Const: { ival: {}, location: 7 } }, location: 7 } } ], limitOption: 'LIMIT_OPTION_DEFAULT', op: 'SETOP_NONE' } } } ] }
In version 15 these queries also produce incorrect tree, but version 14 is correct.

@MGorkov MGorkov changed the title Parser incorrectly parses queris with negative and zero values Parser incorrectly parses queries with negative and zero values Apr 16, 2024
msullivan added a commit to msullivan/libpg_query that referenced this issue May 9, 2024
Currently the value of negative constants are omitted. Only omit *0*
constants.

An earlier attempt (pganalyze#244) caused a mismatch with the protobuf json
output, since that wants to omit values that are equal to the default
value.

I don't *really* think that is particularly sensible behavior for an
integer constant in an AST, but oh well.

Fixes pganalyze#243.
@msullivan msullivan linked a pull request May 9, 2024 that will close this issue
msullivan added a commit to msullivan/libpg_query that referenced this issue May 9, 2024
Currently the value of negative constants are omitted. Only omit *0*
constants.

An earlier attempt (pganalyze#244) caused a mismatch with the protobuf json
output, since that wants to omit values that are equal to the default
value.

I don't *really* think that is particularly sensible behavior for an
integer constant in an AST, but oh well.

Fixes pganalyze#243.
msullivan added a commit to msullivan/libpg_query that referenced this issue May 9, 2024
Currently the value of negative constants are omitted. Only omit *0*
constants.

An earlier attempt (pganalyze#244) caused a mismatch with the protobuf json
output, since that wants to omit values that are equal to the default
value.

I don't *really* think that is particularly sensible behavior for an
integer constant in an AST, but oh well.

Fixes pganalyze#243.
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 a pull request may close this issue.

1 participant