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

case-sensitivity issue when query information_schema.tables between TiDB and MySQL #30357

Closed
zhangyangyu opened this issue Dec 2, 2021 · 6 comments
Assignees
Labels
severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@zhangyangyu
Copy link
Member

zhangyangyu commented Dec 2, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

This seems to affect liquibase migration behaviour. It uses getTables and fire sql like:

SELECT TABLE_SCHEMA TABLE_CAT, NULL  TABLE_SCHEM,  TABLE_NAME, IF(TABLE_TYPE='BASE TABLE' or TABLE_TYPE='SYSTEM VERSIONED', 'TABLE', TABLE_TYPE) as TABLE_TYPE, TABLE_COMMENT REMARKS, NULL TYPE_CAT, NULL TYPE_SCHEM, NULL TYPE_NAME, NULL SELF_REFERENCING_COL_NAME,  NULL REF_GENERATION FROM INFORMATION_SCHEMA.TABLES  WHERE (ISNULL(database()) OR (TABLE_SCHEMA = database())) AND TABLE_NAME = 'databasechangelog'  AND TABLE_TYPE IN ('BASE TABLE','SYSTEM VERSIONED') ORDER BY TABLE_TYPE, TABLE_SCHEMA, TABLE_NAME;

1. Minimal reproduce step (Required)

use test;
CREATE TABLE `CATEGORIES` (`id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`));
select * from information_schema.tables where table_schema='test'; // we can see `CATEGORIES` table
select * from information_schema.tables where table_schema='test' and table_name='categories';

2. What did you expect to see? (Required)

In MySQL:

mysql> select * from information_schema.tables where table_schema='test' and table_name='categories';
+---------------+--------------+------------+------------+--------+---------+------------+------------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-----------------+----------+----------------+---------------+
| TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | TABLE_TYPE | ENGINE | VERSION | ROW_FORMAT | TABLE_ROWS | AVG_ROW_LENGTH | DATA_LENGTH | MAX_DATA_LENGTH | INDEX_LENGTH | DATA_FREE | AUTO_INCREMENT | CREATE_TIME         | UPDATE_TIME | CHECK_TIME | TABLE_COLLATION | CHECKSUM | CREATE_OPTIONS | TABLE_COMMENT |
+---------------+--------------+------------+------------+--------+---------+------------+------------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-----------------+----------+----------------+---------------+
| def           | test         | categories | BASE TABLE | InnoDB |      10 | Dynamic    |          0 |              0 |       16384 |               0 |            0 |         0 |              1 | 2021-12-02 13:44:38 | NULL        | NULL       | utf8_general_ci |     NULL |                |               |
+---------------+--------------+------------+------------+--------+---------+------------+------------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-----------------+----------+----------------+---------------+

3. What did you see instead (Required)

mysql> select * from information_schema.tables where table_schema='test' and table_name='categories';
Empty set (0.01 sec)

4. What is your TiDB version? (Required)

mysql> select tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                                                       |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v5.3.0
Edition: Community
Git Commit Hash: 4a1b2e9fe5b5afb1068c56de47adb07098d768d6
Git Branch: heads/refs/tags/v5.3.0
UTC Build Time: 2021-11-24 13:31:18
GoVersion: go1.16.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

Both TiDB and MySQL has lower_case_table_names to 2 since I am on macOS.

@zhangyangyu zhangyangyu added the type/bug The issue is confirmed as a bug. label Dec 2, 2021
@hawkingrei
Copy link
Member

/assign

@zhangyangyu
Copy link
Member Author

select from INFORMATION_SCHEMA.COLUMNS get the same problem. seems all columns like table_schema and table_name have the same problem.

@xiongjiwei
Copy link
Contributor

dup of #29910

@xiongjiwei
Copy link
Contributor

I will close this one. /cc @hawkingrei

@github-actions
Copy link

github-actions bot commented Dec 7, 2021

Please check whether the issue should be labeled with 'affects-x.y' or 'fixes-x.y.z', and then remove 'needs-more-info' label.

@zhangyangyu
Copy link
Member Author

/remove-label needs-more-info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

5 participants