diff options
-rw-r--r-- | mysql-test/r/partition_column.result | 7 | ||||
-rw-r--r-- | mysql-test/t/partition_column.test | 11 | ||||
-rw-r--r-- | sql/partition_info.cc | 49 | ||||
-rw-r--r-- | sql/partition_info.h | 1 | ||||
-rw-r--r-- | sql/share/errmsg.txt | 2 |
5 files changed, 70 insertions, 0 deletions
diff --git a/mysql-test/r/partition_column.result b/mysql-test/r/partition_column.result index 621a127f310..fb7f815fd98 100644 --- a/mysql-test/r/partition_column.result +++ b/mysql-test/r/partition_column.result @@ -1,4 +1,11 @@ drop table if exists t1; +create table t1 (a int, b int) +partition by key (a,a); +ERROR HY000: Duplicate partition field name a +create table t1 (a int, b int) +partition by list column_list(a,a) +( partition p values in (column_list(1,1))); +ERROR HY000: Duplicate partition field name a create table t1 (a int signed) partition by list (a) ( partition p0 values in (1, 3, 5, 7, 9, NULL), diff --git a/mysql-test/t/partition_column.test b/mysql-test/t/partition_column.test index 5eef85b4fa2..1c7e8d59895 100644 --- a/mysql-test/t/partition_column.test +++ b/mysql-test/t/partition_column.test @@ -9,6 +9,17 @@ drop table if exists t1; --enable_warnings # +# BUG#47837, Crash when two same fields in column list processing +# +--error ER_SAME_NAME_PARTITION_FIELD +create table t1 (a int, b int) +partition by key (a,a); +--error ER_SAME_NAME_PARTITION_FIELD +create table t1 (a int, b int) +partition by list column_list(a,a) +( partition p values in (column_list(1,1))); + +# # BUG#47838, List partitioning have problems with <= and >= # create table t1 (a int signed) diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 0540c094ccc..ef212fce28d 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -334,6 +334,49 @@ bool partition_info::set_up_defaults_for_partitioning(handler *file, /* + Support routine for check_partition_info + + SYNOPSIS + has_unique_fields + no parameters + + RETURN VALUE + Erroneus field name Error, there are two fields with same name + NULL Ok, no field defined twice + + DESCRIPTION + Check that the user haven't defined the same field twice in + key or column list partitioning. +*/ +char* partition_info::has_unique_fields() +{ + char *field_name_outer, *field_name_inner; + List_iterator<char> it_outer(part_field_list); + uint num_fields= part_field_list.elements; + uint i,j; + DBUG_ENTER("partition_info::has_unique_fields"); + + for (i= 0; i < num_fields; i++) + { + field_name_outer= it_outer++; + List_iterator<char> it_inner(part_field_list); + for (j= 0; j < num_fields; j++) + { + field_name_inner= it_inner++; + if (i == j) + continue; + if (!(my_strcasecmp(system_charset_info, + field_name_outer, + field_name_inner))) + { + DBUG_RETURN(field_name_outer); + } + } + } + DBUG_RETURN(NULL); +} + +/* A support function to check if a partition element's name is unique SYNOPSIS @@ -1143,6 +1186,12 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type, } } + if (part_field_list.elements > 0 && + (same_name= has_unique_fields())) + { + my_error(ER_SAME_NAME_PARTITION_FIELD, MYF(0), same_name); + goto end; + } if ((same_name= has_unique_names())) { my_error(ER_SAME_NAME_PARTITION, MYF(0), same_name); diff --git a/sql/partition_info.h b/sql/partition_info.h index 1f2b6b6a95e..6e197198807 100644 --- a/sql/partition_info.h +++ b/sql/partition_info.h @@ -271,6 +271,7 @@ public: bool set_up_defaults_for_partitioning(handler *file, HA_CREATE_INFO *info, uint start_no); + char *has_unique_fields(); char *has_unique_names(); bool check_engine_mix(handlerton *engine_type, bool default_engine); bool check_range_constants(THD *thd); diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index 514dc06728d..3d228f58360 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -5822,6 +5822,8 @@ ER_SAME_NAME_PARTITION eng "Duplicate partition name %-.192s" ger "Doppelter Partitionsname: %-.192s" swe "Duplicerat partitionsnamn %-.192s" +ER_SAME_NAME_PARTITION_FIELD + eng "Duplicate partition field name %-.192s" ER_NO_BINLOG_ERROR eng "It is not allowed to shut off binlog on this command" ger "Es es nicht erlaubt, bei diesem Befehl binlog abzuschalten" |