diff options
author | unknown <bell@laptop.sanja.is.com.ua> | 2003-10-02 22:19:41 +0300 |
---|---|---|
committer | unknown <bell@laptop.sanja.is.com.ua> | 2003-10-02 22:19:41 +0300 |
commit | 45b96bb8af45dca5e179270fcf44baf9f387a3ff (patch) | |
tree | 3af5a1fcf40932259ec303a5683a4ff8984036dc /sql/item_subselect.cc | |
parent | dcf02aa57118465df1b808cee15dfe1863aeabb1 (diff) | |
download | mariadb-git-45b96bb8af45dca5e179270fcf44baf9f387a3ff.tar.gz |
thd pointer storing moved to fix_fields() (WL#1254) (SCRUM)
sql/item_subselect.cc:
thd pointer storing moved to fix_fields()
sql/item_subselect.h:
thd pointer storing moved to fix_fields()
sql/sql_yacc.yy:
thd pointer storing moved to fix_fields()
Diffstat (limited to 'sql/item_subselect.cc')
-rw-r--r-- | sql/item_subselect.cc | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 7c4fe8621a7..8a281809d9a 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -46,7 +46,7 @@ Item_subselect::Item_subselect(): null_value= 1; } -void Item_subselect::init(THD *thd, st_select_lex *select_lex, +void Item_subselect::init(st_select_lex *select_lex, select_subselect *result) { @@ -54,11 +54,10 @@ void Item_subselect::init(THD *thd, st_select_lex *select_lex, DBUG_PRINT("subs", ("select_lex 0x%xl", (ulong) select_lex)); if (select_lex->next_select()) - engine= new subselect_union_engine(thd, select_lex->master_unit(), result, + engine= new subselect_union_engine(select_lex->master_unit(), result, this); else - engine= new subselect_single_select_engine(thd, select_lex, result, - this); + engine= new subselect_single_select_engine(select_lex, result, this); DBUG_VOID_RETURN; } @@ -78,7 +77,7 @@ Item_subselect::select_transformer(JOIN *join) bool Item_subselect::fix_fields(THD *thd_param, TABLE_LIST *tables, Item **ref) { - thd= thd_param; + engine->set_thd((thd= thd_param)); char const *save_where= thd->where; int res= engine->prepare(); @@ -151,12 +150,11 @@ inline table_map Item_subselect::used_tables() const (engine->uncacheable() ? RAND_TABLE_BIT : 0L)); } -Item_singlerow_subselect::Item_singlerow_subselect(THD *thd, - st_select_lex *select_lex): +Item_singlerow_subselect::Item_singlerow_subselect(st_select_lex *select_lex): Item_subselect(), value(0) { DBUG_ENTER("Item_singlerow_subselect::Item_singlerow_subselect"); - init(thd, select_lex, new select_singlerow_subselect(this)); + init(select_lex, new select_singlerow_subselect(this)); max_columns= 1; maybe_null= 1; max_columns= UINT_MAX; @@ -325,12 +323,11 @@ String *Item_singlerow_subselect::val_str (String *str) } } -Item_exists_subselect::Item_exists_subselect(THD *thd, - st_select_lex *select_lex): +Item_exists_subselect::Item_exists_subselect(st_select_lex *select_lex): Item_subselect() { DBUG_ENTER("Item_exists_subselect::Item_exists_subselect"); - init(thd, select_lex, new select_exists_subselect(this)); + init(select_lex, new select_exists_subselect(this)); max_columns= UINT_MAX; null_value= 0; //can't be NULL maybe_null= 0; //can't be NULL @@ -355,13 +352,13 @@ bool Item_in_subselect::test_limit(SELECT_LEX_UNIT *unit) return(0); } -Item_in_subselect::Item_in_subselect(THD *thd, Item * left_exp, +Item_in_subselect::Item_in_subselect(Item * left_exp, st_select_lex *select_lex): Item_exists_subselect() { DBUG_ENTER("Item_in_subselect::Item_in_subselect"); left_expr= left_exp; - init(thd, select_lex, new select_exists_subselect(this)); + init(select_lex, new select_exists_subselect(this)); max_columns= UINT_MAX; maybe_null= 1; abort_on_null= 0; @@ -371,7 +368,7 @@ Item_in_subselect::Item_in_subselect(THD *thd, Item * left_exp, DBUG_VOID_RETURN; } -Item_allany_subselect::Item_allany_subselect(THD *thd, Item * left_exp, +Item_allany_subselect::Item_allany_subselect(Item * left_exp, compare_func_creator fn, st_select_lex *select_lex): Item_in_subselect() @@ -379,7 +376,7 @@ Item_allany_subselect::Item_allany_subselect(THD *thd, Item * left_exp, DBUG_ENTER("Item_in_subselect::Item_in_subselect"); left_expr= left_exp; func= fn; - init(thd, select_lex, new select_exists_subselect(this)); + init(select_lex, new select_exists_subselect(this)); max_columns= 1; abort_on_null= 0; reset(); @@ -708,12 +705,12 @@ Item_allany_subselect::select_transformer(JOIN *join) return single_value_transformer(join, left_expr, func); } -subselect_single_select_engine::subselect_single_select_engine(THD *thd, - st_select_lex *select, - select_subselect *result, - Item_subselect *item): - subselect_engine(thd, item, result), - prepared(0), optimized(0), executed(0) +subselect_single_select_engine:: +subselect_single_select_engine(st_select_lex *select, + select_subselect *result, + Item_subselect *item) + :subselect_engine(item, result), + prepared(0), optimized(0), executed(0), join(0) { select_lex= select; SELECT_LEX_UNIT *unit= select_lex->master_unit(); @@ -724,24 +721,19 @@ subselect_single_select_engine::subselect_single_select_engine(THD *thd, unit->select_limit_cnt= HA_POS_ERROR; // no limit if (unit->select_limit_cnt == HA_POS_ERROR) select_lex->options&= ~OPTION_FOUND_ROWS; - join= new JOIN(thd, select_lex->item_list, select_lex->options, result); - if (!join || !result) - //out of memory - thd->fatal_error(); unit->item= item; this->select_lex= select_lex; } -subselect_union_engine::subselect_union_engine(THD *thd, - st_select_lex_unit *u, +subselect_union_engine::subselect_union_engine(st_select_lex_unit *u, select_subselect *result, - Item_subselect *item): - subselect_engine(thd, item, result) + Item_subselect *item) + :subselect_engine(item, result) { unit= u; if (!result) //out of memory - thd->fatal_error(); + current_thd->fatal_error(); unit->item= item; } @@ -749,6 +741,13 @@ int subselect_single_select_engine::prepare() { if (prepared) return 0; + join= new JOIN(thd, select_lex->item_list, select_lex->options, result); + if (!join || !result) + { + //out of memory + thd->fatal_error(); + return 1; + } prepared= 1; SELECT_LEX *save_select= thd->lex.current_select; thd->lex.current_select= select_lex; |