diff options
author | unknown <gshchepa/uchum@gleb.loc> | 2007-07-05 03:37:41 +0500 |
---|---|---|
committer | unknown <gshchepa/uchum@gleb.loc> | 2007-07-05 03:37:41 +0500 |
commit | 95c5287664a0538af5b49b2c58f027028779ef03 (patch) | |
tree | 6aba922cfa41f2f0966e02b94e451c81c978fa3c /mysql-test | |
parent | 48782e344c4410ad05ac0a2244aff7c943aa3c39 (diff) | |
parent | 285acf57ea2f08cdec214c4530e51394e8fe6b34 (diff) | |
download | mariadb-git-95c5287664a0538af5b49b2c58f027028779ef03.tar.gz |
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
Diffstat (limited to 'mysql-test')
22 files changed, 781 insertions, 251 deletions
diff --git a/mysql-test/include/mix1.inc b/mysql-test/include/mix1.inc index 2aca2ba3698..d8034e19898 100644 --- a/mysql-test/include/mix1.inc +++ b/mysql-test/include/mix1.inc @@ -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 # diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index fb8139e2ce1..db912c650c3 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -1,5 +1,5 @@ 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); diff --git a/mysql-test/r/loaddata.result b/mysql-test/r/loaddata.result index 82c070d7cc9..67665427f9f 100644 --- a/mysql-test/r/loaddata.result +++ b/mysql-test/r/loaddata.result @@ -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; diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index bf347aea196..5d985d053fc 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -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 diff --git a/mysql-test/r/partition_bug18198.result b/mysql-test/r/partition_bug18198.result new file mode 100644 index 00000000000..18d7d904bb0 --- /dev/null +++ b/mysql-test/r/partition_bug18198.result @@ -0,0 +1,173 @@ +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 diff --git a/mysql-test/r/partition_charset.result b/mysql-test/r/partition_charset.result index 665e5d55f8f..f8f75e8bee7 100644 --- a/mysql-test/r/partition_charset.result +++ b/mysql-test/r/partition_charset.result @@ -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 diff --git a/mysql-test/r/partition_error.result b/mysql-test/r/partition_error.result index 4b01b759902..7952c8df609 100644 --- a/mysql-test/r/partition_error.result +++ b/mysql-test/r/partition_error.result @@ -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 diff --git a/mysql-test/r/partition_hash.result b/mysql-test/r/partition_hash.result index 7ef3ee5c6c8..9a82a36d902 100644 --- a/mysql-test/r/partition_hash.result +++ b/mysql-test/r/partition_hash.result @@ -1,18 +1,4 @@ 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; diff --git a/mysql-test/r/partition_list.result b/mysql-test/r/partition_list.result index e64a7a8d154..a68a67c6386 100644 --- a/mysql-test/r/partition_list.result +++ b/mysql-test/r/partition_list.result @@ -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 diff --git a/mysql-test/r/partition_mgm.result b/mysql-test/r/partition_mgm.result index 9b5a34bda50..04ac603fea7 100644 --- a/mysql-test/r/partition_mgm.result +++ b/mysql-test/r/partition_mgm.result @@ -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 diff --git a/mysql-test/r/partition_pruning.result b/mysql-test/r/partition_pruning.result index 5fc0058356d..9595676016c 100644 --- a/mysql-test/r/partition_pruning.result +++ b/mysql-test/r/partition_pruning.result @@ -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 ( @@ -847,23 +828,58 @@ explain partitions select * from t1 where a = 18446744073709551614; 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) +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 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), diff --git a/mysql-test/r/partition_range.result b/mysql-test/r/partition_range.result index d39b39f413a..a61006e87a4 100644 --- a/mysql-test/r/partition_range.result +++ b/mysql-test/r/partition_range.result @@ -1,38 +1,4 @@ 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; diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test index 51f5e5135e6..82fafbf6e73 100644 --- a/mysql-test/t/loaddata.test +++ b/mysql-test/t/loaddata.test @@ -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 # diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 1374c049431..42db23dadef 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -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 diff --git a/mysql-test/t/partition_bug18198.test b/mysql-test/t/partition_bug18198.test new file mode 100644 index 00000000000..7f071c6ec9e --- /dev/null +++ b/mysql-test/t/partition_bug18198.test @@ -0,0 +1,219 @@ +-- 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)); diff --git a/mysql-test/t/partition_charset.test b/mysql-test/t/partition_charset.test index 27d0dc87b89..6842e5268fa 100644 --- a/mysql-test/t/partition_charset.test +++ b/mysql-test/t/partition_charset.test @@ -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; diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test index 20703b979f1..5fc2097cc52 100644 --- a/mysql-test/t/partition_error.test +++ b/mysql-test/t/partition_error.test @@ -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')); diff --git a/mysql-test/t/partition_hash.test b/mysql-test/t/partition_hash.test index ca7972cc01c..98add060a76 100644 --- a/mysql-test/t/partition_hash.test +++ b/mysql-test/t/partition_hash.test @@ -10,18 +10,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 # create table t1 (a int unsigned) diff --git a/mysql-test/t/partition_list.test b/mysql-test/t/partition_list.test index 1e420cfe6ed..1c76de9d55a 100644 --- a/mysql-test/t/partition_list.test +++ b/mysql-test/t/partition_list.test @@ -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)); diff --git a/mysql-test/t/partition_mgm.test b/mysql-test/t/partition_mgm.test index 8458d47d634..a06f8d1aee5 100644 --- a/mysql-test/t/partition_mgm.test +++ b/mysql-test/t/partition_mgm.test @@ -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" diff --git a/mysql-test/t/partition_pruning.test b/mysql-test/t/partition_pruning.test index a60846f18ff..12951c9232a 100644 --- a/mysql-test/t/partition_pruning.test +++ b/mysql-test/t/partition_pruning.test @@ -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,20 +691,47 @@ 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; - -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) +# +# 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) ); -insert into t1 values (0x20), (0x20), (0x41), (0x41), (0xFE), (0xFE); +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), partition p2 values less than (20), diff --git a/mysql-test/t/partition_range.test b/mysql-test/t/partition_range.test index 84f67febe8b..50d850913bc 100644 --- a/mysql-test/t/partition_range.test +++ b/mysql-test/t/partition_range.test @@ -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; |