List:Commits« Previous MessageNext Message »
From:Mikael Ronstrom Date:October 30 2009 8:44pm
Subject:bzr commit into mysql-6.0-codebase branch (mikael:3655)
View as plain text  
#At file:///home/mikael/mysql_clones/mysql-6.0-codebase-wl3352/

 3655 Mikael Ronstrom	2009-10-30 [merge]
      Merge
      modified:
        mysql-test/r/partition_column.result
        mysql-test/r/partition_column_prune.result
        mysql-test/r/partition_datatype.result
        mysql-test/t/partition_column.test
        mysql-test/t/partition_datatype.test
        sql/partition_info.cc
        sql/sql_partition.cc
        sql/sql_partition.h
        sql/sql_show.cc

=== modified file 'mysql-test/r/partition_column.result'
--- a/mysql-test/r/partition_column.result	2009-10-30 16:34:11 +0000
+++ b/mysql-test/r/partition_column.result	2009-10-30 20:08:34 +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 0x2020) ENGINE = MyISAM,
- PARTITION p1 VALUES IN (_ucs2 '') ENGINE = MyISAM) */
 insert into t1 values ('');
 insert into t1 values (_ucs2 0x2020);
 drop table t1;
@@ -77,9 +69,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 0x30,MAXVALUE,'1900-01-01') ENGINE = MyISAM,
- PARTITION p1 VALUES LESS THAN (1,_latin1 0x61,MAXVALUE,'1999-01-01') ENGINE = MyISAM,
- PARTITION p2 VALUES LESS THAN (1,_latin1 0x61,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 +290,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 0x616263,_latin1 0x616263) ENGINE = MyISAM,
- PARTITION p1 VALUES LESS THAN (2,_latin1 0x616263,_latin1 0x616263) ENGINE = MyISAM,
- PARTITION p2 VALUES LESS THAN (3,_latin1 0x616263,_latin1 0x616263) ENGINE = MyISAM,
- PARTITION p3 VALUES LESS THAN (4,_latin1 0x616263,_latin1 0x616263) 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 +321,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 0x41,1) ENGINE = MyISAM,
- PARTITION p1 VALUES LESS THAN (1,_latin1 0x42,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

=== modified file 'mysql-test/r/partition_column_prune.result'
--- a/mysql-test/r/partition_column_prune.result	2009-10-29 17:04:23 +0000
+++ b/mysql-test/r/partition_column_prune.result	2009-10-30 20:43:49 +0000
@@ -56,11 +56,11 @@ insert into t1 values (2,5), (2,15), (2,
 insert into t1 select * from t1;
 explain partitions select * from t1 where a=2;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p01,p02,p03,p11	ALL	NULL	NULL	NULL	NULL	13	Using where
+1	SIMPLE	t1	p01,p02,p03,p11	ALL	NULL	NULL	NULL	NULL	8	Using where
 explain partitions select * from t1 where a=4;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p11,p12,p13,p21	ALL	NULL	NULL	NULL	NULL	16	Using where
+1	SIMPLE	t1	p11,p12,p13,p21	ALL	NULL	NULL	NULL	NULL	14	Using where
 explain partitions select * from t1 where a=2 and b < 22;
 id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	p01,p02,p03	ALL	NULL	NULL	NULL	NULL	16	Using where
+1	SIMPLE	t1	p01,p02,p03	ALL	NULL	NULL	NULL	NULL	14	Using where
 drop table t1;

=== modified file 'mysql-test/r/partition_datatype.result'
--- a/mysql-test/r/partition_datatype.result	2009-10-28 00:11:17 +0000
+++ b/mysql-test/r/partition_datatype.result	2009-10-30 20:43:49 +0000
@@ -273,7 +273,7 @@ select * from t1 where a = 'y';
 a
 y
 drop table t1;
-create table t1 (a varchar(3068)) partition by key (a);
+create table t1 (a varchar(4092)) partition by key (a);
 insert into t1 values ('bbbb');
 insert into t1 values ('aaaa');
 select * from t1 where a = 'aaaa';
@@ -286,7 +286,7 @@ select * from t1 where a = 'bbbb';
 a
 bbbb
 drop table t1;
-create table t1 (a varchar(3069)) partition by key (a);
+create table t1 (a varchar(4093)) partition by key (a);
 insert into t1 values ('bbbb');
 insert into t1 values ('aaaa');
 select * from t1 where a = 'aaaa';
@@ -299,7 +299,7 @@ select * from t1 where a = 'bbbb';
 a
 bbbb
 drop table t1;
-create table t1 (a varchar(3070) not null) partition by key (a);
+create table t1 (a varchar(4094) not null) partition by key (a);
 insert into t1 values ('bbbb');
 insert into t1 values ('aaaa');
 select * from t1 where a = 'aaaa';
@@ -312,7 +312,7 @@ select * from t1 where a = 'bbbb';
 a
 bbbb
 drop table t1;
-create table t1 (a varchar(3070)) partition by key (a);
+create table t1 (a varchar(4094)) partition by key (a);
 ERROR HY000: The total length of the partitioning fields is too large
 create table t1 (a varchar(65533)) partition by key (a);
 ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs

=== modified file 'mysql-test/t/partition_column.test'
--- a/mysql-test/t/partition_column.test	2009-10-30 16:34:50 +0000
+++ b/mysql-test/t/partition_column.test	2009-10-30 20:43:49 +0000
@@ -47,7 +47,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;
 insert into t1 values ('');
 insert into t1 values (_ucs2 0x2020);
 drop table t1;

=== modified file 'mysql-test/t/partition_datatype.test'
--- a/mysql-test/t/partition_datatype.test	2009-10-28 00:11:17 +0000
+++ b/mysql-test/t/partition_datatype.test	2009-10-30 20:43:49 +0000
@@ -193,21 +193,21 @@ create table t1 (a set('y','n')) partiti
 insert into t1 values ('y');
 select * from t1 where a = 'y';
 drop table t1;
-create table t1 (a varchar(3068)) partition by key (a);
+create table t1 (a varchar(4092)) partition by key (a);
 insert into t1 values ('bbbb');
 insert into t1 values ('aaaa');
 select * from t1 where a = 'aaaa';
 select * from t1 where a like 'aaa%';
 select * from t1 where a = 'bbbb';
 drop table t1;
-create table t1 (a varchar(3069)) partition by key (a);
+create table t1 (a varchar(4093)) partition by key (a);
 insert into t1 values ('bbbb');
 insert into t1 values ('aaaa');
 select * from t1 where a = 'aaaa';
 select * from t1 where a like 'aaa%';
 select * from t1 where a = 'bbbb';
 drop table t1;
-create table t1 (a varchar(3070) not null) partition by key (a);
+create table t1 (a varchar(4094) not null) partition by key (a);
 insert into t1 values ('bbbb');
 insert into t1 values ('aaaa');
 select * from t1 where a = 'aaaa';
@@ -215,7 +215,7 @@ select * from t1 where a like 'aaa%';
 select * from t1 where a = 'bbbb';
 drop table t1;
 -- error ER_PARTITION_FIELDS_TOO_LONG
-create table t1 (a varchar(3070)) partition by key (a);
+create table t1 (a varchar(4094)) partition by key (a);
 -- error ER_TOO_BIG_ROWSIZE
 create table t1 (a varchar(65533)) partition by key (a);
 -- error ER_TOO_BIG_ROWSIZE

=== modified file 'sql/partition_info.cc'
--- a/sql/partition_info.cc	2009-10-30 16:34:50 +0000
+++ b/sql/partition_info.cc	2009-10-30 20:43:49 +0000
@@ -2065,10 +2065,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-30 20:11:25 +0000
+++ b/sql/sql_partition.cc	2009-10-30 20:43:49 +0000
@@ -1861,46 +1861,6 @@ static int add_write(File fptr, const ch
     return 1;
 }
 
-static int add_string(File fptr, const char *string);
-
-static int write_hex_char(File fptr, uint number)
-{
-  char buf[2];
-  char c= '0';
-  /* Write number between 0 and 15 as 0-9,A-F */
-  if (number < 10)
-    c+= number;
-  else
-  {
-    c= 'A';
-    c+= (number - 10);
-  }
-  buf[0]= c;
-  buf[1]= 0;
-  return add_string(fptr, (const char*)buf);
-}
-
-static int add_hex_string_object(File fptr, String *string)
-{
-  uint len= string->length();
-  uint i;
-  const char *ptr= string->ptr();
-  char c;
-  int err;
-  uint low, high;
-  err= add_string(fptr, "0x");
-  for (i= 0; i < len; i++)
-  {
-    c= *ptr;
-    ptr++;
-    high= c >> 4;
-    low= c & 15;
-    err+= write_hex_char(fptr, high);
-    err+= write_hex_char(fptr, low);
-  }
-  return err;
-}
-
 static int add_string_object(File fptr, String *string)
 {
   return add_write(fptr, string->ptr(), string->length());
@@ -2138,7 +2098,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:
@@ -2183,6 +2143,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,
@@ -2274,42 +2297,14 @@ static int add_column_list_values(File f
           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_space(fptr);
-            if (res->length())
-            {
-              err+= add_hex_string_object(fptr, res);
-            }
-            else
-            {
-              err+= add_string(fptr,"'");
-              err+= add_string(fptr,"'");
-            }
-
-          }
-          else
-          {
-            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-30 16:34:50 +0000
+++ b/sql/sql_partition.h	2009-10-30 20:43:49 +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-30 16:34:50 +0000
+++ b/sql/sql_show.cc	2009-10-30 20:43:49 +0000
@@ -26,6 +26,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"
@@ -5461,6 +5462,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,
@@ -5469,16 +5471,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(",");
@@ -5495,7 +5494,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 commit into mysql-6.0-codebase branch (mikael:3655) Mikael Ronstrom30 Oct