summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <kaa@polly.local>2006-11-27 19:12:10 +0300
committerunknown <kaa@polly.local>2006-11-27 19:12:10 +0300
commit2e758a7c23fda7fada49d0cca547680cf26cafad (patch)
tree23cfd1de40206e90e471f21d6457c7155943a73f
parent154c6e06775d6e644fd4e5f863104ab566fc4a68 (diff)
downloadmariadb-git-2e758a7c23fda7fada49d0cca547680cf26cafad.tar.gz
Fix for bug #24261 "crash when WHERE contains NOT IN ('<negative value>') for unsigned column type"
When calculating a SEL_TREE for the "c_{i-1} < X < c_i" interval, check if the tree returned for the "-inf < X < c_0" interval is NULL mysql-test/r/func_in.result: Added testcase for bug #24261 "crash when WHERE contains NOT IN ('<negative value>') for unsigned column type" mysql-test/t/func_in.test: Added testcase for bug #24261 "crash when WHERE contains NOT IN ('<negative value>') for unsigned column type" sql/opt_range.cc: When calculating a SEL_TREE for the "c_{i-1} < X < c_i" interval, check if the tree returned for the "-inf < X < c_0" interval is NULL
-rw-r--r--mysql-test/r/func_in.result4
-rw-r--r--mysql-test/t/func_in.test7
-rw-r--r--sql/opt_range.cc3
3 files changed, 13 insertions, 1 deletions
diff --git a/mysql-test/r/func_in.result b/mysql-test/r/func_in.result
index e38e2624e19..60bde9555e4 100644
--- a/mysql-test/r/func_in.result
+++ b/mysql-test/r/func_in.result
@@ -342,4 +342,8 @@ select some_id from t1 where some_id not in(-4,-1,3423534,2342342);
some_id
1
2
+select some_id from t1 where some_id not in('-1', '0');
+some_id
+1
+2
drop table t1;
diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test
index 8ddf1fbe314..0153da12b53 100644
--- a/mysql-test/t/func_in.test
+++ b/mysql-test/t/func_in.test
@@ -231,4 +231,11 @@ insert into t1 values (1),(2);
select some_id from t1 where some_id not in(2,-1);
select some_id from t1 where some_id not in(-4,-1,-4);
select some_id from t1 where some_id not in(-4,-1,3423534,2342342);
+
+#
+# BUG#24261: crash when WHERE contains NOT IN ('<negative value>') for unsigned column type
+#
+
+select some_id from t1 where some_id not in('-1', '0');
+
drop table t1;
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 96239315026..efef9361bda 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -3703,7 +3703,8 @@ static SEL_TREE *get_func_mm_tree(PARAM *param, Item_func *cond_func,
for (uint idx= 0; idx < param->keys; idx++)
{
SEL_ARG *new_interval, *last_val;
- if (((new_interval= tree2->keys[idx])) &&
+ if (((new_interval= tree2->keys[idx])) &&
+ (tree->keys[idx]) &&
((last_val= tree->keys[idx]->last())))
{
new_interval->min_value= last_val->max_value;