Skip to content
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

Allow charset introducers with vindex column values #6236

Closed
gedgar opened this issue May 29, 2020 · 1 comment · Fixed by #6301 or #6314
Closed

Allow charset introducers with vindex column values #6236

gedgar opened this issue May 29, 2020 · 1 comment · Fixed by #6301 or #6314
Assignees
Milestone

Comments

@gedgar
Copy link
Contributor

gedgar commented May 29, 2020

Feature Description

Currently, Vindex column values do not support charset introducers (or any expression for that matter).

This can be problematic if you have a BLOB column set as the from field of a lookup index and as a column in a lookup table for this vindex.

For example, attempting to:
INSERT INTO `Testing.GetByBytesEntity` (`bytes`) VALUES (@1); SELECT `id`, `bytes` FROM `Testing.GetByBytesEntity` WHERE `id`=last_insert_id();

Returns the following error:

vtgate: could not compute value for vindex or auto-inc column: expression is too complex '_binary :vtg19'

In this case, because parameter 1 is of type []byte, the go-sql-driver prepends the value with the _binary charset introducer. Attempts to work around this by sending the binary as a string-encoded equivalent (https://dev.mysql.com/doc/refman/5.7/en/hexadecimal-literals.html) were unsuccessful.

CC @harshit-gangal

@aquarapid
Copy link
Contributor

The PR works for SELECT / INSERT; but fails on at least some UPDATE statements, viz:

mysql> desc t1;
+-----------+----------------+------+-----+---------+-------+
| Field     | Type           | Null | Key | Default | Extra |
+-----------+----------------+------+-----+---------+-------+
| id        | bigint         | NO   | PRI | NULL    |       |
| bytes_key | varbinary(255) | NO   | UNI | NULL    |       |
+-----------+----------------+------+-----+---------+-------+
2 rows in set (0.01 sec)
  • Note that column t1.bytes_key refers to a lookup vindex.

  • Inserts work fine:

mysql> insert into t1 (id, bytes_key) values (1,_binary '\0\0');
Query OK, 1 row affected (0.03 sec)
  • And so do selects, including selects with _binary:
mysql> select * from t1;
+----+----------------------+
| id | bytes_key            |
+----+----------------------+
|  1 | 0x0000               |
+----+----------------------+
1 row in set (0.01 sec)
mysql> select * from t1 where bytes_key = _binary '\0\0';
+----+----------------------+
| id | bytes_key            |
+----+----------------------+
|  1 | 0x0000               |
+----+----------------------+
1 row in set (0.01 sec)
  • However, updates with _binary does not work:
mysql> update t1 set `bytes_key`=_binary '\0\001\002' where `id`=1;
ERROR 1235 (HY000): vtgate: http://localhost:15001/: unsupported: Only values are supported. Invalid update on column: bytes_key

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants