From e2e3b5cb63dc6f4124a2165ee5c72111e163718e Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Wed, 26 Oct 2022 18:06:13 -0700 Subject: [PATCH] Added test case --- ddl/db_partition_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ddl/db_partition_test.go b/ddl/db_partition_test.go index c0e087ef4a046..1de6628cce895 100644 --- a/ddl/db_partition_test.go +++ b/ddl/db_partition_test.go @@ -4535,6 +4535,22 @@ func TestPartitionTableWithAnsiQuotes(t *testing.T) { ` PARTITION "p4" VALUES LESS THAN ('\\''\t\n','\\''\t\n'),` + "\n" + ` PARTITION "pMax" VALUES LESS THAN (MAXVALUE,MAXVALUE))`)) } + +func TestAlterModifyPartitionColTruncateWarning(t *testing.T) { + store := testkit.CreateMockStore(t) + tk := testkit.NewTestKit(t, store) + schemaName := "truncWarn" + tk.MustExec("create database " + schemaName) + tk.MustExec("use " + schemaName) + tk.MustExec(`set sql_mode = default`) + tk.MustExec(`create table t (a varchar(255)) partition by range columns (a) (partition p1 values less than ("0"), partition p2 values less than ("zzzz"))`) + tk.MustExec(`insert into t values ("123456")`) + tk.MustContainErrMsg(`alter table t modify a varchar(5)`, "[types:1265]Data truncated for column 'a', value is '123456'") + tk.MustExec(`set sql_mode = ''`) + tk.MustExec(`alter table t modify a varchar(5)`) + tk.MustQuery(`show warnings`).Check(testkit.Rows()) +} + func TestAlterModifyColumnOnPartitionedTable(t *testing.T) { store := testkit.CreateMockStore(t) tk := testkit.NewTestKit(t, store)