From 73be194f966428646ed13eea0c7b73034cff9f8b Mon Sep 17 00:00:00 2001 From: "igor@rurik.mysql.com" <> Date: Mon, 8 Aug 2005 16:51:12 -0700 Subject: [PATCH] subselect.test, subselect.result: Added a test case for bug #12392. item_cmpfunc.cc: Fixed bug #12392. Missing handling of rows containing NULL components when evaluating IN predicates caused a crash. --- mysql-test/r/subselect.result | 6 ++++++ mysql-test/t/subselect.test | 11 +++++++++++ sql/item_cmpfunc.cc | 2 ++ 3 files changed, 19 insertions(+) diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 25d9a39705d..eaacf5ba2d0 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -2742,3 +2742,9 @@ one two flag 5 6 N 7 8 N DROP TABLE t1,t2; +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); +a b +aaa aaa +DROP TABLE t1; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 0b4791b0023..951dc31006e 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -1770,4 +1770,15 @@ SELECT * FROM t1 DROP TABLE t1,t2; +# +# Bug #12392: where cond with IN predicate for rows and NULL values in table +# + +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); + +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); + +DROP TABLE t1; + # End of 4.1 tests diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index f24638d1a93..9146b3c3b9e 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1551,6 +1551,8 @@ in_row::~in_row() byte *in_row::get_value(Item *item) { tmp.store_value(item); + if (item->is_null()) + return 0; return (byte *)&tmp; }