Repository navigation
Conversation
An IN list is deparsed as a chain of ORs (id = 1 or id = 2). FDWs join quals with "and", so WHERE id IN (1, 2) AND status = 'x' reached the remote as id = 1 or id = 2 and status = 'x', which matches id 1 regardless of status. Aggregate pushdown returns that wrong result directly. Wrap multi-element OR lists in parentheses in Qual::deparse_with_fmt and in mysql_fdw's own deparse_qual. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Contributor
|
Closing as this is 100% AI generated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
Bug fix (qual deparse,
supabase-wrappers/src/interface.rsandmysql_fdw).What is the current behavior?
Qual::deparse_with_fmtrenders an IN list (use_or = true) as a bare OR chain,id = 1 or id = 2 or id = 3. The FDWs join quals with" and ", so:reaches the remote as
ANDbinds tighter thanOR, so ids 1 and 2 match whatever their status is.The same pattern is in
Qual::deparse(used by BigQuery, DuckDB, ClickHouse, MSSQL, and Wasm FDWs through the host'sdeparse) and in the copy inmysql_fdw::deparse_qual.What is the new behavior?
An OR list with more than one element is wrapped in parentheses:
(id = 1 or id = 2 or id = 3). Single-element and empty lists are rendered exactly as before.Additional context
interface.rs:test_qual_deparse_or_list_is_parenthesizedandtest_qual_deparse_single_element_or_list.mysql_fdwcase:COUNT(*) ... WHERE id IN (1, 2, 3) AND status = 'inactive'returns 1 and is still pushed down.main, the unit test fails (left: "id = 1 or id = 2 or id = 3") and the mysql case fails withexpected 1, got 3, run withcargo pgrx test pg17 mysql --features mysql_fdwagainstmysql:8.4.cargo test -p supabase-wrappers --libpasses 38/38 and all 3 mysql pgrx tests pass.cargo fmt --checkpasses, andcargo clippy --tests -D warnings(pg17, mysql_fdw) is clean.This PR was prepared with AI assistance (Claude). I reproduced the failure and ran the tests locally as described above.
🤖 Generated with Claude Code