From 07c1607e2260c6c7a81335b3fe4ac0587a785e38 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Tue, 29 Oct 2024 14:06:52 -0400 Subject: [PATCH] VReplication: Fix mixed case generated column handling We were using the lowercase column name when building the list of columns to ignore but then using the case we got back from MySQL when checking the list. Signed-off-by: Matt Lord --- go/test/endtoend/vreplication/cluster_test.go | 4 ++-- go/test/endtoend/vreplication/config_test.go | 4 ++-- go/test/endtoend/vreplication/unsharded_init_data.sql | 4 ++-- .../vttablet/tabletmanager/vreplication/table_plan_builder.go | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/go/test/endtoend/vreplication/cluster_test.go b/go/test/endtoend/vreplication/cluster_test.go index 13268fc749c..119843651bc 100644 --- a/go/test/endtoend/vreplication/cluster_test.go +++ b/go/test/endtoend/vreplication/cluster_test.go @@ -30,6 +30,8 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" + "vitess.io/vitess/go/mysql" "vitess.io/vitess/go/test/endtoend/cluster" "vitess.io/vitess/go/test/endtoend/throttler" @@ -40,8 +42,6 @@ import ( vttablet "vitess.io/vitess/go/vt/vttablet/common" vtctldatapb "vitess.io/vitess/go/vt/proto/vtctldata" - - "github.com/stretchr/testify/require" ) var ( diff --git a/go/test/endtoend/vreplication/config_test.go b/go/test/endtoend/vreplication/config_test.go index 25a4b734259..d938913b1c3 100644 --- a/go/test/endtoend/vreplication/config_test.go +++ b/go/test/endtoend/vreplication/config_test.go @@ -48,8 +48,8 @@ var ( customerTypes = []string{"'individual'", "'soho'", "'enterprise'"} initialProductSchema = fmt.Sprintf(` create table product(pid int, description varbinary(128), date1 datetime not null default '0000-00-00 00:00:00', date2 datetime not null default '2021-00-01 00:00:00', primary key(pid), key(date1,date2)) CHARSET=utf8mb4; -create table customer(cid int auto_increment, name varchar(128) collate utf8mb4_bin, meta json default null, typ enum(%s), sport set('football','cricket','baseball'), - ts timestamp not null default current_timestamp, bits bit(2) default b'11', date1 datetime not null default '0000-00-00 00:00:00', +create table customer(cid int auto_increment, name varchar(128) collate utf8mb4_bin, meta json default null, industryCategory varchar(100) GENERATED ALWAYS AS (json_extract(meta, '$.industry')) VIRTUAL, + typ enum(%s), sport set('football','cricket','baseball'), ts timestamp not null default current_timestamp, bits bit(2) default b'11', date1 datetime not null default '0000-00-00 00:00:00', date2 datetime not null default '2021-00-01 00:00:00', dec80 decimal(8,0), blb blob, primary key(cid,typ), key(name)) CHARSET=utf8mb4; create table customer_seq(id int, next_id bigint, cache bigint, primary key(id)) comment 'vitess_sequence'; create table merchant(mname varchar(128), category varchar(128), primary key(mname), key(category)) CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; diff --git a/go/test/endtoend/vreplication/unsharded_init_data.sql b/go/test/endtoend/vreplication/unsharded_init_data.sql index 8af0cab6608..3e795cadcfd 100644 --- a/go/test/endtoend/vreplication/unsharded_init_data.sql +++ b/go/test/endtoend/vreplication/unsharded_init_data.sql @@ -1,7 +1,7 @@ -insert into customer(cid, name, typ, sport, meta) values(1, 'Jøhn "❤️" Rizzolo',1,'football,baseball','{}'); +insert into customer(cid, name, typ, sport, meta) values(1, 'Jøhn "❤️" Rizzolo',1,'football,baseball','{"industry":"IT SaaS","company":"PlanetScale"}'); insert into customer(cid, name, typ, sport, meta) values(2, 'Paül','soho','cricket',convert(x'7b7d' using utf8mb4)); -- We use a high cid value here to test the target sequence initialization. -insert into customer(cid, name, typ, sport, blb) values(999999, 'ringo','enterprise','','blob data'); +insert into customer(cid, name, typ, sport, blb, meta) values(999999, 'ringo','enterprise','','blob data', '{"industry":"Music"}'); insert into merchant(mname, category) values('Monoprice', 'eléctronics'); insert into merchant(mname, category) values('newegg', 'elec†ronics'); insert into product(pid, description) values(1, 'keyböard ⌨️'); diff --git a/go/vt/vttablet/tabletmanager/vreplication/table_plan_builder.go b/go/vt/vttablet/tabletmanager/vreplication/table_plan_builder.go index 12afc3fec28..490cd1b21c2 100644 --- a/go/vt/vttablet/tabletmanager/vreplication/table_plan_builder.go +++ b/go/vt/vttablet/tabletmanager/vreplication/table_plan_builder.go @@ -360,7 +360,7 @@ func (tpb *tablePlanBuilder) generate() *TablePlan { fieldsToSkip := make(map[string]bool) for _, colInfo := range tpb.colInfos { if colInfo.IsGenerated { - fieldsToSkip[colInfo.Name] = true + fieldsToSkip[strings.ToLower(colInfo.Name)] = true } } return &TablePlan{