diff options
author | Mikael Ronstrom <mikael@mysql.com> | 2009-10-06 17:01:59 +0200 |
---|---|---|
committer | Mikael Ronstrom <mikael@mysql.com> | 2009-10-06 17:01:59 +0200 |
commit | 576dd76aa81787f71e038efd9e00713b7a44b3c5 (patch) | |
tree | 8a64b121a12e42e2945fe186a5bef63e60082416 /sql | |
parent | 2ef1c756db41b003f6e634104f9024cdb4f2b982 (diff) | |
download | mariadb-git-576dd76aa81787f71e038efd9e00713b7a44b3c5.tar.gz |
BUG#47837, Duplicate field names were allowed in both column list partitioning and key partitioning, added check to give error in this case
Diffstat (limited to 'sql')
-rw-r--r-- | sql/partition_info.cc | 49 | ||||
-rw-r--r-- | sql/partition_info.h | 1 | ||||
-rw-r--r-- | sql/share/errmsg.txt | 2 |
3 files changed, 52 insertions, 0 deletions
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" |