executor: Add Global to SHOW INDEX output (#56028)
ref pingcap/tidb#55452
This commit is contained in:
@ -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 <nil> <nil> BTREE YES <nil> NO"))
|
||||
need := fmt.Sprintf("%s", testkit.Rows("t 0 PRIMARY 1 c1 A 0 <nil> <nil> BTREE YES <nil> 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 <nil> <nil> BTREE YES <nil> NO",
|
||||
"t 1 c2 1 c2 A 0 <nil> <nil> YES BTREE YES <nil> NO",
|
||||
"t 0 PRIMARY 1 c1 A 0 <nil> <nil> BTREE YES <nil> NO NO",
|
||||
"t 1 c2 1 c2 A 0 <nil> <nil> YES BTREE YES <nil> 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 <nil> <nil> YES BTREE YES <nil> NO"))
|
||||
tk.MustQuery("show index from tr;").Check(testkit.Rows("tr 1 idx1 1 purchased A 0 <nil> <nil> YES BTREE YES <nil> 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 <nil> <nil> BTREE YES <nil> YES", "tr 1 vv 1 v A 0 <nil> <nil> YES BTREE YES <nil> NO"))
|
||||
tk.MustQuery("show index from tr").Check(testkit.Rows("tr 0 PRIMARY 1 id A 0 <nil> <nil> BTREE YES <nil> YES NO", "tr 1 vv 1 v A 0 <nil> <nil> YES BTREE YES <nil> 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 <nil> <nil> YES BTREE YES <nil> NO", "tr 0 PRIMARY 1 id A 0 <nil> <nil> BTREE YES <nil> NO"))
|
||||
tk.MustQuery("show index from tr").Check(testkit.Rows("tr 1 vv 1 v A 0 <nil> <nil> YES BTREE YES <nil> NO NO", "tr 0 PRIMARY 1 id A 0 <nil> <nil> BTREE YES <nil> 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 <nil> <nil> YES BTREE YES <nil> NO", "tr 0 PRIMARY 1 id A 0 <nil> <nil> BTREE YES <nil> YES"))
|
||||
tk.MustQuery("show index from tr").Check(testkit.Rows("tr 1 vv 1 v A 0 <nil> <nil> YES BTREE YES <nil> NO NO", "tr 0 PRIMARY 1 id A 0 <nil> <nil> BTREE YES <nil> 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 <nil> <nil> YES BTREE YES <nil> NO", "tr 0 PRIMARY 1 id A 0 <nil> <nil> BTREE YES <nil> NO"))
|
||||
tk.MustQuery("show index from tr").Check(testkit.Rows("tr 1 vv 1 v A 0 <nil> <nil> YES BTREE YES <nil> NO NO", "tr 0 PRIMARY 1 id A 0 <nil> <nil> BTREE YES <nil> 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"))
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 <nil> <nil> YES BTREE YES <nil> 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 <nil> <nil> YES BTREE YES <nil> NO YES"))
|
||||
}
|
||||
|
||||
@ -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|<nil>|<nil>||BTREE| |YES|<nil>|YES",
|
||||
"show_index|1|cIdx|1|c|A|0|<nil>|<nil>|YES|HASH||index_comment_for_cIdx|YES|<nil>|NO",
|
||||
"show_index|1|idx1|1|id|A|0|<nil>|<nil>||HASH| |YES|<nil>|NO",
|
||||
"show_index|1|idx2|1|id|A|0|<nil>|<nil>||BTREE||idx|YES|<nil>|NO",
|
||||
"show_index|1|idx3|1|id|A|0|<nil>|<nil>||HASH||idx|YES|<nil>|NO",
|
||||
"show_index|1|idx4|1|id|A|0|<nil>|<nil>||BTREE||idx|YES|<nil>|NO",
|
||||
"show_index|1|idx5|1|id|A|0|<nil>|<nil>||BTREE||idx|YES|<nil>|NO",
|
||||
"show_index|1|idx6|1|id|A|0|<nil>|<nil>||HASH| |YES|<nil>|NO",
|
||||
"show_index|1|idx7|1|id|A|0|<nil>|<nil>||BTREE| |YES|<nil>|NO",
|
||||
"show_index|1|idx8|1|id|A|0|<nil>|<nil>||BTREE| |YES|<nil>|NO",
|
||||
"show_index|1|idx9|1|id|A|0|<nil>|<nil>||BTREE| |NO|<nil>|NO",
|
||||
"show_index|1|expr_idx|1|NULL|A|0|<nil>|<nil>||BTREE| |YES|`id` * 2 + 1|NO",
|
||||
"show_index|0|PRIMARY|1|id|A|0|<nil>|<nil>||BTREE| |YES|<nil>|YES|NO",
|
||||
"show_index|1|cIdx|1|c|A|0|<nil>|<nil>|YES|HASH||index_comment_for_cIdx|YES|<nil>|NO|NO",
|
||||
"show_index|1|idx1|1|id|A|0|<nil>|<nil>||HASH| |YES|<nil>|NO|NO",
|
||||
"show_index|1|idx2|1|id|A|0|<nil>|<nil>||BTREE||idx|YES|<nil>|NO|NO",
|
||||
"show_index|1|idx3|1|id|A|0|<nil>|<nil>||HASH||idx|YES|<nil>|NO|NO",
|
||||
"show_index|1|idx4|1|id|A|0|<nil>|<nil>||BTREE||idx|YES|<nil>|NO|NO",
|
||||
"show_index|1|idx5|1|id|A|0|<nil>|<nil>||BTREE||idx|YES|<nil>|NO|NO",
|
||||
"show_index|1|idx6|1|id|A|0|<nil>|<nil>||HASH| |YES|<nil>|NO|NO",
|
||||
"show_index|1|idx7|1|id|A|0|<nil>|<nil>||BTREE| |YES|<nil>|NO|NO",
|
||||
"show_index|1|idx8|1|id|A|0|<nil>|<nil>||BTREE| |YES|<nil>|NO|NO",
|
||||
"show_index|1|idx9|1|id|A|0|<nil>|<nil>||BTREE| |NO|<nil>|NO|NO",
|
||||
"show_index|1|expr_idx|1|NULL|A|0|<nil>|<nil>||BTREE| |YES|`id` * 2 + 1|NO|NO",
|
||||
))
|
||||
|
||||
// For show like with escape
|
||||
|
||||
@ -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{
|
||||
|
||||
@ -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));
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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)));
|
||||
|
||||
Reference in New Issue
Block a user