Commit 6ccab8d4 authored by unknown's avatar unknown
Browse files

BUG#19055: There may exist a SEL_TREE objects with type==KEY and keys[i]==NULL for any i.

(for example, such objects can be returned from get_mm_parts() for "string_field = int_val).
Make find_used_partitions_imerge() to handle such SEL_TREE objects.


mysql-test/r/partition_pruning.result:
  BUG#19055: testcase
mysql-test/t/partition_pruning.test:
  BUG#19055: testcase
parent 14e1d69a
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -670,3 +670,11 @@ select * from t1 where a like 'n%';
a
na
drop table t1;
create table t1 (s1 varchar(15)) partition by key (s1);
select * from t1 where s1 = 0 or s1 is null;
s1
insert into t1 values ('aa'),('bb'),('0');
explain partitions select * 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	p0	ALL	NULL	NULL	NULL	NULL	3	Using where
drop table t1;
+9 −1
Original line number Diff line number Diff line
@@ -556,7 +556,7 @@ drop table t1;
# being fixed.

#
#BUG 17946 Like searches fail with partitioning
# BUG#17946 Like searches fail with partitioning
#
create table t1 (a char(32) primary key)
partition by key()
@@ -566,3 +566,11 @@ select * from t1;
select * from t1 where a like 'n%';
drop table t1;


# BUG#19055 Crashes for varchar_col=NUMBER or varchar_col IS NULL
create table t1 (s1 varchar(15)) partition by key (s1);
select * from t1 where s1 = 0 or s1 is null;
insert into t1 values ('aa'),('bb'),('0');
explain partitions select * from t1 where s1 = 0 or s1 is null;
drop table t1;
+9 −2
Original line number Diff line number Diff line
@@ -374,6 +374,12 @@ class SEL_TREE :public Sql_alloc
    keys_map.clear_all();
    bzero((char*) keys,sizeof(keys));
  }
  /*
    Note: there may exist SEL_TREE objects with sel_tree->type=KEY and
    keys[i]=0 for all i. (SergeyP: it is not clear whether there is any
    merit in range analyzer functions (e.g. get_mm_parts) returning a
    pointer to such SEL_TREE instead of NULL)
  */
  SEL_ARG *keys[MAX_KEY];
  key_map keys_map;        /* bitmask of non-NULL elements in keys */

@@ -2580,7 +2586,8 @@ int find_used_partitions_imerge(PART_PRUNE_PARAM *ppar, SEL_IMERGE *imerge)
    ppar->cur_part_fields= 0;
    ppar->cur_subpart_fields= 0;
    init_all_partitions_iterator(ppar->part_info, &ppar->part_iter);
    if (-1 == (res |= find_used_partitions(ppar, (*ptree)->keys[0])))
    SEL_ARG *key_tree= (*ptree)->keys[0];
    if (!key_tree || (-1 == (res |= find_used_partitions(ppar, key_tree))))
      return -1;
  }
  return res;