MySQL SHOW INDEX merge strips table suffix from index names of non-sharding tables
Bug Report
Which version of ShardingSphere did you use?
master @ 101c3d56ccd
Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
Both
Expected behavior
SHOW INDEX FROM <non-sharding table> returns the stored Key_name; ShardingSphere never rewrites index names of single or broadcast tables.
Actual behavior
An index name ending with _<table name> loses the suffix: uk_t_config on t_config is shown as uk, while SHOW CREATE TABLE t_config still shows uk_t_config.
Reason analyze (If you can)
MySQLShardingShowIndexMergedResult.init() (features/sharding/dialect/mysql, line 55-62) applies IndexMetaDataUtils.findGeneratedLogicIndexName() to every row. For non-sharding rows the candidate list is empty, so the exact-candidate protection from #38449 never applies and the suffix is treated as generated. Non-sharding tables have no generated index names since #31173; IndexToken and the sibling MySQLShardingShowCreateTableMergedResult leave them untouched.
Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
- Configure a sharding rule for
t_order; keept_configas a single table. CREATE TABLE t_config (id INT PRIMARY KEY, code VARCHAR(32), UNIQUE KEY uk_t_config (code));SHOW INDEX FROM t_config;
Expected Key_name: PRIMARY, uk_t_config. Actual: PRIMARY, uk.
Example codes for reproduce this issue (such as a github link).
N/A
Source: apache/shardingsphere