-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Ensure hexval and int don't share BindVar after Normalization #14451
Conversation
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Signed-off-by: William Martin <[email protected]>
There was some existing code that attempted to disambiguate literal values as map keys by prefixing a single quote. Since this proved to not be correctly handling all situations, we thought it appropriate to key by the Literal itself. This ensures that a literal type is also considered first class in disambiguation. We chose to use the Literal rather than *Literal because literals with the same type and value are intended to share a BindVar. There's now slightly more data in the key since it is a struct with a Type field of Int, but since the key previously was an arbitrary length string, the difference should be negligble. Running the benchmarks didn't seem to indicate anything of concern. Signed-off-by: William Martin <[email protected]>
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.
Good catch! I think by keying on Literal
we're going to lose some deduplication in some corner cases... but the previous approach just wasn't correct at all. This is a strict improvement for now.
Hello! 👋 This Pull Request is now handled by arewefastyet. The current HEAD and future commits will be benchmarked. You can find the performance comparison on the arewefastyet website. |
Signed-off-by: William Martin <[email protected]>
Signed-off-by: William Martin <[email protected]>
Yeh @vmg I wondered also if that might be the case. Even then it seems like an allow list of shareable values would be a better place to start than with the default assumption that all are shareable. If you have some ideas of which values are shareable, I'd be happy to explore an implementation in another PR. Cheers all for the quick review and making me feel valued! |
Signed-off-by: William Martin <[email protected]> Signed-off-by: Arthur Schreiber <[email protected]>
…ization (#14451) (#14479) Signed-off-by: William Martin <[email protected]> Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
…ization (#14451) (#14477) Signed-off-by: William Martin <[email protected]> Signed-off-by: Arthur Schreiber <[email protected]> Co-authored-by: William Martin <[email protected]>
…ization (#14451) (#14478) Signed-off-by: William Martin <[email protected]> Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
Description
This PR relates to #14450, adding a test and attempting to resolve what appears to be an incorrect sharing of a bind var between a HexVal e.g.
x'31'
and an Int e.g.31
. This occurs because the type is not considered as part of the key for the BindVar map.There was some existing code that attempted to disambiguate literal values as map keys by prefixing a single quote. Since this proved to not be correctly handling all situations, I thought it appropriate to key by the
Literal
itself. This ensures that a literal'sType
is also considered first class in disambiguation.I chose to use the
Literal
rather than*Literal
because literals with the same type and value are intended to share aBindVar
.There's now slightly more data in the key since it is a struct with a
Type
field of sizeInt
, but since the key previously was an arbitrary length string, the difference should be negligible. Running the benchmarks didn't seem to indicate anything of concern. I ran them usinggo test -bench="BenchmarkNormalize" -run="^#" ./go/vt/sqlparser/.
That said, it's totally possible (likely even) that I don't have the full picture here. I just kind of stumbled across this yesterday and have no other experience with vitess so...take it all with a grain of salt! I'm also not at all opposed to doing another approach like the existing single-quote prefix. It just seemed like more edge cases waiting to happen.
I have no opinions on backporting because I'm not an operator and don't know anything about vitess' processes.
Related Issue(s)
Fixes #14450
Checklist
Deployment Notes