Skip to content

Commit

Permalink
add special comments to output from SHOW CRAETE TABLE
Browse files Browse the repository at this point in the history
  • Loading branch information
tangenta committed Jan 19, 2021
1 parent 6d24df3 commit 34fb11a
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 35 deletions.
8 changes: 4 additions & 4 deletions ddl/db_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1577,7 +1577,7 @@ func (s *testIntegrationSuite3) TestAlterColumn(c *C) {
c.Assert(err, NotNil)
result := tk.MustQuery("show create table mc")
createSQL := result.Rows()[0][1]
expected := "CREATE TABLE `mc` (\n `a` int(11) NOT NULL,\n `b` int(11) DEFAULT NULL,\n `c` int(11) DEFAULT NULL,\n PRIMARY KEY (`a`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"
expected := "CREATE TABLE `mc` (\n `a` int(11) NOT NULL,\n `b` int(11) DEFAULT NULL,\n `c` int(11) DEFAULT NULL,\n PRIMARY KEY (`a`) /*T![clustered_index] NONCLUSTERED */\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"
c.Assert(createSQL, Equals, expected)

// Change / modify column should preserve index options.
Expand All @@ -1588,7 +1588,7 @@ func (s *testIntegrationSuite3) TestAlterColumn(c *C) {
tk.MustExec("alter table mc modify column c bigint") // Unique should be preserved
result = tk.MustQuery("show create table mc")
createSQL = result.Rows()[0][1]
expected = "CREATE TABLE `mc` (\n `a` bigint(20) NOT NULL,\n `b` bigint(20) DEFAULT NULL,\n `c` bigint(20) DEFAULT NULL,\n PRIMARY KEY (`a`),\n UNIQUE KEY `c` (`c`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"
expected = "CREATE TABLE `mc` (\n `a` bigint(20) NOT NULL,\n `b` bigint(20) DEFAULT NULL,\n `c` bigint(20) DEFAULT NULL,\n PRIMARY KEY (`a`) /*T![clustered_index] NONCLUSTERED */,\n UNIQUE KEY `c` (`c`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"
c.Assert(createSQL, Equals, expected)

// Dropping or keeping auto_increment is allowed, however adding is not allowed.
Expand All @@ -1597,15 +1597,15 @@ func (s *testIntegrationSuite3) TestAlterColumn(c *C) {
tk.MustExec("alter table mc modify column a bigint auto_increment") // Keeps auto_increment
result = tk.MustQuery("show create table mc")
createSQL = result.Rows()[0][1]
expected = "CREATE TABLE `mc` (\n `a` bigint(20) NOT NULL AUTO_INCREMENT,\n `b` int(11) DEFAULT NULL,\n PRIMARY KEY (`a`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"
expected = "CREATE TABLE `mc` (\n `a` bigint(20) NOT NULL AUTO_INCREMENT,\n `b` int(11) DEFAULT NULL,\n PRIMARY KEY (`a`) /*T![clustered_index] NONCLUSTERED */\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"
c.Assert(createSQL, Equals, expected)
_, err = tk.Exec("alter table mc modify column a bigint") // Droppping auto_increment is not allow when @@tidb_allow_remove_auto_inc == 'off'
c.Assert(err, NotNil)
tk.MustExec("set @@tidb_allow_remove_auto_inc = on")
tk.MustExec("alter table mc modify column a bigint") // Dropping auto_increment is ok when @@tidb_allow_remove_auto_inc == 'on'
result = tk.MustQuery("show create table mc")
createSQL = result.Rows()[0][1]
expected = "CREATE TABLE `mc` (\n `a` bigint(20) NOT NULL,\n `b` int(11) DEFAULT NULL,\n PRIMARY KEY (`a`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"
expected = "CREATE TABLE `mc` (\n `a` bigint(20) NOT NULL,\n `b` int(11) DEFAULT NULL,\n PRIMARY KEY (`a`) /*T![clustered_index] NONCLUSTERED */\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"
c.Assert(createSQL, Equals, expected)

_, err = tk.Exec("alter table mc modify column a bigint auto_increment") // Adds auto_increment should throw error
Expand Down
4 changes: 2 additions & 2 deletions ddl/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1794,7 +1794,7 @@ func (s *testDBSuite5) TestAlterPrimaryKey(c *C) {
" `a` int(11) NOT NULL,\n"+
" `b` int(11) NOT NULL,\n"+
" KEY `idx` (`a`),\n"+
" PRIMARY KEY (`a`,`b`)\n"+
" PRIMARY KEY (`a`,`b`) /*T![clustered_index] NONCLUSTERED */\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"))
tk.MustExec("alter table test_add_pk2 drop primary key")
tk.MustQuery("desc test_add_pk2").Check(testutil.RowsWithSep(",", ""+
Expand Down Expand Up @@ -2794,7 +2794,7 @@ func (s *testSerialDBSuite) TestRepairTable(c *C) {

// Exec the show create table statement to make sure new tableInfo has been set.
result := tk.MustQuery("show create table origin")
c.Assert(result.Rows()[0][1], Equals, "CREATE TABLE `origin` (\n `a` int(11) NOT NULL AUTO_INCREMENT,\n `b` varchar(5) DEFAULT NULL,\n `c` int(11) DEFAULT NULL,\n PRIMARY KEY (`a`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin")
c.Assert(result.Rows()[0][1], Equals, "CREATE TABLE `origin` (\n `a` int(11) NOT NULL AUTO_INCREMENT,\n `b` varchar(5) DEFAULT NULL,\n `c` int(11) DEFAULT NULL,\n PRIMARY KEY (`a`) /*T![clustered_index] NONCLUSTERED */\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin")

}

Expand Down
4 changes: 2 additions & 2 deletions ddl/failtest/fail_db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ func (s *testFailDBSuite) TestModifyColumn(c *C) {
" `bb` mediumint(9) DEFAULT NULL,\n" +
" `a` int(11) NOT NULL DEFAULT '1',\n" +
" `c` int(11) NOT NULL DEFAULT '0',\n" +
" PRIMARY KEY (`c`),\n" +
" PRIMARY KEY (`c`) /*T![clustered_index] CLUSTERED */,\n" +
" KEY `idx` (`bb`),\n" +
" KEY `idx1` (`a`),\n" +
" KEY `idx2` (`bb`,`c`)\n" +
Expand All @@ -497,7 +497,7 @@ func (s *testFailDBSuite) TestModifyColumn(c *C) {
" `bb` mediumint(9) DEFAULT NULL,\n" +
" `c` int(11) NOT NULL DEFAULT '0',\n" +
" `aa` mediumint(9) DEFAULT NULL,\n" +
" PRIMARY KEY (`c`),\n" +
" PRIMARY KEY (`c`) /*T![clustered_index] CLUSTERED */,\n" +
" KEY `idx` (`bb`),\n" +
" KEY `idx1` (`aa`),\n" +
" KEY `idx2` (`bb`,`c`)\n" +
Expand Down
4 changes: 4 additions & 0 deletions executor/clustered_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,9 @@ func (s *testClusteredSerialSuite) TestClusteredIndexSyntax(c *C) {
}
assertPkType("create table t (a int primary key, b int);", intPKDefault)
assertPkType("create table t (a int, b int, primary key(a) clustered);", intClustered)
assertPkType("create table t (a int, b int, primary key(a) /*T![clustered_index] clustered */);", intClustered)
assertPkType("create table t (a int, b int, primary key(a) nonclustered);", nonClustered)
assertPkType("create table t (a int, b int, primary key(a) /*T![clustered_index] nonclustered */);", nonClustered)

// Test for clustered index.
tk.Se.GetSessionVars().EnableClusteredIndex = false
Expand All @@ -309,6 +311,8 @@ func (s *testClusteredSerialSuite) TestClusteredIndexSyntax(c *C) {
tk.Se.GetSessionVars().EnableClusteredIndex = true
assertPkType("create table t (a int, b varchar(255), primary key(b, a));", commonPKDefault)
assertPkType("create table t (a int, b varchar(255), primary key(b, a) nonclustered);", nonClustered)
assertPkType("create table t (a int, b varchar(255), primary key(b, a) /*T![clustered_index] nonclustered */);", nonClustered)
assertPkType("create table t (a int, b varchar(255), primary key(b, a) clustered);", commonClustered)
assertPkType("create table t (a int, b varchar(255), primary key(b, a) /*T![clustered_index] clustered */);", commonClustered)
}
}
16 changes: 8 additions & 8 deletions executor/seqtest/seq_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (s *seqTestSuite) TestShow(c *C) {
row := result.Rows()[0]
// For issue https://github.com/pingcap/tidb/issues/1061
expectedRow := []interface{}{
"SHOW_test", "CREATE TABLE `SHOW_test` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `c1` int(11) DEFAULT NULL COMMENT 'c1_comment',\n `c2` int(11) DEFAULT NULL,\n `c3` int(11) DEFAULT '1',\n `c4` text DEFAULT NULL,\n `c5` tinyint(1) DEFAULT NULL,\n PRIMARY KEY (`id`),\n KEY `idx_wide_c4` (`c3`,`c4`(10))\n) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=28934 COMMENT='table_comment'"}
"SHOW_test", "CREATE TABLE `SHOW_test` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `c1` int(11) DEFAULT NULL COMMENT 'c1_comment',\n `c2` int(11) DEFAULT NULL,\n `c3` int(11) DEFAULT '1',\n `c4` text DEFAULT NULL,\n `c5` tinyint(1) DEFAULT NULL,\n PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */,\n KEY `idx_wide_c4` (`c3`,`c4`(10))\n) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=28934 COMMENT='table_comment'"}
for i, r := range row {
c.Check(r, Equals, expectedRow[i])
}
Expand All @@ -218,7 +218,7 @@ func (s *seqTestSuite) TestShow(c *C) {
c.Check(result.Rows(), HasLen, 1)
row = result.Rows()[0]
expectedRow = []interface{}{
"ptest", "CREATE TABLE `ptest` (\n `a` int(11) NOT NULL,\n `b` double NOT NULL DEFAULT '2.0',\n `c` varchar(10) NOT NULL,\n `d` time DEFAULT NULL,\n `e` timestamp NULL DEFAULT NULL,\n `f` timestamp NULL DEFAULT NULL,\n PRIMARY KEY (`a`),\n UNIQUE KEY `d` (`d`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"}
"ptest", "CREATE TABLE `ptest` (\n `a` int(11) NOT NULL,\n `b` double NOT NULL DEFAULT '2.0',\n `c` varchar(10) NOT NULL,\n `d` time DEFAULT NULL,\n `e` timestamp NULL DEFAULT NULL,\n `f` timestamp NULL DEFAULT NULL,\n PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */,\n UNIQUE KEY `d` (`d`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"}
for i, r := range row {
c.Check(r, Equals, expectedRow[i])
}
Expand Down Expand Up @@ -401,7 +401,7 @@ func (s *seqTestSuite) TestShow(c *C) {
""+
"show_auto_increment CREATE TABLE `show_auto_increment` (\n"+
" `id` int(11) NOT NULL AUTO_INCREMENT,\n"+
" PRIMARY KEY (`id`)\n"+
" PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=4",
))
// for issue https://github.com/pingcap/tidb/issues/4678
Expand All @@ -412,7 +412,7 @@ func (s *seqTestSuite) TestShow(c *C) {
""+
"show_auto_increment CREATE TABLE `show_auto_increment` (\n"+
" `id` int(11) NOT NULL AUTO_INCREMENT,\n"+
" PRIMARY KEY (`id`)\n"+
" PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT="+strconv.Itoa(int(autoID)),
))
tk.MustExec(`drop table show_auto_increment`)
Expand All @@ -421,7 +421,7 @@ func (s *seqTestSuite) TestShow(c *C) {
""+
"show_auto_increment CREATE TABLE `show_auto_increment` (\n"+
" `id` int(11) NOT NULL AUTO_INCREMENT,\n"+
" PRIMARY KEY (`id`)\n"+
" PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin",
))
tk.MustExec("insert into show_auto_increment values(10)")
Expand All @@ -430,7 +430,7 @@ func (s *seqTestSuite) TestShow(c *C) {
""+
"show_auto_increment CREATE TABLE `show_auto_increment` (\n"+
" `id` int(11) NOT NULL AUTO_INCREMENT,\n"+
" PRIMARY KEY (`id`)\n"+
" PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT="+strconv.Itoa(int(autoID)),
))

Expand Down Expand Up @@ -594,7 +594,7 @@ func (s *seqTestSuite) TestShow(c *C) {
"t CREATE TABLE `t` (\n"+
" `y` year(4) NOT NULL,\n"+
" `x` int(11) DEFAULT NULL,\n"+
" PRIMARY KEY (`y`)\n"+
" PRIMARY KEY (`y`) /*T![clustered_index] NONCLUSTERED */\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"))

// Test show create table with zerofill flag
Expand All @@ -604,7 +604,7 @@ func (s *seqTestSuite) TestShow(c *C) {
"t CREATE TABLE `t` (\n"+
" `id` int(11) NOT NULL,\n"+
" `val` tinyint(10) unsigned zerofill DEFAULT NULL,\n"+
" PRIMARY KEY (`id`)\n"+
" PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"))

// Test show columns with different types of default value
Expand Down
8 changes: 8 additions & 0 deletions executor/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,7 @@ func ConstructResultOfShowCreateTable(ctx sessionctx.Context, tableInfo *model.T
// If PKIsHanle, pk info is not in tb.Indices(). We should handle it here.
buf.WriteString(",\n")
fmt.Fprintf(buf, " PRIMARY KEY (%s)", stringutil.Escape(pkCol.Name.O, sqlMode))
buf.WriteString(fmt.Sprintf(" /*T![clustered_index] CLUSTERED */"))
}

publicIndices := make([]*model.IndexInfo, 0, len(tableInfo.Indices))
Expand Down Expand Up @@ -865,6 +866,13 @@ func ConstructResultOfShowCreateTable(ctx sessionctx.Context, tableInfo *model.T
if idxInfo.Invisible {
fmt.Fprintf(buf, ` /*!80000 INVISIBLE */`)
}
if idxInfo.Primary {
if tableInfo.PKIsHandle || tableInfo.IsCommonHandle {
buf.WriteString(fmt.Sprintf(" /*T![clustered_index] CLUSTERED */"))
} else {
buf.WriteString(fmt.Sprintf(" /*T![clustered_index] NONCLUSTERED */"))
}
}
if i != len(publicIndices)-1 {
buf.WriteString(",\n")
}
Expand Down
32 changes: 16 additions & 16 deletions executor/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ func (s *testSuite5) TestShowCreateTable(c *C) {
" `END_TIME` datetime NOT NULL,\n"+
" `USER_TYPE` int(11) DEFAULT NULL,\n"+
" `APP_ID` int(11) DEFAULT NULL,\n"+
" PRIMARY KEY (`LOG_ID`,`END_TIME`),\n"+
" PRIMARY KEY (`LOG_ID`,`END_TIME`) /*T![clustered_index] NONCLUSTERED */,\n"+
" KEY `IDX_EndTime` (`END_TIME`),\n"+
" KEY `IDX_RoundId` (`ROUND_ID`),\n"+
" KEY `IDX_UserId_EndTime` (`USER_ID`,`END_TIME`)\n"+
Expand Down Expand Up @@ -789,7 +789,7 @@ func (s *testSuite5) TestShowCreateTable(c *C) {
"child CREATE TABLE `child` (\n"+
" `id` int(11) NOT NULL AUTO_INCREMENT,\n"+
" `parent_id` int(11) NOT NULL,\n"+
" PRIMARY KEY (`id`),\n"+
" PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */,\n"+
" KEY `par_ind` (`parent_id`),\n"+
" CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`)\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin",
Expand All @@ -803,7 +803,7 @@ func (s *testSuite5) TestShowCreateTable(c *C) {
"child CREATE TABLE `child` (\n"+
" `id` int(11) NOT NULL AUTO_INCREMENT,\n"+
" `parent_id` int(11) NOT NULL,\n"+
" PRIMARY KEY (`id`),\n"+
" PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */,\n"+
" KEY `par_ind` (`parent_id`),\n"+
" CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`) ON DELETE SET NULL ON UPDATE CASCADE\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin",
Expand Down Expand Up @@ -887,7 +887,7 @@ func (s *testAutoRandomSuite) TestShowCreateTableAutoRandom(c *C) {
"auto_random_tbl1 CREATE TABLE `auto_random_tbl1` (\n"+
" `a` bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(3) */,\n"+
" `b` varchar(255) DEFAULT NULL,\n"+
" PRIMARY KEY (`a`)\n"+
" PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin",
))

Expand All @@ -898,7 +898,7 @@ func (s *testAutoRandomSuite) TestShowCreateTableAutoRandom(c *C) {
"auto_random_tbl2 CREATE TABLE `auto_random_tbl2` (\n"+
" `a` bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */,\n"+
" `b` char(1) DEFAULT NULL,\n"+
" PRIMARY KEY (`a`)\n"+
" PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin",
))

Expand All @@ -908,7 +908,7 @@ func (s *testAutoRandomSuite) TestShowCreateTableAutoRandom(c *C) {
""+
"auto_random_tbl3 CREATE TABLE `auto_random_tbl3` (\n"+
" `a` bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */,\n"+
" PRIMARY KEY (`a`)\n"+
" PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin",
))
// Test show auto_random table option.
Expand All @@ -918,7 +918,7 @@ func (s *testAutoRandomSuite) TestShowCreateTableAutoRandom(c *C) {
"auto_random_tbl4 CREATE TABLE `auto_random_tbl4` (\n"+
" `a` bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */,\n"+
" `b` varchar(255) DEFAULT NULL,\n"+
" PRIMARY KEY (`a`)\n"+
" PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![auto_rand_base] AUTO_RANDOM_BASE=100 */",
))
// Test implicit auto_random with auto_random table option.
Expand All @@ -928,7 +928,7 @@ func (s *testAutoRandomSuite) TestShowCreateTableAutoRandom(c *C) {
"auto_random_tbl5 CREATE TABLE `auto_random_tbl5` (\n"+
" `a` bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */,\n"+
" `b` char(1) DEFAULT NULL,\n"+
" PRIMARY KEY (`a`)\n"+
" PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![auto_rand_base] AUTO_RANDOM_BASE=50 */",
))
// Test auto_random table option already with special comment.
Expand All @@ -937,7 +937,7 @@ func (s *testAutoRandomSuite) TestShowCreateTableAutoRandom(c *C) {
""+
"auto_random_tbl6 CREATE TABLE `auto_random_tbl6` (\n"+
" `a` bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */,\n"+
" PRIMARY KEY (`a`)\n"+
" PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![auto_rand_base] AUTO_RANDOM_BASE=200 */",
))
}
Expand All @@ -953,7 +953,7 @@ func (s *testAutoRandomSuite) TestAutoIdCache(c *C) {
""+
"t CREATE TABLE `t` (\n"+
" `a` int(11) NOT NULL AUTO_INCREMENT,\n"+
" PRIMARY KEY (`a`)\n"+
" PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![auto_id_cache] AUTO_ID_CACHE=10 */",
))
tk.MustExec("drop table if exists t")
Expand All @@ -963,7 +963,7 @@ func (s *testAutoRandomSuite) TestAutoIdCache(c *C) {
"t CREATE TABLE `t` (\n"+
" `a` int(11) NOT NULL AUTO_INCREMENT,\n"+
" `b` int(11) NOT NULL,\n"+
" PRIMARY KEY (`b`),\n"+
" PRIMARY KEY (`b`) /*T![clustered_index] CLUSTERED */,\n"+
" UNIQUE KEY `a` (`a`)\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![auto_id_cache] AUTO_ID_CACHE=100 */",
))
Expand All @@ -973,7 +973,7 @@ func (s *testAutoRandomSuite) TestAutoIdCache(c *C) {
""+
"t CREATE TABLE `t` (\n"+
" `a` int(11) NOT NULL,\n"+
" PRIMARY KEY (`a`)\n"+
" PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![auto_id_cache] AUTO_ID_CACHE=5 */",
))
}
Expand All @@ -995,7 +995,7 @@ func (s *testAutoRandomSuite) TestAutoRandomBase(c *C) {
"t CREATE TABLE `t` (\n"+
" `a` bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */,\n"+
" `b` int(11) NOT NULL AUTO_INCREMENT,\n"+
" PRIMARY KEY (`a`),\n"+
" PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */,\n"+
" UNIQUE KEY `b` (`b`)\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=100 /*T![auto_rand_base] AUTO_RANDOM_BASE=100 */",
))
Expand All @@ -1006,7 +1006,7 @@ func (s *testAutoRandomSuite) TestAutoRandomBase(c *C) {
"t CREATE TABLE `t` (\n"+
" `a` bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */,\n"+
" `b` int(11) NOT NULL AUTO_INCREMENT,\n"+
" PRIMARY KEY (`a`),\n"+
" PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */,\n"+
" UNIQUE KEY `b` (`b`)\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=5100 /*T![auto_rand_base] AUTO_RANDOM_BASE=6001 */",
))
Expand Down Expand Up @@ -1043,7 +1043,7 @@ func (s *testSuite5) TestShowEscape(c *C) {
""+
"t`abl\"e CREATE TABLE `t``abl\"e` (\n"+
" `c``olum\"n` int(11) NOT NULL,\n"+
" PRIMARY KEY (`c``olum\"n`)\n"+
" PRIMARY KEY (`c``olum\"n`) /*T![clustered_index] CLUSTERED */\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin",
))

Expand All @@ -1054,7 +1054,7 @@ func (s *testSuite5) TestShowEscape(c *C) {
""+
"t`abl\"e CREATE TABLE \"t`abl\"\"e\" (\n"+
" \"c`olum\"\"n\" int(11) NOT NULL,\n"+
" PRIMARY KEY (\"c`olum\"\"n\")\n"+
" PRIMARY KEY (\"c`olum\"\"n\") /*T![clustered_index] CLUSTERED */\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin",
))

Expand Down
2 changes: 1 addition & 1 deletion infoschema/tables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func (s *testTableSuite) TestInfoschemaFieldValue(c *C) {
"t CREATE TABLE `t` (\n" +
" `c` int(11) NOT NULL AUTO_INCREMENT,\n" +
" `d` int(11) DEFAULT NULL,\n" +
" PRIMARY KEY (`c`)\n" +
" PRIMARY KEY (`c`) /*T![clustered_index] CLUSTERED */\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=30002"))

// Test auto_increment for table without auto_increment column
Expand Down
Loading

0 comments on commit 34fb11a

Please sign in to comment.