Skip to content

allow hash vindexes to support signed ints#4309

Merged
sougou merged 2 commits intovitessio:masterfrom
slanning:vindex-signed-int
Oct 29, 2018
Merged

allow hash vindexes to support signed ints#4309
sougou merged 2 commits intovitessio:masterfrom
slanning:vindex-signed-int

Conversation

@slanning
Copy link
Copy Markdown
Contributor

corresponding to #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

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>
continue
var num uint64
var err error
if id.IsSigned() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copy link
Copy Markdown
Contributor

@sougou sougou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not 'exactly' what I had in mind, but this will do.

@sougou sougou merged commit 2dc33ec into vitessio:master Oct 29, 2018
@slanning slanning deleted the vindex-signed-int branch October 30, 2018 10:16
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.

2 participants