diff options
author | unknown <baker@bk-internal.mysql.com> | 2006-11-29 18:31:13 +0100 |
---|---|---|
committer | unknown <baker@bk-internal.mysql.com> | 2006-11-29 18:31:13 +0100 |
commit | 2477bd5a03a3f578f17d35c96d26d34f418878b8 (patch) | |
tree | 625bdbdf1243dc2c653f0fe023bde84cd3d54ba4 /sql/item_cmpfunc.cc | |
parent | 0ec590fab893e70d57d63bf5248a2224c43ec121 (diff) | |
parent | d6eb3627555bd3d782514a5983173bb1201c0ec6 (diff) | |
download | mariadb-git-2477bd5a03a3f578f17d35c96d26d34f418878b8.tar.gz |
Merge bk-internal.mysql.com:/data0/bk/mysql-5.1
into bk-internal.mysql.com:/data0/bk/mysql-5.1-arch
configure.in:
Auto merged
sql/field.cc:
Auto merged
sql/field.h:
Auto merged
sql/mysql_priv.h:
Auto merged
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r-- | sql/item_cmpfunc.cc | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index b252144ae2e..39c63e9a46a 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -833,9 +833,41 @@ longlong Item_in_optimizer::val_int() { DBUG_ASSERT(fixed == 1); cache->store(args[0]); + if (cache->null_value) { - null_value= 1; + if (((Item_in_subselect*)args[1])->is_top_level_item()) + { + /* + We're evaluating "NULL IN (SELECT ...)". The result can be NULL or + FALSE, and we can return one instead of another. Just return NULL. + */ + null_value= 1; + } + else + { + if (!((Item_in_subselect*)args[1])->is_correlated && + result_for_null_param != UNKNOWN) + { + /* Use cached value from previous execution */ + null_value= result_for_null_param; + } + else + { + /* + We're evaluating "NULL IN (SELECT ...)". The result is: + FALSE if SELECT produces an empty set, or + NULL otherwise. + We disable the predicates we've pushed down into subselect, run the + subselect and see if it has produced any rows. + */ + ((Item_in_subselect*)args[1])->enable_pushed_conds= FALSE; + longlong tmp= args[1]->val_bool_result(); + result_for_null_param= null_value= + !((Item_in_subselect*)args[1])->engine->no_rows(); + ((Item_in_subselect*)args[1])->enable_pushed_conds= TRUE; + } + } return 0; } bool tmp= args[1]->val_bool_result(); |