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
release-22.2: opt: fix invalid st_union optimizations #112796
release-22.2: opt: fix invalid st_union optimizations #112796
Conversation
The `st_union` aggregate function was incorrectly thought to ignore duplicate values. That is, given any number of duplicate input values, it was assumed to produce the same result. This is not the case in both Postgres with Postgis and CRDB (see cockroachdb#111556). This incorrect assumption caused the optimizer to perform invalid optimizations and produce query plans that return incorrect results. This commit fixes the bug by marking `st_union` as a non-duplicate-ignoring aggregate. Fixes cockroachdb#111556 Release note (bug fix): Queries with the `st_union` aggregate function could produce incorrect results in some cases due to the query optimizer performing invalid optimizations. This bug has been present since the `st_union` function was introduced in version 20.2.0.
Thanks for opening a backport. Please check the backport criteria before merging:
If some of the basic criteria cannot be satisfied, ensure that the exceptional criteria are satisfied within.
Add a brief release justification to the body of your PR to justify this backport. Some other things to consider:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @DrewKimball, @rafiss, and @yuzefovich)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: complete! 2 of 0 LGTMs obtained (waiting on @rafiss and @yuzefovich)
Backport 1/1 commits from #112729.
/cc @cockroachdb/release
The
st_union
aggregate function was incorrectly thought to ignoreduplicate values. That is, given any number of duplicate input values,
it was assumed to produce the same result. This is not the case in both
Postgres with Postgis and CRDB (see #111556).
This incorrect assumption caused the optimizer to perform invalid
optimizations and produce query plans that return incorrect results.
This commit fixes the bug by marking
st_union
as anon-duplicate-ignoring aggregate.
Fixes #111556
Release note (bug fix): Queries with the
st_union
aggregate functioncould produce incorrect results in some cases due to the query optimizer
performing invalid optimizations. This bug has been present since the
st_union
function was introduced in version 20.2.0.Release justification: Low-risk bug fix that fixes incorrect query
results when using the
st_union
aggregate function.