summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/func_in.result19
-rw-r--r--mysql-test/t/func_in.test21
-rw-r--r--sql/opt_range.cc2
3 files changed, 41 insertions, 1 deletions
diff --git a/mysql-test/r/func_in.result b/mysql-test/r/func_in.result
index fc56660ac62..210b0a9ef91 100644
--- a/mysql-test/r/func_in.result
+++ b/mysql-test/r/func_in.result
@@ -812,3 +812,22 @@ EXECUTE s;
1
DROP TABLE t1;
# End of 5.3 tests
+#
+# Start of 10.0 tests
+#
+#
+# MDEV-10020 InnoDB NOT IN Query Crash When One Item Is NULL
+#
+CREATE TABLE t1
+(
+a INT(11),
+b VARCHAR(10),
+KEY (b)
+);
+INSERT INTO t1 VALUES (1,'x'),(2,'y'),(3,'z');
+SELECT * FROM t1 WHERE b NOT IN (NULL, '', 'A');
+a b
+DROP TABLE t1;
+#
+# End of 10.0 tests
+#
diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test
index 1e695142d90..17736ac40c6 100644
--- a/mysql-test/t/func_in.test
+++ b/mysql-test/t/func_in.test
@@ -606,3 +606,24 @@ EXECUTE s;
DROP TABLE t1;
--echo # End of 5.3 tests
+
+--echo #
+--echo # Start of 10.0 tests
+--echo #
+
+--echo #
+--echo # MDEV-10020 InnoDB NOT IN Query Crash When One Item Is NULL
+--echo #
+CREATE TABLE t1
+(
+ a INT(11),
+ b VARCHAR(10),
+ KEY (b)
+);
+INSERT INTO t1 VALUES (1,'x'),(2,'y'),(3,'z');
+SELECT * FROM t1 WHERE b NOT IN (NULL, '', 'A');
+DROP TABLE t1;
+
+--echo #
+--echo # End of 10.0 tests
+--echo #
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index f051ed07a7e..ae5899d8de4 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -7730,7 +7730,7 @@ static SEL_TREE *get_func_mm_tree(RANGE_OPT_PARAM *param, Item_func *cond_func,
break;
}
SEL_TREE *tree2;
- for (; i < func->array->count; i++)
+ for (; i < func->array->used_count; i++)
{
if (func->array->compare_elems(i, i-1))
{