pgcat
pgcat copied to clipboard
Switch query parser to `pg_query.rs`
Is your feature request related to a problem? Please describe.
Currently, pgcat
is using sqlparser-rs to parse user queries. That's taken us to where we are today, which is great. However, sqlparser-rs does not correctly parse all PostgreSQL queries. There are already some open PRs to fix the known issues (e.g., https://github.com/sqlparser-rs/sqlparser-rs/pull/1000 and https://github.com/sqlparser-rs/sqlparser-rs/pull/1002), but it's not going to be 100% PG compatible.
Describe the solution you'd like The closest to PostgreSQL parser that we can get is to use the PostgreSQL parser itself :)
Here's the maintained (extracted) C library: libpg_query, and here's its port to Rust (by pganalyze
): pg_query.rs
I wanted to ask for everyone's opinion (especially the main pgcat
maintainers) about changing our SQL parser from sqlparser-rs to pg_query.rs. If I see enough support for this change, I can put-together a PR for it.
I believe not only pg_query.rs is the most correct Postgres SQL parser but also it's faster than sqlparser. There is a draft PR by another contributor with that integration: https://github.com/postgresml/pgcat/pull/525
Thanks for the reference to PR #525. Cool stuff!
However, that PR only uses pg_query.rs without removing the current usages of sqlparser
. I'll create a PR for that.
Just curious about any progress for this ?