From a8f639fccc19ef80d67c52e698bf6366fdcf6f94 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 20 Apr 2007 15:14:09 +0500 Subject: Bug#27704: incorrect comparison of rows with NULL components Support for NULL components was incomplete for row comparison, fixed. Added support for abort_on_null at compare_row() like in 5.x sql/item_cmpfunc.h: Bug#27704: incorrect comparison of rows with NULL components Added support for abort_on_null at Item_bool_func2 like in 5.x sql/item_cmpfunc.cc: Bug#27704: incorrect comparison of rows with NULL components Support for NULL components was incomplete for row comparison, fixed. Added support for abort_on_null at compare_row() like in 5.x mysql-test/t/row.test: Test case updated for Bug#27704 (incorrect comparison of rows with NULL components) mysql-test/r/row.result: Test case updated for Bug#27704 (incorrect comparison of rows with NULL components) mysql-test/r/subselect.result: Test case updated for Bug#27704 (incorrect comparison of rows with NULL components) --- mysql-test/r/row.result | 99 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 1 deletion(-) (limited to 'mysql-test/r/row.result') diff --git a/mysql-test/r/row.result b/mysql-test/r/row.result index 1c1c4809f36..6169619712b 100644 --- a/mysql-test/r/row.result +++ b/mysql-test/r/row.result @@ -53,7 +53,7 @@ SELECT (1,2,3)=(1,NULL,3); NULL SELECT (1,2,3)=(1,NULL,0); (1,2,3)=(1,NULL,0) -NULL +0 SELECT ROW(1,2,3)=ROW(1,2,3); ROW(1,2,3)=ROW(1,2,3) 1 @@ -188,3 +188,100 @@ SELECT ROW(2,1) IN (ROW(21,2),ROW(ROW(1,1,3),0)); ERROR 21000: Operand should contain 1 column(s) SELECT ROW(2,1) IN (ROW(ROW(1,1,3),0),ROW(21,2)); ERROR 21000: Operand should contain 1 column(s) +CREATE TABLE t1(a int, b int, c int); +INSERT INTO t1 VALUES (1, 2, 3), +(NULL, 2, 3 ), (1, NULL, 3 ), (1, 2, NULL), +(NULL, 2, 3+1), (1, NULL, 3+1), (1, 2+1, NULL), +(NULL, 2, 3-1), (1, NULL, 3-1), (1, 2-1, NULL); +SELECT (1,2,3) = (1, NULL, 3); +(1,2,3) = (1, NULL, 3) +NULL +SELECT (1,2,3) = (1+1, NULL, 3); +(1,2,3) = (1+1, NULL, 3) +0 +SELECT (1,2,3) = (1, NULL, 3+1); +(1,2,3) = (1, NULL, 3+1) +0 +SELECT * FROM t1 WHERE (a,b,c) = (1,2,3); +a b c +1 2 3 +SELECT (1,2,3) <> (1, NULL, 3); +(1,2,3) <> (1, NULL, 3) +NULL +SELECT (1,2,3) <> (1+1, NULL, 3); +(1,2,3) <> (1+1, NULL, 3) +1 +SELECT (1,2,3) <> (1, NULL, 3+1); +(1,2,3) <> (1, NULL, 3+1) +1 +SELECT * FROM t1 WHERE (a,b,c) <> (1,2,3); +a b c +NULL 2 4 +1 NULL 4 +1 3 NULL +NULL 2 2 +1 NULL 2 +1 1 NULL +SELECT (1,2,3) < (NULL, 2, 3); +(1,2,3) < (NULL, 2, 3) +NULL +SELECT (1,2,3) < (1, NULL, 3); +(1,2,3) < (1, NULL, 3) +NULL +SELECT (1,2,3) < (1-1, NULL, 3); +(1,2,3) < (1-1, NULL, 3) +0 +SELECT (1,2,3) < (1+1, NULL, 3); +(1,2,3) < (1+1, NULL, 3) +1 +SELECT * FROM t1 WHERE (a,b,c) < (1,2,3); +a b c +1 1 NULL +SELECT (1,2,3) <= (NULL, 2, 3); +(1,2,3) <= (NULL, 2, 3) +NULL +SELECT (1,2,3) <= (1, NULL, 3); +(1,2,3) <= (1, NULL, 3) +NULL +SELECT (1,2,3) <= (1-1, NULL, 3); +(1,2,3) <= (1-1, NULL, 3) +0 +SELECT (1,2,3) <= (1+1, NULL, 3); +(1,2,3) <= (1+1, NULL, 3) +1 +SELECT * FROM t1 WHERE (a,b,c) <= (1,2,3); +a b c +1 2 3 +1 1 NULL +SELECT (1,2,3) > (NULL, 2, 3); +(1,2,3) > (NULL, 2, 3) +NULL +SELECT (1,2,3) > (1, NULL, 3); +(1,2,3) > (1, NULL, 3) +NULL +SELECT (1,2,3) > (1-1, NULL, 3); +(1,2,3) > (1-1, NULL, 3) +1 +SELECT (1,2,3) > (1+1, NULL, 3); +(1,2,3) > (1+1, NULL, 3) +0 +SELECT * FROM t1 WHERE (a,b,c) > (1,2,3); +a b c +1 3 NULL +SELECT (1,2,3) >= (NULL, 2, 3); +(1,2,3) >= (NULL, 2, 3) +NULL +SELECT (1,2,3) >= (1, NULL, 3); +(1,2,3) >= (1, NULL, 3) +NULL +SELECT (1,2,3) >= (1-1, NULL, 3); +(1,2,3) >= (1-1, NULL, 3) +1 +SELECT (1,2,3) >= (1+1, NULL, 3); +(1,2,3) >= (1+1, NULL, 3) +0 +SELECT * FROM t1 WHERE (a,b,c) >= (1,2,3); +a b c +1 2 3 +1 3 NULL +DROP TABLE t1; -- cgit v1.2.1