diff --git a/go/vt/schemadiff/schema_diff_test.go b/go/vt/schemadiff/schema_diff_test.go index 5aff4a0b408..270449841d9 100644 --- a/go/vt/schemadiff/schema_diff_test.go +++ b/go/vt/schemadiff/schema_diff_test.go @@ -294,6 +294,18 @@ func TestSchemaDiff(t *testing.T) { entityOrder: []string{"t1", "t2", "v2"}, instantCapability: InstantDDLCapabilityPossible, }, + { + name: "two identical tables, one with explicit charset, one without", + fromQueries: []string{ + "create table foobar (id int primary key, foo varchar(64) character set utf8mb3 collate utf8mb3_bin)", + }, + toQueries: []string{ + "create table foobar (id int primary key, foo varchar(64) collate utf8mb3_bin)", + }, + entityOrder: []string{}, + instantCapability: InstantDDLCapabilityIrrelevant, + }, + { name: "instant DDL possible on 8.0.32", toQueries: []string{ diff --git a/go/vt/schemadiff/table_test.go b/go/vt/schemadiff/table_test.go index 2177f1570e9..cb734245876 100644 --- a/go/vt/schemadiff/table_test.go +++ b/go/vt/schemadiff/table_test.go @@ -1878,6 +1878,11 @@ func TestCreateTableDiff(t *testing.T) { diff: "alter table t collate utf8mb4_0900_bin", cdiff: "ALTER TABLE `t` COLLATE utf8mb4_0900_bin", }, + { + name: "ignore identical implicit charset", + from: "create table t (id int primary key, v varchar(64) character set utf8mb3 collate utf8mb3_bin)", + to: "create table t (id int primary key, v varchar(64) collate utf8mb3_bin)", + }, { name: "normalized unsigned attribute", from: "create table t1 (id int primary key)", @@ -2889,6 +2894,11 @@ func TestNormalize(t *testing.T) { from: "create table t (id int signed primary key, v varchar(255) charset utf8mb3 collate utf8_unicode_ci) charset utf8mb3 collate utf8_unicode_ci", to: "CREATE TABLE `t` (\n\t`id` int,\n\t`v` varchar(255),\n\tPRIMARY KEY (`id`)\n) CHARSET utf8mb3,\n COLLATE utf8mb3_unicode_ci", }, + { + name: "remove column charset if collation is explicit and implies specified charset", + from: "create table t (id int primary key, v varchar(255) charset utf8mb4 collate utf8mb4_german2_ci)", + to: "CREATE TABLE `t` (\n\t`id` int,\n\t`v` varchar(255) COLLATE utf8mb4_german2_ci,\n\tPRIMARY KEY (`id`)\n)", + }, { name: "correct case table options for engine", from: "create table t (id int signed primary key) engine innodb",