List:Commits« Previous MessageNext Message »
From:Mikael Ronstrom Date:October 6 2009 3:02pm
Subject:bzr commit into mysql-5.4 branch (mikael:2887) Bug#47837
View as plain text  
#At file:///home/mikael/mysql_clones/mysql-trunk-wl3352/

 2887 Mikael Ronstrom	2009-10-06
      BUG#47837, Duplicate field names were allowed in both column list partitioning and key partitioning, added check to give error in this case
      modified:
        mysql-test/r/partition_column.result
        mysql-test/t/partition_column.test
        sql/partition_info.cc
        sql/partition_info.h
        sql/share/errmsg.txt

=== modified file 'mysql-test/r/partition_column.result'
--- a/mysql-test/r/partition_column.result	2009-10-06 14:22:54 +0000
+++ b/mysql-test/r/partition_column.result	2009-10-06 15:01:59 +0000
@@ -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),

=== modified file 'mysql-test/t/partition_column.test'
--- a/mysql-test/t/partition_column.test	2009-10-06 14:22:15 +0000
+++ b/mysql-test/t/partition_column.test	2009-10-06 15:01:59 +0000
@@ -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)

=== modified file 'sql/partition_info.cc'
--- a/sql/partition_info.cc	2009-10-01 13:09:20 +0000
+++ b/sql/partition_info.cc	2009-10-06 15:01:59 +0000
@@ -334,6 +334,49 @@ bool partition_info::set_up_defaults_for
 
 
 /*
+  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_inf
     }
   }
 
+  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);

=== modified file 'sql/partition_info.h'
--- a/sql/partition_info.h	2009-10-01 13:04:42 +0000
+++ b/sql/partition_info.h	2009-10-06 15:01:59 +0000
@@ -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);

=== modified file 'sql/share/errmsg.txt'
--- a/sql/share/errmsg.txt	2009-09-15 15:07:52 +0000
+++ b/sql/share/errmsg.txt	2009-10-06 15:01:59 +0000
@@ -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"

Thread
bzr commit into mysql-5.4 branch (mikael:2887) Bug#47837Mikael Ronstrom6 Oct