List:Commits« Previous MessageNext Message »
From:Mikael Ronstrom Date:October 30 2009 9:12pm
Subject:bzr push into mysql-5.5-next-mr branch (mikael:2911 to 2914)
View as plain text  
 2914 Mikael Ronstrom	2009-10-30
      Fixed such that we fail if using integer constants for character set fields, now need to have correct constant types
      modified:
        mysql-test/r/partition_column.result
        mysql-test/t/partition_column.test
        sql/sql_partition.cc

 2913 Mikael Ronstrom	2009-10-30
      Fixed so that character set constants are encoded as hex strings in frm file, but as utf8 strings in the same manner as default values in show create table and information schema tables
      modified:
        mysql-test/r/partition_column.result
        mysql-test/t/partition_column.test
        sql/partition_info.cc
        sql/sql_partition.cc
        sql/sql_partition.h
        sql/sql_show.cc

 2912 Mikael Ronstrom	2009-10-30
      Ensuring character set constants are safe, first step fix
      modified:
        mysql-test/r/partition_column.result
        sql/sql_partition.cc

 2911 Mikael Ronstrom	2009-10-29
      Changed COLUMN_LIST to COLUMNS after arch review
      modified:
        mysql-test/r/partition_column.result
        mysql-test/r/partition_column_prune.result
        mysql-test/r/partition_innodb.result
        mysql-test/r/partition_range.result
        mysql-test/t/partition_column.test
        mysql-test/t/partition_column_prune.test
        mysql-test/t/partition_innodb.test
        mysql-test/t/partition_range.test
        sql/lex.h
        sql/opt_range.cc
        sql/sql_partition.cc
        sql/sql_yacc.yy

=== modified file 'mysql-test/r/partition_column.result'
--- a/mysql-test/r/partition_column.result	2009-10-29 17:04:23 +0000
+++ b/mysql-test/r/partition_column.result	2009-10-30 20:44:41 +0000
@@ -28,14 +28,6 @@ create table t1 (a varchar(2) character 
 partition by list columns (a)
 (partition p0 values in (0x2020),
 partition p1 values in (''));
-show create table t1;
-Table	Create Table
-t1	CREATE TABLE `t1` (
-  `a` varchar(2) CHARACTER SET ucs2 DEFAULT NULL
-) ENGINE=MyISAM DEFAULT CHARSET=latin1
-/*!50100 PARTITION BY LIST  COLUMNS(a)
-(PARTITION p0 VALUES IN (_ucs2'  ') ENGINE = MyISAM,
- PARTITION p1 VALUES IN (_ucs2'') ENGINE = MyISAM) */
 insert into t1 values ('');
 insert into t1 values (_ucs2 0x2020);
 drop table t1;
@@ -47,6 +39,15 @@ subpartitions 4
 partition p1 values less than (1, 'a', MAXVALUE, '1999-01-01'),
 partition p2 values less than (1, 'a', MAXVALUE, MAXVALUE),
 partition p3 values less than (1, MAXVALUE, MAXVALUE, MAXVALUE));
+ERROR HY000: Partition column values of incorrect type
+create table t1 (a int, b char(10), c varchar(25), d datetime)
+partition by range columns(a,b,c,d)
+subpartition by hash (to_seconds(d))
+subpartitions 4
+( partition p0 values less than (1, '0', MAXVALUE, '1900-01-01'),
+partition p1 values less than (1, 'a', MAXVALUE, '1999-01-01'),
+partition p2 values less than (1, 'a', MAXVALUE, MAXVALUE),
+partition p3 values less than (1, MAXVALUE, MAXVALUE, MAXVALUE));
 select partition_method, partition_expression, partition_description
 from information_schema.partitions where table_name = "t1";
 partition_method	partition_expression	partition_description
@@ -77,9 +78,9 @@ t1	CREATE TABLE `t1` (
 /*!50100 PARTITION BY RANGE  COLUMNS(a,b,c,d)
 SUBPARTITION BY HASH (to_seconds(d))
 SUBPARTITIONS 4
-(PARTITION p0 VALUES LESS THAN (1,_latin1'0',MAXVALUE,'1900-01-01') ENGINE = MyISAM,
- PARTITION p1 VALUES LESS THAN (1,_latin1'a',MAXVALUE,'1999-01-01') ENGINE = MyISAM,
- PARTITION p2 VALUES LESS THAN (1,_latin1'a',MAXVALUE,MAXVALUE) ENGINE = MyISAM,
+(PARTITION p0 VALUES LESS THAN (1,'0',MAXVALUE,'1900-01-01') ENGINE = MyISAM,
+ PARTITION p1 VALUES LESS THAN (1,'a',MAXVALUE,'1999-01-01') ENGINE = MyISAM,
+ PARTITION p2 VALUES LESS THAN (1,'a',MAXVALUE,MAXVALUE) ENGINE = MyISAM,
  PARTITION p3 VALUES LESS THAN (1,MAXVALUE,MAXVALUE,MAXVALUE) ENGINE = MyISAM) */
 drop table t1;
 create table t1 (a int, b int)
@@ -298,10 +299,10 @@ t1	CREATE TABLE `t1` (
 /*!50100 PARTITION BY RANGE  COLUMNS(a,b,c)
 SUBPARTITION BY KEY (c,d)
 SUBPARTITIONS 3
-(PARTITION p0 VALUES LESS THAN (1,_latin1'abc',_latin1'abc') ENGINE = MyISAM,
- PARTITION p1 VALUES LESS THAN (2,_latin1'abc',_latin1'abc') ENGINE = MyISAM,
- PARTITION p2 VALUES LESS THAN (3,_latin1'abc',_latin1'abc') ENGINE = MyISAM,
- PARTITION p3 VALUES LESS THAN (4,_latin1'abc',_latin1'abc') ENGINE = MyISAM) */
+(PARTITION p0 VALUES LESS THAN (1,'abc','abc') ENGINE = MyISAM,
+ PARTITION p1 VALUES LESS THAN (2,'abc','abc') ENGINE = MyISAM,
+ PARTITION p2 VALUES LESS THAN (3,'abc','abc') ENGINE = MyISAM,
+ PARTITION p3 VALUES LESS THAN (4,'abc','abc') ENGINE = MyISAM) */
 insert into t1 values (1,'a','b',1),(2,'a','b',2),(3,'a','b',3);
 insert into t1 values (1,'b','c',1),(2,'b','c',2),(3,'b','c',3);
 insert into t1 values (1,'c','d',1),(2,'c','d',2),(3,'c','d',3);
@@ -329,8 +330,8 @@ t1	CREATE TABLE `t1` (
   `c` int(11) DEFAULT NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
 /*!50100 PARTITION BY RANGE  COLUMNS(a,b,c)
-(PARTITION p0 VALUES LESS THAN (1,_latin1'A',1) ENGINE = MyISAM,
- PARTITION p1 VALUES LESS THAN (1,_latin1'B',1) ENGINE = MyISAM) */
+(PARTITION p0 VALUES LESS THAN (1,'A',1) ENGINE = MyISAM,
+ PARTITION p1 VALUES LESS THAN (1,'B',1) ENGINE = MyISAM) */
 insert into t1 values (1, 'A', 1);
 explain partitions select * from t1 where a = 1 AND b <= 'A' and c = 1;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
@@ -429,7 +430,7 @@ create table t1 (a char(6))
 partition by range columns(a)
 (partition p0 values less than (23456),
 partition p1 values less than (23456));
-ERROR HY000: VALUES LESS THAN value must be strictly increasing for each partition
+ERROR HY000: Partition column values of incorrect type
 create table t1 (a int, b int)
 partition by range columns(a,b)
 (partition p0 values less than (10));

=== modified file 'mysql-test/t/partition_column.test'
--- a/mysql-test/t/partition_column.test	2009-10-29 17:04:23 +0000
+++ b/mysql-test/t/partition_column.test	2009-10-30 20:44:41 +0000
@@ -47,11 +47,11 @@ create table t1 (a varchar(2) character 
 partition by list columns (a)
 (partition p0 values in (0x2020),
  partition p1 values in (''));
-show create table t1;
 insert into t1 values ('');
 insert into t1 values (_ucs2 0x2020);
 drop table t1;
 
+--error ER_WRONG_TYPE_COLUMN_VALUE_ERROR
 create table t1 (a int, b char(10), c varchar(25), d datetime)
 partition by range columns(a,b,c,d)
 subpartition by hash (to_seconds(d))
@@ -60,6 +60,15 @@ subpartitions 4
   partition p1 values less than (1, 'a', MAXVALUE, '1999-01-01'),
   partition p2 values less than (1, 'a', MAXVALUE, MAXVALUE),
   partition p3 values less than (1, MAXVALUE, MAXVALUE, MAXVALUE));
+
+create table t1 (a int, b char(10), c varchar(25), d datetime)
+partition by range columns(a,b,c,d)
+subpartition by hash (to_seconds(d))
+subpartitions 4
+( partition p0 values less than (1, '0', MAXVALUE, '1900-01-01'),
+  partition p1 values less than (1, 'a', MAXVALUE, '1999-01-01'),
+  partition p2 values less than (1, 'a', MAXVALUE, MAXVALUE),
+  partition p3 values less than (1, MAXVALUE, MAXVALUE, MAXVALUE));
 select partition_method, partition_expression, partition_description
   from information_schema.partitions where table_name = "t1";
 show create table t1;
@@ -311,7 +320,7 @@ partition by range columns(a)
 (partition p0 values less than (H23456),
  partition p1 values less than (M23456));
 
--- error ER_RANGE_NOT_INCREASING_ERROR
+-- error ER_WRONG_TYPE_COLUMN_VALUE_ERROR
 create table t1 (a char(6))
 partition by range columns(a)
 (partition p0 values less than (23456),

=== modified file 'sql/partition_info.cc'
--- a/sql/partition_info.cc	2009-10-28 17:22:36 +0000
+++ b/sql/partition_info.cc	2009-10-30 20:08:34 +0000
@@ -2062,10 +2062,8 @@ int partition_info::fix_parser_data(THD 
 {
   List_iterator<partition_element> it(partitions);
   partition_element *part_elem;
-  part_elem_value *val;
   uint num_elements;
   uint i= 0, j, k;
-  int result;
   DBUG_ENTER("partition_info::fix_parser_data");
 
   if (!(part_type == RANGE_PARTITION ||

=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc	2009-10-29 17:04:23 +0000
+++ b/sql/sql_partition.cc	2009-10-30 20:44:41 +0000
@@ -2055,7 +2055,7 @@ static int check_part_field(enum_field_t
     case MYSQL_TYPE_TIME:
     case MYSQL_TYPE_DATETIME:
       *result_type= STRING_RESULT;
-      *need_cs_check= FALSE;
+      *need_cs_check= TRUE;
       return FALSE;
     case MYSQL_TYPE_VARCHAR:
     case MYSQL_TYPE_STRING:
@@ -2100,6 +2100,69 @@ static Create_field* get_sql_field(char 
   DBUG_RETURN(NULL);
 }
 
+int get_converted_part_value_from_string(Item *item,
+                                         String *res,
+                                         CHARSET_INFO *field_cs,
+                                         String *val_conv,
+                                         bool use_hex)
+{
+  String val;
+  uint dummy_errors;
+  uint len, high, low, i;
+  const char *ptr;
+  char buf[3];
+
+  if (!res)
+  {
+    my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0));
+    return 1;
+  }
+  if (item->result_type() == INT_RESULT)
+  {
+    longlong value= item->val_int();
+    val_conv->set(value, system_charset_info);
+    return 0;
+  }
+  val_conv->length(0);
+  if (!field_cs || res->length() == 0)
+  {
+    val_conv->append("'");
+    if (res->length() != 0)
+      val_conv->append(*res);
+    val_conv->append("'");
+    return 0;
+  }
+  if (field_cs && use_hex)
+  {
+    val_conv->append("_");
+    val_conv->append(field_cs->csname);
+    val_conv->append(" ");
+  }
+  if (use_hex)
+  {
+    val_conv->append("0x");
+    len= res->length();
+    ptr= res->ptr();
+    for (i= 0; i < len; i++)
+    {
+      high= (*ptr) >> 4;
+      low= (*ptr) & 0x0F;
+      buf[0]= _dig_vec_upper[high];
+      buf[1]= _dig_vec_upper[low];
+      buf[2]= 0;
+      val_conv->append((const char*)buf);
+      ptr++;
+    }
+  }
+  else
+  {
+    val.copy(res->ptr(), res->length(), field_cs,
+             system_charset_info, &dummy_errors);
+    append_unescaped(val_conv, val.ptr(), val.length());
+  }
+  return 0;
+}
+
 static int add_column_list_values(File fptr, partition_info *part_info,
                                   part_elem_value *list_value,
                                   HA_CREATE_INFO *create_info,
@@ -2177,6 +2240,11 @@ static int add_column_list_values(File f
           else
             field_cs= NULL;
         }
+        if (result_type != item_expr->result_type())
+        {
+          my_error(ER_WRONG_TYPE_COLUMN_VALUE_ERROR, MYF(0));
+          return 1;
+        }
         if (field_cs && field_cs != item_expr->collation.collation)
         {
           if (!(item_expr= convert_charset_partition_constant(item_expr,
@@ -2186,33 +2254,14 @@ static int add_column_list_values(File f
             return 1;
           }
         }
-        if (result_type != item_expr->result_type())
-        {
-          my_error(ER_WRONG_TYPE_COLUMN_VALUE_ERROR, MYF(0));
-          return 1;
-        }
-        if (result_type == INT_RESULT)
-        {
-          longlong val;
-          val= item_expr->val_int();
-          err+= add_int(fptr, val);
-        }
-        else
         {
+          String val_conv;
           res= item_expr->val_str(&str);
-          if (!res)
-          {
-            my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0));
+          if (get_converted_part_value_from_string(item_expr, res,
+                                                   field_cs, &val_conv,
+                                                   (bool)(alter_info != NULL)))
             return 1;
-          }
-          if (field_cs)
-          {
-            err+= add_string(fptr,"_");
-            err+= add_string(fptr, field_cs->csname);
-          }
-          err+= add_string(fptr,"'");
-          err+= add_string_object(fptr, res);
-          err+= add_string(fptr,"'");
+          err+= add_string_object(fptr, &val_conv);
         }
       }
     }

=== modified file 'sql/sql_partition.h'
--- a/sql/sql_partition.h	2009-10-28 17:32:48 +0000
+++ b/sql/sql_partition.h	2009-10-30 20:08:34 +0000
@@ -75,6 +75,11 @@ void get_partition_set(const TABLE *tabl
                        const key_range *key_spec,
                        part_id_range *part_spec);
 uint get_partition_field_store_length(Field *field);
+int get_converted_part_value_from_string(Item *item,
+                                         String *res,
+                                         CHARSET_INFO *cs,
+                                         String *val_conv,
+                                         bool use_hex);
 void get_full_part_id_from_key(const TABLE *table, uchar *buf,
                                KEY *key_info,
                                const key_range *key_spec,

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2009-10-28 17:22:36 +0000
+++ b/sql/sql_show.cc	2009-10-30 20:08:34 +0000
@@ -25,6 +25,7 @@
 #include "sql_trigger.h"
 #include "authors.h"
 #include "contributors.h"
+#include "sql_partition.h"
 #ifdef HAVE_EVENT_SCHEDULER
 #include "events.h"
 #include "event_data_objects.h"
@@ -4970,6 +4971,7 @@ get_partition_column_description(partiti
     {
       char buffer[MAX_KEY_LENGTH];
       String str(buffer, sizeof(buffer), &my_charset_bin);
+      String val_conv;
       Item *item= col_val->item_expression;
 
       if (!(item= part_info->get_column_item(item,
@@ -4978,16 +4980,13 @@ get_partition_column_description(partiti
         DBUG_RETURN(1);
       }
       String *res= item->val_str(&str);
-      if (!res)
+      if (get_converted_part_value_from_string(item, res,
+                              part_info->part_field_array[i]->charset(),
+                              &val_conv, FALSE))
       {
-        my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0));
         DBUG_RETURN(1);
       }
-      if (item->result_type() == STRING_RESULT)
-        tmp_str.append("'");
-      tmp_str.append(*res);
-      if (item->result_type() == STRING_RESULT)
-        tmp_str.append("'");
+      tmp_str.append(val_conv);
     }
     if (i != num_elements - 1)
       tmp_str.append(",");
@@ -5004,7 +5003,6 @@ static int get_schema_partitions_record(
   char buff[61];
   String tmp_res(buff, sizeof(buff), cs);
   String tmp_str;
-  uint num_elements;
   TABLE *show_table= tables->table;
   handler *file;
 #ifdef WITH_PARTITION_STORAGE_ENGINE

Thread
bzr push into mysql-5.5-next-mr branch (mikael:2911 to 2914) Mikael Ronstrom30 Oct