-
-
Notifications
You must be signed in to change notification settings - Fork 238
fix hexadecimal literal value conversion #1474
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
Conversation
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.
Nice work digging in and finding this fix! Code looks good, I just had two small questions and wanted to take one more quick look in the morning when my brain is fresh.
| Query: "INSERT INTO test(decimal_test, decimal_test_2, decimal_test_3) VALUES (?, ?, ?)", | ||
| Bindings: map[string]sql.Expression{ | ||
| "v1": expression.NewLiteral(10, sql.Int64), | ||
| "v2": expression.NewLiteral([]byte("10.5"), sql.MustCreateString(sqltypes.VarBinary, 4, sql.Collation_binary)), |
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.
Does the varbinary type trigger the same issue as X'10'? Just curious if it's worth adding that hex value to the test.
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.
Do you mean to test with X'10' instead of 10.5 as binding value?
Something I noticed that I did not understand clearly was that we convert many types into varbinary in https://github.com/dolthub/vitess/blob/main/go/mysql/query.go#L842 , but we are not able to convert them back to its original type in this method, https://github.com/dolthub/go-mysql-server/blob/main/server/handler.go#L180 , so for example passing in X'10' causes panic because we try to handle it as the same way as any string like "X'10'"
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.
Interesting... sending a hex string as a bindvar still causes a panic? Could you please open a tracking issue for that one with a good repro and we can tackle it separately?
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.
made an issue here dolthub/dolt#4989
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.
Looks good. Thanks for iterating on the feedback!
I'm still concerned about that panic with hex formatted string bind vars, but we can tackle that one separately.
MySQL docs:
In numeric contexts, MySQL treats a hexadecimal literal like a BIGINT UNSIGNED (64-bit unsigned integer).