summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Ronstrom <mikael@mysql.com>2009-10-22 18:17:59 +0200
committerMikael Ronstrom <mikael@mysql.com>2009-10-22 18:17:59 +0200
commitcecef1c56ecd595218cf08832e2e2fa68aa7c252 (patch)
treea1be6428de363a1e7a89cd3384f3f72b7da57081
parent6f27ad15b208091d3904bb4f73ffab2871f99581 (diff)
downloadmariadb-git-cecef1c56ecd595218cf08832e2e2fa68aa7c252.tar.gz
BUG#46183, added character set identifier on character constants in VALUES part for column list partitioned tables to ensure constants are handled properly according to character sets
-rw-r--r--mysql-test/r/partition_column.result42
-rw-r--r--mysql-test/t/partition_column.test24
-rw-r--r--sql/sql_partition.cc7
3 files changed, 56 insertions, 17 deletions
diff --git a/mysql-test/r/partition_column.result b/mysql-test/r/partition_column.result
index 4270af1f83b..79ab838f6cb 100644
--- a/mysql-test/r/partition_column.result
+++ b/mysql-test/r/partition_column.result
@@ -1,4 +1,19 @@
drop table if exists t1;
+create table t1 (a varchar(2) character set ucs2)
+partition by list column_list (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 COLUMN_LIST(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;
create table t1 (a int, b char(10), c varchar(25), d datetime)
partition by range column_list(a,b,c,d)
subpartition by hash (to_seconds(d))
@@ -26,6 +41,21 @@ RANGE COLUMN_LIST a,b,c,d 1,MAXVALUE,MAXVALUE,MAXVALUE
RANGE COLUMN_LIST a,b,c,d 1,MAXVALUE,MAXVALUE,MAXVALUE
RANGE COLUMN_LIST a,b,c,d 1,MAXVALUE,MAXVALUE,MAXVALUE
RANGE COLUMN_LIST a,b,c,d 1,MAXVALUE,MAXVALUE,MAXVALUE
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(10) DEFAULT NULL,
+ `c` varchar(25) DEFAULT NULL,
+ `d` datetime DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE COLUMN_LIST(a,b,c,d)
+SUBPARTITION BY HASH (to_seconds(d))
+SUBPARTITIONS 4
+(PARTITION p0 VALUES LESS THAN (1,_latin1'0',MAXVALUE,0) ENGINE = MyISAM,
+ PARTITION p1 VALUES LESS THAN (1,_latin1'a',MAXVALUE,730120) ENGINE = MyISAM,
+ PARTITION p2 VALUES LESS THAN (1,_latin1'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)
partition by range column_list (a,b)
@@ -243,10 +273,10 @@ t1 CREATE TABLE `t1` (
/*!50100 PARTITION BY RANGE COLUMN_LIST(a,b,c)
SUBPARTITION BY KEY (c,d)
SUBPARTITIONS 3
-(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) */
+(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) */
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);
@@ -274,8 +304,8 @@ t1 CREATE TABLE `t1` (
`c` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY RANGE COLUMN_LIST(a,b,c)
-(PARTITION p0 VALUES LESS THAN (1,'A',1) ENGINE = MyISAM,
- PARTITION p1 VALUES LESS THAN (1,'B',1) ENGINE = MyISAM) */
+(PARTITION p0 VALUES LESS THAN (1,_latin1'A',1) ENGINE = MyISAM,
+ PARTITION p1 VALUES LESS THAN (1,_latin1'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
diff --git a/mysql-test/t/partition_column.test b/mysql-test/t/partition_column.test
index 13f422d32f4..6c39557f296 100644
--- a/mysql-test/t/partition_column.test
+++ b/mysql-test/t/partition_column.test
@@ -8,6 +8,18 @@
drop table if exists t1;
--enable_warnings
+#
+# BUG#48163, Dagger in UCS2 not working as partition value
+#
+create table t1 (a varchar(2) character set ucs2)
+partition by list column_list (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;
+
create table t1 (a int, b char(10), c varchar(25), d datetime)
partition by range column_list(a,b,c,d)
subpartition by hash (to_seconds(d))
@@ -18,19 +30,9 @@ subpartitions 4
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;
+show create table t1;
drop table t1;
-#
-# BUG#48163, Dagger in UCS2 not working as partition value
-#
-#create table t1 (a varchar(2) character set ucs2)
-#partition by list column_list (a)
-#(partition p0 values in (0x2020),
-# partition p1 values in (''));
-#insert into t1 values ('');
-#drop table t1;
-
--error ER_NULL_IN_VALUES_LESS_THAN
create table t1 (a int, b int)
partition by range column_list (a,b)
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 0a6a2b98941..8ec3d196c3b 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -2147,7 +2147,14 @@ static int add_column_list_values(File fptr, partition_info *part_info,
return 1;
}
if (item_expr->result_type() == STRING_RESULT)
+ {
+ if (field_cs)
+ {
+ err+= add_string(fptr,"_");
+ err+= add_string(fptr, field_cs->csname);
+ }
err+= add_string(fptr,"'");
+ }
err+= add_string_object(fptr, res);
if (item_expr->result_type() == STRING_RESULT)
err+= add_string(fptr,"'");