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

*: use CLUSTERED and NONCLUSTERED to control primary key type #22409

Merged
merged 13 commits into from
Feb 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/ddltest/ddl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ func (s *TestDDLSuite) Bootstrap(c *C) {
tk.MustExec("create table test_mixed (c1 int, c2 int, primary key(c1))")
tk.MustExec("create table test_inc (c1 int, c2 int, primary key(c1))")

tk.MustExec("set @@tidb_enable_clustered_index = 1")
tk.Se.GetSessionVars().EnableClusteredIndex = true
tk.MustExec("drop table if exists test_insert_common, test_conflict_insert_common, " +
"test_update_common, test_conflict_update_common, test_delete_common, test_conflict_delete_common, " +
"test_mixed_common, test_inc_common")
Expand All @@ -544,7 +544,7 @@ func (s *TestDDLSuite) Bootstrap(c *C) {
tk.MustExec("create table test_conflict_delete_common (c1 int, c2 int, primary key(c1, c2))")
tk.MustExec("create table test_mixed_common (c1 int, c2 int, primary key(c1, c2))")
tk.MustExec("create table test_inc_common (c1 int, c2 int, primary key(c1, c2))")
tk.MustExec("set @@tidb_enable_clustered_index = 0")
tk.Se.GetSessionVars().EnableClusteredIndex = false
}

func (s *TestDDLSuite) TestSimple(c *C) {
Expand Down
5 changes: 4 additions & 1 deletion cmd/explaintest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/pingcap/errors"
"github.com/pingcap/log"
"github.com/pingcap/parser/ast"
"github.com/pingcap/tidb/domain"
"github.com/pingcap/tidb/session"
"github.com/pingcap/tidb/sessionctx"
"github.com/pingcap/tidb/util/logutil"
Expand Down Expand Up @@ -656,13 +657,15 @@ func main() {
"set @@tidb_window_concurrency=4",
"set @@tidb_projection_concurrency=4",
"set @@tidb_distsql_scan_concurrency=15",
"set @@tidb_enable_clustered_index=0;",
"set @@global.tidb_enable_clustered_index=0;",
}
for _, sql := range resets {
if _, err = mdb.Exec(sql); err != nil {
log.Fatal(fmt.Sprintf("%s failed", sql), zap.Error(err))
}
}
// Wait global variables to reload.
time.Sleep(domain.GlobalVariableCacheExpiry)

if _, err = mdb.Exec("set sql_mode='STRICT_TRANS_TABLES'"); err != nil {
log.Fatal("set sql_mode='STRICT_TRANS_TABLES' failed", zap.Error(err))
Expand Down
12 changes: 6 additions & 6 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 Expand Up @@ -2639,8 +2639,8 @@ func (s *testIntegrationSuite7) TestDuplicateErrorMessage(c *C) {
config.UpdateGlobal(func(conf *config.Config) {
conf.EnableGlobalIndex = globalIndex
})
for _, clusteredIndex := range []int{0, 1} {
tk.MustExec(fmt.Sprintf("set session tidb_enable_clustered_index=%d;", clusteredIndex))
for _, clusteredIndex := range []bool{false, true} {
tk.Se.GetSessionVars().EnableClusteredIndex = clusteredIndex
for _, t := range tests {
tk.MustExec("drop table if exists t;")
fields := make([]string, len(t.types))
Expand Down
12 changes: 6 additions & 6 deletions ddl/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (s *testSerialDBSuite) TestAddIndexWithPK(c *C) {
})

testAddIndexWithPK(tk, s, c)
tk.MustExec("set @@tidb_enable_clustered_index = 1;")
tk.Se.GetSessionVars().EnableClusteredIndex = true
testAddIndexWithPK(tk, s, c)
}

Expand Down Expand Up @@ -1058,7 +1058,7 @@ func (s *testDBSuite6) TestAddMultiColumnsIndexClusterIndex(c *C) {
tk.MustExec("create database test_add_multi_col_index_clustered;")
tk.MustExec("use test_add_multi_col_index_clustered;")

tk.MustExec("set @@tidb_enable_clustered_index = 1")
tk.Se.GetSessionVars().EnableClusteredIndex = true
tk.MustExec("create table t (a int, b varchar(10), c int, primary key (a, b));")
tk.MustExec("insert into t values (1, '1', 1), (2, '2', NULL), (3, '3', 3);")
tk.MustExec("create index idx on t (a, c);")
Expand Down Expand Up @@ -1158,7 +1158,7 @@ func testAddIndex(c *C, store kv.Storage, lease time.Duration, tp testAddIndexTy
case testPartition:
tk.MustExec("set @@session.tidb_enable_table_partition = '1';")
case testClusteredIndex:
tk.MustExec("set @@tidb_enable_clustered_index = 1")
tk.Se.GetSessionVars().EnableClusteredIndex = true
}
tk.MustExec("drop table if exists test_add_index")
tk.MustExec(createTableSQL)
Expand Down 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 Expand Up @@ -4529,7 +4529,7 @@ func (s *testSerialDBSuite) TestAddIndexForGeneratedColumn(c *C) {
})

testAddIndexForGeneratedColumn(tk, s, c)
tk.MustExec("set @@tidb_enable_clustered_index = 1;")
tk.Se.GetSessionVars().EnableClusteredIndex = true
testAddIndexForGeneratedColumn(tk, s, c)
}

Expand Down
43 changes: 28 additions & 15 deletions ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,8 @@ func columnDefToCol(ctx sessionctx.Context, offset int, colDef *ast.ColumnDef, o
case ast.ColumnOptionPrimaryKey:
// Check PriKeyFlag first to avoid extra duplicate constraints.
if col.Flag&mysql.PriKeyFlag == 0 {
constraint := &ast.Constraint{Tp: ast.ConstraintPrimaryKey, Keys: keys}
constraint := &ast.Constraint{Tp: ast.ConstraintPrimaryKey, Keys: keys,
Option: &ast.IndexOption{PrimaryKeyTp: v.PrimaryKeyTp}}
constraints = append(constraints, constraint)
col.Flag |= mysql.PriKeyFlag
// Add NotNullFlag early so that processColumnFlags() can see it.
Expand Down Expand Up @@ -1424,23 +1425,35 @@ func buildTableInfo(
if err != nil {
return nil, err
}
if !config.GetGlobalConfig().AlterPrimaryKey {
singleIntPK := isSingleIntPK(constr, lastCol)
clusteredIdx := ctx.GetSessionVars().EnableClusteredIndex
if singleIntPK || clusteredIdx {
// Primary key cannot be invisible.
if constr.Option != nil && constr.Option.Visibility == ast.IndexVisibilityInvisible {
return nil, ErrPKIndexCantBeInvisible
}
}
if singleIntPK {
pkTp := model.PrimaryKeyTypeDefault
if constr.Option != nil {
pkTp = constr.Option.PrimaryKeyTp
}
switch pkTp {
case model.PrimaryKeyTypeNonClustered:
break
case model.PrimaryKeyTypeClustered:
if isSingleIntPK(constr, lastCol) {
tbInfo.PKIsHandle = true
// Avoid creating index for PK handle column.
continue
}
if clusteredIdx {
} else {
tbInfo.IsCommonHandle = true
}
case model.PrimaryKeyTypeDefault:
alterPKConf := config.GetGlobalConfig().AlterPrimaryKey
if isSingleIntPK(constr, lastCol) {
tbInfo.PKIsHandle = !alterPKConf
Copy link
Member

@jackysp jackysp Jan 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add && ctx.GetSessionVars().EnableClusteredIndex either to make it consistent with common handle?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of tests will be broken. Let's do this in another PR when it is decided.

} else {
tbInfo.IsCommonHandle = !alterPKConf && ctx.GetSessionVars().EnableClusteredIndex
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we return a warning if model.PrimaryKeyTypeClustered && !ctx.GetSessionVars().EnableClusteredIndex?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the variable has lower priority.

}
}
if tbInfo.PKIsHandle || tbInfo.IsCommonHandle {
// Primary key cannot be invisible.
if constr.Option != nil && constr.Option.Visibility == ast.IndexVisibilityInvisible {
return nil, ErrPKIndexCantBeInvisible
}
}
if tbInfo.PKIsHandle {
continue
}
}

Expand Down
6 changes: 3 additions & 3 deletions ddl/failtest/fail_db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ func (s *testFailDBSuite) TestAddIndexWorkerNum(c *C) {
tk.MustExec("use test_db")
tk.MustExec("drop table if exists test_add_index")
if s.IsCommonHandle {
tk.MustExec("set @@tidb_enable_clustered_index = 1")
tk.Se.GetSessionVars().EnableClusteredIndex = true
tk.MustExec("create table test_add_index (c1 bigint, c2 bigint, c3 bigint, primary key(c1, c3))")
} else {
tk.MustExec("create table test_add_index (c1 bigint, c2 bigint, c3 bigint, primary key(c1))")
Expand Down Expand Up @@ -485,7 +485,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 @@ -499,7 +499,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
8 changes: 4 additions & 4 deletions ddl/serial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (s *testSerialSuite) TestChangeMaxIndexLength(c *C) {
func (s *testSerialSuite) TestPrimaryKey(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("set @@tidb_enable_clustered_index = 0")
tk.Se.GetSessionVars().EnableClusteredIndex = false

tk.MustExec("create table primary_key_test (a int, b varchar(10))")
tk.MustExec("create table primary_key_test_1 (a int, b varchar(10), primary key(a))")
Expand Down Expand Up @@ -174,7 +174,7 @@ func (s *testSerialSuite) TestPrimaryKey(c *C) {
conf.AlterPrimaryKey = false
})
tk.MustExec("drop table if exists t;")
tk.MustExec("set tidb_enable_clustered_index=1")
tk.Se.GetSessionVars().EnableClusteredIndex = true
tk.MustExec("create table t(a int, b varchar(64), primary key(b));")
tk.MustExec("insert into t values(1,'a'), (2, 'b');")
config.UpdateGlobal(func(conf *config.Config) {
Expand Down Expand Up @@ -332,7 +332,7 @@ func (s *testSerialSuite) TestMultiRegionGetTableEndCommonHandle(c *C) {
tk.MustExec("drop database if exists test_get_endhandle")
tk.MustExec("create database test_get_endhandle")
tk.MustExec("use test_get_endhandle")
tk.MustExec("set @@tidb_enable_clustered_index = true")
tk.Se.GetSessionVars().EnableClusteredIndex = true

tk.MustExec("create table t(a varchar(20), b int, c float, d bigint, primary key (a, b, c))")
var builder strings.Builder
Expand Down Expand Up @@ -376,7 +376,7 @@ func (s *testSerialSuite) TestGetTableEndCommonHandle(c *C) {
tk.MustExec("drop database if exists test_get_endhandle")
tk.MustExec("create database test_get_endhandle")
tk.MustExec("use test_get_endhandle")
tk.MustExec("set @@tidb_enable_clustered_index = true")
tk.Se.GetSessionVars().EnableClusteredIndex = true

tk.MustExec("create table t(a varchar(15), b bigint, c int, primary key (a, b))")
tk.MustExec("create table t1(a varchar(15), b bigint, c int, primary key (a(2), b))")
Expand Down
5 changes: 3 additions & 2 deletions domain/global_vars_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ type GlobalVariableCache struct {
SingleFight singleflight.Group
}

const globalVariableCacheExpiry = 2 * time.Second
// GlobalVariableCacheExpiry is the global variable cache TTL.
const GlobalVariableCacheExpiry = 2 * time.Second

// Update updates the global variable cache.
func (gvc *GlobalVariableCache) Update(rows []chunk.Row, fields []*ast.ResultField) {
Expand All @@ -56,7 +57,7 @@ func (gvc *GlobalVariableCache) Update(rows []chunk.Row, fields []*ast.ResultFie
func (gvc *GlobalVariableCache) Get() (succ bool, rows []chunk.Row, fields []*ast.ResultField) {
gvc.RLock()
defer gvc.RUnlock()
if time.Since(gvc.lastModify) < globalVariableCacheExpiry {
if time.Since(gvc.lastModify) < GlobalVariableCacheExpiry {
succ, rows, fields = !gvc.disable, gvc.rows, gvc.fields
return
}
Expand Down
8 changes: 4 additions & 4 deletions executor/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (s *testSuite5) TestClusteredIndexAdminRecoverIndex(c *C) {
tk.MustExec("drop database if exists test_cluster_index_admin_recover;")
tk.MustExec("create database test_cluster_index_admin_recover;")
tk.MustExec("use test_cluster_index_admin_recover;")
tk.MustExec("set tidb_enable_clustered_index=1;")
tk.Se.GetSessionVars().EnableClusteredIndex = true
dbName := model.NewCIStr("test_cluster_index_admin_recover")
tblName := model.NewCIStr("t")

Expand Down Expand Up @@ -310,7 +310,7 @@ func (s *testSuite5) TestAdminRecoverIndex1(c *C) {
sc := s.ctx.GetSessionVars().StmtCtx
tk.MustExec("use test")
tk.MustExec("drop table if exists admin_test")
tk.MustExec("set @@tidb_enable_clustered_index=0;")
tk.Se.GetSessionVars().EnableClusteredIndex = false
tk.MustExec("create table admin_test (c1 varchar(255), c2 int, c3 int default 1, primary key(c1), unique key(c2))")
tk.MustExec("insert admin_test (c1, c2) values ('1', 1), ('2', 2), ('3', 3), ('10', 10), ('20', 20)")

Expand Down Expand Up @@ -515,7 +515,7 @@ func (s *testSuite5) TestAdminCleanupIndexPKNotHandle(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists admin_test")
tk.MustExec("set @@tidb_enable_clustered_index=0;")
tk.Se.GetSessionVars().EnableClusteredIndex = false
tk.MustExec("create table admin_test (c1 int, c2 int, c3 int, primary key (c1, c2))")
tk.MustExec("insert admin_test (c1, c2) values (1, 2), (3, 4), (-5, 5)")

Expand Down Expand Up @@ -627,7 +627,7 @@ func (s *testSuite5) TestClusteredAdminCleanupIndex(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists admin_test")
tk.MustExec("set tidb_enable_clustered_index=1")
tk.Se.GetSessionVars().EnableClusteredIndex = true
tk.MustExec("create table admin_test (c1 varchar(255), c2 int, c3 char(10) default 'c3', primary key (c1, c3), unique key(c2), key (c3))")
tk.MustExec("insert admin_test (c1, c2) values ('c1_1', 2), ('c1_2', 4), ('c1_3', NULL)")
tk.MustExec("insert admin_test (c1, c3) values ('c1_4', 'c3_4'), ('c1_5', 'c3_5'), ('c1_6', default)")
Expand Down
2 changes: 1 addition & 1 deletion executor/aggregate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ func (s *testSuiteAgg) TestAggEliminator(c *C) {
func (s *testSuiteAgg) TestClusterIndexMaxMinEliminator(c *C) {
tk := testkit.NewTestKitWithInit(c, s.store)
tk.MustExec("drop table if exists t;")
tk.MustExec("set @@tidb_enable_clustered_index=1;")
tk.Se.GetSessionVars().EnableClusteredIndex = true
tk.MustExec("create table t (a int, b int, c int, primary key(a, b));")
for i := 0; i < 10+1; i++ {
tk.MustExec("insert into t values (?, ?, ?)", i, i, i)
Expand Down
2 changes: 1 addition & 1 deletion executor/analyze_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (s *testSuite1) TestClusterIndexAnalyze(c *C) {
tk.MustExec("drop database if exists test_cluster_index_analyze;")
tk.MustExec("create database test_cluster_index_analyze;")
tk.MustExec("use test_cluster_index_analyze;")
tk.MustExec("set @@tidb_enable_clustered_index=1;")
tk.Se.GetSessionVars().EnableClusteredIndex = true

tk.MustExec("create table t (a int, b int, c int, primary key(a, b));")
for i := 0; i < 100; i++ {
Expand Down
2 changes: 1 addition & 1 deletion executor/batch_point_get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (s *testBatchPointGetSuite) TestBatchPointGetLockExistKey(c *C) {

errCh <- tk1.ExecToErr("use test")
errCh <- tk2.ExecToErr("use test")
errCh <- tk1.ExecToErr("set session tidb_enable_clustered_index = 0")
tk1.Se.GetSessionVars().EnableClusteredIndex = false

errCh <- tk1.ExecToErr(fmt.Sprintf("drop table if exists %s", tableName))
errCh <- tk1.ExecToErr(fmt.Sprintf("create table %s(id int, v int, k int, %s key0(id, v))", tableName, key))
Expand Down
Loading