You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #9118 we began to normalize hex values -- Base16 Numbers (HexNum) such as 0xA1 and Binary as Hex (HexVal) such as x'A1' -- in queries so that the planner cache is used for them.
For HexVals we had use the original string literal of the form x'A1' in the BindVar and pass that original user value on to mysqld (in the golang parser we decode the string literal to the hex value of A1).
The vindex functions, however, use the BindVar values when mapping the column value to a keyspace ID and so should use the binary value actually stored in the mysql column after handling the string literal: A1. Currently we are not doing that and thus the binary hash is done on x'A1' when it should be done on A1.
Reproduction Steps
Using the docker_local container from main:
make docker_local && ./docker/local/run.sh
./201_customer_tablets.sh ; ./202_move_tables.sh ; sleep 10; ./203_switch_reads.sh ; ./204_switch_writes.sh ; ./205_clean_commerce.sh ; ./301_customer_sharded.sh ; ./302_new_shards.sh ; ./303_reshard.sh ; sleep 10; ./304_switch_reads.sh ; ./305_switch_writes.sh ; ./306_down_shard_0.sh
vtctlclient GetVSchema customer > /tmp/customer.json
vtctlclient ApplyVSchema -vschema "$(jq '. | .vindexes += {"binary":{"type":"binary"}}' < /tmp/customer.json)" customer
mysql customer -e "select shard from customer.binary where id = x'7901'"
mysql customer -e "select shard from customer.binary where id = x'997901'"
Test results
13.0-SNAPSHOT:
$ mysql customer -e "select shard from customer.binary where id = x'7901'"
+-------+
| shard |
+-------+
| -80 |
+-------+
$ mysql customer -e "select shard from customer.binary where id = x'997901'"
+-------+
| shard |
+-------+
| -80 |
+-------+
11.0.2:
$ mysql customer -e "select shard from customer.binary where id = x'7901'"
+-------+
| shard |
+-------+
| -80 |
+-------+
$ mysql customer -e "select shard from customer.binary where id = x'997901'"
+-------+
| shard |
+-------+
| 80- |
+-------+
Binary version
Example:
$ vtgate --version
Version: 13.0.0-SNAPSHOT (Git revision 94c55f0832 branch 'main') built on Mon Nov 22 23:17:03 UTC 2021 by vitess@73f80c185996 using go1.17 linux/amd64
The text was updated successfully, but these errors were encountered:
mattlord
changed the title
Binary Hash VIndex Function Always Uses First Shard
Binary Hash VIndex Function With HexVals Always Uses First Shard
Nov 23, 2021
Overview of the Issue
In #9118 we began to normalize hex values -- Base16 Numbers (HexNum) such as
0xA1
and Binary as Hex (HexVal) such asx'A1'
-- in queries so that the planner cache is used for them.For HexVals we had use the original string literal of the form
x'A1'
in the BindVar and pass that original user value on to mysqld (in the golang parser we decode the string literal to the hex value ofA1
).The vindex functions, however, use the BindVar values when mapping the column value to a keyspace ID and so should use the binary value actually stored in the mysql column after handling the string literal:
A1
. Currently we are not doing that and thus the binary hash is done onx'A1'
when it should be done onA1
.Reproduction Steps
Using the docker_local container from main:
Test results
13.0-SNAPSHOT:
11.0.2:
Binary version
Example:
$ vtgate --version Version: 13.0.0-SNAPSHOT (Git revision 94c55f0832 branch 'main') built on Mon Nov 22 23:17:03 UTC 2021 by vitess@73f80c185996 using go1.17 linux/amd64
The text was updated successfully, but these errors were encountered: