diff --git a/executor/infoschema_reader_test.go b/executor/infoschema_reader_test.go index 9622ef95f718e..6e594532781f9 100644 --- a/executor/infoschema_reader_test.go +++ b/executor/infoschema_reader_test.go @@ -915,7 +915,7 @@ func (s *testInfoschemaClusterTableSuite) TestTableStorageStats(c *C) { tk.MustQuery("select TABLE_SCHEMA, sum(TABLE_SIZE) from information_schema.TABLE_STORAGE_STATS where TABLE_SCHEMA = 'test' group by TABLE_SCHEMA;").Check(testkit.Rows( "test 2", )) - c.Assert(len(tk.MustQuery("select TABLE_NAME from information_schema.TABLE_STORAGE_STATS where TABLE_SCHEMA = 'mysql';").Rows()), Equals, 24) + c.Assert(len(tk.MustQuery("select TABLE_NAME from information_schema.TABLE_STORAGE_STATS where TABLE_SCHEMA = 'mysql';").Rows()), Equals, 25) // More tests about the privileges. tk.MustExec("create user 'testuser'@'localhost'") @@ -941,14 +941,14 @@ func (s *testInfoschemaClusterTableSuite) TestTableStorageStats(c *C) { Hostname: "localhost", }, nil, nil), Equals, true) - tk.MustQuery("select count(1) from information_schema.TABLE_STORAGE_STATS where TABLE_SCHEMA = 'mysql'").Check(testkit.Rows("24")) + tk.MustQuery("select count(1) from information_schema.TABLE_STORAGE_STATS where TABLE_SCHEMA = 'mysql'").Check(testkit.Rows("25")) c.Assert(tk.Se.Auth(&auth.UserIdentity{ Username: "testuser3", Hostname: "localhost", }, nil, nil), Equals, true) - tk.MustQuery("select count(1) from information_schema.TABLE_STORAGE_STATS where TABLE_SCHEMA = 'mysql'").Check(testkit.Rows("24")) + tk.MustQuery("select count(1) from information_schema.TABLE_STORAGE_STATS where TABLE_SCHEMA = 'mysql'").Check(testkit.Rows("25")) } func (s *testInfoschemaTableSuite) TestSequences(c *C) { diff --git a/session/bootstrap.go b/session/bootstrap.go index 9c677f8be1a2e..01ea22012b02b 100644 --- a/session/bootstrap.go +++ b/session/bootstrap.go @@ -339,6 +339,22 @@ const ( WITH_GRANT_OPTION enum('N','Y') NOT NULL DEFAULT 'N', PRIMARY KEY (USER,HOST,PRIV) );` + + // CreatePlacementPolicyTable store the placement policys. + CreatePlacementPolicyTable = `CREATE TABLE IF NOT EXISTS mysql.placement_policy ( + NAME varchar(64) NOT NULL, + PRIMARY_REGION varchar(255) DEFAULT NULL, + REGIONS varchar(255) DEFAULT NULL, + LEADERS BIGINT UNSIGNED DEFAULT NULL, + FOLLOWERS BIGINT UNSIGNED DEFAULT NULL, + VOTERS BIGINT UNSIGNED DEFAULT NULL, + SCHEDULE varchar(255) DEFAULT NULL, + CONSTRAINTS varchar(255) DEFAULT NULL, + LEADER_CONSTRAINTS varchar(255) DEFAULT NULL, + FOLLOWER_CONSTRAINTS varchar(255) DEFAULT NULL, + VOTER_CONSTRAINTS varchar(255) DEFAULT NULL, + PRIMARY KEY (NAME) + );` ) // bootstrap initiates system DB for a store. @@ -498,11 +514,13 @@ const ( version71 = 71 // version72 adds snapshot column for mysql.stats_meta version72 = 72 + // version73 adds the placement policy for mysql.placement_meta + version73 = 73 ) // currentBootstrapVersion is defined as a variable, so we can modify its value for testing. // please make sure this is the largest version -var currentBootstrapVersion int64 = version72 +var currentBootstrapVersion int64 = version73 var ( bootstrapVersion = []func(Session, int64){ @@ -578,6 +596,7 @@ var ( upgradeToVer70, upgradeToVer71, upgradeToVer72, + upgradeToVer73, } ) @@ -1527,6 +1546,13 @@ func upgradeToVer72(s Session, ver int64) { doReentrantDDL(s, "ALTER TABLE mysql.stats_meta ADD COLUMN snapshot BIGINT(64) UNSIGNED NOT NULL DEFAULT 0", infoschema.ErrColumnExists) } +func upgradeToVer73(s Session, ver int64) { + if ver >= version73 { + return + } + doReentrantDDL(s, CreatePlacementPolicyTable) +} + func writeOOMAction(s Session) { comment := "oom-action is `log` by default in v3.0.x, `cancel` by default in v4.0.11+" mustExecute(s, `INSERT HIGH_PRIORITY INTO %n.%n VALUES (%?, %?, %?) ON DUPLICATE KEY UPDATE VARIABLE_VALUE= %?`, @@ -1605,6 +1631,8 @@ func doDDLWorks(s Session) { mustExecute(s, CreateStatsFMSketchTable) // Create global_grants mustExecute(s, CreateGlobalGrantsTable) + // Create placement_policy + mustExecute(s, CreatePlacementPolicyTable) } // doDMLWorks executes DML statements in bootstrap stage.