From 66d8cdc3d02af9bbf1b652e1c5cbcfbd68c4ea3b Mon Sep 17 00:00:00 2001 From: samba <74422601+samba-rgb@users.noreply.github.com> Date: Fri, 20 Sep 2024 02:34:31 +0530 Subject: [PATCH] executor: Add Global to SHOW INDEX output (#56028) ref pingcap/tidb#55452 --- pkg/ddl/db_change_test.go | 16 +-- pkg/executor/show.go | 8 ++ pkg/executor/show_test.go | 27 ++++ .../test/seqtest/seq_executor_test.go | 24 ++-- pkg/planner/core/planbuilder.go | 4 +- .../r/ddl/multi_schema_change.result | 6 +- .../r/ddl/primary_key_handle.result | 4 +- .../r/executor/executor.result | 8 +- tests/integrationtest/r/executor/show.result | 30 ++-- .../r/session/clustered_index.result | 128 +++++++++--------- 10 files changed, 145 insertions(+), 110 deletions(-) diff --git a/pkg/ddl/db_change_test.go b/pkg/ddl/db_change_test.go index 1e9f595210a03..740b94135d01b 100644 --- a/pkg/ddl/db_change_test.go +++ b/pkg/ddl/db_change_test.go @@ -846,7 +846,7 @@ func TestShowIndex(t *testing.T) { } rows := tk.ResultSetToResult(result, fmt.Sprintf("sql:%s", showIndexSQL)) got := fmt.Sprintf("%s", rows.Rows()) - need := fmt.Sprintf("%s", testkit.Rows("t 0 PRIMARY 1 c1 A 0 BTREE YES NO")) + need := fmt.Sprintf("%s", testkit.Rows("t 0 PRIMARY 1 c1 A 0 BTREE YES NO NO")) if got != need { checkErr = fmt.Errorf("need %v, but got %v", need, got) } @@ -857,8 +857,8 @@ func TestShowIndex(t *testing.T) { require.NoError(t, checkErr) tk.MustQuery(showIndexSQL).Check(testkit.Rows( - "t 0 PRIMARY 1 c1 A 0 BTREE YES NO", - "t 1 c2 1 c2 A 0 YES BTREE YES NO", + "t 0 PRIMARY 1 c1 A 0 BTREE YES NO NO", + "t 1 c2 1 c2 A 0 YES BTREE YES NO NO", )) testfailpoint.Disable(t, "github.com/pingcap/tidb/pkg/ddl/onJobUpdated") @@ -875,26 +875,26 @@ func TestShowIndex(t *testing.T) { partition p5 values less than (2015) );`) tk.MustExec("create index idx1 on tr (purchased);") - tk.MustQuery("show index from tr;").Check(testkit.Rows("tr 1 idx1 1 purchased A 0 YES BTREE YES NO")) + tk.MustQuery("show index from tr;").Check(testkit.Rows("tr 1 idx1 1 purchased A 0 YES BTREE YES NO NO")) tk.MustExec("drop table if exists tr") tk.MustExec("create table tr(id int primary key clustered, v int, key vv(v))") - tk.MustQuery("show index from tr").Check(testkit.Rows("tr 0 PRIMARY 1 id A 0 BTREE YES YES", "tr 1 vv 1 v A 0 YES BTREE YES NO")) + tk.MustQuery("show index from tr").Check(testkit.Rows("tr 0 PRIMARY 1 id A 0 BTREE YES YES NO", "tr 1 vv 1 v A 0 YES BTREE YES NO NO")) tk.MustQuery("select key_name, clustered from information_schema.tidb_indexes where table_name = 'tr' order by key_name").Check(testkit.Rows("PRIMARY YES", "vv NO")) tk.MustExec("drop table if exists tr") tk.MustExec("create table tr(id int primary key nonclustered, v int, key vv(v))") - tk.MustQuery("show index from tr").Check(testkit.Rows("tr 1 vv 1 v A 0 YES BTREE YES NO", "tr 0 PRIMARY 1 id A 0 BTREE YES NO")) + tk.MustQuery("show index from tr").Check(testkit.Rows("tr 1 vv 1 v A 0 YES BTREE YES NO NO", "tr 0 PRIMARY 1 id A 0 BTREE YES NO NO")) tk.MustQuery("select key_name, clustered from information_schema.tidb_indexes where table_name = 'tr' order by key_name").Check(testkit.Rows("PRIMARY NO", "vv NO")) tk.MustExec("drop table if exists tr") tk.MustExec("create table tr(id char(100) primary key clustered, v int, key vv(v))") - tk.MustQuery("show index from tr").Check(testkit.Rows("tr 1 vv 1 v A 0 YES BTREE YES NO", "tr 0 PRIMARY 1 id A 0 BTREE YES YES")) + tk.MustQuery("show index from tr").Check(testkit.Rows("tr 1 vv 1 v A 0 YES BTREE YES NO NO", "tr 0 PRIMARY 1 id A 0 BTREE YES YES NO")) tk.MustQuery("select key_name, clustered from information_schema.tidb_indexes where table_name = 'tr' order by key_name").Check(testkit.Rows("PRIMARY YES", "vv NO")) tk.MustExec("drop table if exists tr") tk.MustExec("create table tr(id char(100) primary key nonclustered, v int, key vv(v))") - tk.MustQuery("show index from tr").Check(testkit.Rows("tr 1 vv 1 v A 0 YES BTREE YES NO", "tr 0 PRIMARY 1 id A 0 BTREE YES NO")) + tk.MustQuery("show index from tr").Check(testkit.Rows("tr 1 vv 1 v A 0 YES BTREE YES NO NO", "tr 0 PRIMARY 1 id A 0 BTREE YES NO NO")) tk.MustQuery("select key_name, clustered from information_schema.tidb_indexes where table_name = 'tr' order by key_name").Check(testkit.Rows("PRIMARY NO", "vv NO")) } diff --git a/pkg/executor/show.go b/pkg/executor/show.go index 1291f0d54e214..70c9e20b87fef 100644 --- a/pkg/executor/show.go +++ b/pkg/executor/show.go @@ -822,6 +822,7 @@ func (e *ShowExec) fetchShowIndex() error { "YES", // Index_visible nil, // Expression "YES", // Clustered + "NO", // Global_index }) } for _, idx := range tb.Indices() { @@ -833,6 +834,12 @@ func (e *ShowExec) fetchShowIndex() error { if tb.Meta().IsCommonHandle && idxInfo.Primary { isClustered = "YES" } + + isGlobalIndex := "NO" + if idxInfo.Global { + isGlobalIndex = "YES" + } + for i, col := range idxInfo.Columns { nonUniq := 1 if idx.Meta().Unique { @@ -885,6 +892,7 @@ func (e *ShowExec) fetchShowIndex() error { visible, // Index_visible expression, // Expression isClustered, // Clustered + isGlobalIndex, // Global_index }) } } diff --git a/pkg/executor/show_test.go b/pkg/executor/show_test.go index 66d8939189df6..17db17fd8406e 100644 --- a/pkg/executor/show_test.go +++ b/pkg/executor/show_test.go @@ -97,3 +97,30 @@ func TestShow(t *testing.T) { tk.MustExec("create global temporary table test.t2(id int) ON COMMIT DELETE ROWS;") tk.MustQuery("show tables from test like 't2';").Check(testkit.Rows("t2")) } + +func TestShowIndex(t *testing.T) { + store := testkit.CreateMockStore(t) + tk := testkit.NewTestKit(t, store) + + tk.MustExec("use test") + tk.MustExec("create table t(id int, abclmn int);") + + tk.MustExec("create index idx on t(abclmn);") + tk.MustQuery("show index from t").Check(testkit.Rows("t 1 idx 1 abclmn A 0 YES BTREE YES NO NO")) +} + +func TestShowIndexWithGlobalIndex(t *testing.T) { + store := testkit.CreateMockStore(t) + tk := testkit.NewTestKit(t, store) + + tk.MustExec("use test") + tk.MustExec("set tidb_enable_global_index=true;") + + defer tk.MustExec("set tidb_enable_global_index=false;") + + tk.MustExec("create table test_t1 (a int, b int) partition by range (b) (partition p0 values less than (10), partition p1 values less than (maxvalue));") + + tk.MustExec("insert test_t1 values (1, 1);") + tk.MustExec("alter table test_t1 add unique index p_a (a) GLOBAL;") + tk.MustQuery("show index from test_t1").Check(testkit.Rows("test_t1 0 p_a 1 a A 0 YES BTREE YES NO YES")) +} diff --git a/pkg/executor/test/seqtest/seq_executor_test.go b/pkg/executor/test/seqtest/seq_executor_test.go index 784bd8ad3c7c8..cf1a04363f62d 100644 --- a/pkg/executor/test/seqtest/seq_executor_test.go +++ b/pkg/executor/test/seqtest/seq_executor_test.go @@ -270,18 +270,18 @@ func TestShow(t *testing.T) { tk.MustExec(`create index expr_idx on show_index ((id*2+1))`) testSQL = "SHOW index from show_index;" tk.MustQuery(testSQL).Check(testkit.RowsWithSep("|", - "show_index|0|PRIMARY|1|id|A|0||||BTREE| |YES||YES", - "show_index|1|cIdx|1|c|A|0|||YES|HASH||index_comment_for_cIdx|YES||NO", - "show_index|1|idx1|1|id|A|0||||HASH| |YES||NO", - "show_index|1|idx2|1|id|A|0||||BTREE||idx|YES||NO", - "show_index|1|idx3|1|id|A|0||||HASH||idx|YES||NO", - "show_index|1|idx4|1|id|A|0||||BTREE||idx|YES||NO", - "show_index|1|idx5|1|id|A|0||||BTREE||idx|YES||NO", - "show_index|1|idx6|1|id|A|0||||HASH| |YES||NO", - "show_index|1|idx7|1|id|A|0||||BTREE| |YES||NO", - "show_index|1|idx8|1|id|A|0||||BTREE| |YES||NO", - "show_index|1|idx9|1|id|A|0||||BTREE| |NO||NO", - "show_index|1|expr_idx|1|NULL|A|0||||BTREE| |YES|`id` * 2 + 1|NO", + "show_index|0|PRIMARY|1|id|A|0||||BTREE| |YES||YES|NO", + "show_index|1|cIdx|1|c|A|0|||YES|HASH||index_comment_for_cIdx|YES||NO|NO", + "show_index|1|idx1|1|id|A|0||||HASH| |YES||NO|NO", + "show_index|1|idx2|1|id|A|0||||BTREE||idx|YES||NO|NO", + "show_index|1|idx3|1|id|A|0||||HASH||idx|YES||NO|NO", + "show_index|1|idx4|1|id|A|0||||BTREE||idx|YES||NO|NO", + "show_index|1|idx5|1|id|A|0||||BTREE||idx|YES||NO|NO", + "show_index|1|idx6|1|id|A|0||||HASH| |YES||NO|NO", + "show_index|1|idx7|1|id|A|0||||BTREE| |YES||NO|NO", + "show_index|1|idx8|1|id|A|0||||BTREE| |YES||NO|NO", + "show_index|1|idx9|1|id|A|0||||BTREE| |NO||NO|NO", + "show_index|1|expr_idx|1|NULL|A|0||||BTREE| |YES|`id` * 2 + 1|NO|NO", )) // For show like with escape diff --git a/pkg/planner/core/planbuilder.go b/pkg/planner/core/planbuilder.go index c6005381e6b0b..e082f5e569b2a 100644 --- a/pkg/planner/core/planbuilder.go +++ b/pkg/planner/core/planbuilder.go @@ -5497,11 +5497,11 @@ func buildShowSchema(s *ast.ShowStmt, isView bool, isSequence bool) (schema *exp case ast.ShowIndex: names = []string{"Table", "Non_unique", "Key_name", "Seq_in_index", "Column_name", "Collation", "Cardinality", "Sub_part", "Packed", - "Null", "Index_type", "Comment", "Index_comment", "Visible", "Expression", "Clustered"} + "Null", "Index_type", "Comment", "Index_comment", "Visible", "Expression", "Clustered", "Global"} ftypes = []byte{mysql.TypeVarchar, mysql.TypeLonglong, mysql.TypeVarchar, mysql.TypeLonglong, mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeLonglong, mysql.TypeLonglong, mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeVarchar, - mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeVarchar} + mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeVarchar} case ast.ShowPlugins: names = []string{"Name", "Status", "Type", "Library", "License", "Version"} ftypes = []byte{ diff --git a/tests/integrationtest/r/ddl/multi_schema_change.result b/tests/integrationtest/r/ddl/multi_schema_change.result index f59048933d130..ae93d25f72883 100644 --- a/tests/integrationtest/r/ddl/multi_schema_change.result +++ b/tests/integrationtest/r/ddl/multi_schema_change.result @@ -172,7 +172,7 @@ create table t (a int, b int, c int); alter table t add index t(a), add index t(b); Error 8200 (HY000): Unsupported operate same index 't' show index from t; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global drop table if exists t; create table t (a int, b int, c int); alter table t add index t(a), drop column a; @@ -180,14 +180,14 @@ Error 8200 (HY000): Unsupported operate same column 'a' alter table t add index t(a, b), drop column a; Error 8200 (HY000): Unsupported operate same column 'a' show index from t; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global drop table if exists t; create table t (a int, b int, c int); insert into t values (1, 1, 1), (2, 2, 2), (3, 3, 1); alter table t add unique index i1(a), add unique index i2(a, b), add unique index i3(c); Error 1062 (23000): Duplicate entry '1' for key 't.i3' show index from t; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global alter table t add index i1(a), add index i2(a, b), add index i3(c); drop table if exists t; create table t (a int, b int, c int, index t(a)); diff --git a/tests/integrationtest/r/ddl/primary_key_handle.result b/tests/integrationtest/r/ddl/primary_key_handle.result index 296ff80f8ed57..38df5c40aae92 100644 --- a/tests/integrationtest/r/ddl/primary_key_handle.result +++ b/tests/integrationtest/r/ddl/primary_key_handle.result @@ -312,5 +312,5 @@ a b alter table t6 drop primary key; Error 3522 (HY000): A primary key index cannot be invisible show index from t6 where Key_name='PRIMARY'; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t6 0 PRIMARY 1 b A 0 NULL NULL BTREE YES NULL NO +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t6 0 PRIMARY 1 b A 0 NULL NULL BTREE YES NULL NO NO diff --git a/tests/integrationtest/r/executor/executor.result b/tests/integrationtest/r/executor/executor.result index 2160bd11832cd..fcfab2c5b341e 100644 --- a/tests/integrationtest/r/executor/executor.result +++ b/tests/integrationtest/r/executor/executor.result @@ -3158,11 +3158,11 @@ InnoDB DEFAULT Supports transactions, row-level locking, and foreign keys YES YE drop table if exists t; create table t(a int primary key); show index in t; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t 0 PRIMARY 1 a A 0 NULL NULL BTREE YES NULL YES +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t 0 PRIMARY 1 a A 0 NULL NULL BTREE YES NULL YES NO show index from t; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t 0 PRIMARY 1 a A 0 NULL NULL BTREE YES NULL YES +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t 0 PRIMARY 1 a A 0 NULL NULL BTREE YES NULL YES NO show master status; File Position Binlog_Do_DB Binlog_Ignore_DB Executed_Gtid_Set tidb-binlog 0 diff --git a/tests/integrationtest/r/executor/show.result b/tests/integrationtest/r/executor/show.result index 4c0627d302622..df40d90f8809f 100644 --- a/tests/integrationtest/r/executor/show.result +++ b/tests/integrationtest/r/executor/show.result @@ -88,21 +88,21 @@ t CREATE TABLE `t` ( drop table if exists t2; CREATE TABLE t2(a int primary key, b int unique, c int not null, unique index (c)); SHOW INDEX IN t2; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t2 0 PRIMARY 1 a A 0 NULL NULL BTREE YES NULL YES -t2 0 c 1 c A 0 NULL NULL BTREE YES NULL NO -t2 0 b 1 b A 0 NULL NULL YES BTREE YES NULL NO +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t2 0 PRIMARY 1 a A 0 NULL NULL BTREE YES NULL YES NO +t2 0 c 1 c A 0 NULL NULL BTREE YES NULL NO NO +t2 0 b 1 b A 0 NULL NULL YES BTREE YES NULL NO NO CREATE INDEX t2_b_c_index ON t2 (b, c); CREATE INDEX t2_c_b_index ON t2 (c, b); SHOW INDEX IN t2; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t2 0 PRIMARY 1 a A 0 NULL NULL BTREE YES NULL YES -t2 0 c 1 c A 0 NULL NULL BTREE YES NULL NO -t2 0 b 1 b A 0 NULL NULL YES BTREE YES NULL NO -t2 1 t2_b_c_index 1 b A 0 NULL NULL YES BTREE YES NULL NO -t2 1 t2_b_c_index 2 c A 0 NULL NULL BTREE YES NULL NO -t2 1 t2_c_b_index 1 c A 0 NULL NULL BTREE YES NULL NO -t2 1 t2_c_b_index 2 b A 0 NULL NULL YES BTREE YES NULL NO +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t2 0 PRIMARY 1 a A 0 NULL NULL BTREE YES NULL YES NO +t2 0 c 1 c A 0 NULL NULL BTREE YES NULL NO NO +t2 0 b 1 b A 0 NULL NULL YES BTREE YES NULL NO NO +t2 1 t2_b_c_index 1 b A 0 NULL NULL YES BTREE YES NULL NO NO +t2 1 t2_b_c_index 2 c A 0 NULL NULL BTREE YES NULL NO NO +t2 1 t2_c_b_index 1 c A 0 NULL NULL BTREE YES NULL NO NO +t2 1 t2_c_b_index 2 b A 0 NULL NULL YES BTREE YES NULL NO NO drop table if exists test1; CREATE TABLE `test1` (`id` int(0) NOT NULL,`num` int(0) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; create or replace view test1_v as(select id,row_number() over (partition by num) from test1); @@ -895,9 +895,9 @@ xor year yearweek SHOW INDEX FROM performance_schema.events_statements_summary_by_digest; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -events_statements_summary_by_digest 0 SCHEMA_NAME 1 SCHEMA_NAME A 0 NULL NULL YES BTREE YES NULL NO -events_statements_summary_by_digest 0 SCHEMA_NAME 2 DIGEST A 0 NULL NULL YES BTREE YES NULL NO +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +events_statements_summary_by_digest 0 SCHEMA_NAME 1 SCHEMA_NAME A 0 NULL NULL YES BTREE YES NULL NO NO +events_statements_summary_by_digest 0 SCHEMA_NAME 2 DIGEST A 0 NULL NULL YES BTREE YES NULL NO NO drop table if exists t1, t3, t4, t5, t6, t7; create global temporary table t1 (id int) on commit delete rows; create global temporary table t3 (i int primary key, j int) on commit delete rows; diff --git a/tests/integrationtest/r/session/clustered_index.result b/tests/integrationtest/r/session/clustered_index.result index c4b84a24273a7..e51010810a0d8 100644 --- a/tests/integrationtest/r/session/clustered_index.result +++ b/tests/integrationtest/r/session/clustered_index.result @@ -300,29 +300,29 @@ create table t6(id varchar(10) primary key nonclustered, v int); create table t7(id varchar(10), v int, primary key (id) /*T![clustered_index] CLUSTERED */); create table t8(id varchar(10), v int, primary key (id) /*T![clustered_index] NONCLUSTERED */); show index from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t1 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t1 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES NO show index from t2; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t2 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t2 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO NO show index from t3; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t3 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t3 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES NO show index from t4; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t4 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t4 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES NO show index from t5; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t5 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t5 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO NO show index from t6; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t6 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t6 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO NO show index from t7; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t7 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t7 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES NO show index from t8; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t8 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t8 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO NO set @@tidb_enable_clustered_index = 'off'; drop table if exists t1, t2, t3, t4, t5, t6, t7, t8; create table t1(id int primary key, v int); @@ -334,29 +334,29 @@ create table t6(id varchar(10) primary key nonclustered, v int); create table t7(id varchar(10), v int, primary key (id) /*T![clustered_index] CLUSTERED */); create table t8(id varchar(10), v int, primary key (id) /*T![clustered_index] NONCLUSTERED */); show index from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t1 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t1 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO NO show index from t2; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t2 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t2 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO NO show index from t3; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t3 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t3 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES NO show index from t4; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t4 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t4 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES NO show index from t5; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t5 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t5 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO NO show index from t6; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t6 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t6 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO NO show index from t7; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t7 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t7 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES NO show index from t8; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t8 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t8 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO NO set @@tidb_enable_clustered_index = 'on'; drop table if exists t1, t2, t3, t4, t5, t6, t7, t8; create table t1(id int primary key, v int); @@ -368,29 +368,29 @@ create table t6(id varchar(10) primary key nonclustered, v int); create table t7(id varchar(10), v int, primary key (id) /*T![clustered_index] CLUSTERED */); create table t8(id varchar(10), v int, primary key (id) /*T![clustered_index] NONCLUSTERED */); show index from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t1 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t1 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES NO show index from t2; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t2 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t2 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES NO show index from t3; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t3 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t3 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES NO show index from t4; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t4 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t4 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES NO show index from t5; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t5 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t5 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO NO show index from t6; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t6 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t6 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO NO show index from t7; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t7 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t7 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES NO show index from t8; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t8 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t8 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO NO set @@tidb_enable_clustered_index = 'int_only'; drop table if exists t1, t2, t3, t4, t5, t6, t7, t8; create table t1(id int primary key, v int); @@ -402,29 +402,29 @@ create table t6(id varchar(10) primary key nonclustered, v int); create table t7(id varchar(10), v int, primary key (id) /*T![clustered_index] CLUSTERED */); create table t8(id varchar(10), v int, primary key (id) /*T![clustered_index] NONCLUSTERED */); show index from t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t1 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t1 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES NO show index from t2; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t2 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t2 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO NO show index from t3; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t3 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t3 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES NO show index from t4; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t4 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t4 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES NO show index from t5; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t5 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t5 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO NO show index from t6; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t6 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t6 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO NO show index from t7; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t7 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t7 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL YES NO show index from t8; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered -t8 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression Clustered Global +t8 0 PRIMARY 1 id A 0 NULL NULL BTREE YES NULL NO NO set @@tidb_enable_clustered_index = 'on'; drop table if exists t; create table t (col_1 varchar(255), col_2 tinyint, primary key idx_1 (col_1(1)));