Skip to content

Conversation

@jennifersp
Copy link
Contributor

@jennifersp jennifersp commented Dec 14, 2022

MySQL docs:
In numeric contexts, MySQL treats a hexadecimal literal like a BIGINT UNSIGNED (64-bit unsigned integer).

@jennifersp jennifersp requested a review from fulghum December 14, 2022 00:49
Copy link
Contributor

@fulghum fulghum left a 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)),
Copy link
Contributor

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.

Copy link
Contributor Author

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'"

Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

@fulghum fulghum left a 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.

@jennifersp jennifersp merged commit a605cda into main Dec 14, 2022
@jennifersp jennifersp deleted the jennifer/hex branch December 14, 2022 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

insert on decimal type column fails with prepared stmt - decimal conversion issue

3 participants