diff --git a/mysql-test/main/partition_ucs2.result b/mysql-test/main/partition_ucs2.result new file mode 100644 index 00000000000..ae2f3f15fa3 --- /dev/null +++ b/mysql-test/main/partition_ucs2.result @@ -0,0 +1,13 @@ +# +# Start of 10.3 tests +# +# +# MDEV-20855 Crash with PARTITION BY LIST and extended characters +# +SET NAMES utf8; +CREATE OR REPLACE TABLE t1 (a TIME) +PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN (_ucs2 0x0411)); +ERROR HY000: This partition function is not allowed +# +# End of 10.3 tests +# diff --git a/mysql-test/main/partition_ucs2.test b/mysql-test/main/partition_ucs2.test new file mode 100644 index 00000000000..8af2b6196c6 --- /dev/null +++ b/mysql-test/main/partition_ucs2.test @@ -0,0 +1,19 @@ +--source include/have_partition.inc +--source include/have_ucs2.inc + +--echo # +--echo # Start of 10.3 tests +--echo # + +--echo # +--echo # MDEV-20855 Crash with PARTITION BY LIST and extended characters +--echo # + +SET NAMES utf8; +--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +CREATE OR REPLACE TABLE t1 (a TIME) + PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN (_ucs2 0x0411)); + +--echo # +--echo # End of 10.3 tests +--echo # diff --git a/mysql-test/main/partition_utf8.result b/mysql-test/main/partition_utf8.result index 7718e651423..956ee790160 100644 --- a/mysql-test/main/partition_utf8.result +++ b/mysql-test/main/partition_utf8.result @@ -51,3 +51,19 @@ t1 CREATE TABLE `t1` ( insert into t1 values (''); insert into t1 values (_ucs2 0x2020); drop table t1; +# +# Start of 10.3 tests +# +# +# MDEV-20855 Crash with PARTITION BY LIST and extended characters +# +SET NAMES utf8; +CREATE OR REPLACE TABLE t1 (a CHAR(10)) CHARACTER SET latin1 +PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN ('Б')); +ERROR HY000: This partition function is not allowed +CREATE OR REPLACE TABLE t1 (a TIME) +PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN ('Б')); +ERROR HY000: This partition function is not allowed +# +# End of 10.3 tests +# diff --git a/mysql-test/main/partition_utf8.test b/mysql-test/main/partition_utf8.test index d3ad7ba671e..65050429a52 100644 --- a/mysql-test/main/partition_utf8.test +++ b/mysql-test/main/partition_utf8.test @@ -40,3 +40,25 @@ show create table t1; insert into t1 values (''); insert into t1 values (_ucs2 0x2020); drop table t1; + +--echo # +--echo # Start of 10.3 tests +--echo # + +--echo # +--echo # MDEV-20855 Crash with PARTITION BY LIST and extended characters +--echo # + +SET NAMES utf8; + +--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +CREATE OR REPLACE TABLE t1 (a CHAR(10)) CHARACTER SET latin1 + PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN ('Б')); + +--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED +CREATE OR REPLACE TABLE t1 (a TIME) + PARTITION BY LIST COLUMNS (a) (PARTITION p0 VALUES IN ('Б')); + +--echo # +--echo # End of 10.3 tests +--echo # diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index d23ee8583e3..00a78ce3199 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -146,7 +146,7 @@ Item* convert_charset_partition_constant(Item *item, CHARSET_INFO *cs) item= item->safe_charset_converter(thd, cs); context->table_list= NULL; thd->where= "convert character set partition constant"; - if (item->fix_fields_if_needed(thd, (Item**)NULL)) + if (item && item->fix_fields_if_needed(thd, (Item**)NULL)) item= NULL; thd->where= save_where; context->table_list= save_list;