MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Mattias Jonsson Date:February 18 2009 7:05pm
Subject:bzr commit into mysql-5.1-bugteam branch (mattias.jonsson:2756)
Bug#39338
View as plain text  
#At file:///Users/mattiasj/clones/bzrroot/b39338-51-bugteam/ based on revid:sergey.glukhov@stripped

 2756 Mattias Jonsson	2009-02-18
      Bug#39338: Fieldnames in INFORMATIONSCHEMA.PARTITIONS.PARTITION_EXPRESSION
      become unescaped
      
      Problem was only with the print out of the KEY partitioning list of
      fields, it did not include quotes, even if it was needed.
      
      Fixed by always add quotes if needed.
     @ mysql-test/r/partition.result
        Bug#39338: Fieldnames in INFORMATIONSCHEMA.PARTITIONS.PARTITION_EXPRESSION
        become unescaped
        
        Updated result
     @ mysql-test/t/partition.test
        Bug#39338: Fieldnames in INFORMATIONSCHEMA.PARTITIONS.PARTITION_EXPRESSION
        become unescaped
        
        Added test case
     @ sql/sql_show.cc
        Bug#39338: Fieldnames in INFORMATIONSCHEMA.PARTITIONS.PARTITION_EXPRESSION
        become unescaped
        
        Added quotes if necessary.

    modified:
      mysql-test/r/partition.result
      mysql-test/t/partition.test
      sql/sql_show.cc
=== modified file 'mysql-test/r/partition.result'
--- a/mysql-test/r/partition.result	2008-11-24 16:24:03 +0000
+++ b/mysql-test/r/partition.result	2009-02-18 19:05:39 +0000
@@ -1,5 +1,42 @@
 drop table if exists t1, t2;
 CREATE TABLE t1 (
+ID int(11) NOT NULL,
+`aaaa,aaaaa` tinyint(3) UNSIGNED NOT NULL DEFAULT '0',
+ddddddddd int(11) NOT NULL DEFAULT '0',
+new_field0 varchar(50),
+PRIMARY KEY(ID, `aaaa,aaaaa`, ddddddddd))
+PARTITION BY RANGE(ID)
+PARTITIONS 3
+SUBPARTITION BY LINEAR KEY(ID,`aaaa,aaaaa`)
+SUBPARTITIONS 2 (
+PARTITION p01 VALUES LESS THAN(100),
+PARTITION p11 VALUES LESS THAN(200),
+PARTITION p21 VALUES LESS THAN MAXVALUE);
+SELECT PARTITION_EXPRESSION, SUBPARTITION_EXPRESSION FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME='t1';
+PARTITION_EXPRESSION	SUBPARTITION_EXPRESSION
+ID	`ID`,`aaaa,aaaaa`
+ID	`ID`,`aaaa,aaaaa`
+ID	`ID`,`aaaa,aaaaa`
+ID	`ID`,`aaaa,aaaaa`
+ID	`ID`,`aaaa,aaaaa`
+ID	`ID`,`aaaa,aaaaa`
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `ID` int(11) NOT NULL,
+  `aaaa,aaaaa` tinyint(3) unsigned NOT NULL DEFAULT '0',
+  `ddddddddd` int(11) NOT NULL DEFAULT '0',
+  `new_field0` varchar(50) DEFAULT NULL,
+  PRIMARY KEY (`ID`,`aaaa,aaaaa`,`ddddddddd`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (ID)
+SUBPARTITION BY LINEAR KEY (ID,`aaaa,aaaaa`)
+SUBPARTITIONS 2
+(PARTITION p01 VALUES LESS THAN (100) ENGINE = MyISAM,
+ PARTITION p11 VALUES LESS THAN (200) ENGINE = MyISAM,
+ PARTITION p21 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
+drop table t1;
+CREATE TABLE t1 (
 pk INT NOT NULL AUTO_INCREMENT,
 PRIMARY KEY (pk)
 )

=== modified file 'mysql-test/t/partition.test'
--- a/mysql-test/t/partition.test	2008-11-24 16:24:03 +0000
+++ b/mysql-test/t/partition.test	2009-02-18 19:05:39 +0000
@@ -15,6 +15,29 @@ drop table if exists t1, t2;
 --enable_warnings
 
 #
+# Bug#39338: Fieldnames in INFORMATIONSCHEMA.PARTITIONS.PARTITION_EXPRESSION
+#            become unescaped
+# NOTE: the partition expression is saved as a string, so changing from
+#       normal quotes to ansi quotes does not change the expression, only
+#       for partition by KEY.
+CREATE TABLE t1 (
+    ID int(11) NOT NULL,
+    `aaaa,aaaaa` tinyint(3) UNSIGNED NOT NULL DEFAULT '0',
+    ddddddddd int(11) NOT NULL DEFAULT '0',
+    new_field0 varchar(50),
+    PRIMARY KEY(ID, `aaaa,aaaaa`, ddddddddd))
+PARTITION BY RANGE(ID)
+PARTITIONS 3
+SUBPARTITION BY LINEAR KEY(ID,`aaaa,aaaaa`)
+SUBPARTITIONS 2 (
+    PARTITION p01 VALUES LESS THAN(100),
+    PARTITION p11 VALUES LESS THAN(200),
+    PARTITION p21 VALUES LESS THAN MAXVALUE);
+SELECT PARTITION_EXPRESSION, SUBPARTITION_EXPRESSION FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME='t1';
+show create table t1;
+drop table t1;
+
+#
 # Bug#40954: Crash if range search and order by.
 #
 CREATE TABLE t1 (

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2008-12-29 12:15:48 +0000
+++ b/sql/sql_show.cc	2009-02-18 19:05:39 +0000
@@ -4743,7 +4743,8 @@ static int get_schema_key_column_usage_r
 
 
 #ifdef WITH_PARTITION_STORAGE_ENGINE
-static void collect_partition_expr(List<char> &field_list, String *str)
+static void collect_partition_expr(THD *thd, List<char> &field_list,
+                                   String *str)
 {
   List_iterator<char> part_it(field_list);
   ulong no_fields= field_list.elements;
@@ -4751,7 +4752,7 @@ static void collect_partition_expr(List<
   str->length(0);
   while ((field_str= part_it++))
   {
-    str->append(field_str);
+    append_identifier(thd, str, field_str, strlen(field_str));
     if (--no_fields != 0)
       str->append(",");
   }
@@ -4915,7 +4916,7 @@ static int get_schema_partitions_record(
     }
     else if (part_info->list_of_part_fields)
     {
-      collect_partition_expr(part_info->part_field_list, &tmp_str);
+      collect_partition_expr(thd, part_info->part_field_list, &tmp_str);
       table->field[9]->store(tmp_str.ptr(), tmp_str.length(), cs);
     }
     table->field[9]->set_notnull();
@@ -4944,7 +4945,7 @@ static int get_schema_partitions_record(
       }
       else if (part_info->list_of_subpart_fields)
       {
-        collect_partition_expr(part_info->subpart_field_list, &tmp_str);
+        collect_partition_expr(thd, part_info->subpart_field_list, &tmp_str);
         table->field[10]->store(tmp_str.ptr(), tmp_str.length(), cs);
       }
       table->field[10]->set_notnull();


Attachment: [text/bzr-bundle] bzr/mattias.jonsson@sun.com-20090218190539-8emdruq49nzju2d4.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (mattias.jonsson:2756)Bug#39338Mattias Jonsson18 Feb