Commit d5db93b4 authored by unknown's avatar unknown
Browse files

Merge mysql.com:/home/mydev/mysql-5.1

into  mysql.com:/home/mydev/mysql-5.1-aid

parents e125c953 c992a1f7
Loading
Loading
Loading
Loading
+62 −0
Original line number Diff line number Diff line
@@ -597,3 +597,65 @@ NULL
explain partitions select * from t1 where f_int1 is null;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	part4_p2sp0	system	NULL	NULL	NULL	NULL	1	
drop table t1;
create table t1 (a int not null, b int not null)
partition by list(a) 
subpartition by hash(b) subpartitions 4 
(
partition p0 values in (1),
partition p1 values in (2),
partition p2 values in (3)
);
insert into t1 values (1,1),(1,2),(1,3),(1,4),
(2,1),(2,2),(2,3),(2,4);
explain partitions select * from t1 where a=1 AND (b=1 OR b=2);
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	p0_p0sp1,p0_p0sp2	ALL	NULL	NULL	NULL	NULL	2	Using where
drop table t1;
create table t1 (a int, b int not null)
partition by list(a) 
subpartition by hash(b) subpartitions 2
(
partition p0 values in (1),
partition p1 values in (2),
partition p2 values in (3),
partition pn values in (NULL)
);
insert into t1 values (1,1),(1,2),(1,3),(1,4),
(2,1),(2,2),(2,3),(2,4), (NULL,1);
explain partitions select * from t1 where a IS NULL AND (b=1 OR b=2);
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	pn_p3sp0,pn_p3sp1	system	NULL	NULL	NULL	NULL	1	
explain partitions select * from t1 where (a IS NULL or a < 1) AND (b=1 OR b=2);
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	pn_p3sp0,pn_p3sp1	system	NULL	NULL	NULL	NULL	1	
explain partitions select * from t1 where (a IS NULL or a < 2) AND (b=1 OR b=2);
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	p0_p0sp0,p0_p0sp1,pn_p3sp0,pn_p3sp1	ALL	NULL	NULL	NULL	NULL	5	Using where
explain partitions select * from t1 where (a IS NULL or a <= 1) AND (b=1 OR b=2);
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	p0_p0sp0,p0_p0sp1,pn_p3sp0,pn_p3sp1	ALL	NULL	NULL	NULL	NULL	5	Using where
drop table t1;
create table t1 ( a int)  partition by list (MOD(a, 10))
( partition p0  values in (0), 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),
partition p6 values in (6), partition pn values in (NULL)
);
insert into t1 values (NULL), (0),(1),(2),(3),(4),(5),(6);
explain partitions select * from t1 where a is null or a < 2;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	p0,p1,p2,p3,p4,p5,p6,pn	ALL	NULL	NULL	NULL	NULL	8	Using where
drop table t1;
create table t1 (s1 int) partition by list (s1) 
(partition p1 values in (0), 
partition p2 values in (1), 
partition p3 values in (null));
insert into t1 values (0),(1),(null);
select count(*) from t1 where s1 < 0 or s1 is null;
count(*)
1
explain partitions select count(*) from t1 where s1 < 0 or s1 is null;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	p3	system	NULL	NULL	NULL	NULL	1	
drop table t1;
+11 −0
Original line number Diff line number Diff line
@@ -4821,6 +4821,17 @@ begin
declare x int;
select id from t1 order by x;
end|
drop procedure if exists bug14945|
create table t3 (id int not null auto_increment primary key)|
create procedure bug14945() deterministic truncate t3|
insert into t3 values (null)|
call bug14945()|
insert into t3 values (null)|
select * from t3|
id
1
drop table t3|
drop procedure bug14945|
create procedure bug16474_2(x int)
select id from t1 order by x|
call bug16474_1()|
+59 −0
Original line number Diff line number Diff line
@@ -492,6 +492,65 @@ insert into t1 set f_int1 = null;

select * from t1 where f_int1 is null;
explain partitions select * from t1 where f_int1 is null;
drop table t1;

#
# BUG#18558
#
create table t1 (a int not null, b int not null)
partition by list(a) 
  subpartition by hash(b) subpartitions 4 
(
  partition p0 values in (1),
  partition p1 values in (2),
  partition p2 values in (3)
);
insert into t1 values (1,1),(1,2),(1,3),(1,4),
  (2,1),(2,2),(2,3),(2,4);
explain partitions select * from t1 where a=1 AND (b=1 OR b=2);
drop table t1;

create table t1 (a int, b int not null)
partition by list(a) 
  subpartition by hash(b) subpartitions 2
(
  partition p0 values in (1),
  partition p1 values in (2),
  partition p2 values in (3),
  partition pn values in (NULL)
);
insert into t1 values (1,1),(1,2),(1,3),(1,4),
  (2,1),(2,2),(2,3),(2,4), (NULL,1);

explain partitions select * from t1 where a IS NULL AND (b=1 OR b=2);

explain partitions select * from t1 where (a IS NULL or a < 1) AND (b=1 OR b=2);
explain partitions select * from t1 where (a IS NULL or a < 2) AND (b=1 OR b=2);
explain partitions select * from t1 where (a IS NULL or a <= 1) AND (b=1 OR b=2);

drop table t1;

create table t1 ( a int)  partition by list (MOD(a, 10))
( partition p0  values in (0), 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),
   partition p6 values in (6), partition pn values in (NULL)
);
insert into t1 values (NULL), (0),(1),(2),(3),(4),(5),(6);
explain partitions select * from t1 where a is null or a < 2;
drop table t1;

# Testcase from BUG#18751
create table t1 (s1 int) partition by list (s1) 
  (partition p1 values in (0), 
   partition p2 values in (1), 
   partition p3 values in (null));
 
insert into t1 values (0),(1),(null);
 
select count(*) from t1 where s1 < 0 or s1 is null;
explain partitions select count(*) from t1 where s1 < 0 or s1 is null;
drop table t1;

# No tests for NULLs in RANGE(monotonic_expr()) - they depend on BUG#15447
# being fixed.
+15 −0
Original line number Diff line number Diff line
@@ -5672,6 +5672,21 @@ begin
  select id from t1 order by x;
end|

# 
# BUG#14945: Truncate table doesn't reset the auto_increment counter
#
--disable_warnings
drop procedure if exists bug14945|
--enable_warnings
create table t3 (id int not null auto_increment primary key)|
create procedure bug14945() deterministic truncate t3|
insert into t3 values (null)|
call bug14945()|
insert into t3 values (null)|
select * from t3|
drop table t3|
drop procedure bug14945|

# This does NOT order by column index; variable is an expression.
create procedure bug16474_2(x int)
  select id from t1 order by x|
+1 −3
Original line number Diff line number Diff line
@@ -2296,8 +2296,6 @@ bool prune_partitions(THD *thd, TABLE *table, Item *pprune_cond)
  RANGE_OPT_PARAM  *range_par= &prune_param.range_param;

  prune_param.part_info= part_info;
  prune_param.part_iter.has_null_value= FALSE;

  init_sql_alloc(&alloc, thd->variables.range_alloc_block_size, 0);
  range_par->mem_root= &alloc;
  range_par->old_root= thd->mem_root;
@@ -2730,7 +2728,7 @@ int find_used_partitions(PART_PRUNE_PARAM *ppar, SEL_ARG *key_tree)
                                      key_tree->min_flag | key_tree->max_flag,
                                      &ppar->part_iter);
      if (!res)
        goto go_right; /* res=0 --> no satisfying partitions */
        goto go_right; /* res==0 --> no satisfying partitions */
      if (res == -1)
      {
        //get a full range iterator
Loading