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

pg_query_parse fails to parse valid SQL statement #132

Closed
svenklemm opened this issue Apr 15, 2022 · 3 comments
Closed

pg_query_parse fails to parse valid SQL statement #132

svenklemm opened this issue Apr 15, 2022 · 3 comments

Comments

@svenklemm
Copy link
Contributor

The following query fails with syntax error at or near "?", at index 17

CREATE OPERATOR #? (LEFTARG=bool,RIGHTARG=bool,FUNCTION=boolge);

In postgresql 13 this query runs without problems.

@lfittl
Copy link
Member

lfittl commented Apr 19, 2022

@svenklemm Ah, interesting - I think the root cause here is the parser patch that supports treating ? as param refs, for compatibility with pg_stat_statements query texts on Postgres 9.6 and older (https://github.com/pganalyze/libpg_query/blob/13-latest/patches/02_parser_support_question_mark_as_param_ref.patch)

Since Postgres 9.6 is EOL now, it seems reasonable to drop this patch altogether in the next major libpg_query release (i.e. the one targeting Postgres 14).

Is this part of an extension you are using, or a custom operator in your environment?

We do have special exclusion for certain commonly used operators, and so we could add it there, ahead of dropping the patch altogether: https://github.com/pganalyze/libpg_query/blob/13-latest/patches/02_parser_support_question_mark_as_param_ref.patch#L303

@svenklemm
Copy link
Contributor Author

Thanks for the pointer. The promscale extension defines a #? operator: https://github.com/timescale/promscale/blob/master/pkg/migrations/sql/idempotent/tracing-tags.sql#L51

svenklemm added a commit to svenklemm/libpg_query that referenced this issue Apr 19, 2022
The following statement will produce an error with pg_query_parse
while being accepted by PG13.

CREATE OPERATOR #? (LEFTARG=bool,RIGHTARG=bool,FUNCTION=boolge);

pganalyze#132
lfittl pushed a commit that referenced this issue Apr 20, 2022
The following statement will produce an error with pg_query_parse
while being accepted by PG13.

CREATE OPERATOR #? (LEFTARG=bool,RIGHTARG=bool,FUNCTION=boolge);

#132
@lfittl
Copy link
Member

lfittl commented Apr 20, 2022

@svenklemm Thanks for the PR - merged!

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

No branches or pull requests

2 participants