From 2e272fe7375216850adbce8b4c4731c51d3cc120 Mon Sep 17 00:00:00 2001 From: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> Date: Wed, 20 Apr 2022 16:50:19 +0300 Subject: [PATCH] Vitess online ddl: modifyint column from textual to non-textual, ignore character set conversion on target (#10116) Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> --- .../vrepl_suite/testdata/utf8-to-int/alter | 1 + .../testdata/utf8-to-int/create.sql | 21 +++++++++++++++++++ .../vrepl_suite/testdata/utf8mb4-to-int/alter | 1 + .../testdata/utf8mb4-to-int/create.sql | 21 +++++++++++++++++++ .../testdata/utf8mb4-to-int/ignore_versions | 1 + go/vt/vttablet/onlineddl/vrepl.go | 3 ++- 6 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 go/test/endtoend/onlineddl/vrepl_suite/testdata/utf8-to-int/alter create mode 100644 go/test/endtoend/onlineddl/vrepl_suite/testdata/utf8-to-int/create.sql create mode 100644 go/test/endtoend/onlineddl/vrepl_suite/testdata/utf8mb4-to-int/alter create mode 100644 go/test/endtoend/onlineddl/vrepl_suite/testdata/utf8mb4-to-int/create.sql create mode 100644 go/test/endtoend/onlineddl/vrepl_suite/testdata/utf8mb4-to-int/ignore_versions diff --git a/go/test/endtoend/onlineddl/vrepl_suite/testdata/utf8-to-int/alter b/go/test/endtoend/onlineddl/vrepl_suite/testdata/utf8-to-int/alter new file mode 100644 index 00000000000..ff74892c2c8 --- /dev/null +++ b/go/test/endtoend/onlineddl/vrepl_suite/testdata/utf8-to-int/alter @@ -0,0 +1 @@ +modify column t int not null default '0' diff --git a/go/test/endtoend/onlineddl/vrepl_suite/testdata/utf8-to-int/create.sql b/go/test/endtoend/onlineddl/vrepl_suite/testdata/utf8-to-int/create.sql new file mode 100644 index 00000000000..141a7f24039 --- /dev/null +++ b/go/test/endtoend/onlineddl/vrepl_suite/testdata/utf8-to-int/create.sql @@ -0,0 +1,21 @@ +drop table if exists onlineddl_test; +create table onlineddl_test ( + id int auto_increment, + t varchar(128) charset utf8 collate utf8_general_ci, + primary key(id) +) auto_increment=1; + +drop event if exists onlineddl_test; +delimiter ;; +create event onlineddl_test + on schedule every 1 second + starts current_timestamp + ends current_timestamp + interval 60 second + on completion not preserve + enable + do +begin + insert into onlineddl_test values (null, 11); + insert into onlineddl_test values (null, '13'); + insert into onlineddl_test values (null, '17'); +end ;; diff --git a/go/test/endtoend/onlineddl/vrepl_suite/testdata/utf8mb4-to-int/alter b/go/test/endtoend/onlineddl/vrepl_suite/testdata/utf8mb4-to-int/alter new file mode 100644 index 00000000000..ff74892c2c8 --- /dev/null +++ b/go/test/endtoend/onlineddl/vrepl_suite/testdata/utf8mb4-to-int/alter @@ -0,0 +1 @@ +modify column t int not null default '0' diff --git a/go/test/endtoend/onlineddl/vrepl_suite/testdata/utf8mb4-to-int/create.sql b/go/test/endtoend/onlineddl/vrepl_suite/testdata/utf8mb4-to-int/create.sql new file mode 100644 index 00000000000..9d6f82e5957 --- /dev/null +++ b/go/test/endtoend/onlineddl/vrepl_suite/testdata/utf8mb4-to-int/create.sql @@ -0,0 +1,21 @@ +drop table if exists onlineddl_test; +create table onlineddl_test ( + id int auto_increment, + t varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + primary key(id) +) auto_increment=1; + +drop event if exists onlineddl_test; +delimiter ;; +create event onlineddl_test + on schedule every 1 second + starts current_timestamp + ends current_timestamp + interval 60 second + on completion not preserve + enable + do +begin + insert into onlineddl_test values (null, 11); + insert into onlineddl_test values (null, '13'); + insert into onlineddl_test values (null, '17'); +end ;; diff --git a/go/test/endtoend/onlineddl/vrepl_suite/testdata/utf8mb4-to-int/ignore_versions b/go/test/endtoend/onlineddl/vrepl_suite/testdata/utf8mb4-to-int/ignore_versions new file mode 100644 index 00000000000..b6de5f8d9f5 --- /dev/null +++ b/go/test/endtoend/onlineddl/vrepl_suite/testdata/utf8mb4-to-int/ignore_versions @@ -0,0 +1 @@ +(5.5|5.6) diff --git a/go/vt/vttablet/onlineddl/vrepl.go b/go/vt/vttablet/onlineddl/vrepl.go index d2b1a445a10..6a94c894ff7 100644 --- a/go/vt/vttablet/onlineddl/vrepl.go +++ b/go/vt/vttablet/onlineddl/vrepl.go @@ -472,7 +472,8 @@ func (v *VRepl) generateFilterQuery(ctx context.Context) error { return vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "Character set %s not supported for column %s", sourceCol.Charset, sourceCol.Name) } toEncoding, ok := mysql.CharacterSetEncoding[targetCol.Charset] - if !ok { + // Let's see if target col is at all textual + if targetCol.Type == vrepl.StringColumnType && !ok { return vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "Character set %s not supported for column %s", targetCol.Charset, targetCol.Name) } if fromEncoding == nil && toEncoding == nil {