Commit 95c52876 authored by unknown's avatar unknown

Merge gleb.loc:/home/uchum/work/bk/5.1

into  gleb.loc:/home/uchum/work/bk/5.1-opt


sql/item.h:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_partition.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
parents 48782e34 285acf57
......@@ -28,7 +28,7 @@
eval SET SESSION STORAGE_ENGINE = $engine_type;
--disable_warnings
drop table if exists t1,t2,t1m,t1i,t2m,t2i,t4;
drop table if exists t1,t2,t3,t1m,t1i,t2m,t2i,t4;
--enable_warnings
......@@ -707,8 +707,67 @@ DISCONNECT c2;
DROP TABLE t1,t2;
#
# Bug #25798: a query with forced index merge returns wrong result
#
CREATE TABLE t1 (
id int NOT NULL auto_increment PRIMARY KEY,
b int NOT NULL,
c datetime NOT NULL,
INDEX idx_b(b),
INDEX idx_c(c)
) ENGINE=InnoDB;
CREATE TABLE t2 (
b int NOT NULL auto_increment PRIMARY KEY,
c datetime NOT NULL
) ENGINE= MyISAM;
INSERT INTO t2(c) VALUES ('2007-01-01');
INSERT INTO t2(c) SELECT c FROM t2;
INSERT INTO t2(c) SELECT c FROM t2;
INSERT INTO t2(c) SELECT c FROM t2;
INSERT INTO t2(c) SELECT c FROM t2;
INSERT INTO t2(c) SELECT c FROM t2;
INSERT INTO t2(c) SELECT c FROM t2;
INSERT INTO t2(c) SELECT c FROM t2;
INSERT INTO t2(c) SELECT c FROM t2;
INSERT INTO t2(c) SELECT c FROM t2;
INSERT INTO t2(c) SELECT c FROM t2;
INSERT INTO t1(b,c) SELECT b,c FROM t2;
UPDATE t2 SET c='2007-01-02';
INSERT INTO t1(b,c) SELECT b,c FROM t2;
UPDATE t2 SET c='2007-01-03';
INSERT INTO t1(b,c) SELECT b,c FROM t2;
set @@sort_buffer_size=8192;
SELECT COUNT(*) FROM t1;
--replace_column 9 #
EXPLAIN
SELECT COUNT(*) FROM t1
WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1;
SELECT COUNT(*) FROM t1
WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1;
--replace_column 9 #
EXPLAIN
SELECT COUNT(*) FROM t1 FORCE INDEX(idx_b, idx_c)
WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1;
SELECT COUNT(*) FROM t1 FORCE INDEX(idx_b, idx_c)
WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1;
set @@sort_buffer_size=default;
DROP TABLE t1,t2;
--echo End of 5.0 tests
#
# Test of behaviour with CREATE ... SELECT
#
......
SET SESSION STORAGE_ENGINE = InnoDB;
drop table if exists t1,t2,t1m,t1i,t2m,t2i,t4;
drop table if exists t1,t2,t3,t1m,t1i,t2m,t2i,t4;
create table t1 (
c_id int(11) not null default '0',
org_id int(11) default null,
......@@ -680,6 +680,57 @@ INSERT INTO t1 VALUES (1);
switch to connection default
SET AUTOCOMMIT=default;
DROP TABLE t1,t2;
CREATE TABLE t1 (
id int NOT NULL auto_increment PRIMARY KEY,
b int NOT NULL,
c datetime NOT NULL,
INDEX idx_b(b),
INDEX idx_c(c)
) ENGINE=InnoDB;
CREATE TABLE t2 (
b int NOT NULL auto_increment PRIMARY KEY,
c datetime NOT NULL
) ENGINE= MyISAM;
INSERT INTO t2(c) VALUES ('2007-01-01');
INSERT INTO t2(c) SELECT c FROM t2;
INSERT INTO t2(c) SELECT c FROM t2;
INSERT INTO t2(c) SELECT c FROM t2;
INSERT INTO t2(c) SELECT c FROM t2;
INSERT INTO t2(c) SELECT c FROM t2;
INSERT INTO t2(c) SELECT c FROM t2;
INSERT INTO t2(c) SELECT c FROM t2;
INSERT INTO t2(c) SELECT c FROM t2;
INSERT INTO t2(c) SELECT c FROM t2;
INSERT INTO t2(c) SELECT c FROM t2;
INSERT INTO t1(b,c) SELECT b,c FROM t2;
UPDATE t2 SET c='2007-01-02';
INSERT INTO t1(b,c) SELECT b,c FROM t2;
UPDATE t2 SET c='2007-01-03';
INSERT INTO t1(b,c) SELECT b,c FROM t2;
set @@sort_buffer_size=8192;
SELECT COUNT(*) FROM t1;
COUNT(*)
3072
EXPLAIN
SELECT COUNT(*) FROM t1
WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL idx_b,idx_c NULL NULL NULL # Using where
SELECT COUNT(*) FROM t1
WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1;
COUNT(*)
3072
EXPLAIN
SELECT COUNT(*) FROM t1 FORCE INDEX(idx_b, idx_c)
WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge idx_b,idx_c idx_c,idx_b 8,4 NULL # Using sort_union(idx_c,idx_b); Using where
SELECT COUNT(*) FROM t1 FORCE INDEX(idx_b, idx_c)
WHERE (c >= '2007-01-02' AND c <= '2007-01-03') OR b >= 1;
COUNT(*)
3072
set @@sort_buffer_size=default;
DROP TABLE t1,t2;
End of 5.0 tests
CREATE TABLE t1 (a int, b int);
insert into t1 values (1,1),(1,2);
......
......@@ -86,6 +86,60 @@ field1 field2
a"b cd"ef
a"b c"d"e
drop table t1;
CREATE TABLE t1 (
id INT AUTO_INCREMENT PRIMARY KEY,
c1 VARCHAR(255)
);
CREATE TABLE t2 (
id INT,
c2 VARCHAR(255)
);
INSERT INTO t1 (c1) VALUES
('r'), ('rr'), ('rrr'), ('rrrr'),
('.r'), ('.rr'), ('.rrr'), ('.rrrr'),
('r.'), ('rr.'), ('rrr.'), ('rrrr.'),
('.r.'), ('.rr.'), ('.rrr.'), ('.rrrr.');
SELECT * FROM t1;
id c1
1 r
2 rr
3 rrr
4 rrrr
5 .r
6 .rr
7 .rrr
8 .rrrr
9 r.
10 rr.
11 rrr.
12 rrrr.
13 .r.
14 .rr.
15 .rrr.
16 .rrrr.
SELECT * INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/t1' FIELDS ENCLOSED BY 'r' FROM t1;
r1r rrrr
r2r rrrrrr
r3r rrrrrrrr
r4r rrrrrrrrrr
r5r r.rrr
r6r r.rrrrr
r7r r.rrrrrrr
r8r r.rrrrrrrrr
r9r rrr.r
r10r rrrrr.r
r11r rrrrrrr.r
r12r rrrrrrrrr.r
r13r r.rr.r
r14r r.rrrr.r
r15r r.rrrrrr.r
r16r r.rrrrrrrr.r
LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/t1' INTO TABLE t2 FIELDS ENCLOSED BY 'r';
SELECT t1.id, c1, c2 FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE c1 != c2;
id c1 c2
SELECT t1.id, c1, c2 FROM t1 RIGHT JOIN t2 ON t1.id=t2.id WHERE c1 != c2;
id c1 c2
DROP TABLE t1,t2;
create table t1 (a int default 100, b int, c varchar(60));
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (a, @b) set b=@b+10, c=concat("b=",@b);
select * from t1;
......
......@@ -1267,14 +1267,4 @@ ALTER TABLE general_log PARTITION BY RANGE (TO_DAYS(event_time))
ERROR HY000: Incorrect usage of PARTITION and log table
ALTER TABLE general_log ENGINE = CSV;
SET GLOBAL general_log = default;
CREATE TABLE `t1` ( `a` varchar(1)) ENGINE=MyISAM
PARTITION BY LIST (CASE a WHEN 'a' THEN 1
WHEN 'b' THEN 2
WHEN 'c' THEN 3
END) (
PARTITION a VALUES IN (1),
PARTITION b VALUES IN (2),
PARTITION c VALUES IN (3)
);
DROP TABLE t1;
End of 5.1 tests
drop table if exists t1;
create table t1 (col1 datetime)
partition by range(datediff(col1,col1))
(partition p0 values less than (10), partition p1 values less than (30));
drop table t1;
create table t1 (col1 int)
partition by range(greatest(col1,10))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(isnull(col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(least(col1,12))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(case when col1>0 then 10 else 20 end)
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(ifnull(col1,5))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(nullif(col1,5))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(bit_length(col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 char(5))
partition by range(bit_length(col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(char_length(col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 char(5))
partition by range(char_length(col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 char(5))
partition by range(character_length(col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(find_in_set(col1,1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 char(5))
partition by range(find_in_set(col1,'1'))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(instr(col1,3))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 char(5))
partition by range(instr(col1,'3'))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 char(5))
partition by range(length(col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 char(5))
partition by range(locate(1,col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(locate(1,col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 char(5))
partition by range(octet_length(col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 char(5))
partition by range(position(1 in col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(position(1 in col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 char(5))
partition by range(strcmp(col1,2))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(strcmp(col1,2))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(crc32(col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(round(col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(sign(col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 datetime)
partition by range(period_add(col1,5))
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 datetime, col2 datetime)
partition by range(period_diff(col1,col2))
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int, col2 int)
partition by range(period_diff(col1,col2))
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 datetime)
partition by range(timestampdiff(day,5,col1))
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 date)
partition by range(unix_timestamp(col1))
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 datetime)
partition by range(week(col1))
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 varchar(25))
partition by range(cast(col1 as signed))
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 varchar(25))
partition by range(convert(col1,unsigned))
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(col1 | 20)
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(col1 & 20)
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(col1 ^ 20)
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(col1 << 20)
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(col1 >> 20)
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(~col1)
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(bit_count(col1))
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(inet_aton(col1))
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
......@@ -16,3 +16,7 @@ s1
1
3
drop table t1;
create table t1 (a varchar(1), primary key (a))
partition by list (ascii(a))
(partition p1 values in (65));
ERROR HY000: This partition function is not allowed
......@@ -25,7 +25,7 @@ partitions 3
(partition x1 values in (1,2,9,4) tablespace ts1,
partition x2 values in (3, 11, 5, 7) tablespace ts2,
partition x3 values in (16, 8, 5+19, 70-43) tablespace ts3);
ERROR HY000: The PARTITION function returns the wrong type
ERROR HY000: This partition function is not allowed
CREATE TABLE t1 (
a int not null,
b int not null,
......@@ -89,7 +89,7 @@ partitions 3
(partition x1 tablespace ts1,
partition x2 tablespace ts2,
partition x3 tablespace ts3);
ERROR HY000: The PARTITION function returns the wrong type
ERROR HY000: This partition function is not allowed
CREATE TABLE t1 (
a int not null,
b int not null,
......@@ -422,7 +422,7 @@ partition by range (sin(a))
partitions 2
(partition x1 values less than (4),
partition x2 values less than (5));
ERROR HY000: The PARTITION function returns the wrong type
ERROR HY000: This partition function is not allowed
CREATE TABLE t1 (
a int not null,
b int not null,
......@@ -600,7 +600,7 @@ ERROR HY000: Partition constant is out of partition function domain
create table t1 (v varchar(12))
partition by range (ascii(v))
(partition p0 values less than (10));
drop table t1;
ERROR HY000: This partition function is not allowed
create table t1 (a int)
partition by hash (rand(a));
ERROR 42000: Constant/Random expression in (sub)partitioning function is not allowed near ')' at line 2
......@@ -619,4 +619,4 @@ partition by range (a + (select count(*) from t1))
ERROR HY000: This partition function is not allowed
create table t1 (a char(10))
partition by hash (extractvalue(a,'a'));
ERROR HY000: The PARTITION function returns the wrong type
ERROR HY000: This partition function is not allowed
drop table if exists t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin)
partition by hash(length(a))
partitions 10;
insert into t1 values (''),(' '),('a'),('a '),('a ');
explain partitions select * from t1 where a='a ';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 5 Using where
explain partitions select * from t1 where a='a';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 5 Using where
explain partitions select * from t1 where a='a ' OR a='a';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 5 Using where
drop table t1;
create table t1 (a int unsigned)
partition by hash(a div 2)
partitions 4;
......
......@@ -295,3 +295,7 @@ select * from t1;
a
100
drop table t1;
create table t1 (a char(1))
partition by list (ascii(ucase(a)))
(partition p1 values in (2));
ERROR HY000: This partition function is not allowed
......@@ -10,13 +10,13 @@ subpartition sp01, subpartition sp02));
ERROR HY000: Wrong number of subpartitions defined, mismatch with previous setting
drop table t1;
CREATE TABLE t1 (f_date DATE, f_varchar VARCHAR(30))
PARTITION BY HASH(CAST(YEAR(f_date) AS SIGNED INTEGER)) PARTITIONS 2;
PARTITION BY HASH(YEAR(f_date)) PARTITIONS 2;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f_date` date DEFAULT NULL,
`f_varchar` varchar(30) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (CAST(YEAR(f_date) AS SIGNED INTEGER)) PARTITIONS 2 */
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (YEAR(f_date)) PARTITIONS 2 */
hello/master-data/test/t1#P#p0.MYD
hello/master-data/test/t1#P#p0.MYI
hello/master-data/test/t1#P#p1.MYD
......@@ -29,7 +29,7 @@ Table Create Table
t1 CREATE TABLE `t1` (
`f_date` date DEFAULT NULL,
`f_varchar` varchar(30) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (CAST(YEAR(f_date) AS SIGNED INTEGER)) PARTITIONS 1 */
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (YEAR(f_date)) PARTITIONS 1 */
hello/master-data/test/t1#P#p0.MYD
hello/master-data/test/t1#P#p0.MYI
hello/master-data/test/t1.frm
......
......@@ -676,25 +676,6 @@ f_int1 f_int2
8 8
9 9
drop table t1;
create table t1 (a char(10) binary)
partition by list(length(a))
(partition p1 values in (1),
partition p2 values in (2),
partition p3 values in (3),
partition p4 values in (4),
partition p5 values in (5)
);
insert into t1 values ('a'),('bb'),('ccc'),('dddd'),('eeEee');
select * from t1 where a>='a' and a <= 'dddd';
a
a
bb
ccc
dddd
explain partitions select * from t1 where a>='a' and a <= 'dddd';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p1,p2,p3,p4,p5 ALL NULL NULL NULL NULL 5 Using where
drop table t1;
create table t1 (f_int1 integer) partition by list(abs(mod(f_int1,2)))
subpartition by hash(f_int1) subpartitions 2
(
......@@ -848,22 +829,57 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
drop table t1;
create table t1 (a int)
partition by range((a & 0xFF) << 56) (
partition p0 values less than (0x40 << 56),
partition p1 values less than (0x80 << 56),
partition p2 values less than (0xFF << 56)
partition by range(a) (
partition p0 values less than (64),
partition p1 values less than (128),
partition p2 values less than (255)
);
create table t2 (a int)
partition by range(a+0) (
partition p0 values less than (64),
partition p1 values less than (128),
partition p2 values less than (255)
);
insert into t1 values (0x20), (0x20), (0x41), (0x41), (0xFE), (0xFE);
insert into t2 values (0x20), (0x20), (0x41), (0x41), (0xFE), (0xFE);
explain partitions select * from t1 where a=0;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 2 Using where
explain partitions select * from t2 where a=0;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p0 ALL NULL NULL NULL NULL 2 Using where
explain partitions select * from t1 where a=0xFE;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p2 ALL NULL NULL NULL NULL 2 Using where
explain partitions select * from t1 where a>0xFE and a<= 0xFF;
explain partitions select * from t2 where a=0xFE;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p2 ALL NULL NULL NULL NULL 2 Using where
explain partitions select * from t1 where a > 0xFE AND a <= 0xFF;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t2 where a > 0xFE AND a <= 0xFF;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t1 where a >= 0xFE AND a <= 0xFF;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p2 ALL NULL NULL NULL NULL 2 Using where
explain partitions select * from t2 where a >= 0xFE AND a <= 0xFF;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p2 ALL NULL NULL NULL NULL 2 Using where
explain partitions select * from t1 where a < 64 AND a >= 63;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 2 Using where
explain partitions select * from t2 where a < 64 AND a >= 63;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p0 ALL NULL NULL NULL NULL 2 Using where
explain partitions select * from t1 where a <= 64 AND a >= 63;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1 ALL NULL NULL NULL NULL 4 Using where
explain partitions select * from t2 where a <= 64 AND a >= 63;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p0,p1 ALL NULL NULL NULL NULL 4 Using where
drop table t1;
drop table t2;
create table t1(a bigint unsigned not null) partition by range(a+0) (
partition p1 values less than (10),
partition p2 values less than (20),
......
drop table if exists t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin, b int)
partition by range (length(a) * b)
(partition p0 values less than (2), partition p1 values less than (400));
insert into t1 values ('a ', 2),('a',3);
drop table t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin, b int)
partition by range (b* length(a) * b)
(partition p0 values less than (2), partition p1 values less than (400));
insert into t1 values ('a ', 2),('a',3);
drop table t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin,
b varchar(10) charset latin1 collate latin1_bin)
partition by range (length(b) * length(a))
(partition p0 values less than (2), partition p1 values less than (400));
insert into t1 values ('a ', 'b '),('a','b');
drop table t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin,
b varchar(10) charset latin1 collate latin1_bin)
partition by range (length(a) * length(b))
(partition p0 values less than (2), partition p1 values less than (400));
insert into t1 values ('a ', 'b '),('a','b');
drop table t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin,
b varchar(10) charset latin1 collate latin1_bin, c int)
partition by range (length(a) * c)
(partition p0 values less than (2), partition p1 values less than (400));
insert into t1 values ('a ', 'b ', 2),('a','b', 3);
drop table t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin,
b varchar(10) charset latin1 collate latin1_bin, c int)
partition by range (c * length(a))
(partition p0 values less than (2), partition p1 values less than (400));
insert into t1 values ('a ', 'b ', 2),('a','b', 3);
drop table t1;
create table t1 (a int unsigned)
partition by range (a)
(partition pnull values less than (0),
......@@ -109,7 +75,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pnull_pnullsp0,pnull_pnullsp1,p0_p0sp0,p0_p0sp1 ALL NULL NULL NULL NULL 4 Using where
explain partitions select * from t1 where a > 1;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p1_p1sp0,p1_p1sp1 ALL NULL NULL NULL NULL 2 Using where
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
drop table t1;
CREATE TABLE t1 (
a int not null,
......@@ -743,45 +709,3 @@ WHERE (a >= '2004-07-01' AND a <= '2004-09-30') OR
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p407,p408,p409,p507,p508,p509 ALL NULL NULL NULL NULL 18 Using where
DROP TABLE t1;
create table t1 (a varchar(20))
partition by range (crc32(md5(a)))
(partition p0 values less than (100),
partition p1 values less than maxvalue);
insert into t1 values ("12345678901234567890");
insert into t1 values ("A2345678901234567890");
insert into t1 values ("B2345678901234567890");
insert into t1 values ("1234567890123456789");
insert into t1 values ("1234567890123456");
select * from t1;
a
12345678901234567890
A2345678901234567890
B2345678901234567890
1234567890123456789
1234567890123456
explain partitions select * from t1 where a = "12345678901234567890";
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p1 ALL NULL NULL NULL NULL 5 Using where
explain partitions select * from t1 where a = "12345678901234567890" OR
a = "A2345678901234567890" OR
a = "B2345678901234567890" OR
a = "C2345678901234567890";
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p1 ALL NULL NULL NULL NULL 5 Using where
explain partitions select * from t1 where a = "01234567890123456";
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p1 ALL NULL NULL NULL NULL 5 Using where
select * from t1 where a = "01234567890123456";
a
select * from t1 where a = "12345678901234567890" OR
a = "A2345678901234567890" OR
a = "B2345678901234567890" OR
a = "C2345678901234567890";
a
12345678901234567890
A2345678901234567890
B2345678901234567890
select * from t1 where a = "12345678901234567890";
a
12345678901234567890
drop table t1;
......@@ -67,6 +67,41 @@ load data infile '../std_data_ln/loaddata_dq.dat' into table t1 fields terminate
select * from t1;
drop table t1;
#
# Bug #29294 SELECT INTO OUTFILE/LOAD DATA INFILE with special
# characters in the FIELDS ENCLOSED BY clause
#
CREATE TABLE t1 (
id INT AUTO_INCREMENT PRIMARY KEY,
c1 VARCHAR(255)
);
CREATE TABLE t2 (
id INT,
c2 VARCHAR(255)
);
INSERT INTO t1 (c1) VALUES
('r'), ('rr'), ('rrr'), ('rrrr'),
('.r'), ('.rr'), ('.rrr'), ('.rrrr'),
('r.'), ('rr.'), ('rrr.'), ('rrrr.'),
('.r.'), ('.rr.'), ('.rrr.'), ('.rrrr.');
SELECT * FROM t1;
--exec rm -f $MYSQLTEST_VARDIR/tmp/t1
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/t1' FIELDS ENCLOSED BY 'r' FROM t1;
--exec cat $MYSQLTEST_VARDIR/tmp/t1
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/t1' INTO TABLE t2 FIELDS ENCLOSED BY 'r';
SELECT t1.id, c1, c2 FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE c1 != c2;
SELECT t1.id, c1, c2 FROM t1 RIGHT JOIN t2 ON t1.id=t2.id WHERE c1 != c2;
--exec rm $MYSQLTEST_VARDIR/tmp/t1
DROP TABLE t1,t2;
# End of 4.1 tests
#
......
......@@ -1496,17 +1496,7 @@ SET GLOBAL general_log = default;
#
# Bug #27084 partitioning by list seems failing when using case
# BUG #18198: Case no longer supported, test case removed
#
CREATE TABLE `t1` ( `a` varchar(1)) ENGINE=MyISAM
PARTITION BY LIST (CASE a WHEN 'a' THEN 1
WHEN 'b' THEN 2
WHEN 'c' THEN 3
END) (
PARTITION a VALUES IN (1),
PARTITION b VALUES IN (2),
PARTITION c VALUES IN (3)
);
DROP TABLE t1;
--echo End of 5.1 tests
-- source include/have_partition.inc
--disable_warnings
drop table if exists t1;
--enable_warnings
create table t1 (col1 datetime)
partition by range(datediff(col1,col1))
(partition p0 values less than (10), partition p1 values less than (30));
drop table t1;
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 int)
partition by range(greatest(col1,10))
(partition p0 values less than (2), partition p1 values less than (6));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 int)
partition by range(isnull(col1))
(partition p0 values less than (2), partition p1 values less than (6));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 int)
partition by range(least(col1,12))
(partition p0 values less than (2), partition p1 values less than (6));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 int)
partition by range(case when col1>0 then 10 else 20 end)
(partition p0 values less than (2), partition p1 values less than (6));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 int)
partition by range(ifnull(col1,5))
(partition p0 values less than (2), partition p1 values less than (6));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 int)
partition by range(nullif(col1,5))
(partition p0 values less than (2), partition p1 values less than (6));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 int)
partition by range(bit_length(col1))
(partition p0 values less than (2), partition p1 values less than (6));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 char(5))
partition by range(bit_length(col1))
(partition p0 values less than (2), partition p1 values less than (6));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 int)
partition by range(char_length(col1))
(partition p0 values less than (2), partition p1 values less than (6));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 char(5))
partition by range(char_length(col1))
(partition p0 values less than (2), partition p1 values less than (6));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 char(5))
partition by range(character_length(col1))
(partition p0 values less than (2), partition p1 values less than (6));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 int)
partition by range(find_in_set(col1,1))
(partition p0 values less than (2), partition p1 values less than (6));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 char(5))
partition by range(find_in_set(col1,'1'))
(partition p0 values less than (2), partition p1 values less than (6));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 int)
partition by range(instr(col1,3))
(partition p0 values less than (2), partition p1 values less than (6));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 char(5))
partition by range(instr(col1,'3'))
(partition p0 values less than (2), partition p1 values less than (6));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 char(5))
partition by range(length(col1))
(partition p0 values less than (2), partition p1 values less than (6));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 char(5))
partition by range(locate(1,col1))
(partition p0 values less than (2), partition p1 values less than (6));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 int)
partition by range(locate(1,col1))
(partition p0 values less than (2), partition p1 values less than (6));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 char(5))
partition by range(octet_length(col1))
(partition p0 values less than (2), partition p1 values less than (6));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 char(5))
partition by range(position(1 in col1))
(partition p0 values less than (2), partition p1 values less than (6));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 int)
partition by range(position(1 in col1))
(partition p0 values less than (2), partition p1 values less than (6));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 char(5))
partition by range(strcmp(col1,2))
(partition p0 values less than (2), partition p1 values less than (6));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 int)
partition by range(strcmp(col1,2))
(partition p0 values less than (2), partition p1 values less than (6));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 int)
partition by range(crc32(col1))
(partition p0 values less than (2), partition p1 values less than (6));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 int)
partition by range(round(col1))
(partition p0 values less than (2), partition p1 values less than (6));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 int)
partition by range(sign(col1))
(partition p0 values less than (2), partition p1 values less than (6));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 datetime)
partition by range(period_add(col1,5))
(partition p0 values less than (10), partition p1 values less than (30));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 datetime, col2 datetime)
partition by range(period_diff(col1,col2))
(partition p0 values less than (10), partition p1 values less than (30));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 int, col2 int)
partition by range(period_diff(col1,col2))
(partition p0 values less than (10), partition p1 values less than (30));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 datetime)
partition by range(timestampdiff(day,5,col1))
(partition p0 values less than (10), partition p1 values less than (30));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 date)
partition by range(unix_timestamp(col1))
(partition p0 values less than (10), partition p1 values less than (30));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 datetime)
partition by range(week(col1))
(partition p0 values less than (10), partition p1 values less than (30));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 varchar(25))
partition by range(cast(col1 as signed))
(partition p0 values less than (10), partition p1 values less than (30));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 varchar(25))
partition by range(convert(col1,unsigned))
(partition p0 values less than (10), partition p1 values less than (30));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 int)
partition by range(col1 | 20)
(partition p0 values less than (10), partition p1 values less than (30));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 int)
partition by range(col1 & 20)
(partition p0 values less than (10), partition p1 values less than (30));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 int)
partition by range(col1 ^ 20)
(partition p0 values less than (10), partition p1 values less than (30));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 int)
partition by range(col1 << 20)
(partition p0 values less than (10), partition p1 values less than (30));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 int)
partition by range(col1 >> 20)
(partition p0 values less than (10), partition p1 values less than (30));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 int)
partition by range(~col1)
(partition p0 values less than (10), partition p1 values less than (30));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 int)
partition by range(bit_count(col1))
(partition p0 values less than (10), partition p1 values less than (30));
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (col1 int)
partition by range(inet_aton(col1))
(partition p0 values less than (10), partition p1 values less than (30));
......@@ -19,3 +19,11 @@ flush tables;
set names latin1;
select * from t1;
drop table t1;
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (a varchar(1), primary key (a))
partition by list (ascii(a))
(partition p1 values in (65));
#insert into t1 values ('A');
#replace into t1 values ('A');
#drop table t1;
......@@ -33,7 +33,7 @@ partitions 2;
#
# Partition by key list, wrong result type
#
--error ER_PARTITION_FUNC_NOT_ALLOWED_ERROR
--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (
a int not null,
b int not null,
......@@ -109,7 +109,7 @@ partitions 3
#
# Partition by hash, invalid result type
#
--error ER_PARTITION_FUNC_NOT_ALLOWED_ERROR
--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (
a int not null,
b int not null,
......@@ -533,7 +533,7 @@ partitions 2
#
# Partition by range, wrong result type of partition function
#
--error ER_PARTITION_FUNC_NOT_ALLOWED_ERROR
--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (
a int not null,
b int not null,
......@@ -769,10 +769,11 @@ partition by range (a)
#
# Bug 18198 Partitions: Verify that erroneus partition functions doesn't work
#
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (v varchar(12))
partition by range (ascii(v))
(partition p0 values less than (10));
drop table t1;
#drop table t1;
-- error 1064
create table t1 (a int)
......@@ -790,7 +791,7 @@ partition by hash (extract(hour from convert_tz(a, '+00:00', '+00:00')));
create table t1 (a int)
partition by range (a + (select count(*) from t1))
(partition p1 values less than (1));
-- error ER_PARTITION_FUNC_NOT_ALLOWED_ERROR
-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (a char(10))
partition by hash (extractvalue(a,'a'));
......
......@@ -9,18 +9,6 @@
drop table if exists t1;
--enable_warnings
#
# BUG 18198: Partition functions handling
#
create table t1 (a varchar(10) charset latin1 collate latin1_bin)
partition by hash(length(a))
partitions 10;
insert into t1 values (''),(' '),('a'),('a '),('a ');
explain partitions select * from t1 where a='a ';
explain partitions select * from t1 where a='a';
explain partitions select * from t1 where a='a ' OR a='a';
drop table t1;
#
# More partition pruning tests, especially on interval walking
#
......
......@@ -179,4 +179,8 @@ insert into t1 values (null);
select * from t1;
drop table t1;
--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
create table t1 (a char(1))
partition by list (ascii(ucase(a)))
(partition p1 values in (2));
......@@ -20,7 +20,7 @@ subpartition sp01, subpartition sp02));
drop table t1;
CREATE TABLE t1 (f_date DATE, f_varchar VARCHAR(30))
PARTITION BY HASH(CAST(YEAR(f_date) AS SIGNED INTEGER)) PARTITIONS 2;
PARTITION BY HASH(YEAR(f_date)) PARTITIONS 2;
SHOW CREATE TABLE t1;
--replace_result $MYSQLTEST_VARDIR "hello"
......
......@@ -538,18 +538,17 @@ select * from t1 where f_int1 between 5 and 15 order by f_int1;
drop table t1;
# part2: bug in pruning code
create table t1 (a char(10) binary)
partition by list(length(a))
(partition p1 values in (1),
partition p2 values in (2),
partition p3 values in (3),
partition p4 values in (4),
partition p5 values in (5)
);
insert into t1 values ('a'),('bb'),('ccc'),('dddd'),('eeEee');
select * from t1 where a>='a' and a <= 'dddd';
explain partitions select * from t1 where a>='a' and a <= 'dddd';
drop table t1;
#create table t1 (a char(10) binary)
#partition by list(ascii(a))
# (partition p1 values in (ascii('a')),
# partition p2 values in (ascii('b')),
# partition p3 values in (ascii('c')),
# partition p4 values in (ascii('d')),
# partition p5 values in (ascii('e')));
#insert into t1 values ('a'),('bb'),('ccc'),('dddd'),('eeEee');
#select * from t1 where a>='a' and a <= 'dddd';
#explain partitions select * from t1 where a>='a' and a <= 'dddd';
#drop table t1;
# BUG#18659: Assertion failure when subpartitioning is used and partition is
# "IS NULL"
......@@ -692,19 +691,46 @@ explain partitions select * from t1 where a = 18446744073709551000;
explain partitions select * from t1 where a = 18446744073709551613;
explain partitions select * from t1 where a = 18446744073709551614;
drop table t1;
#
# Test all variants of usage for interval_via_mapping
# and interval_via_walking
#
# t1 will use interval_via_mapping since it uses a
# monotonic function, whereas t2 will use
# interval_via_walking since the intervals are short
# and the function isn't monotonic (it is, but it isn't
# discovered in this version).
#
create table t1 (a int)
partition by range(a) (
partition p0 values less than (64),
partition p1 values less than (128),
partition p2 values less than (255)
);
create table t1 (a int)
partition by range((a & 0xFF) << 56) (
partition p0 values less than (0x40 << 56),
partition p1 values less than (0x80 << 56),
partition p2 values less than (0xFF << 56)
create table t2 (a int)
partition by range(a+0) (
partition p0 values less than (64),
partition p1 values less than (128),
partition p2 values less than (255)
);
insert into t1 values (0x20), (0x20), (0x41), (0x41), (0xFE), (0xFE);
insert into t2 values (0x20), (0x20), (0x41), (0x41), (0xFE), (0xFE);
explain partitions select * from t1 where a=0;
explain partitions select * from t2 where a=0;
explain partitions select * from t1 where a=0xFE;
explain partitions select * from t1 where a>0xFE and a<= 0xFF;
explain partitions select * from t2 where a=0xFE;
explain partitions select * from t1 where a > 0xFE AND a <= 0xFF;
explain partitions select * from t2 where a > 0xFE AND a <= 0xFF;
explain partitions select * from t1 where a >= 0xFE AND a <= 0xFF;
explain partitions select * from t2 where a >= 0xFE AND a <= 0xFF;
explain partitions select * from t1 where a < 64 AND a >= 63;
explain partitions select * from t2 where a < 64 AND a >= 63;
explain partitions select * from t1 where a <= 64 AND a >= 63;
explain partitions select * from t2 where a <= 64 AND a >= 63;
drop table t1;
drop table t2;
create table t1(a bigint unsigned not null) partition by range(a+0) (
partition p1 values less than (10),
......
......@@ -12,45 +12,45 @@ drop table if exists t1;
#
# BUG 18198: Various tests for partition functions
#
create table t1 (a varchar(10) charset latin1 collate latin1_bin, b int)
partition by range (length(a) * b)
(partition p0 values less than (2), partition p1 values less than (400));
insert into t1 values ('a ', 2),('a',3);
drop table t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin, b int)
partition by range (b* length(a) * b)
(partition p0 values less than (2), partition p1 values less than (400));
insert into t1 values ('a ', 2),('a',3);
drop table t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin,
b varchar(10) charset latin1 collate latin1_bin)
partition by range (length(b) * length(a))
(partition p0 values less than (2), partition p1 values less than (400));
insert into t1 values ('a ', 'b '),('a','b');
drop table t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin,
b varchar(10) charset latin1 collate latin1_bin)
partition by range (length(a) * length(b))
(partition p0 values less than (2), partition p1 values less than (400));
insert into t1 values ('a ', 'b '),('a','b');
drop table t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin,
b varchar(10) charset latin1 collate latin1_bin, c int)
partition by range (length(a) * c)
(partition p0 values less than (2), partition p1 values less than (400));
insert into t1 values ('a ', 'b ', 2),('a','b', 3);
drop table t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin,
b varchar(10) charset latin1 collate latin1_bin, c int)
partition by range (c * length(a))
(partition p0 values less than (2), partition p1 values less than (400));
insert into t1 values ('a ', 'b ', 2),('a','b', 3);
drop table t1;
#create table t1 (a varchar(10) charset latin1 collate latin1_bin, b int)
#partition by range (ascii(a) * b)
#(partition p0 values less than (2), partition p1 values less than (4000));
#insert into t1 values ('a ', 2),('a',3);
#drop table t1;
#create table t1 (a varchar(10) charset latin1 collate latin1_bin, b int)
#partition by range (b* ascii(a) * b)
#(partition p0 values less than (2), partition p1 values less than (4000));
#insert into t1 values ('a ', 2),('a',3);
#drop table t1;
#create table t1 (a varchar(10) charset latin1 collate latin1_bin,
# b varchar(10) charset latin1 collate latin1_bin)
#partition by range (ascii(b) * ascii(a))
#(partition p0 values less than (2), partition p1 values less than (40000));
#insert into t1 values ('a ', 'b '),('a','b');
#drop table t1;
#create table t1 (a varchar(10) charset latin1 collate latin1_bin,
# b varchar(10) charset latin1 collate latin1_bin)
#partition by range (ascii(a) * ascii(b))
#(partition p0 values less than (2), partition p1 values less than (40000));
#insert into t1 values ('a ', 'b '),('a','b');
#drop table t1;
#create table t1 (a varchar(10) charset latin1 collate latin1_bin,
# b varchar(10) charset latin1 collate latin1_bin, c int)
#partition by range (ascii(a) * c)
#(partition p0 values less than (2), partition p1 values less than (4000));
#insert into t1 values ('a ', 'b ', 2),('a','b', 3);
#drop table t1;
#create table t1 (a varchar(10) charset latin1 collate latin1_bin,
# b varchar(10) charset latin1 collate latin1_bin, c int)
#partition by range (c * ascii(a))
#(partition p0 values less than (2), partition p1 values less than (4000));
#insert into t1 values ('a ', 'b ', 2),('a','b', 3);
#drop table t1;
#
# More checks for partition pruning
......@@ -733,29 +733,27 @@ DROP TABLE t1;
#
# Bug 18198: Try with a couple of cases using VARCHAR fields in
# partition function.
create table t1 (a varchar(20))
partition by range (crc32(md5(a)))
(partition p0 values less than (100),
partition p1 values less than maxvalue);
insert into t1 values ("12345678901234567890");
insert into t1 values ("A2345678901234567890");
insert into t1 values ("B2345678901234567890");
insert into t1 values ("1234567890123456789");
insert into t1 values ("1234567890123456");
select * from t1;
explain partitions select * from t1 where a = "12345678901234567890";
explain partitions select * from t1 where a = "12345678901234567890" OR
a = "A2345678901234567890" OR
a = "B2345678901234567890" OR
a = "C2345678901234567890";
explain partitions select * from t1 where a = "01234567890123456";
select * from t1 where a = "01234567890123456";
select * from t1 where a = "12345678901234567890" OR
a = "A2345678901234567890" OR
a = "B2345678901234567890" OR
a = "C2345678901234567890";
select * from t1 where a = "12345678901234567890";
drop table t1;
#create table t1 (a varchar(20))
#partition by range (ascii(a))
#(partition p0 values less than (100),
# partition p1 values less than maxvalue);
#insert into t1 values ("12345678901234567890");
#insert into t1 values ("A2345678901234567890");
#insert into t1 values ("B2345678901234567890");
#insert into t1 values ("1234567890123456789");
#insert into t1 values ("1234567890123456");
#select * from t1;
#explain partitions select * from t1 where a = "12345678901234567890";
#explain partitions select * from t1 where a = "12345678901234567890" OR
# a = "A2345678901234567890" OR
# a = "B2345678901234567890" OR
# a = "C2345678901234567890";
#explain partitions select * from t1 where a = "01234567890123456";
#select * from t1 where a = "01234567890123456";
#select * from t1 where a = "12345678901234567890" OR
# a = "A2345678901234567890" OR
# a = "B2345678901234567890" OR
# a = "C2345678901234567890";
#select * from t1 where a = "12345678901234567890";
#drop table t1;
......@@ -1128,6 +1128,7 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file,
BUFFPEK *buffpek;
QUEUE queue;
qsort2_cmp cmp;
void *first_cmp_arg;
volatile THD::killed_state *killed= &current_thd->killed;
THD::killed_state not_killable;
DBUG_ENTER("merge_buffers");
......@@ -1152,9 +1153,18 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file,
/* The following will fire if there is not enough space in sort_buffer */
DBUG_ASSERT(maxcount!=0);
if (param->unique_buff)
{
cmp= param->compare;
first_cmp_arg= (void *) &param->cmp_context;
}
else
{
cmp= get_ptr_compare(sort_length);
first_cmp_arg= (void*) &sort_length;
}
if (init_queue(&queue, (uint) (Tb-Fb)+1, offsetof(BUFFPEK,key), 0,
(queue_compare) (cmp= get_ptr_compare(sort_length)),
(void*) &sort_length))
(queue_compare) cmp, first_cmp_arg))
DBUG_RETURN(1); /* purecov: inspected */
for (buffpek= Fb ; buffpek <= Tb ; buffpek++)
{
......@@ -1207,7 +1217,7 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file,
buffpek= (BUFFPEK*) queue_top(&queue);
if (cmp) // Remove duplicates
{
if (!(*cmp)(&sort_length, &(param->unique_buff),
if (!(*cmp)(first_cmp_arg, &(param->unique_buff),
(uchar**) &buffpek->key))
goto skip_duplicate;
memcpy(param->unique_buff, (uchar*) buffpek->key, rec_length);
......@@ -1259,7 +1269,7 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file,
*/
if (cmp)
{
if (!(*cmp)(&sort_length, &(param->unique_buff), (uchar**) &buffpek->key))
if (!(*cmp)(first_cmp_arg, &(param->unique_buff), (uchar**) &buffpek->key))
{
buffpek->key+= rec_length; // Remove duplicate
--buffpek->mem_count;
......
......@@ -843,8 +843,7 @@ public:
german character for double s is equal to 2 s.
The default is that an item is not allowed
in a partition function. However all mathematical functions, string
manipulation functions, date functions are allowed. Allowed functions
in a partition function. Allowed functions
can never depend on server version, they cannot depend on anything
related to the environment. They can also only depend on a set of
fields in the table itself. They cannot depend on other tables and
......@@ -1633,6 +1632,7 @@ public:
uint decimal_precision() const
{ return (uint)(max_length - test(value < 0)); }
bool eq(const Item *, bool binary_cmp) const;
bool check_partition_func_processor(uchar *bool_arg) { return FALSE;}
};
......@@ -1650,6 +1650,7 @@ public:
void print(String *str);
Item_num *neg ();
uint decimal_precision() const { return max_length; }
bool check_partition_func_processor(uchar *bool_arg) { return FALSE;}
};
......@@ -1692,6 +1693,7 @@ public:
uint decimal_precision() const { return decimal_value.precision(); }
bool eq(const Item *, bool binary_cmp) const;
void set_decimal_value(my_decimal *value_par);
bool check_partition_func_processor(uchar *bool_arg) { return FALSE;}
};
......@@ -1752,7 +1754,6 @@ public:
{}
void print(String *str) { str->append(func_name); }
Item *safe_charset_converter(CHARSET_INFO *tocs);
bool check_partition_func_processor(uchar *int_arg) {return TRUE;}
};
......@@ -1861,7 +1862,6 @@ public:
CHARSET_INFO *cs= NULL):
Item_string(name, length, cs)
{}
bool check_partition_func_processor(uchar *int_arg) {return TRUE;}
};
......@@ -1915,7 +1915,6 @@ public:
unsigned_flag=1;
}
enum_field_types field_type() const { return int_field_type; }
bool check_partition_func_processor(uchar *int_arg) {return TRUE;}
};
......@@ -2237,7 +2236,6 @@ public:
}
Item *clone_item();
virtual Item *real_item() { return ref; }
bool check_partition_func_processor(uchar *int_arg) {return TRUE;}
};
#ifdef MYSQL_SERVER
......
......@@ -355,7 +355,6 @@ public:
}
Item *neg_transformer(THD *thd);
virtual Item *negated_item();
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool subst_argument_checker(uchar **arg) { return TRUE; }
};
......@@ -367,7 +366,6 @@ public:
enum Functype functype() const { return NOT_FUNC; }
const char *func_name() const { return "not"; }
Item *neg_transformer(THD *thd);
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
void print(String *str);
};
......@@ -598,7 +596,6 @@ public:
bool is_bool_func() { return 1; }
CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
uint decimal_precision() const { return 1; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -610,7 +607,6 @@ public:
optimize_type select_optimize() const { return OPTIMIZE_NONE; }
const char *func_name() const { return "strcmp"; }
void print(String *str) { Item_func::print(str); }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -673,7 +669,6 @@ public:
const char *func_name() const { return "ifnull"; }
Field *tmp_table_field(TABLE *table);
uint decimal_precision() const;
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -714,7 +709,6 @@ public:
void print(String *str) { Item_func::print(str); }
table_map not_null_tables() const { return 0; }
bool is_null();
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
/* Functions to handle the optimized IN */
......@@ -1141,7 +1135,6 @@ public:
void print(String *str);
Item *find_item(String *str);
CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
bool check_partition_func_processor(uchar *bool_arg) { return FALSE;}
void cleanup();
};
......@@ -1211,7 +1204,6 @@ public:
bool nulls_in_row();
bool is_bool_func() { return 1; }
CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
class cmp_item_row :public cmp_item
......@@ -1283,7 +1275,6 @@ public:
optimize_type select_optimize() const { return OPTIMIZE_NULL; }
Item *neg_transformer(THD *thd);
CHARSET_INFO *compare_collation() { return args[0]->collation.collation; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
/* Functions used by HAVING for rewriting IN subquery */
......@@ -1310,7 +1301,6 @@ public:
*/
table_map used_tables() const
{ return used_tables_cache | RAND_TABLE_BIT; }
bool check_partition_func_processor(uchar *int_arg) {return TRUE;}
};
......@@ -1333,7 +1323,6 @@ public:
void print(String *str);
CHARSET_INFO *compare_collation() { return args[0]->collation.collation; }
void top_level_item() { abort_on_null=1; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -1372,7 +1361,6 @@ public:
const char *func_name() const { return "like"; }
bool fix_fields(THD *thd, Item **ref);
void cleanup();
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
#ifdef USE_REGEX
......@@ -1395,7 +1383,6 @@ public:
const char *func_name() const { return "regexp"; }
void print(String *str) { print_op(str); }
CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
#else
......@@ -1452,7 +1439,6 @@ public:
Item *transform(Item_transformer transformer, uchar *arg);
void traverse_cond(Cond_traverser, void *arg, traverse_order order);
void neg_arguments(THD *thd);
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
bool subst_argument_checker(uchar **arg) { return TRUE; }
Item *compile(Item_analyzer analyzer, uchar **arg_p,
Item_transformer transformer, uchar *arg_t);
......
......@@ -253,7 +253,6 @@ public:
void fix_num_length_and_dec();
void find_num_type();
String *str_op(String *str) { DBUG_ASSERT(0); return 0; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -311,7 +310,6 @@ public:
{ max_length=args[0]->max_length; unsigned_flag=0; }
void print(String *str);
uint decimal_precision() const { return args[0]->decimal_precision(); }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -345,7 +343,6 @@ public:
void fix_length_and_dec() {};
const char *func_name() const { return "decimal_typecast"; }
void print(String *);
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -442,6 +439,7 @@ public:
void fix_length_and_dec();
void fix_num_length_and_dec();
uint decimal_precision() const { return args[0]->decimal_precision(); }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -454,6 +452,7 @@ public:
my_decimal *decimal_op(my_decimal *);
const char *func_name() const { return "abs"; }
void fix_length_and_dec();
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
// A class to handle logarithmic and trigonometric functions
......@@ -488,7 +487,6 @@ public:
Item_func_exp(Item *a) :Item_dec_func(a) {}
double val_real();
const char *func_name() const { return "exp"; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -498,7 +496,6 @@ public:
Item_func_ln(Item *a) :Item_dec_func(a) {}
double val_real();
const char *func_name() const { return "ln"; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -509,7 +506,6 @@ public:
Item_func_log(Item *a,Item *b) :Item_dec_func(a,b) {}
double val_real();
const char *func_name() const { return "log"; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -519,7 +515,6 @@ public:
Item_func_log2(Item *a) :Item_dec_func(a) {}
double val_real();
const char *func_name() const { return "log2"; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -529,7 +524,6 @@ public:
Item_func_log10(Item *a) :Item_dec_func(a) {}
double val_real();
const char *func_name() const { return "log10"; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -539,7 +533,6 @@ public:
Item_func_sqrt(Item *a) :Item_dec_func(a) {}
double val_real();
const char *func_name() const { return "sqrt"; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -549,7 +542,6 @@ public:
Item_func_pow(Item *a,Item *b) :Item_dec_func(a,b) {}
double val_real();
const char *func_name() const { return "pow"; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -559,7 +551,6 @@ public:
Item_func_acos(Item *a) :Item_dec_func(a) {}
double val_real();
const char *func_name() const { return "acos"; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
class Item_func_asin :public Item_dec_func
......@@ -568,7 +559,6 @@ public:
Item_func_asin(Item *a) :Item_dec_func(a) {}
double val_real();
const char *func_name() const { return "asin"; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
class Item_func_atan :public Item_dec_func
......@@ -578,7 +568,6 @@ public:
Item_func_atan(Item *a,Item *b) :Item_dec_func(a,b) {}
double val_real();
const char *func_name() const { return "atan"; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
class Item_func_cos :public Item_dec_func
......@@ -587,7 +576,6 @@ public:
Item_func_cos(Item *a) :Item_dec_func(a) {}
double val_real();
const char *func_name() const { return "cos"; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
class Item_func_sin :public Item_dec_func
......@@ -596,7 +584,6 @@ public:
Item_func_sin(Item *a) :Item_dec_func(a) {}
double val_real();
const char *func_name() const { return "sin"; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
class Item_func_tan :public Item_dec_func
......@@ -605,7 +592,6 @@ public:
Item_func_tan(Item *a) :Item_dec_func(a) {}
double val_real();
const char *func_name() const { return "tan"; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
class Item_func_integer :public Item_int_func
......@@ -633,6 +619,7 @@ public:
longlong int_op();
double real_op();
my_decimal *decimal_op(my_decimal *);
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -644,6 +631,7 @@ public:
longlong int_op();
double real_op();
my_decimal *decimal_op(my_decimal *);
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
/* This handles round and truncate */
......@@ -684,7 +672,6 @@ public:
Item_func_sign(Item *a) :Item_int_func(a) {}
const char *func_name() const { return "sign"; }
longlong val_int();
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -699,7 +686,6 @@ public:
const char *func_name() const { return name; }
void fix_length_and_dec()
{ decimals= NOT_FIXED_DEC; max_length= float_length(decimals); }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -725,7 +711,6 @@ public:
void fix_length_and_dec();
enum Item_result result_type () const { return cmp_type; }
bool result_as_longlong() { return compare_as_dates; };
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
uint cmp_datetimes(ulonglong *value);
};
......@@ -781,7 +766,6 @@ public:
longlong val_int();
const char *func_name() const { return "length"; }
void fix_length_and_dec() { max_length=10; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
class Item_func_bit_length :public Item_func_length
......@@ -801,7 +785,6 @@ public:
longlong val_int();
const char *func_name() const { return "char_length"; }
void fix_length_and_dec() { max_length=10; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
class Item_func_coercibility :public Item_int_func
......@@ -825,7 +808,6 @@ public:
longlong val_int();
void fix_length_and_dec();
void print(String *str);
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -850,7 +832,6 @@ public:
longlong val_int();
const char *func_name() const { return "ascii"; }
void fix_length_and_dec() { max_length=3; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
class Item_func_ord :public Item_int_func
......@@ -860,7 +841,6 @@ public:
Item_func_ord(Item *a) :Item_int_func(a) {}
longlong val_int();
const char *func_name() const { return "ord"; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
class Item_func_find_in_set :public Item_int_func
......@@ -874,7 +854,6 @@ public:
longlong val_int();
const char *func_name() const { return "find_in_set"; }
void fix_length_and_dec();
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
/* Base class for all bit functions: '~', '|', '^', '&', '>>', '<<' */
......@@ -886,7 +865,6 @@ public:
Item_func_bit(Item *a) :Item_int_func(a) {}
void fix_length_and_dec() { unsigned_flag= 1; }
void print(String *str) { print_op(str); }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
class Item_func_bit_or :public Item_func_bit
......@@ -912,7 +890,6 @@ public:
longlong val_int();
const char *func_name() const { return "bit_count"; }
void fix_length_and_dec() { max_length=2; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
class Item_func_shift_left :public Item_func_bit
......@@ -1363,7 +1340,6 @@ public:
longlong val_int();
const char *func_name() const { return "inet_aton"; }
void fix_length_and_dec() { decimals= 0; max_length= 21; maybe_null= 1; unsigned_flag= 1;}
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......
......@@ -50,7 +50,6 @@ public:
String *val_str(String *);
void fix_length_and_dec();
const char *func_name() const { return "md5"; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -94,7 +93,6 @@ public:
String *val_str(String *);
void fix_length_and_dec();
const char *func_name() const { return "concat"; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
class Item_func_concat_ws :public Item_str_func
......@@ -116,7 +114,6 @@ public:
String *val_str(String *);
void fix_length_and_dec();
const char *func_name() const { return "reverse"; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -154,7 +151,6 @@ protected:
public:
Item_str_conv(Item *item) :Item_str_func(item) {}
String *val_str(String *);
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -455,7 +451,6 @@ public:
String *val_str(String *);
void fix_length_and_dec();
const char *func_name() const { return "soundex"; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -549,7 +544,6 @@ public:
String *val_str(String *);
void fix_length_and_dec();
const char *func_name() const { return "rpad"; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -562,7 +556,6 @@ public:
String *val_str(String *);
void fix_length_and_dec();
const char *func_name() const { return "lpad"; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -577,7 +570,6 @@ public:
collation.set(default_charset());
max_length= 64;
}
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -594,7 +586,6 @@ public:
decimals=0;
max_length=args[0]->max_length*2*collation.collation->mbmaxlen;
}
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
class Item_func_unhex :public Item_str_func
......@@ -614,7 +605,6 @@ public:
decimals=0;
max_length=(1+args[0]->max_length)/2;
}
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -638,7 +628,6 @@ public:
}
void print(String *str);
const char *func_name() const { return "cast_as_binary"; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -678,7 +667,6 @@ public:
String* val_str(String* str);
const char *func_name() const { return "inet_ntoa"; }
void fix_length_and_dec() { decimals = 0; max_length=3*8+7; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
class Item_func_quote :public Item_str_func
......@@ -693,7 +681,6 @@ public:
collation.set(args[0]->collation);
max_length= args[0]->max_length * 2 + 2;
}
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
class Item_func_conv_charset :public Item_str_func
......@@ -794,7 +781,6 @@ public:
const char *func_name() const { return "crc32"; }
void fix_length_and_dec() { max_length=10; }
longlong val_int();
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
class Item_func_uncompressed_length : public Item_int_func
......
......@@ -38,7 +38,6 @@ public:
{
max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
}
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -53,7 +52,6 @@ public:
decimals=0;
max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
}
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -129,6 +127,7 @@ public:
max_length=10*my_charset_bin.mbmaxlen;
maybe_null=1;
}
bool check_partition_func_processor(uchar *int_arg) {return TRUE;}
};
......@@ -224,7 +223,6 @@ public:
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null=1;
}
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
class Item_func_yearweek :public Item_int_func
......@@ -303,6 +301,7 @@ class Item_func_dayname :public Item_func_weekday
max_length=9*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null=1;
}
bool check_partition_func_processor(uchar *int_arg) {return TRUE;}
};
......@@ -319,7 +318,6 @@ public:
decimals=0;
max_length=10*MY_CHARSET_BIN_MB_MAXLEN;
}
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -603,7 +601,6 @@ public:
void fix_length_and_dec();
uint format_length(const String *format);
bool eq(const Item *item, bool binary_cmp) const;
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -617,7 +614,6 @@ class Item_func_from_unixtime :public Item_date_func
const char *func_name() const { return "from_unixtime"; }
void fix_length_and_dec();
bool get_date(MYSQL_TIME *res, uint fuzzy_date);
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -676,7 +672,6 @@ public:
}
const char *func_name() const { return "sec_to_time"; }
bool result_as_longlong() { return TRUE; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -698,7 +693,6 @@ public:
bool get_date(MYSQL_TIME *res, uint fuzzy_date);
bool eq(const Item *item, bool binary_cmp) const;
void print(String *str);
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -753,7 +747,6 @@ public:
max_length=args[0]->max_length;
maybe_null= 1;
}
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -773,7 +766,6 @@ public:
String *val_str(String *a);
void fix_length_and_dec();
void print(String *str);
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -884,7 +876,6 @@ public:
max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
}
longlong val_int();
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -907,7 +898,6 @@ public:
}
void print(String *str);
const char *func_name() const { return "add_time"; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
double val_real() { return val_real_from_decimal(); }
my_decimal *val_decimal(my_decimal *decimal_value)
{
......@@ -949,7 +939,6 @@ public:
:Item_str_timefunc(a, b ,c) {}
String *val_str(String *str);
const char *func_name() const { return "maketime"; }
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
class Item_func_microsecond :public Item_int_func
......@@ -981,7 +970,6 @@ public:
maybe_null=1;
}
void print(String *str);
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......@@ -1028,7 +1016,6 @@ public:
{
return tmp_table_field_from_field_type(table, 1);
}
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......
......@@ -41,7 +41,6 @@ public:
Item_func_xml_extractvalue(Item *a,Item *b) :Item_xml_str_func(a,b) {}
const char *func_name() const { return "extractvalue"; }
String *val_str(String *);
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
......
......@@ -1445,7 +1445,7 @@ static int binlog_close_connection(handlerton *hton, THD *thd)
{
binlog_trx_data *const trx_data=
(binlog_trx_data*) thd->ha_data[binlog_hton->slot];
DBUG_ASSERT(mysql_bin_log.is_open() && trx_data->empty());
DBUG_ASSERT(trx_data->empty());
thd->ha_data[binlog_hton->slot]= 0;
trx_data->~binlog_trx_data();
my_free((uchar*)trx_data, MYF(0));
......@@ -1570,7 +1570,6 @@ static int binlog_commit(handlerton *hton, THD *thd, bool all)
DBUG_ENTER("binlog_commit");
binlog_trx_data *const trx_data=
(binlog_trx_data*) thd->ha_data[binlog_hton->slot];
DBUG_ASSERT(mysql_bin_log.is_open());
if (trx_data->empty())
{
......@@ -1598,7 +1597,6 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all)
int error=0;
binlog_trx_data *const trx_data=
(binlog_trx_data*) thd->ha_data[binlog_hton->slot];
DBUG_ASSERT(mysql_bin_log.is_open());
if (trx_data->empty()) {
trx_data->reset();
......@@ -1659,7 +1657,6 @@ static int binlog_savepoint_set(handlerton *hton, THD *thd, void *sv)
static int binlog_savepoint_rollback(handlerton *hton, THD *thd, void *sv)
{
DBUG_ENTER("binlog_savepoint_rollback");
DBUG_ASSERT(mysql_bin_log.is_open());
/*
Write ROLLBACK TO SAVEPOINT to the binlog cache if we have updated some
......
......@@ -905,7 +905,6 @@ bool partition_info::set_up_charset_field_preps()
Field *field, **ptr;
uchar **char_ptrs;
unsigned i;
bool found;
size_t size;
uint tot_fields= 0;
uint tot_part_fields= 0;
......@@ -918,7 +917,6 @@ bool partition_info::set_up_charset_field_preps()
{
ptr= part_field_array;
/* Set up arrays and buffers for those fields */
i= 0;
while ((field= *(ptr++)))
{
if (field_is_partition_charset(field))
......@@ -954,7 +952,7 @@ bool partition_info::set_up_charset_field_preps()
}
part_charset_field_array[i]= NULL;
}
if (is_sub_partitioned() && list_of_subpart_fields &&
if (is_sub_partitioned() && !list_of_subpart_fields &&
check_part_func_fields(subpart_field_array, FALSE))
{
/* Set up arrays and buffers for those fields */
......@@ -962,7 +960,10 @@ bool partition_info::set_up_charset_field_preps()
while ((field= *(ptr++)))
{
if (field_is_partition_charset(field))
{
tot_subpart_fields++;
tot_fields++;
}
}
size= tot_subpart_fields * sizeof(char*);
if (!(char_ptrs= (uchar**) sql_calloc(size)))
......@@ -975,10 +976,10 @@ bool partition_info::set_up_charset_field_preps()
if (!(char_ptrs= (uchar**) sql_alloc(size)))
goto error;
subpart_charset_field_array= (Field**)char_ptrs;
ptr= subpart_field_array;
i= 0;
while ((field= *(ptr++)))
{
unsigned j= 0;
CHARSET_INFO *cs;
uchar *field_buf;
LINT_INIT(field_buf);
......@@ -987,28 +988,16 @@ bool partition_info::set_up_charset_field_preps()
continue;
cs= ((Field_str*)field)->charset();
size= field->pack_length();
found= FALSE;
for (j= 0; j < tot_part_fields; j++)
{
if (field == part_charset_field_array[i])
found= TRUE;
}
if (!found)
{
tot_fields++;
if (!(field_buf= (uchar*) sql_calloc(size)))
goto error;
}
subpart_charset_field_array[i]= field;
subpart_field_buffers[i++]= field_buf;
}
if (!(char_ptrs= (uchar**) sql_calloc(size)))
goto error;
restore_subpart_field_ptrs= char_ptrs;
subpart_charset_field_array[i]= NULL;
}
if (tot_fields)
{
uint j,k,l;
uint k;
size= tot_fields*sizeof(char**);
if (!(char_ptrs= (uchar**)sql_calloc(size)))
goto error;
......@@ -1026,11 +1015,12 @@ bool partition_info::set_up_charset_field_preps()
full_part_field_buffers[i]= part_field_buffers[i];
}
k= tot_part_fields;
l= 0;
for (i= 0; i < tot_subpart_fields; i++)
{
uint j;
bool found= FALSE;
field= subpart_charset_field_array[i];
found= FALSE;
for (j= 0; j < tot_part_fields; j++)
{
if (field == part_charset_field_array[i])
......@@ -1038,12 +1028,12 @@ bool partition_info::set_up_charset_field_preps()
}
if (!found)
{
full_part_charset_field_array[l]= subpart_charset_field_array[k];
full_part_field_buffers[l]= subpart_field_buffers[k];
k++; l++;
full_part_charset_field_array[k]= subpart_charset_field_array[i];
full_part_field_buffers[k]= subpart_field_buffers[i];
k++;
}
}
full_part_charset_field_array[tot_fields]= NULL;
full_part_charset_field_array[k]= NULL;
}
DBUG_RETURN(FALSE);
error:
......
......@@ -1445,6 +1445,7 @@ select_export::prepare(List<Item> &list, SELECT_LEX_UNIT *u)
field_sep_char= (exchange->enclosed->length() ? (*exchange->enclosed)[0] :
field_term_length ? (*exchange->field_term)[0] : INT_MAX);
escape_char= (exchange->escaped->length() ? (*exchange->escaped)[0] : -1);
is_ambiguous_field_sep= test(strchr(ESCAPE_CHARS, field_sep_char));
line_sep_char= (exchange->line_term->length() ?
(*exchange->line_term)[0] : INT_MAX);
if (!field_term_length)
......@@ -1585,7 +1586,9 @@ bool select_export::send_data(List<Item> &items)
NEED_ESCAPING(pos[1])))
{
char tmp_buff[2];
tmp_buff[0]= escape_char;
tmp_buff[0]= ((int) *pos == field_sep_char &&
is_ambiguous_field_sep) ?
field_sep_char : escape_char;
tmp_buff[1]= *pos ? *pos : '0';
if (my_b_write(&cache,(uchar*) start,(uint) (pos-start)) ||
my_b_write(&cache,(uchar*) tmp_buff,2))
......
......@@ -1949,9 +1949,18 @@ public:
};
#define ESCAPE_CHARS "ntrb0ZN" // keep synchronous with READ_INFO::unescape
class select_export :public select_to_file {
uint field_term_length;
int field_sep_char,escape_char,line_sep_char;
/*
The is_ambiguous_field_sep field is true if a value of the field_sep_char
field is one of the 'n', 't', 'r' etc characters
(see the READ_INFO::unescape method and the ESCAPE_CHARS constant value).
*/
bool is_ambiguous_field_sep;
bool fixed_row_size;
public:
select_export(sql_exchange *ex) :select_to_file(ex) {}
......
......@@ -851,6 +851,7 @@ continue_loop:;
char
READ_INFO::unescape(char chr)
{
/* keep this switch synchornous with the ESCAPE_CHARS macro */
switch(chr) {
case 'n': return '\n';
case 't': return '\t';
......
......@@ -2869,6 +2869,8 @@ uint32 get_partition_id_range_for_endpoint(partition_info *part_info,
}
if (unsigned_flag)
part_func_value-= 0x8000000000000000ULL;
if (left_endpoint && !include_endpoint)
part_func_value++;
while (max_part_id > min_part_id)
{
loc_part_id= (max_part_id + min_part_id + 1) >> 1;
......@@ -3294,7 +3296,9 @@ static uint32 get_sub_part_id_from_key(const TABLE *table,uchar *buf,
key_restore(buf, (uchar*)key_spec->key, key_info, key_spec->length);
if (likely(rec0 == buf))
{
part_id= part_info->get_subpartition_id(part_info);
}
else
{
Field **part_field_array= part_info->subpart_field_array;
......@@ -3337,8 +3341,10 @@ bool get_part_id_from_key(const TABLE *table, uchar *buf, KEY *key_info,
key_restore(buf, (uchar*)key_spec->key, key_info, key_spec->length);
if (likely(rec0 == buf))
{
result= part_info->get_part_partition_id(part_info, part_id,
&func_value);
}
else
{
Field **part_field_array= part_info->part_field_array;
......@@ -3384,8 +3390,10 @@ void get_full_part_id_from_key(const TABLE *table, uchar *buf,
key_restore(buf, (uchar*)key_spec->key, key_info, key_spec->length);
if (likely(rec0 == buf))
{
result= part_info->get_partition_id(part_info, &part_spec->start_part,
&func_value);
}
else
{
Field **part_field_array= part_info->full_part_field_array;
......
......@@ -2273,11 +2273,9 @@ bool uses_only_table_name_fields(Item *item, TABLE_LIST *table)
if (item->type() == Item::FUNC_ITEM)
{
Item_func *item_func= (Item_func*)item;
Item **child;
Item **item_end= (item_func->arguments()) + item_func->argument_count();
for (child= item_func->arguments(); child != item_end; child++)
for (uint i=0; i<item_func->argument_count(); i++)
{
if (!uses_only_table_name_fields(*child, table))
if (!uses_only_table_name_fields(item_func->arguments()[i], table))
return 0;
}
}
......
......@@ -50,6 +50,12 @@ typedef struct st_buffpek { /* Struktur om sorteringsbuffrarna */
ulong max_keys; /* Max keys in buffert */
} BUFFPEK;
struct BUFFPEK_COMPARE_CONTEXT
{
qsort_cmp2 key_compare;
void *key_compare_arg;
};
typedef struct st_sort_param {
uint rec_length; /* Length of sorted records */
uint sort_length; /* Length of sorted columns */
......@@ -65,6 +71,9 @@ typedef struct st_sort_param {
uchar *unique_buff;
bool not_killable;
char* tmp_buffer;
/* The fields below are used only by Unique class */
qsort2_cmp compare;
BUFFPEK_COMPARE_CONTEXT cmp_context;
} SORTPARAM;
......
......@@ -4107,8 +4107,7 @@ part_bit_expr:
}
Lex->part_info->curr_part_elem->has_null_value= TRUE;
}
else if (part_expr->result_type() != INT_RESULT &&
!part_expr->null_value)
else if (part_expr->result_type() != INT_RESULT)
{
my_parse_error(ER(ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR));
MYSQL_YYABORT;
......
......@@ -360,17 +360,12 @@ Unique::reset()
}
/*
The comparison function, passed to queue_init() in merge_walk() must
The comparison function, passed to queue_init() in merge_walk() and in
merge_buffers() when the latter is called from Uniques::get() must
use comparison function of Uniques::tree, but compare members of struct
BUFFPEK.
*/
struct BUFFPEK_COMPARE_CONTEXT
{
qsort_cmp2 key_compare;
void *key_compare_arg;
};
C_MODE_START
static int buffpek_compare(void *arg, uchar *key_ptr1, uchar *key_ptr2)
......@@ -629,6 +624,10 @@ bool Unique::get(TABLE *table)
sort_param.unique_buff= sort_buffer+(sort_param.keys*
sort_param.sort_length);
sort_param.compare= (qsort2_cmp) buffpek_compare;
sort_param.cmp_context.key_compare= tree.compare;
sort_param.cmp_context.key_compare_arg= tree.custom_arg;
/* Merge the buffers to one file, removing duplicates */
if (merge_many_buff(&sort_param,sort_buffer,file_ptr,&maxbuffer,&file))
goto err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment