diff options
author | unknown <sergefp@mysql.com> | 2006-06-04 17:17:37 +0400 |
---|---|---|
committer | unknown <sergefp@mysql.com> | 2006-06-04 17:17:37 +0400 |
commit | 6ccab8d4deabce37b7a975f56dd1232a2ecb99e6 (patch) | |
tree | c64fda04df90c318137a856076a32be88a19a16f | |
parent | 14e1d69aeaa09075fe3ec609d5ccdcf899508d7d (diff) | |
download | mariadb-git-6ccab8d4deabce37b7a975f56dd1232a2ecb99e6.tar.gz |
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
-rw-r--r-- | mysql-test/r/partition_pruning.result | 8 | ||||
-rw-r--r-- | mysql-test/t/partition_pruning.test | 10 | ||||
-rw-r--r-- | sql/opt_range.cc | 11 |
3 files changed, 26 insertions, 3 deletions
diff --git a/mysql-test/r/partition_pruning.result b/mysql-test/r/partition_pruning.result index 405cc3e6e25..62c7a962ba1 100644 --- a/mysql-test/r/partition_pruning.result +++ b/mysql-test/r/partition_pruning.result @@ -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; diff --git a/mysql-test/t/partition_pruning.test b/mysql-test/t/partition_pruning.test index 0c922392d32..3e9a59d1069 100644 --- a/mysql-test/t/partition_pruning.test +++ b/mysql-test/t/partition_pruning.test @@ -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; + diff --git a/sql/opt_range.cc b/sql/opt_range.cc index ffaf3fad6c8..8bcc0f42cc5 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -374,6 +374,12 @@ public: 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; @@ -5104,7 +5111,7 @@ get_mm_parts(RANGE_OPT_PARAM *param, COND *cond_func, Field *field, tree->keys_map.set_bit(key_part->key); } } - + DBUG_RETURN(tree); } |