From a877da7433e4de4213830da8290624cfd2a1aff7 Mon Sep 17 00:00:00 2001 From: Rohit Nayak Date: Tue, 9 May 2023 11:39:32 +0200 Subject: [PATCH] Set default characterset to be utf8mb4 while applying schemas so that table and column names can have special characters Signed-off-by: Rohit Nayak --- go/test/endtoend/vreplication/config_test.go | 6 +++--- .../endtoend/vreplication/initial_data_test.go | 18 +++++++++--------- .../endtoend/vreplication/vreplication_test.go | 2 +- .../vreplication/vreplication_test_env.go | 10 +++++----- go/vt/mysqlctl/mysqld.go | 1 + 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/go/test/endtoend/vreplication/config_test.go b/go/test/endtoend/vreplication/config_test.go index e39aff9efde..157e0871314 100644 --- a/go/test/endtoend/vreplication/config_test.go +++ b/go/test/endtoend/vreplication/config_test.go @@ -57,7 +57,7 @@ create table vdiff_order (order_id varchar(50) collate utf8mb4_unicode_ci not nu create table datze (id int, dt1 datetime not null default current_timestamp, dt2 datetime not null, ts1 timestamp default current_timestamp, primary key (id), key (dt1)); create table json_tbl (id int, j1 json, j2 json, primary key(id)); create table geom_tbl (id int, g geometry, p point, ls linestring, pg polygon, mp multipoint, mls multilinestring, mpg multipolygon, gc geometrycollection, primary key(id)); -create table blob_tbl (id int, val1 varchar(20), blb1 blob, val2 varbinary(20), blb2 longblob, txt1 text, blb3 tinyblob, txt2 longtext, blb4 mediumblob, primary key(id)); +create table ` + "`blüb_tbl`" + ` (id int, val1 varchar(20), ` + "`blöb1`" + ` blob, val2 varbinary(20), ` + "`bl@b2`" + ` longblob, txt1 text, blb3 tinyblob, txt2 longtext, blb4 mediumblob, primary key(id)); ` // These should always be ignored in vreplication internalSchema = ` @@ -185,7 +185,7 @@ create table blob_tbl (id int, val1 varchar(20), blb1 blob, val2 varbinary(20), } ] }, - "blob_tbl": { + "blüb_tbl": { "column_vindexes": [ { "column": "id", @@ -332,7 +332,7 @@ create table blob_tbl (id int, val1 varchar(20), blb1 blob, val2 varbinary(20), } ] }, - "blob_tbl": { + "blüb_tbl": { "column_vindexes": [ { "column": "id", diff --git a/go/test/endtoend/vreplication/initial_data_test.go b/go/test/endtoend/vreplication/initial_data_test.go index 66952d8992b..828c7136373 100644 --- a/go/test/endtoend/vreplication/initial_data_test.go +++ b/go/test/endtoend/vreplication/initial_data_test.go @@ -95,15 +95,15 @@ func insertMoreProductsForTargetThrottler(t *testing.T) { } var blobTableQueries = []string{ - "insert into blob_tbl(id, val1, txt1) values (1, 'Jøhn \"❤️\" Paül','Jøhn \"❤️\" Paül keyböard ⌨️ jo˙n')", - "insert into blob_tbl(id, val1, blb1, blb2) values (2, 'val1_aaa', 'blb1_aaa', 'blb2_AAAA')", - "update blob_tbl set val1 = 'val1_bbb', blb2 = 'blb2_bbb' where id = 1", - "insert into blob_tbl(id, val2, txt1, txt2, blb4) values (3, 'val2_ccc', 'txt1_ccc', 'txt2_ccc', 'blb4_CCC')", - "update blob_tbl set txt1 = 'txt1_ddd'", - "update blob_tbl set blb3 = 'blb3_eee'", - "delete from blob_tbl where id = 2", - "insert into blob_tbl(id, val2, txt1, txt2, blb4) values (4, 'val2_fff', 'txt1_fff', 'txt2_fff', 'blb4_FFF')", - "update blob_tbl set txt1 = 'txt1_eee', blb3 = 'blb3_eee' where id = 4", + "insert into `blüb_tbl`(id, val1, txt1) values (1, 'Jøhn \"❤️\" Paül','Jøhn \"❤️\" Paül keyböard ⌨️ jo˙n')", + "insert into `blüb_tbl`(id, val1, `blöb1`, `bl@b2`) values (2, 'val1_aaa', 'blb1_aaa', 'blb2_AAAA')", + "update `blüb_tbl` set val1 = 'val1_bbb', `bl@b2` = 'blb2_bbb' where id = 1", + "insert into `blüb_tbl`(id, val2, txt1, txt2, blb4) values (3, 'val2_ccc', 'txt1_ccc', 'txt2_ccc', 'blb4_CCC')", + "update `blüb_tbl` set txt1 = 'txt1_ddd'", + "update `blüb_tbl` set blb3 = 'blb3_eee'", + "delete from `blüb_tbl` where id = 2", + "insert into `blüb_tbl`(id, val2, txt1, txt2, blb4) values (4, 'val2_fff', 'txt1_fff', 'txt2_fff', 'blb4_FFF')", + "update `blüb_tbl` set txt1 = 'txt1_eee', blb3 = 'blb3_eee' where id = 4", } func insertIntoBlobTable(t *testing.T) { diff --git a/go/test/endtoend/vreplication/vreplication_test.go b/go/test/endtoend/vreplication/vreplication_test.go index 0aa88bba833..9651c1c7bc5 100644 --- a/go/test/endtoend/vreplication/vreplication_test.go +++ b/go/test/endtoend/vreplication/vreplication_test.go @@ -682,7 +682,7 @@ func shardCustomer(t *testing.T, testReverse bool, cells []*Cell, sourceCellOrAl defaultCell := cells[0] custKs := vc.Cells[defaultCell.Name].Keyspaces["customer"] - tables := "customer,Lead,Lead-1,db_order_test,geom_tbl,json_tbl,blob_tbl,vdiff_order" + tables := "customer,Lead,Lead-1,db_order_test,geom_tbl,json_tbl,blüb_tbl,vdiff_order" moveTablesAction(t, "Create", sourceCellOrAlias, workflow, sourceKs, targetKs, tables) customerTab1 := custKs.Shards["-80"].Tablets["zone1-200"].Vttablet diff --git a/go/test/endtoend/vreplication/vreplication_test_env.go b/go/test/endtoend/vreplication/vreplication_test_env.go index d7686f0e5d9..eceb9284148 100644 --- a/go/test/endtoend/vreplication/vreplication_test_env.go +++ b/go/test/endtoend/vreplication/vreplication_test_env.go @@ -19,14 +19,14 @@ package vreplication var dryRunResultsSwitchWritesCustomerShard = []string{ "Lock keyspace product", "Lock keyspace customer", - "Stop writes on keyspace product, tables [Lead,Lead-1,blob_tbl,customer,db_order_test,geom_tbl,json_tbl,vdiff_order]:", + "Stop writes on keyspace product, tables [Lead,Lead-1,blüb_tbl,customer,db_order_test,geom_tbl,json_tbl,vdiff_order]:", "/ Keyspace product, Shard 0 at Position", "Wait for VReplication on stopped streams to catchup for up to 30s", "Create reverse replication workflow p2c_reverse", "Create journal entries on source databases", - "Enable writes on keyspace customer tables [Lead,Lead-1,blob_tbl,customer,db_order_test,geom_tbl,json_tbl,vdiff_order]", + "Enable writes on keyspace customer tables [Lead,Lead-1,blüb_tbl,customer,db_order_test,geom_tbl,json_tbl,vdiff_order]", "Switch routing from keyspace product to keyspace customer", - "Routing rules for tables [Lead,Lead-1,blob_tbl,customer,db_order_test,geom_tbl,json_tbl,vdiff_order] will be updated", + "Routing rules for tables [Lead,Lead-1,blüb_tbl,customer,db_order_test,geom_tbl,json_tbl,vdiff_order] will be updated", "Switch writes completed, freeze and delete vreplication streams on:", " tablet 200 ", " tablet 300 ", @@ -41,8 +41,8 @@ var dryRunResultsSwitchWritesCustomerShard = []string{ var dryRunResultsReadCustomerShard = []string{ "Lock keyspace product", - "Switch reads for tables [Lead,Lead-1,blob_tbl,customer,db_order_test,geom_tbl,json_tbl,vdiff_order] to keyspace customer for tablet types [RDONLY,REPLICA]", - "Routing rules for tables [Lead,Lead-1,blob_tbl,customer,db_order_test,geom_tbl,json_tbl,vdiff_order] will be updated", + "Switch reads for tables [Lead,Lead-1,blüb_tbl,customer,db_order_test,geom_tbl,json_tbl,vdiff_order] to keyspace customer for tablet types [RDONLY,REPLICA]", + "Routing rules for tables [Lead,Lead-1,blüb_tbl,customer,db_order_test,geom_tbl,json_tbl,vdiff_order] will be updated", "Unlock keyspace product", } diff --git a/go/vt/mysqlctl/mysqld.go b/go/vt/mysqlctl/mysqld.go index 410619140ec..b3e144f2266 100644 --- a/go/vt/mysqlctl/mysqld.go +++ b/go/vt/mysqlctl/mysqld.go @@ -1070,6 +1070,7 @@ func (mysqld *Mysqld) executeMysqlScript(connParams *mysql.ConnParams, sql io.Re args := []string{ "--defaults-extra-file=" + cnf, "--batch", + "--default-character-set=utf8mb4", } env, err := buildLdPaths() if err != nil {