sql: be safer about swapping out IVarHelpers #22310
Merged
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.
Fixes #22249.
This fix is admittedly somewhat ad-hoc, though I argue that it is
strictly less ad-hoc than the system we had before! The provided logic
test would panic because there was a place in the code where we were not
appropriately resetting an IVarHelper after swapping it out, leaving an
EvalContext with a nil IVarHelper.
I think this swapping out of IVarHelpers is something that has evolved
organically and has never been a particularly principled thing for us to
do. We should at some point figure out what it means for us to evaluate
a new expression with different indexed var bindings with the same
"context".
Release note (bug fix): Fix a panic with certain queries involving
REGCLASS