summaryrefslogtreecommitdiff
path: root/sql/item_subselect.cc
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2003-04-23 00:01:19 +0300
committerunknown <bell@sanja.is.com.ua>2003-04-23 00:01:19 +0300
commit06017a0db0fc6f67e5e0698d285532aa3cca0180 (patch)
treeff2080060461e268ec91b47246ea6667fd8d2ba1 /sql/item_subselect.cc
parent1db8654191c18def869c03d246e75be704411d03 (diff)
downloadmariadb-git-06017a0db0fc6f67e5e0698d285532aa3cca0180.tar.gz
fixed bug 185 (constant IN (SELECT field ...) do not return NULL correctly)
mysql-test/r/subselect.result: new test results test of bug 185 mysql-test/t/subselect.test: test of bug 185 sql/item.h: new method sql/item_cmpfunc.cc: new Item to control NULL value in HAVING clouse sql/item_cmpfunc.h: new Item to control NULL value in HAVING clouse sql/item_subselect.cc: if IN was rewrited through WHERE thien it will be rewrited in following way: WHERE left_expr=item or is null(item) heving is_not_null_test(item) sql/item_subselect.h: Item_is_not_null_test can change was_null flag sql/sql_select.cc: some layout fix
Diffstat (limited to 'sql/item_subselect.cc')
-rw-r--r--sql/item_subselect.cc28
1 files changed, 25 insertions, 3 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 76451680b59..6c0b799b4de 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -508,9 +508,31 @@ void Item_in_subselect::single_value_transformer(THD *thd,
sl->item_list.push_back(new Item_int("Not_used", (longlong) 1, 21));
if (sl->table_list.elements)
{
- item= (*func)(expr, new Item_asterisk_remover(this, item,
- (char *)"<no matter>",
- (char*)"<result>"));
+ Item *having= item, *isnull= item;
+ if (item->type() == Item::FIELD_ITEM &&
+ ((Item_field*) item)->field_name[0] == '*')
+ {
+ Item_asterisk_remover *remover;
+ item= remover= new Item_asterisk_remover(this, item,
+ (char*)"<no matter>",
+ (char*)"<result>");
+ having=
+ new Item_is_not_null_test(this,
+ new Item_ref(remover->storage(),
+ (char*)"<no matter>",
+ (char*)"<null test>"));
+ isnull=
+ new Item_is_not_null_test(this,
+ new Item_ref(remover->storage(),
+ (char*)"<no matter>",
+ (char*)"<null test>"));
+ }
+ having= new Item_is_not_null_test(this, having);
+ sl->having= (sl->having ?
+ new Item_cond_and(having, sl->having) :
+ having);
+ item= new Item_cond_or((*func)(expr, item),
+ new Item_func_isnull(isnull));
sl->where= and_items(sl->where, item);
}
else