postgresml / pgcat

PostgreSQL pooler with sharding, load balancing and failover support.
MIT License
3.13k stars 193 forks source link

Query parsing error (read/write splitting mode) #776

Closed leo-ural closed 2 months ago

leo-ural commented 3 months ago

An error occurs while pgcat is in read/write queries splitting mode. Original SQL query is: SELECT req_tab_0.* FROM validation req_tab_0 WHERE array['http://www.w3.org/ns/shacl#ValidationResult'] && req_tab_0.type::text[] AND ( ( (req_tab_0.focusnode = 'DataSource_Credilogic_DataSourceAddress_144959227') ) )

When parsing the query pgcat has logged an error: QueryRouterParserError("sql parser error: Expected an expression:, found: &")

Version: pgcat-0.1.0

pchaseh commented 3 months ago

The 0.1.0 release was built on Feb 22nd, where-in sqlparser v0.34 would have still been in use. You can see from the commit https://github.com/sqlparser-rs/sqlparser-rs/commit/a50671d95d34688529fbc3d4452bec164ff21497 that support for the overlap operator is only available in v0.36 or later. You'll have to build your own pgcat binary from the latest master branch until the maintainers offer a newer release which includes sqlparser v0.41 (see https://github.com/postgresml/pgcat/commit/0d94d0b90a2ba257b0462dd140e6af4818462e44).

drdrsh commented 2 months ago

I verified that this was fixed in the updated sqlparser version and is no longer reproducible under the latest version of PgCat.

I used that query to create a test case for the parser. Thank you for reporting