List:Commits« Previous MessageNext Message »
From:Maitrayi Sabaratnam Date:November 1 2010 9:13am
Subject:bzr commit into mysql-5.1-telco-7.0 branch (maitrayi.sabaratnam:3901)
Bug#53354
View as plain text  
#At file:///export/tmp/maitrayi/mysql-src/repo-7.0/mysql-5.1-telco-7.0-bug53354/ based on revid:jonas@stripped

 3901 Maitrayi Sabaratnam	2010-11-01
      Bug#53354 crash when creating partitioned table with multiple columns in the partition key

    modified:
      mysql-test/suite/ndb/r/ndb_basic.result
      mysql-test/suite/ndb/t/ndb_basic.test
      sql/sql_partition.cc
=== modified file 'mysql-test/suite/ndb/r/ndb_basic.result'

=== modified file 'mysql-test/suite/ndb/r/ndb_basic.result'
--- a/mysql-test/suite/ndb/r/ndb_basic.result	2010-10-11 11:19:57 +0000
+++ b/mysql-test/suite/ndb/r/ndb_basic.result	2010-11-01 09:13:06 +0000
@@ -985,6 +985,8 @@
 alter online table t1 add column c500 bit(1) column_format DYNAMIC;
 delete from t1;
 drop table t1;
+create table `t1` (`a` int, b int, primary key (a,b)) engine=ndb partition by key(`a`,`b`,`a`);
+ERROR HY000: Field in list of fields for partition function not found in table
 create table t1 (
 a1234567890123456789012345678901234567890 int primary key,
 a12345678901234567890123456789a1234567890 int,

=== modified file 'mysql-test/suite/ndb/t/ndb_basic.test'
--- a/mysql-test/suite/ndb/t/ndb_basic.test	2010-05-03 04:49:08 +0000
+++ b/mysql-test/suite/ndb/t/ndb_basic.test	2010-11-01 09:13:06 +0000
@@ -923,6 +923,13 @@
 drop table t1;
 
 #
+# test bug#53354 - crash when creating partitioned table with multiple columns in the partition key
+#
+
+--error ER_FIELD_NOT_FOUND_PART_ERROR
+create table `t1` (`a` int, b int, primary key (a,b)) engine=ndb partition by key(`a`,`b`,`a`);
+
+#
 # test max size of attribute name and truncation
 #
 

=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc	2010-10-12 14:53:28 +0000
+++ b/sql/sql_partition.cc	2010-11-01 09:13:06 +0000
@@ -764,6 +764,11 @@
   bool result;
   char *field_name;
   bool is_list_empty= TRUE;
+#ifndef MCP_BUG53354
+  int fields_handled = 0;
+  char* field_name_array[MAX_KEY];
+#endif
+
   DBUG_ENTER("handle_list_of_fields");
 
   while ((field_name= it++))
@@ -779,6 +784,25 @@
       result= TRUE;
       goto end;
     }
+
+#ifndef MCP_BUG53354
+    /* 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 (strcmp(field_name_array[i], field_name) == 0)
+      {
+         my_error(ER_FIELD_NOT_FOUND_PART_ERROR, MYF(0));
+         DBUG_RETURN(TRUE);
+      }
+    }
+    fields_handled++;
+#endif
   }
   if (is_list_empty)
   {


Attachment: [text/bzr-bundle] bzr/maitrayi.sabaratnam@oracle.com-20101101091306-gsng2kouj6y5mhgt.bundle
Thread
bzr commit into mysql-5.1-telco-7.0 branch (maitrayi.sabaratnam:3901)Bug#53354Maitrayi Sabaratnam1 Nov