vitessio / vitess

Vitess is a database clustering system for horizontal scaling of MySQL.
http://vitess.io
Apache License 2.0
18.57k stars 2.09k forks source link

INFORMATION_SCHEMA.TABLE_SCHEMA comparison with dynamic value no longer works #6827

Closed aquarapid closed 4 years ago

aquarapid commented 4 years ago

6638 seems to have broken this query (based on our 101_initial_cluster.sh cluster examples):

mysql> SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = (SELECT SCHEMA()) AND TABLE_NAME = 'product' AND COLUMN_KEY = 'PRI';
ERROR 1235 (HY000): vtgate: http://localhost:15001/: comparison with `table_schema` column not supported

However, bare comparisons with a static value still works:

mysql> SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = "commerce" AND TABLE_NAME = 'product' AND COLUMN_KEY = 'PRI';
+-------------+
| COLUMN_NAME |
+-------------+
| sku         |
+-------------+

if you revert #6638 , and run the first query, it works as expected:

mysql> SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = (SELECT SCHEMA()) AND TABLE_NAME = 'product' AND COLUMN_KEY = 'PRI';
+-------------+
| COLUMN_NAME |
+-------------+
| sku         |
+-------------+

This has broken Apache Sqoop, which generates queries like this, and the form of the query cannot be overridden (at least in Sqoop 1.4.7)

aquarapid commented 4 years ago

In the specific case of Sqoop, this query can be avoided (and Sqoop can be made to work), by using the --split-by option, and explicitly specifying the PK for the table in question.