release-20.2: opt: fix normalization of st_distance when use_spheroid parameter used #55852
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.
Backport 1/1 commits from #55739.
/cc @cockroachdb/release
This commit fixes the normalization rule that converts
st_distance
tost_dwithin
orst_dwithinexclusive
, which was broken in the case whenthe
use_spheroid
parameter was used. Prior to this commit, the rule wasassigning the
use_spheroid
parameter as the 3rd parameter tost_dwithin
or
st_dwithinexclusive
and thedistance
parameter as the 4th, but thatorder does not match the function signatures. This commit fixes the issue
by assigning
distance
as the 3rd parameter anduse_spheroid
as the 4thif it exists.
Fixes #55675
Release note (bug fix): Fixed an internal error that could occur during
query planning when the use_spheroid parameter was used in the ST_Distance
function as part of a filter predicate. For example,
SELECT ... WHERE ST_Distance(geog1, geog2, false) < 10
previously caused an error. Thishas now been fixed.