diff options
author | Mattias Jonsson <mattias.jonsson@oracle.com> | 2011-01-10 16:20:28 +0100 |
---|---|---|
committer | Mattias Jonsson <mattias.jonsson@oracle.com> | 2011-01-10 16:20:28 +0100 |
commit | c574a9c414f817975f75a08744b2f0bea1232ff3 (patch) | |
tree | 14b8f2c7135475941207613ee7885046f1c2f071 /sql | |
parent | 078ed281817d370faa3e7f563cf32568528b3591 (diff) | |
download | mariadb-git-c574a9c414f817975f75a08744b2f0bea1232ff3.tar.gz |
Bug#57924: crash when creating partitioned table with
multiple columns in the partition key
ndb crash if duplicate columns in the partitioning key.
Backport from mysql-5.1-telco-7.0, see bug#53354.
Changed from case sensitive field name comparision
to non case sensitive too.
mysql-test/r/partition_error.result:
updated result
mysql-test/t/partition_error.test:
Added test for the error in non-ndb partitioned table.
sql/sql_partition.cc:
Added check for duplicated field names in the
partitioning key.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_partition.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 44ed9e759c6..8cd43a4f60e 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -761,6 +761,9 @@ static bool handle_list_of_fields(List_iterator<char> it, bool result; char *field_name; bool is_list_empty= TRUE; + int fields_handled = 0; + char* field_name_array[MAX_KEY]; + DBUG_ENTER("handle_list_of_fields"); while ((field_name= it++)) @@ -776,6 +779,25 @@ static bool handle_list_of_fields(List_iterator<char> it, result= TRUE; goto end; } + + /* + Check for duplicate fields in the list. + Assuming that there are not many fields in the partition key list. + If there were, it would be better to replace the for-loop + with a more efficient algorithm. + */ + + field_name_array[fields_handled] = field_name; + for (int i = 0; i < fields_handled; ++i) + { + if (my_strcasecmp(system_charset_info, + field_name_array[i], field_name) == 0) + { + my_error(ER_FIELD_NOT_FOUND_PART_ERROR, MYF(0)); + DBUG_RETURN(TRUE); + } + } + fields_handled++; } if (is_list_empty) { |