summaryrefslogtreecommitdiff
path: root/sql/item_subselect.cc
diff options
context:
space:
mode:
authorunknown <timour@askmonty.org>2012-05-22 15:22:55 +0300
committerunknown <timour@askmonty.org>2012-05-22 15:22:55 +0300
commit02bdc608b5599663b55a79bc9eddbd91dc06ee2a (patch)
tree75885467cf3939b837c1bbaa05eabd74367f0910 /sql/item_subselect.cc
parentb87ccfdfbc0a08c7cb93c41f4e36c07c6ff40b00 (diff)
downloadmariadb-git-02bdc608b5599663b55a79bc9eddbd91dc06ee2a.tar.gz
Fix bug lp:1002079
Analysis: The optimizer detects an empty result through constant table optimization. Then it calls return_zero_rows(), which in turns calls inderctly Item_maxmin_subselect::no_rows_in_result(). The latter method set "value=0", however "value" is pointer to Item_cache, and not just an integer value. All of the Item_[maxmin | singlerow]_subselect::val_XXX methods does: if (forced_const) return value->val_real(); which of course crashes when value is a NULL pointer. Solution: When the optimizer discovers an empty result set, set Item_singlerow_subselect::value to a FALSE constant Item instead of NULL.
Diffstat (limited to 'sql/item_subselect.cc')
-rw-r--r--sql/item_subselect.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 9d7edda8eb5..cae1a9f7541 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -892,13 +892,21 @@ void Item_maxmin_subselect::print(String *str, enum_query_type query_type)
void Item_maxmin_subselect::no_rows_in_result()
{
- value= 0;
+ value= Item_cache::get_cache(new Item_null());
null_value= 0;
was_values= 0;
make_const();
}
+void Item_singlerow_subselect::no_rows_in_result()
+{
+ value= Item_cache::get_cache(new Item_null());
+ reset();
+ make_const();
+}
+
+
void Item_singlerow_subselect::reset()
{
Item_subselect::reset();