diff options
author | unknown <igor@olga.mysql.com> | 2006-12-12 11:53:09 -0800 |
---|---|---|
committer | unknown <igor@olga.mysql.com> | 2006-12-12 11:53:09 -0800 |
commit | 22192d083ace932c5ee2c29b550012648ebf245e (patch) | |
tree | 68fa80dd5079e1ad36b1d2265cf1e000ebcd53fc /sql | |
parent | 4108725364e4271ceedea644875e1abac00c2dc4 (diff) | |
parent | 33446269e18d0506802ca89df30f89e3e5978154 (diff) | |
download | mariadb-git-22192d083ace932c5ee2c29b550012648ebf245e.tar.gz |
Merge olga.mysql.com:/home/igor/mysql-4.1-opt
into olga.mysql.com:/home/igor/mysql-5.0-opt
sql/item_subselect.cc:
Auto merged
mysql-test/r/subselect.result:
Manual merge
mysql-test/t/subselect.test:
Manual merge
sql/item_subselect.h:
Manual merge
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_subselect.cc | 19 | ||||
-rw-r--r-- | sql/item_subselect.h | 3 |
2 files changed, 19 insertions, 3 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index bffecb3c84c..4910fff4c4e 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -349,6 +349,7 @@ Item_singlerow_subselect::select_transformer(JOIN *join) */ !(select_lex->item_list.head()->type() == FIELD_ITEM || select_lex->item_list.head()->type() == REF_ITEM) && + !join->conds && !join->having && /* switch off this optimization for prepare statement, because we do not rollback this changes @@ -373,8 +374,6 @@ Item_singlerow_subselect::select_transformer(JOIN *join) */ substitution->walk(&Item::remove_dependence_processor, (byte *) select_lex->outer_select()); - /* SELECT without FROM clause can't have WHERE or HAVING clause */ - DBUG_ASSERT(join->conds == 0 && join->having == 0); return RES_REDUCE; } return RES_OK; @@ -2278,6 +2277,22 @@ bool subselect_single_select_engine::no_tables() /* + Check statically whether the subquery can return NULL + + SINOPSYS + subselect_single_select_engine::may_be_null() + + RETURN + FALSE can guarantee that the subquery never return NULL + TRUE otherwise +*/ +bool subselect_single_select_engine::may_be_null() +{ + return ((no_tables() && !join->conds && !join->having) ? maybe_null : 1); +} + + +/* Report about presence of tables in subquery SYNOPSIS diff --git a/sql/item_subselect.h b/sql/item_subselect.h index 35ded79b75d..e9edb157f54 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -363,7 +363,7 @@ public: enum Item_result type() { return res_type; } enum_field_types field_type() { return res_field_type; } virtual void exclude()= 0; - bool may_be_null() { return maybe_null; }; + virtual bool may_be_null() { return maybe_null; }; virtual table_map upper_select_const_tables()= 0; static table_map calc_const_tables(TABLE_LIST *); virtual void print(String *str)= 0; @@ -400,6 +400,7 @@ public: void print (String *str); bool change_result(Item_subselect *si, select_subselect *result); bool no_tables(); + bool may_be_null(); bool is_executed() const { return executed; } bool no_rows(); }; |