summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.cc
diff options
context:
space:
mode:
authorAlexey Kopytov <Alexey.Kopytov@Sun.com>2010-09-09 16:46:13 +0400
committerAlexey Kopytov <Alexey.Kopytov@Sun.com>2010-09-09 16:46:13 +0400
commit453107bc561338e0764443561a11d05dbe6486ee (patch)
tree233d8e7523dab779a2fc1a184a996a82ddd452fd /sql/item_cmpfunc.cc
parent8822ecff2dea2e83fdad84d7a9307e8aa5905bce (diff)
downloadmariadb-git-453107bc561338e0764443561a11d05dbe6486ee.tar.gz
Bug #54190: Comparison to row subquery produces incorrect
result Row subqueries producing no rows were not handled as UNKNOWN values in row comparison expressions. That was a result of the following two problems: 1. Item_singlerow_subselect did not mark the resulting row value as NULL/UNKNOWN when no rows were produced. 2. Arg_comparator::compare_row() did not take into account that a whole argument may be NULL rather than just individual scalar values. Before bug#34384 was fixed, the above problems were hidden because an uninitialized (i.e. without any stored value) cached object would appear as NULL for scalar values in a row subquery returning an empty result. After the fix Arg_comparator::compare_row() would try to evaluate uninitialized cached objects. Fixed by removing the aforementioned problems. mysql-test/r/row.result: Added a test case for bug #54190. mysql-test/r/subselect.result: Updated the result for a test relying on wrong behavior. mysql-test/t/row.test: Added a test case for bug #54190. sql/item_cmpfunc.cc: If either of the argument rows is NULL, return NULL as the result of comparison. sql/item_subselect.cc: Adjust null_value for Item_singlerow_subselect depending on whether a row has been produced by the row subquery.
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r--sql/item_cmpfunc.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index fe4616f64d7..b2ed2df0f45 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -1583,6 +1583,13 @@ int Arg_comparator::compare_row()
bool was_null= 0;
(*a)->bring_value();
(*b)->bring_value();
+
+ if ((*a)->null_value || (*b)->null_value)
+ {
+ owner->null_value= 1;
+ return -1;
+ }
+
uint n= (*a)->cols();
for (uint i= 0; i<n; i++)
{