diff options
author | unknown <bell@sanja.is.com.ua> | 2002-12-26 01:28:59 +0200 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2002-12-26 01:28:59 +0200 |
commit | 1dfa625f7b2a0767ce458c47122093a8c2ecf664 (patch) | |
tree | 6a73d0cc2b8728ab821e54448c158fa784365acb /sql/item_subselect.cc | |
parent | da4d8e1b62edc5bc6f31d70279a619325ae69442 (diff) | |
download | mariadb-git-1dfa625f7b2a0767ce458c47122093a8c2ecf664.tar.gz |
support of subselect without FROM reducing (SCRUM)
fixed bug of calling setup_fields without correct lex->current_select pointer in mysql_derived
more correct creation of reference in Item_field::fix_field
mysql-test/r/subselect.result:
new explain with subselect reduced
mysql-test/t/subselect.test:
new explain with subselect reduced
sql/item.cc:
support of subselect without FROM reducing
more correct creation of reference in Item_field::fix_field
sql/item.h:
support of subselect without FROM reducing
sql/item_cmpfunc.cc:
support of subselect without FROM reducing
sql/item_cmpfunc.h:
support of subselect without FROM reducing
sql/item_func.cc:
support of subselect without FROM reducing
sql/item_func.h:
support of subselect without FROM reducing
sql/item_row.cc:
support of subselect without FROM reducing
sql/item_row.h:
support of subselect without FROM reducing
sql/item_strfunc.h:
fixed layout
support of subselect without FROM reducing
sql/item_subselect.cc:
support of subselect without FROM reducing
sql/item_subselect.h:
support of subselect without FROM reducing
sql/mysql_priv.h:
reference in Item_field::fix_field related changes
sql/sql_base.cc:
reference in Item_field::fix_field related changes
sql/sql_derived.cc:
fixed bug of calling setup_fields without correct lex->current_select pointer
Diffstat (limited to 'sql/item_subselect.cc')
-rw-r--r-- | sql/item_subselect.cc | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 65c942a75ce..fe38c458495 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -146,6 +146,54 @@ void Item_singlerow_subselect::reset() value->null_value= 1; } +void Item_singlerow_subselect::select_transformer(st_select_lex_unit *unit) +{ + SELECT_LEX *select_lex= unit->first_select(); + + if (!select_lex->next_select() && !select_lex->table_list.elements && + select_lex->item_list.elements == 1) + { + + have_to_be_excluded= 1; + THD *thd= current_thd; + if (thd->lex.describe) + { + char warn_buff[MYSQL_ERRMSG_SIZE]; + sprintf(warn_buff, ER(ER_SELECT_REDUCED), select_lex->select_number); + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, + ER_SELECT_REDUCED, warn_buff); + } + substitution= select_lex->item_list.head(); + substitution->set_outer_resolving(); + if (substitution->type() == FIELD_ITEM || + substitution->type() == REF_ITEM) + name= substitution->name; // Save name for correct resolving + + if (select_lex->where || select_lex->having) + { + Item *cond; + if (!select_lex->having) + cond= select_lex->where; + else if (!select_lex->where) + cond= select_lex->having; + else + if (!(cond= new Item_cond_and(select_lex->having, select_lex->where))) + { + my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0)); + thd->fatal_error= 1; + return; + } + if (!(substitution= new Item_func_if(cond, substitution, + new Item_null()))) + { + my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0)); + thd->fatal_error= 1; + return; + } + } + } +} + void Item_singlerow_subselect::store(uint i, Item *item) { row[i]->store(item); |