allow hash vindexes to support signed ints#4309
Merged
sougou merged 2 commits intovitessio:masterfrom Oct 29, 2018
Merged
Conversation
corresponding to vitessio#4303 Previously the code for `hash` indexes would check if the value was negative and fail with a `DestinationNone` error. This change allows a signed int64 index column value to be negative by casting it to a uint64. Signed-off-by: Scott Lanning <scott.lanning@booking.com>
sougou
reviewed
Oct 27, 2018
| continue | ||
| var num uint64 | ||
| var err error | ||
| if id.IsSigned() { |
Contributor
There was a problem hiding this comment.
This is better than what we have, but this will fail implicit conversions from string values. You could instead recreate (or reuse) this logic: https://github.com/vitessio/vitess/blob/master/go/sqltypes/arithmetic.go#L294, which will make this function more permissive.
I personally prefer more strict typing, but others have argued that we should more closely mimic MySQL. Let me know which way you want to go.
Contributor
Author
There was a problem hiding this comment.
That's how I originally did it, but apparently got confused along the way. See if it looks better now.
after @sougou's feedback in PR 4309 (An alternative way to make things work was to comment out the check for negative values in sqltypes.ToUint64 but I thought that might be too low-level to mess with.) Signed-off-by: Scott Lanning <scott.lanning@booking.com>
sougou
approved these changes
Oct 29, 2018
Contributor
sougou
left a comment
There was a problem hiding this comment.
Not 'exactly' what I had in mind, but this will do.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
corresponding to #4303
Previously the code for
hashindexes would check if the value was negativeand fail with a
DestinationNoneerror. This change allows a signed int64 index column valueto be negative by casting it to a uint64.
Signed-off-by: Scott Lanning scott.lanning@booking.com