-
Notifications
You must be signed in to change notification settings - Fork 181
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
Incorrect query is parsed without any errors #261
Comments
Interesting example! So the reason this differs from what Postgres itself regards as valid syntax is that we have a parser patch in libpg_query that adds support for this: The intent is to deal with normalized queries in pg_stat_statements that result from type casts, like It may be possible to address this in libpg_query by either:
Given that Postgres is extensible with custom types, I'd be inclined to focus on (1) as the right way to resolve this. To help assess what makes sense here, can you share more on your use case, where this becomes a problem? |
Thanks @lfittl. Regarding my use-case, I am generating PostgreSQL queries with a LLM. I want to ensure its syntactically correct. |
I feel like you shouldn’t ever find such replacements within a text query literal in a DDL query. Such modifications only happen to DML queries. Can you condition the acceptance of the hack on the state of the parse? |
Query
The query is incorrect, because there is no
=
betweenWHERE customer_id $1
howeverpg_query_free_plpgsql_parse_result(query)
returns correctly.The text was updated successfully, but these errors were encountered: