diff options
author | Sergey Glukhov <Sergey.Glukhov@sun.com> | 2010-02-26 15:39:25 +0400 |
---|---|---|
committer | Sergey Glukhov <Sergey.Glukhov@sun.com> | 2010-02-26 15:39:25 +0400 |
commit | 9245ed4a12ce25214d60f93cbf20882cb2b78741 (patch) | |
tree | 86ad600c103f19ca2727b788b2ae1cd8df029f49 /sql/item_cmpfunc.h | |
parent | 936ed6ca86633a91976fd6fcd931683ec007f440 (diff) | |
download | mariadb-git-9245ed4a12ce25214d60f93cbf20882cb2b78741.tar.gz |
Bug#50995 Having clause on subquery result produces incorrect results.
The problem is that cond->fix_fields(thd, 0) breaks
condition(cuts off 'having'). The reason of that is
that NULL valued Item pointer is present in the
middle of Item list and it breaks the Item processing
loop.
mysql-test/r/having.result:
test case
mysql-test/t/having.test:
test case
sql/item_cmpfunc.h:
added ASSERT to make sure that we do not add NULL valued Item pointer
sql/sql_select.cc:
skip adding an item to condition if Item pointer is NULL.
skip adding a list to condition if this list is empty.
Diffstat (limited to 'sql/item_cmpfunc.h')
-rw-r--r-- | sql/item_cmpfunc.h | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 38025ff0af5..425f54fb079 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -1474,9 +1474,21 @@ public: Item_cond(THD *thd, Item_cond *item); Item_cond(List<Item> &nlist) :Item_bool_func(), list(nlist), abort_on_null(0) {} - bool add(Item *item) { return list.push_back(item); } - bool add_at_head(Item *item) { return list.push_front(item); } - void add_at_head(List<Item> *nlist) { list.prepand(nlist); } + bool add(Item *item) + { + DBUG_ASSERT(item); + return list.push_back(item); + } + bool add_at_head(Item *item) + { + DBUG_ASSERT(item); + return list.push_front(item); + } + void add_at_head(List<Item> *nlist) + { + DBUG_ASSERT(nlist->elements); + list.prepand(nlist); + } bool fix_fields(THD *, Item **ref); enum Type type() const { return COND_ITEM; } |