Repository navigation
fix: follow a text set operation through a scalar subquery in the guard's rewrite (#510, port of #505) - #514
Merged
CaffeinatedCoder merged 2 commits intoOct 26, 2026
Conversation
…rd's rewrite (#505) The guard's walker treats a scalar subquery that projects a text Union, Add, Intersect or Except as derived, and so lets ==, != and Count over it through, trusting the expander to write them as mutual containment and count(DISTINCT). The expander's IsDerived had no arm for a scalar subquery, so the raw = and cardinality reached the server and compared the unsorted array_cat: {a,c} ∪ {a,b} == {a,b,c} dropped the row, and (… ?? subquery).Count counted {a,c,a,b} as 4. 10.3.0 refused the query. IsDerived now judges a scalar subquery by its one projection, as the walker does. UnionCanonicalityTests runs ==, != and Count over COALESCE through a correlated scalar subquery, and Add, Intersect and Except the same way, against memory over the loaded rows; with the arm removed both new tests fail on the answer. Found-By: RV Defect-Class: SQL Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 4bd2b7b)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit a0209a8)
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.
Closes #510
Port of #508 (#505) to
release/10.x: both commits cherry-picked with-x, applied without conflicts.Problem
….Select(o => o.Tags.Union(x)).FirstOrDefault() == targetcompared the unsortedarray_cat, because the guard's expander didn't follow a scalar subquery that its walker had let through. 10.3.0 threw for that query, so this is a regression in the unreleased 10.4.0. #497's 10.4.0 changelog row already promises==andCountover a textUnion, and this makes it true.Change
The
IsDerivedarm, twoUnionCanonicalityTests, and the seedguard-rewrite-misses-a-scalar-subquery.No
### Changed answersrow and nosilentlabel: no release shipped the wrong answer.Tests
UnionCanonicalityTests17/17. With the seed applied, both new tests fail (15/17).-p:EfFloat=10.0.13 -p:NpgsqlEfFloat=10.0.3):UnionCanonicalityTests17/17.🤖 Generated with Claude Code