From 0717e816ee70ebeb67f0195a7f9bd90faaa6c2aa Mon Sep 17 00:00:00 2001 From: Toliver Jue Date: Wed, 26 Aug 2020 14:55:05 +0900 Subject: [PATCH 1/2] VReplication: _vt.vreplication source column VARBINARY->BLOB Signed-off-by: Toliver Jue --- go/vt/binlog/binlogplayer/binlog_player.go | 5 +++++ go/vt/vttablet/tabletmanager/vreplication/engine.go | 1 + go/vt/vttablet/tabletmanager/vreplication/engine_test.go | 1 + 3 files changed, 7 insertions(+) diff --git a/go/vt/binlog/binlogplayer/binlog_player.go b/go/vt/binlog/binlogplayer/binlog_player.go index e231e503c71..c560d9e5730 100644 --- a/go/vt/binlog/binlogplayer/binlog_player.go +++ b/go/vt/binlog/binlogplayer/binlog_player.go @@ -533,6 +533,11 @@ var AlterVReplicationTable = []string{ "ALTER TABLE _vt.vreplication ADD COLUMN db_name VARBINARY(255) NOT NULL", } +// AlterVReplicationTableSourceToBlob changes source column of vreplication table to BLOB +var AlterVReplicationTableSourceToBlob = []string{ + "ALTER TABLE _vt.vreplication MODIFY source BLOB NOT NULL", +} + // VRSettings contains the settings of a vreplication table. type VRSettings struct { StartPos mysql.Position diff --git a/go/vt/vttablet/tabletmanager/vreplication/engine.go b/go/vt/vttablet/tabletmanager/vreplication/engine.go index 79732f43ff8..4f275d00735 100644 --- a/go/vt/vttablet/tabletmanager/vreplication/engine.go +++ b/go/vt/vttablet/tabletmanager/vreplication/engine.go @@ -68,6 +68,7 @@ func init() { allddls := append([]string{}, binlogplayer.CreateVReplicationTable()...) allddls = append(allddls, binlogplayer.AlterVReplicationTable...) allddls = append(allddls, createReshardingJournalTable, createCopyState) + allddls = append(allddls, binlogplayer.AlterVReplicationTableSourceToBlob...) withDDL = withddl.New(allddls) } diff --git a/go/vt/vttablet/tabletmanager/vreplication/engine_test.go b/go/vt/vttablet/tabletmanager/vreplication/engine_test.go index 3ebb563fa39..ceef6fb8a06 100644 --- a/go/vt/vttablet/tabletmanager/vreplication/engine_test.go +++ b/go/vt/vttablet/tabletmanager/vreplication/engine_test.go @@ -497,6 +497,7 @@ func TestCreateDBAndTable(t *testing.T) { dbClient.ExpectRequestRE("ALTER TABLE _vt.vreplication ADD COLUMN db_name.*", &sqltypes.Result{}, nil) dbClient.ExpectRequestRE("create table if not exists _vt.resharding_journal.*", &sqltypes.Result{}, nil) dbClient.ExpectRequestRE("create table if not exists _vt.copy_state.*", &sqltypes.Result{}, nil) + dbClient.ExpectRequestRE("ALTER TABLE _vt.vreplication MODIFY source.*", &sqltypes.Result{}, nil) } expectDDLs() dbClient.ExpectRequest("use _vt", &sqltypes.Result{}, nil) From 92eace948db7b0b22e989ef2d89ec548fc2fe1b0 Mon Sep 17 00:00:00 2001 From: Toliver Jue Date: Wed, 26 Aug 2020 19:48:49 +0900 Subject: [PATCH 2/2] combine ALTER statements Signed-off-by: Toliver Jue --- go/vt/binlog/binlogplayer/binlog_player.go | 4 ---- go/vt/vttablet/tabletmanager/vreplication/engine.go | 1 - go/vt/vttablet/tabletmanager/vreplication/engine_test.go | 2 +- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/go/vt/binlog/binlogplayer/binlog_player.go b/go/vt/binlog/binlogplayer/binlog_player.go index c560d9e5730..892eb97a9eb 100644 --- a/go/vt/binlog/binlogplayer/binlog_player.go +++ b/go/vt/binlog/binlogplayer/binlog_player.go @@ -531,10 +531,6 @@ func CreateVReplicationTable() []string { // AlterVReplicationTable adds new columns to vreplication table var AlterVReplicationTable = []string{ "ALTER TABLE _vt.vreplication ADD COLUMN db_name VARBINARY(255) NOT NULL", -} - -// AlterVReplicationTableSourceToBlob changes source column of vreplication table to BLOB -var AlterVReplicationTableSourceToBlob = []string{ "ALTER TABLE _vt.vreplication MODIFY source BLOB NOT NULL", } diff --git a/go/vt/vttablet/tabletmanager/vreplication/engine.go b/go/vt/vttablet/tabletmanager/vreplication/engine.go index 4f275d00735..79732f43ff8 100644 --- a/go/vt/vttablet/tabletmanager/vreplication/engine.go +++ b/go/vt/vttablet/tabletmanager/vreplication/engine.go @@ -68,7 +68,6 @@ func init() { allddls := append([]string{}, binlogplayer.CreateVReplicationTable()...) allddls = append(allddls, binlogplayer.AlterVReplicationTable...) allddls = append(allddls, createReshardingJournalTable, createCopyState) - allddls = append(allddls, binlogplayer.AlterVReplicationTableSourceToBlob...) withDDL = withddl.New(allddls) } diff --git a/go/vt/vttablet/tabletmanager/vreplication/engine_test.go b/go/vt/vttablet/tabletmanager/vreplication/engine_test.go index ceef6fb8a06..dbd095a7a80 100644 --- a/go/vt/vttablet/tabletmanager/vreplication/engine_test.go +++ b/go/vt/vttablet/tabletmanager/vreplication/engine_test.go @@ -495,9 +495,9 @@ func TestCreateDBAndTable(t *testing.T) { dbClient.ExpectRequest("DROP TABLE IF EXISTS _vt.blp_checkpoint", &sqltypes.Result{}, nil) dbClient.ExpectRequestRE("CREATE TABLE IF NOT EXISTS _vt.vreplication.*", &sqltypes.Result{}, nil) dbClient.ExpectRequestRE("ALTER TABLE _vt.vreplication ADD COLUMN db_name.*", &sqltypes.Result{}, nil) + dbClient.ExpectRequestRE("ALTER TABLE _vt.vreplication MODIFY source.*", &sqltypes.Result{}, nil) dbClient.ExpectRequestRE("create table if not exists _vt.resharding_journal.*", &sqltypes.Result{}, nil) dbClient.ExpectRequestRE("create table if not exists _vt.copy_state.*", &sqltypes.Result{}, nil) - dbClient.ExpectRequestRE("ALTER TABLE _vt.vreplication MODIFY source.*", &sqltypes.Result{}, nil) } expectDDLs() dbClient.ExpectRequest("use _vt", &sqltypes.Result{}, nil)