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

SHOW TABLE STATUS case sensitivity #7518

Closed
morgo opened this issue Aug 28, 2018 · 9 comments · Fixed by #35086
Closed

SHOW TABLE STATUS case sensitivity #7518

morgo opened this issue Aug 28, 2018 · 9 comments · Fixed by #35086
Assignees
Labels
affects-6.1 This bug affects the 6.1.x(LTS) versions. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. severity/minor sig/sql-infra SIG: SQL Infra type/compatibility

Comments

@morgo
Copy link
Contributor

morgo commented Aug 28, 2018

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
MySQL [test]> show tables;
Empty set (0.00 sec)

MySQL [test]> CREATE TABLE t1 (a int);
Query OK, 0 rows affected (0.12 sec)

MySQL [test]> SELECT * FROM T1;
Empty set (0.11 sec)

MySQL [test]> SHOW TABLE STATUS like 't1';
+------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+-----------------------------------+---------------------+---------------------+-----------------+----------+----------------+---------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time                       | Update_time         | Check_time          | Collation       | Checksum | Create_options | Comment |
+------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+-----------------------------------+---------------------+---------------------+-----------------+----------+----------------+---------+
| t1   | InnoDB |      10 | Compact    |  100 |            100 |         100 |             100 |          100 |       100 |            100 | 2018-08-28 14:31:40.165 +0000 UTC | 2018-08-28 14:32:04 | 2018-08-28 14:32:04 | utf8_general_ci |          |                |         |
+------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+-----------------------------------+---------------------+---------------------+-----------------+----------+----------------+---------+
1 row in set (0.00 sec)

MySQL [test]> SHOW TABLE STATUS like 'T1';
Empty set (0.00 sec)

Also:

MySQL [test]> SELECT * FROM information_schema.tables where table_schema='test' and table_name='T1'\G
Empty set (0.02 sec)

This command is however correct:

MySQL [test]> SHOW CREATE TABLE T1;
+-------+------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                         |
+-------+------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin |
+-------+------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

(I checked some other commands too: SHOW INDEXES FROM T1 is also correct leading to some inconsistency.)

  1. What did you expect to see?

SHOW TABLE STATUS should be case insensitive / behave the same as the select statement, since TiDB behaves according to lower_case_table_names=2.

  1. What did you see instead?

No result.

  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?

MySQL [test]> SELECT tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v2.1.0-beta-229-g5404e2e
Git Commit Hash: 5404e2e
Git Branch: master
UTC Build Time: 2018-08-14 01:46:09
GoVersion: go version go1.10.2 linux/amd64
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
1 row in set (0.00 sec)

@zimulala zimulala added the help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. label Aug 30, 2018
@iamzhoug37
Copy link
Contributor

iamzhoug37 commented Oct 18, 2018

Let me fix this problem

iamzhoug37 pushed a commit to iamzhoug37/tidb that referenced this issue Oct 22, 2018
iamzhoug37 pushed a commit to iamzhoug37/tidb that referenced this issue Oct 25, 2018
bugfix fixed pingcap#7518

expression: MySQL compatible current_user function (pingcap#7801)

plan: propagate constant over outer join (pingcap#7794)

- extract `outerCol = const` from join conditions and filter conditions,
  substitute `outerCol` in join conditions with `const`;
- extract `outerCol = innerCol` from join conditions, derive new join
  conditions based on this column equal condition and `outerCol` related
  expressions in join conditions and filter conditions;

util/timeutil: fix data race caused by forgetting set stats lease to 0 (pingcap#7901)

stats: handle ddl event for partition table (pingcap#7903)

plan: implement Operand and Pattern of cascades planner. (pingcap#7910)

planner: not convert to TableDual if empty range is derived from deferred constants (pingcap#7808)

plan: move projEliminate behind aggEliminate (pingcap#7909)

admin: fix admin check table bug of byte compare (pingcap#7887)

* admin: remove reflect deepEqual

stats: fix panic caused by empty histogram (pingcap#7912)

plan: fix panic caused by empty schema of LogicalTableDual (pingcap#7906)

* fix drop view if exist error (pingcap#7833)

executor: refine `explain analyze` (pingcap#7888)

executor: add an variable to compatible with MySQL insert for OGG (pingcap#7863)

expression: maintain `DeferredExpr` in aggressive constant folding. (pingcap#7915)

stats: fix histogram boundaries overflow error (pingcap#7883)

ddl:support the definition of `null` change to `not null` using `alter table` (pingcap#7771)

* ddl:support the definition of null change to not null using alter table

ddl: add check when create table with foreign key. (pingcap#7885)

* ddl: add check when create table with foreign key

planner: eliminate if null on non null column (pingcap#7924)

executor: fix a bug in point get (pingcap#7934)

planner, executor: refine ColumnPrune for LogicalUnionAll (pingcap#7930)

executor: fix panic when limit is too large (pingcap#7936)

ddl: add TiDB version to metrics (pingcap#7902)

stats: limit the length of sample values (pingcap#7931)

vendor: update tipb (pingcap#7893)

planner: support the Group and GroupExpr for the cascades planner (pingcap#7917)

store/tikv: log more information when other err occurs (pingcap#7948)

types: fix date time parse (pingcap#7933)

ddl: just print error message when ddl job is normal to calcel, to eliminate noisy log (pingcap#7875)

stats: update delta info for partition table (pingcap#7947)

explaintest: add explain test for partition pruning (pingcap#7505)

util: move disjoint set to util package (pingcap#7950)

util: add PreAlloc4Row and Insert for Chunk and List (pingcap#7916)

executor: add the slow log for commit (pingcap#7951)

expression: add builtin json_keys (pingcap#7776)

privilege: add USAGE in `show grants` for mysql compatibility (pingcap#7955)

ddl: fix invailid ddl job panic (pingcap#7940)

*: move ast.NewValueExpr to standalone parser_driver package (pingcap#7952)

Make the ast package get rid of the dependency of types.Datum

server: allow cors http request (pingcap#7939)

*: move `Statement` and `RecordSet` from ast to sqlexec package (pingcap#7970)

pr suggestion update

executor/aggfuncs: split unit tests to corresponding file (pingcap#7993)

store/tikv: fix typo (pingcap#7990)

executor, planner: clone proj schema for different children in buildProj4Union (pingcap#7999)

executor: let information_schema be the first database in ShowDatabases (pingcap#7938)

stats: use local feedback for partition table (pingcap#7963)

executor: add unit test for aggfuncs (pingcap#7966)

server: add log for binary execute statement (pingcap#7987)

admin: refine admin check decoder (pingcap#7862)

executor: improve wide table insert & update performance (pingcap#7935)

ddl: fix reassigned partition id in `truncate table` does not take effect (pingcap#7919)

fix reassigned partition id in truncate table does not take effect

add changelog for 2.1.0 rc4 (pingcap#8020)

*: make parser package dependency as small as possible (pingcap#7989)

parser: support `:=` in the `set` syntax (pingcap#8018)

According to MySQL document, `set` use the = assignment operator,
but the := assignment operator is also permitted

stats: garbage collect stats for partition table (pingcap#7962)

docs: add the proposal for the column pool (pingcap#7988)

expression: refine built-in func truncate to support uint arg (pingcap#8000)

stats: support show stats for partition table (pingcap#8023)

stats: update error rate for partition table (pingcap#8022)

stats: fix estimation for out of range point queries (pingcap#8015)

*: move parser to a separate repository (pingcap#8036)

executor: fix wrong result when index join on union scan. (pingcap#8031)

Do not modify Plan of dataReaderBuilder directly, because it would
impact next batch of outer rows, as well as other concurrent inner
workers. Instead, build a local child builder to store the child plan.

planner: fix a panic of a cached prepared statement with IndexScan (pingcap#8017)

*: fix the issue of executing DDL after executing SQL failure in txn (pingcap#8044)

* ddl, executor: fix the issue of executing DDL after executing SQL failure in txn

add unit test

remove debug info

add like evaluator case sensitive test

ddl, domain: make schema correct after canceling jobs (pingcap#7997)

unit test fix

code format

proposal: maintaining histograms in plan. (pingcap#7605)

support _tidb_rowid for table scan range (pingcap#8047)

var rename fix
iamzhoug37 added a commit to iamzhoug37/tidb that referenced this issue Oct 25, 2018
iamzhoug37 added a commit to iamzhoug37/tidb that referenced this issue Oct 26, 2018
@ghost
Copy link

ghost commented Jul 30, 2020

Confirming this issue is still present:

..
mysql> SHOW TABLE STATUS like 'T1';
Empty set (0.01 sec)

mysql> SELECT tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v4.0.0-beta.2-859-gccfc9b2ad
Edition: Community
Git Commit Hash: ccfc9b2ad0dcf8e447210de5f559d7fc208db968
Git Branch: master
UTC Build Time: 2020-07-29 09:37:45
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0.00 sec)

@dveeden
Copy link
Contributor

dveeden commented Oct 26, 2021

..
mysql> SHOW TABLE STATUS like 'T1';
Empty set (0.02 sec)

mysql> SELECT tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v5.3.0-alpha-1209-g19a2b3c31
Edition: Community
Git Commit Hash: 19a2b3c31106470f83696f8fdaf443f150061a66
Git Branch: master
UTC Build Time: 2021-10-26 12:13:58
GoVersion: go1.16.8
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0.00 sec)

@likzn
Copy link
Contributor

likzn commented Apr 17, 2022

image
I found schemaleTables in InfoSchema.The schemaleTables has all tables of assigned schema and it has case insensitive method.

TableExists(schema, table model.CIStr) bool

How about add a rewrite(like "t%" -> in(t1,t2)),we can make a select in tidb rather than predicate pushdown to TiKV. And i think it can solve this problem and it will not break compatibility(#8066 (comment)) of TiKV. @dveeden @xiongjiwei @morgo

@hawkingrei
Copy link
Member

It is fixed by #31919.

@dveeden
Copy link
Contributor

dveeden commented May 31, 2022

@hawkingrei are you sure this is fixed?

Trying with a recent master build gives me this:

mysql> SELECT tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v6.1.0-alpha-536-g2c3f717af
Edition: Community
Git Commit Hash: 2c3f717af66c6925f46776da867790ca150ecfcc
Git Branch: master
UTC Build Time: 2022-05-31 06:40:11
GoVersion: go1.18
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
Store: tikv
1 row in set (0.00 sec)

mysql> show tables;
Empty set (0.00 sec)

mysql> CREATE TABLE t1 (a int);
Query OK, 0 rows affected (0.11 sec)

mysql> SELECT * FROM T1;
Empty set (0.00 sec)

mysql> SHOW TABLE STATUS like 't1';
+------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-------------+----------+----------------+---------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time         | Update_time | Check_time | Collation   | Checksum | Create_options | Comment |
+------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-------------+----------+----------------+---------+
| t1   | InnoDB |      10 | Compact    |    0 |              0 |           0 |               0 |            0 |         0 |           NULL | 2022-05-31 08:47:11 | NULL        | NULL       | utf8mb4_bin |          |                |         |
+------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-------------+----------+----------------+---------+
1 row in set (0.01 sec)

mysql> SHOW TABLE STATUS like 'T1';
Empty set (0.02 sec)

mysql> SELECT * FROM information_schema.tables where table_schema='test' and table_name='T1'\G
Empty set (0.02 sec)

mysql> SHOW CREATE TABLE T1;
+-------+------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                               |
+-------+------------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE `t1` (
  `a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+-------+------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

@hawkingrei hawkingrei reopened this May 31, 2022
@hawkingrei
Copy link
Member

Sorry, Show table is fixed by #31919. but show table status is not fixed. but I think it is easy that it has the same way to fix it.

@likzn
Copy link
Contributor

likzn commented May 31, 2022

/assign

@AricSu
Copy link
Contributor

AricSu commented Jan 9, 2023

image
There seems to be still some parts of compatibility issues with MySQL. Please, reopen and fix it, thanks.
@hawkingrei

@jebter jebter added the sig/sql-infra SIG: SQL Infra label Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-6.1 This bug affects the 6.1.x(LTS) versions. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. severity/minor sig/sql-infra SIG: SQL Infra type/compatibility
Projects
None yet
8 participants