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

*: Remove direct placement in parser #31768

Merged
9 changes: 0 additions & 9 deletions ddl/db_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3115,23 +3115,14 @@ func (s *testSerialDBSuite) TestPlacementOnTemporaryTable(c *C) {
defer tk.MustExec("drop placement policy x")

// Cannot create temporary table with placement options
tk.MustGetErrCode("create global temporary table tplacement1 (id int) followers=4 on commit delete rows", errno.ErrOptOnTemporaryTable)
tk.MustGetErrCode("create global temporary table tplacement1 (id int) primary_region='us-east-1' regions='us-east-1,us-west-1' on commit delete rows", errno.ErrOptOnTemporaryTable)
tk.MustGetErrCode("create global temporary table tplacement1 (id int) placement policy='x' on commit delete rows", errno.ErrOptOnTemporaryTable)
tk.MustGetErrCode("create temporary table tplacement2 (id int) followers=4", errno.ErrOptOnTemporaryTable)
tk.MustGetErrCode("create temporary table tplacement2 (id int) primary_region='us-east-1' regions='us-east-1,us-west-1'", errno.ErrOptOnTemporaryTable)
tk.MustGetErrCode("create temporary table tplacement2 (id int) placement policy='x'", errno.ErrOptOnTemporaryTable)

// Cannot alter temporary table with placement options
tk.MustExec("create global temporary table tplacement1 (id int) on commit delete rows")
defer tk.MustExec("drop table tplacement1")
tk.MustGetErrCode("alter table tplacement1 followers=4", errno.ErrOptOnTemporaryTable)
tk.MustGetErrCode("alter table tplacement1 primary_region='us-east-1' regions='us-east-1,us-west-1'", errno.ErrOptOnTemporaryTable)
tk.MustGetErrCode("alter table tplacement1 placement policy='x'", errno.ErrOptOnTemporaryTable)

tk.MustExec("create temporary table tplacement2 (id int)")
tk.MustGetErrCode("alter table tplacement2 followers=4", errno.ErrUnsupportedDDLOperation)
tk.MustGetErrCode("alter table tplacement2 primary_region='us-east-1' regions='us-east-1,us-west-1'", errno.ErrUnsupportedDDLOperation)
tk.MustGetErrCode("alter table tplacement2 placement policy='x'", errno.ErrUnsupportedDDLOperation)

// Temporary table will not inherit placement from db
Expand Down
4 changes: 0 additions & 4 deletions ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,6 @@ func checkAndNormalizePlacement(ctx sessionctx.Context, placementPolicyRef *mode
}

if directPlacementOpts != nil {
if !ctx.GetSessionVars().EnableDirectPlacement {
return nil, nil, errors.New("Direct placement is disabled")
}

// check the direct placement option compatibility.
if err := checkPolicyValidation(directPlacementOpts); err != nil {
return nil, nil, errors.Trace(err)
Expand Down
565 changes: 206 additions & 359 deletions ddl/placement_policy_test.go

Large diffs are not rendered by default.

135 changes: 15 additions & 120 deletions ddl/placement_sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,46 +250,19 @@ PARTITION BY RANGE (c) (

func (s *testDBSuite6) TestCreateSchemaWithPlacement(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("set @@tidb_enable_direct_placement=1")
tk.MustExec("drop schema if exists SchemaDirectPlacementTest")
tk.MustExec("drop schema if exists SchemaPolicyPlacementTest")
defer func() {
tk.MustExec("drop schema if exists SchemaDirectPlacementTest")
tk.MustExec("drop schema if exists SchemaPolicyPlacementTest")
tk.MustExec("drop placement policy if exists PolicySchemaTest")
tk.MustExec("drop placement policy if exists PolicyTableTest")
}()

tk.MustExec(`CREATE SCHEMA SchemaDirectPlacementTest PRIMARY_REGION='nl' REGIONS = "se,nz,nl" FOLLOWERS=3`)
tk.MustQuery("SHOW CREATE SCHEMA schemadirectplacementtest").Check(testkit.Rows("SchemaDirectPlacementTest CREATE DATABASE `SchemaDirectPlacementTest` /*!40100 DEFAULT CHARACTER SET utf8mb4 */ /*T![placement] PRIMARY_REGION=\"nl\" REGIONS=\"se,nz,nl\" FOLLOWERS=3 */"))

tk.MustExec(`CREATE PLACEMENT POLICY PolicySchemaTest LEADER_CONSTRAINTS = "[+region=nl]" FOLLOWER_CONSTRAINTS="[+region=se]" FOLLOWERS=4 LEARNER_CONSTRAINTS="[+region=be]" LEARNERS=4`)
tk.MustExec(`CREATE PLACEMENT POLICY PolicyTableTest LEADER_CONSTRAINTS = "[+region=tl]" FOLLOWER_CONSTRAINTS="[+region=tf]" FOLLOWERS=2 LEARNER_CONSTRAINTS="[+region=tle]" LEARNERS=1`)
tk.MustQuery("SHOW PLACEMENT like 'POLICY %PolicySchemaTest%'").Check(testkit.Rows("POLICY PolicySchemaTest LEADER_CONSTRAINTS=\"[+region=nl]\" FOLLOWERS=4 FOLLOWER_CONSTRAINTS=\"[+region=se]\" LEARNERS=4 LEARNER_CONSTRAINTS=\"[+region=be]\" NULL"))
tk.MustQuery("SHOW PLACEMENT like 'POLICY %PolicyTableTest%'").Check(testkit.Rows("POLICY PolicyTableTest LEADER_CONSTRAINTS=\"[+region=tl]\" FOLLOWERS=2 FOLLOWER_CONSTRAINTS=\"[+region=tf]\" LEARNERS=1 LEARNER_CONSTRAINTS=\"[+region=tle]\" NULL"))
tk.MustExec("CREATE SCHEMA SchemaPolicyPlacementTest PLACEMENT POLICY = `PolicySchemaTest`")
tk.MustQuery("SHOW CREATE SCHEMA SCHEMAPOLICYPLACEMENTTEST").Check(testkit.Rows("SchemaPolicyPlacementTest CREATE DATABASE `SchemaPolicyPlacementTest` /*!40100 DEFAULT CHARACTER SET utf8mb4 */ /*T![placement] PLACEMENT POLICY=`PolicySchemaTest` */"))

tk.MustExec(`CREATE TABLE SchemaDirectPlacementTest.UseSchemaDefault (a int unsigned primary key, b varchar(255))`)
tk.MustQuery(`SHOW CREATE TABLE SchemaDirectPlacementTest.UseSchemaDefault`).Check(testkit.Rows(
"UseSchemaDefault CREATE TABLE `UseSchemaDefault` (\n" +
" `a` int(10) unsigned NOT NULL,\n" +
" `b` varchar(255) DEFAULT NULL,\n" +
" PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![placement] PRIMARY_REGION=\"nl\" REGIONS=\"se,nz,nl\" FOLLOWERS=3 */"))
tk.MustQuery("SELECT CATALOG_NAME, SCHEMA_NAME, DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME, TIDB_PLACEMENT_POLICY_NAME FROM information_schema.schemata WHERE SCHEMA_NAME='SchemaDirectPlacementTest'").Check(testkit.Rows(`def SchemaDirectPlacementTest utf8mb4 utf8mb4_bin <nil>`))
tk.MustQuery("SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TIDB_PLACEMENT_POLICY_NAME FROM information_schema.Tables WHERE TABLE_SCHEMA='SchemaDirectPlacementTest' AND TABLE_NAME = 'UseSchemaDefault'").Check(testkit.Rows(`def SchemaDirectPlacementTest UseSchemaDefault <nil>`))

tk.MustExec(`CREATE TABLE SchemaDirectPlacementTest.UseDirectPlacement (a int unsigned primary key, b varchar(255)) PRIMARY_REGION="se" REGIONS="se"`)

tk.MustQuery(`SHOW CREATE TABLE SchemaDirectPlacementTest.UseDirectPlacement`).Check(testkit.Rows(
"UseDirectPlacement CREATE TABLE `UseDirectPlacement` (\n" +
" `a` int(10) unsigned NOT NULL,\n" +
" `b` varchar(255) DEFAULT NULL,\n" +
" PRIMARY KEY (`a`) /*T![clustered_index] CLUSTERED */\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![placement] PRIMARY_REGION=\"se\" REGIONS=\"se\" */"))
tk.MustQuery("SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TIDB_PLACEMENT_POLICY_NAME FROM information_schema.Tables WHERE TABLE_SCHEMA='SchemaDirectPlacementTest' AND TABLE_NAME = 'UseDirectPlacement'").Check(testkit.Rows("def SchemaDirectPlacementTest UseDirectPlacement <nil>"))

tk.MustExec(`CREATE TABLE SchemaPolicyPlacementTest.UseSchemaDefault (a int unsigned primary key, b varchar(255))`)
tk.MustQuery(`SHOW CREATE TABLE SchemaPolicyPlacementTest.UseSchemaDefault`).Check(testkit.Rows(
"UseSchemaDefault CREATE TABLE `UseSchemaDefault` (\n" +
Expand All @@ -310,17 +283,7 @@ func (s *testDBSuite6) TestCreateSchemaWithPlacement(c *C) {
tk.MustQuery("SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TIDB_PLACEMENT_POLICY_NAME FROM information_schema.Tables WHERE TABLE_SCHEMA='SchemaPolicyPlacementTest' AND TABLE_NAME = 'UsePolicy'").Check(testkit.Rows(`def SchemaPolicyPlacementTest UsePolicy PolicyTableTest`))

is := s.dom.InfoSchema()

db, ok := is.SchemaByName(model.NewCIStr("SchemaDirectPlacementTest"))
c.Assert(ok, IsTrue)
c.Assert(db.PlacementPolicyRef, IsNil)
c.Assert(db.DirectPlacementOpts, NotNil)
c.Assert(db.DirectPlacementOpts.PrimaryRegion, Matches, "nl")
c.Assert(db.DirectPlacementOpts.Regions, Matches, "se,nz,nl")
c.Assert(db.DirectPlacementOpts.Followers, Equals, uint64(3))
c.Assert(db.DirectPlacementOpts.Learners, Equals, uint64(0))

db, ok = is.SchemaByName(model.NewCIStr("SchemaPolicyPlacementTest"))
db, ok := is.SchemaByName(model.NewCIStr("SchemaPolicyPlacementTest"))
c.Assert(ok, IsTrue)
c.Assert(db.PlacementPolicyRef, NotNil)
c.Assert(db.DirectPlacementOpts, IsNil)
Expand All @@ -329,7 +292,6 @@ func (s *testDBSuite6) TestCreateSchemaWithPlacement(c *C) {

func (s *testDBSuite6) TestAlterDBPlacement(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("set @@tidb_enable_direct_placement=1")
tk.MustExec("drop database if exists TestAlterDB;")
tk.MustExec("create database TestAlterDB;")
tk.MustExec("use TestAlterDB")
Expand Down Expand Up @@ -382,60 +344,34 @@ func (s *testDBSuite6) TestAlterDBPlacement(c *C) {

// Reset Test
tk.MustExec("drop database if exists TestAlterDB;")
tk.MustExec("create database TestAlterDB;")
tk.MustExec("create database TestAlterDB PLACEMENT POLICY alter_x;")
tk.MustExec("use TestAlterDB")

// DirectOption Test
tk.MustExec("ALTER DATABASE TestAlterDB PRIMARY_REGION=\"se\" FOLLOWERS=2 REGIONS=\"se\";")
// Test for information_schema.schemata
tk.MustQuery("SELECT CATALOG_NAME, SCHEMA_NAME, DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME, TIDB_PLACEMENT_POLICY_NAME FROM information_schema.schemata WHERE SCHEMA_NAME='TestAlterDB'").Check(testkit.Rows(`def TestAlterDB utf8mb4 utf8mb4_bin <nil>`))
// Test for Show Create Database
tk.MustQuery(`show create database TestAlterDB`).Check(testutil.RowsWithSep("|",
"TestAlterDB CREATE DATABASE `TestAlterDB` /*!40100 DEFAULT CHARACTER SET utf8mb4 */ "+
"/*T![placement] PRIMARY_REGION=\"se\" REGIONS=\"se\" FOLLOWERS=2 */",
))
// Test for Alter Placement Rule affect table created.
tk.MustExec("create table t3(a int);")
tk.MustQuery(`show create table t3`).Check(testutil.RowsWithSep("|",
"t3 CREATE TABLE `t3` (\n"+
" `a` int(11) DEFAULT NULL\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin "+
"/*T![placement] PRIMARY_REGION=\"se\" REGIONS=\"se\" FOLLOWERS=2 */",
"/*T![placement] PLACEMENT POLICY=`alter_x` */",
))
tk.MustQuery("SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TIDB_PLACEMENT_POLICY_NAME FROM information_schema.Tables WHERE TABLE_SCHEMA='TestAlterDB' AND TABLE_NAME = 't3'").Check(testkit.Rows("def TestAlterDB t3 <nil>"))
tk.MustQuery("SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TIDB_PLACEMENT_POLICY_NAME FROM information_schema.Tables WHERE TABLE_SCHEMA='TestAlterDB' AND TABLE_NAME = 't3'").Check(testkit.Rows(`def TestAlterDB t3 alter_x`))

// Test for override default option
tk.MustExec("create table t4(a int) PLACEMENT POLICY=\"alter_x\";")
tk.MustExec("create table t4(a int) PLACEMENT POLICY=\"alter_y\";")
tk.MustQuery(`show create table t4`).Check(testutil.RowsWithSep("|",
"t4 CREATE TABLE `t4` (\n"+
" `a` int(11) DEFAULT NULL\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin "+
"/*T![placement] PLACEMENT POLICY=`alter_x` */",
"/*T![placement] PLACEMENT POLICY=`alter_y` */",
))
tk.MustQuery("SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TIDB_PLACEMENT_POLICY_NAME FROM information_schema.Tables WHERE TABLE_SCHEMA='TestAlterDB' AND TABLE_NAME = 't4'").Check(testkit.Rows(`def TestAlterDB t4 alter_x`))
tk.MustQuery("SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TIDB_PLACEMENT_POLICY_NAME FROM information_schema.Tables WHERE TABLE_SCHEMA='TestAlterDB' AND TABLE_NAME = 't4'").Check(testkit.Rows(`def TestAlterDB t4 alter_y`))

// Hybrid Test
// Test for alter both policy and direct options.
tk.MustQuery(`show create database TestAlterDB`).Check(testutil.RowsWithSep("|",
"TestAlterDB CREATE DATABASE `TestAlterDB` /*!40100 DEFAULT CHARACTER SET utf8mb4 */ "+
"/*T![placement] PRIMARY_REGION=\"se\" REGIONS=\"se\" FOLLOWERS=2 */",
))
tk.MustGetErrCode("ALTER DATABASE TestAlterDB PLACEMENT POLICY=`alter_x` FOLLOWERS=2;", mysql.ErrPlacementPolicyWithDirectOption)
tk.MustGetErrCode("ALTER DATABASE TestAlterDB DEFAULT PLACEMENT POLICY=`alter_y` PRIMARY_REGION=\"se\" FOLLOWERS=2;", mysql.ErrPlacementPolicyWithDirectOption)
tk.MustQuery(`show create database TestAlterDB`).Check(testutil.RowsWithSep("|",
"TestAlterDB CREATE DATABASE `TestAlterDB` /*!40100 DEFAULT CHARACTER SET utf8mb4 */ "+
"/*T![placement] PRIMARY_REGION=\"se\" REGIONS=\"se\" FOLLOWERS=2 */",
))
// Test for change direct options to policy.
tk.MustExec("ALTER DATABASE TestAlterDB PLACEMENT POLICY=`alter_x`;")
tk.MustQuery(`show create database TestAlterDB`).Check(testutil.RowsWithSep("|",
"TestAlterDB CREATE DATABASE `TestAlterDB` /*!40100 DEFAULT CHARACTER SET utf8mb4 */ "+
"/*T![placement] PLACEMENT POLICY=`alter_x` */",
))
// Test for change policy to direct options.
tk.MustExec("ALTER DATABASE TestAlterDB PRIMARY_REGION=\"se\" FOLLOWERS=2 REGIONS=\"se\" ;")
// Test alter to another policy
tk.MustExec("ALTER DATABASE TestAlterDB PLACEMENT POLICY=`alter_y`;")
tk.MustQuery(`show create database TestAlterDB`).Check(testutil.RowsWithSep("|",
"TestAlterDB CREATE DATABASE `TestAlterDB` /*!40100 DEFAULT CHARACTER SET utf8mb4 */ "+
"/*T![placement] PRIMARY_REGION=\"se\" REGIONS=\"se\" FOLLOWERS=2 */",
"/*T![placement] PLACEMENT POLICY=`alter_y` */",
))
}

Expand Down Expand Up @@ -716,7 +652,6 @@ func (s *testDBSuite6) TestPlacementTiflashCheck(c *C) {
}()

tk.MustExec("use test")
tk.MustExec("set @@tidb_enable_direct_placement=1")
tk.MustExec("drop placement policy if exists p1")
tk.MustExec("drop table if exists tp")

Expand All @@ -732,14 +667,8 @@ func (s *testDBSuite6) TestPlacementTiflashCheck(c *C) {

err := tk.ExecToErr("alter table tp placement policy p1")
c.Assert(ddl.ErrIncompatibleTiFlashAndPlacement.Equal(err), IsTrue)
err = tk.ExecToErr("alter table tp primary_region='r2' regions='r2'")
c.Assert(ddl.ErrIncompatibleTiFlashAndPlacement.Equal(err), IsTrue)
err = tk.ExecToErr("alter table tp partition p0 placement policy p1")
c.Assert(ddl.ErrIncompatibleTiFlashAndPlacement.Equal(err), IsTrue)
err = tk.ExecToErr("alter table tp partition p0 primary_region='r2' regions='r2'")
c.Assert(ddl.ErrIncompatibleTiFlashAndPlacement.Equal(err), IsTrue)
err = tk.ExecToErr("alter table tp add partition(partition p2 VALUES LESS THAN (10000) placement policy p1)")
c.Assert(ddl.ErrIncompatibleTiFlashAndPlacement.Equal(err), IsTrue)
tk.MustQuery("show create table tp").Check(testkit.Rows("" +
"tp CREATE TABLE `tp` (\n" +
" `id` int(11) DEFAULT NULL\n" +
Expand Down Expand Up @@ -779,7 +708,7 @@ func (s *testDBSuite6) TestPlacementTiflashCheck(c *C) {
" PARTITION `p1` VALUES LESS THAN (1000))"))

tk.MustExec("drop table tp")
tk.MustExec(`CREATE TABLE tp (id INT) primary_region='r2' regions='r2' PARTITION BY RANGE (id) (
tk.MustExec(`CREATE TABLE tp (id INT) PLACEMENT POLICY p1 PARTITION BY RANGE (id) (
PARTITION p0 VALUES LESS THAN (100),
PARTITION p1 VALUES LESS THAN (1000)
)`)
Expand All @@ -788,14 +717,14 @@ func (s *testDBSuite6) TestPlacementTiflashCheck(c *C) {
tk.MustQuery("show create table tp").Check(testkit.Rows("" +
"tp CREATE TABLE `tp` (\n" +
" `id` int(11) DEFAULT NULL\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![placement] PRIMARY_REGION=\"r2\" REGIONS=\"r2\" */\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![placement] PLACEMENT POLICY=`p1` */\n" +
"PARTITION BY RANGE (`id`)\n" +
"(PARTITION `p0` VALUES LESS THAN (100),\n" +
" PARTITION `p1` VALUES LESS THAN (1000))"))

tk.MustExec("drop table tp")
tk.MustExec(`CREATE TABLE tp (id INT) PARTITION BY RANGE (id) (
PARTITION p0 VALUES LESS THAN (100) primary_region='r3' regions='r3',
PARTITION p0 VALUES LESS THAN (100) PLACEMENT POLICY p1,
PARTITION p1 VALUES LESS THAN (1000)
)`)
err = tk.ExecToErr("alter table tp set tiflash replica 1")
Expand All @@ -805,40 +734,6 @@ func (s *testDBSuite6) TestPlacementTiflashCheck(c *C) {
" `id` int(11) DEFAULT NULL\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin\n" +
"PARTITION BY RANGE (`id`)\n" +
"(PARTITION `p0` VALUES LESS THAN (100) /*T![placement] PRIMARY_REGION=\"r3\" REGIONS=\"r3\" */,\n" +
"(PARTITION `p0` VALUES LESS THAN (100) /*T![placement] PLACEMENT POLICY=`p1` */,\n" +
" PARTITION `p1` VALUES LESS THAN (1000))"))
}

func (s *testDBSuite6) TestEnableDirectPlacement(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")

tk.MustExec("drop database if exists db1")
tk.MustExec("drop table if exists tp")
tk.MustExec("drop placement policy if exists p1")
defer func() {
tk.MustExec("drop database if exists db1")
tk.MustExec("drop table if exists tp")
tk.MustExec("drop placement policy if exists p1")
}()
tk.MustExec("create placement policy p1 primary_region='r1' regions='r1,r2'")
tk.MustExec(`CREATE TABLE tp (id INT) placement policy p1 PARTITION BY RANGE (id) (
PARTITION p0 VALUES LESS THAN (100) placement policy p1,
PARTITION p1 VALUES LESS THAN (1000)
)`)
tk.MustExec("create database db1 placement policy p1")

errorSQLs := []string{
"create database db2 followers=1",
"alter database db1 followers=1",
"create table t(a int) followers=1",
"alter table tp followers=1",
"alter table tp partition p0 followers=1",
"alter table tp add partition(partition p2 values less than(10000) followers=1)",
}

for _, sql := range errorSQLs {
err := tk.ExecToErr(sql)
c.Assert(err.Error(), Equals, "Direct placement is disabled")
}
}
10 changes: 1 addition & 9 deletions ddl/serial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,6 @@ func (s *testSerialSuite) TestCreateTableWithLikeAtTemporaryMode(c *C) {

// Test create table like at temporary mode.
tk.MustExec("use test")
tk.MustExec("set @@tidb_enable_direct_placement=1")
tk.MustExec("drop table if exists temporary_table;")
tk.MustExec("create global temporary table temporary_table (a int, b int,index(a)) on commit delete rows")
tk.MustExec("drop table if exists temporary_table_t1;")
Expand Down Expand Up @@ -704,21 +703,14 @@ func (s *testSerialSuite) TestCreateTableWithLikeAtTemporaryMode(c *C) {
tk.MustExec("drop placement policy if exists p1")
tk.MustExec("create placement policy p1 primary_region='r1' regions='r1,r2'")
defer tk.MustExec("drop placement policy p1")
tk.MustExec("drop table if exists placement_table1, placement_table1")
tk.MustExec("drop table if exists placement_table1")
tk.MustExec("create table placement_table1(id int) placement policy p1")
defer tk.MustExec("drop table if exists placement_table1")
tk.MustExec("create table placement_table2(id int) LEADER_CONSTRAINTS='[+region=hz]' FOLLOWERS=3")
defer tk.MustExec("drop table if exists placement_table2")

_, err = tk.Exec("create global temporary table g_tmp_placement1 like placement_table1 on commit delete rows")
c.Assert(err.Error(), Equals, core.ErrOptOnTemporaryTable.GenWithStackByArgs("placement").Error())
_, err = tk.Exec("create global temporary table g_tmp_placement2 like placement_table2 on commit delete rows")
c.Assert(err.Error(), Equals, core.ErrOptOnTemporaryTable.GenWithStackByArgs("placement").Error())

_, err = tk.Exec("create temporary table l_tmp_placement1 like placement_table1")
c.Assert(err.Error(), Equals, core.ErrOptOnTemporaryTable.GenWithStackByArgs("placement").Error())
_, err = tk.Exec("create temporary table l_tmp_placement2 like placement_table2")
c.Assert(err.Error(), Equals, core.ErrOptOnTemporaryTable.GenWithStackByArgs("placement").Error())
}

// TestCancelAddIndex1 tests canceling ddl job when the add index worker is not started.
Expand Down
Loading