-
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
Use decoded hex string when calculating the keyspace ID #9277
Conversation
6d5e75d
to
b92b7dc
Compare
Example vindex function results from 11.0 before we started normalizing hex values (after this PR main produces the same results):
|
c2ec4d6
to
ac36806
Compare
c9195fd
to
133b0b1
Compare
f5672be
to
ea394c9
Compare
a5aeaa6
to
61cb238
Compare
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.
It looks good to me! :)
Before merging, let's see if 61cb238 resolves @harshit-gangal 's comment
5f2d970
to
55dcac1
Compare
Here's a full user test:
Results:
|
This is done by properly managing the HexVal BindVar: - The "raw" value is what was seen in the query - The ToBytes value returns they bytes that mysql would return Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
This is needed as with full hex value support we may need to escape the hex value string which can produce an error. Signed-off-by: Matt Lord <mattalord@gmail.com>
55dcac1
to
7682930
Compare
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.
LGTM
Signed-off-by: Matt Lord <mattalord@gmail.com>
7682930
to
55568d4
Compare
Very well-written description. Thank you for taking the time to write it up along with the code changes. |
Use decoded hex string when calculating the keyspace ID Signed-off-by: Matt Lord <mattalord@gmail.com>
Description
This is a follow-up to #9118
There we normalized the incoming
x'A1'
or0xA1
string literal token that represents binary data as hex so that we can pass it on to MySQL as a BindVar.However, this means that when calculating the Keyspace ID in the vindex functions we need to decode the value again (as we do when parsing the incoming query) so that we're doing the keyspace range check using a decoded representation of the bytes that end up being stored in the column in MySQL.
This is accomplished here and here by properly managing the HexVal and HexNum BindVars:
Value.val
/Value.Raw()
and its variants) is "internal" and represents what was seen in the SQL query (e.g.x'997902'
or0x997902
)Value.ToBytes()
) returns the bytes that mysql would return when querying the column (e.g.�y
).For example:
We then see the exact same results for the vindex functions using the
x'A1'
format seen before normalizing hex values.🆕 With this PR we also add support for using the
0xA1
format with vindexes which did NOT work before:11.0:
This branch:
So now for vindexes we are properly treating
x'A1'
and0xA1
as equivalent. This is proper because while the string literal in the SQL query differs the same bytes are stored in MySQL for both. You can see a complete user test here.Related Issue(s)
Fixes: #9275
Checklist