diff options
author | unknown <holyfoot/hf@mysql.com/hfmain.(none)> | 2007-01-03 11:17:00 +0400 |
---|---|---|
committer | unknown <holyfoot/hf@mysql.com/hfmain.(none)> | 2007-01-03 11:17:00 +0400 |
commit | 8e0eea0d336fe259a753ebc380bc85cf31b29599 (patch) | |
tree | 3c8c3c2e6a5a481679add72c5e84eb00976f6cea /sql | |
parent | c81140f5a18602844d2419c49b326cf0fddea5e7 (diff) | |
parent | 13515c01d978f67847b5ac22ec82b111b2373197 (diff) | |
download | mariadb-git-8e0eea0d336fe259a753ebc380bc85cf31b29599.tar.gz |
Merge mysql.com:/d2/hf/common/my41-common
into mysql.com:/d2/hf/opt/my41-opt
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 cd1f8f83821..20a092d7607 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -350,6 +350,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 optimisation for prepare statement, because we do not rollback this changes @@ -374,8 +375,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; @@ -1796,6 +1795,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 SINOPSYS diff --git a/sql/item_subselect.h b/sql/item_subselect.h index 7b064bfe92c..539dcc5676a 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -301,7 +301,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; @@ -335,6 +335,7 @@ public: void print (String *str); int change_item(Item_subselect *si, select_subselect *result); bool no_tables(); + bool may_be_null(); }; |