#include <item_subselect.h>
Inheritance diagram for Item_subselect:


Definition at line 32 of file item_subselect.h.
Definition at line 64 of file item_subselect.h.
00064 {UNKNOWN_SUBS, SINGLEROW_SUBS, 00065 EXISTS_SUBS, IN_SUBS, ALL_SUBS, ANY_SUBS};
| Item_subselect::Item_subselect | ( | ) |
Definition at line 37 of file item_subselect.cc.
References Item::null_value, reset(), and Item::with_subselect.
00037 : 00038 Item_result_field(), value_assigned(0), thd(0), substitution(0), 00039 engine(0), old_engine(0), used_tables_cache(0), have_to_be_excluded(0), 00040 const_item_cache(1), engine_changed(0), changed(0) 00041 { 00042 with_subselect= 1; 00043 reset(); 00044 /* 00045 item value is NULL if select_subselect not changed this value 00046 (i.e. some rows will be found returned) 00047 */ 00048 null_value= 1; 00049 }
Here is the call graph for this function:

| Item_subselect::~Item_subselect | ( | ) |
Definition at line 121 of file item_subselect.cc.
References engine.
00122 { 00123 delete engine; 00124 }
| void Item_subselect::assigned | ( | bool | a | ) | [inline] |
Definition at line 87 of file item_subselect.h.
References value_assigned.
00087 { value_assigned= a; }
| bool Item_subselect::assigned | ( | ) | [inline] |
Definition at line 86 of file item_subselect.h.
References value_assigned.
Referenced by subselect_single_select_engine::exec().
00086 { return value_assigned; }
Here is the caller graph for this function:

| bool Item_subselect::change_engine | ( | subselect_engine * | eng | ) | [inline] |
Definition at line 105 of file item_subselect.h.
References engine, engine_changed, and old_engine.
00106 { 00107 old_engine= engine; 00108 engine= eng; 00109 engine_changed= 1; 00110 return eng == 0; 00111 }
| void Item_subselect::cleanup | ( | ) | [virtual] |
Reimplemented from Item_result_field.
Reimplemented in Item_singlerow_subselect, and Item_maxmin_subselect.
Definition at line 95 of file item_subselect.cc.
References subselect_engine::cleanup(), Item_result_field::cleanup(), DBUG_ENTER, DBUG_VOID_RETURN, engine, old_engine, reset(), and value_assigned.
Referenced by Item_singlerow_subselect::cleanup().
00096 { 00097 DBUG_ENTER("Item_subselect::cleanup"); 00098 Item_result_field::cleanup(); 00099 if (old_engine) 00100 { 00101 if (engine) 00102 engine->cleanup(); 00103 engine= old_engine; 00104 old_engine= 0; 00105 } 00106 if (engine) 00107 engine->cleanup(); 00108 reset(); 00109 value_assigned= 0; 00110 DBUG_VOID_RETURN; 00111 }
Here is the call graph for this function:

Here is the caller graph for this function:

| bool Item_subselect::const_item | ( | ) | const [virtual] |
Reimplemented from Item.
Definition at line 270 of file item_subselect.cc.
References const_item_cache.
Referenced by get_tmp_table_item().
00271 { 00272 return const_item_cache; 00273 }
Here is the caller graph for this function:

| bool Item_subselect::exec | ( | ) | [virtual] |
Definition at line 238 of file item_subselect.cc.
References engine, engine_changed, and subselect_engine::exec().
Referenced by Item_singlerow_subselect::bring_value(), Item_in_subselect::val_bool(), Item_exists_subselect::val_bool(), Item_singlerow_subselect::val_bool(), Item_in_subselect::val_decimal(), Item_exists_subselect::val_decimal(), Item_singlerow_subselect::val_decimal(), Item_in_subselect::val_int(), Item_exists_subselect::val_int(), Item_singlerow_subselect::val_int(), Item_in_subselect::val_real(), Item_exists_subselect::val_real(), Item_singlerow_subselect::val_real(), Item_in_subselect::val_str(), Item_exists_subselect::val_str(), and Item_singlerow_subselect::val_str().
00239 { 00240 int res; 00241 00242 res= engine->exec(); 00243 00244 if (engine_changed) 00245 { 00246 engine_changed= 0; 00247 return exec(); 00248 } 00249 return (res); 00250 }
Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from Item.
Reimplemented in Item_in_subselect.
Definition at line 134 of file item_subselect.cc.
References changed, check_stack_overrun(), subselect_engine::cols(), const_item_cache, DBUG_ASSERT, engine, ER_OPERAND_COLUMNS, err, subselect_engine::exclude(), fix_length_and_dec(), Item::fixed, have_to_be_excluded, max_columns, my_error(), MYF, Item::name, subselect_engine::prepare(), RAND_TABLE_BIT, subselect_engine::set_thd(), STACK_MIN_SIZE, substitution, thd, TRUE, subselect_engine::uncacheable(), UNCACHEABLE_RAND, unit, and used_tables_cache.
Referenced by Item_in_subselect::fix_fields().
00135 { 00136 char const *save_where= thd_param->where; 00137 uint8 uncacheable; 00138 bool res; 00139 00140 DBUG_ASSERT(fixed == 0); 00141 engine->set_thd((thd= thd_param)); 00142 00143 if (check_stack_overrun(thd, STACK_MIN_SIZE, (gptr)&res)) 00144 return TRUE; 00145 00146 res= engine->prepare(); 00147 00148 // all transformation is done (used by prepared statements) 00149 changed= 1; 00150 00151 if (!res) 00152 { 00153 if (substitution) 00154 { 00155 int ret= 0; 00156 00157 // did we changed top item of WHERE condition 00158 if (unit->outer_select()->where == (*ref)) 00159 unit->outer_select()->where= substitution; // correct WHERE for PS 00160 else if (unit->outer_select()->having == (*ref)) 00161 unit->outer_select()->having= substitution; // correct HAVING for PS 00162 00163 (*ref)= substitution; 00164 substitution->name= name; 00165 if (have_to_be_excluded) 00166 engine->exclude(); 00167 substitution= 0; 00168 thd->where= "checking transformed subquery"; 00169 if (!(*ref)->fixed) 00170 ret= (*ref)->fix_fields(thd, ref); 00171 thd->where= save_where; 00172 return ret; 00173 } 00174 // Is it one field subselect? 00175 if (engine->cols() > max_columns) 00176 { 00177 my_error(ER_OPERAND_COLUMNS, MYF(0), 1); 00178 return TRUE; 00179 } 00180 fix_length_and_dec(); 00181 } 00182 else 00183 goto err; 00184 00185 if ((uncacheable= engine->uncacheable())) 00186 { 00187 const_item_cache= 0; 00188 if (uncacheable & UNCACHEABLE_RAND) 00189 used_tables_cache|= RAND_TABLE_BIT; 00190 } 00191 fixed= 1; 00192 00193 err: 00194 thd->where= save_where; 00195 return res; 00196 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void Item_subselect::fix_length_and_dec | ( | ) | [virtual] |
Implements Item_result_field.
Reimplemented in Item_singlerow_subselect, and Item_exists_subselect.
Definition at line 258 of file item_subselect.cc.
References engine, and subselect_engine::fix_length_and_dec().
Referenced by fix_fields().
00259 { 00260 engine->fix_length_and_dec(0); 00261 }
Here is the call graph for this function:

Here is the caller graph for this function:

| bool Item_subselect::get_const_item_cache | ( | ) | [inline] |
Definition at line 101 of file item_subselect.h.
References const_item_cache.
Referenced by Item_maxmin_subselect::Item_maxmin_subselect().
00101 { return const_item_cache; }
Here is the caller graph for this function:

| Item * Item_subselect::get_tmp_table_item | ( | THD * | thd | ) | [virtual] |
Reimplemented from Item.
Definition at line 275 of file item_subselect.cc.
References const_item(), Item::copy_or_same(), Item_result_field::result_field, and Item::with_sum_func.
00276 { 00277 if (!with_sum_func && !const_item()) 00278 return new Item_field(result_field); 00279 return copy_or_same(thd); 00280 }
Here is the call graph for this function:

| table_map Item_subselect::get_used_tables_cache | ( | ) | [inline] |
Definition at line 100 of file item_subselect.h.
References used_tables_cache.
Referenced by Item_maxmin_subselect::Item_maxmin_subselect().
00100 { return used_tables_cache; }
Here is the caller graph for this function:

| void Item_subselect::init | ( | st_select_lex * | select_lex, | |
| select_subselect * | result | |||
| ) | [virtual] |
Definition at line 52 of file item_subselect.cc.
References subselect_engine::change_result(), DBUG_ENTER, DBUG_PRINT, DBUG_VOID_RETURN, engine, IN_HAVING, NO_MATTER, parsing_place, and unit.
Referenced by Item_allany_subselect::Item_allany_subselect(), Item_exists_subselect::Item_exists_subselect(), Item_in_subselect::Item_in_subselect(), Item_maxmin_subselect::Item_maxmin_subselect(), and Item_singlerow_subselect::Item_singlerow_subselect().
00054 { 00055 00056 DBUG_ENTER("Item_subselect::init"); 00057 DBUG_PRINT("enter", ("select_lex: 0x%x", (ulong) select_lex)); 00058 unit= select_lex->master_unit(); 00059 00060 if (unit->item) 00061 { 00062 /* 00063 Item can be changed in JOIN::prepare while engine in JOIN::optimize 00064 => we do not copy old_engine here 00065 */ 00066 engine= unit->item->engine; 00067 parsing_place= unit->item->parsing_place; 00068 unit->item->engine= 0; 00069 unit->item= this; 00070 engine->change_result(this, result); 00071 } 00072 else 00073 { 00074 SELECT_LEX *outer_select= unit->outer_select(); 00075 /* 00076 do not take into account expression inside aggregate functions because 00077 they can access original table fields 00078 */ 00079 parsing_place= (outer_select->in_sum_expr ? 00080 NO_MATTER : 00081 outer_select->parsing_place); 00082 if (select_lex->next_select()) 00083 engine= new subselect_union_engine(unit, result, this); 00084 else 00085 engine= new subselect_single_select_engine(select_lex, result, this); 00086 } 00087 { 00088 SELECT_LEX *upper= unit->outer_select(); 00089 if (upper->parsing_place == IN_HAVING) 00090 upper->subquery_in_having= 1; 00091 } 00092 DBUG_VOID_RETURN; 00093 }
Here is the call graph for this function:

Here is the caller graph for this function:

| bool Item_subselect::is_evaluated | ( | ) | const [inline] |
Definition at line 427 of file item_subselect.h.
References engine, and subselect_engine::is_executed().
00428 { 00429 return engine->is_executed(); 00430 }
Here is the call graph for this function:

| bool Item_subselect::is_null | ( | ) | [inline, virtual] |
Reimplemented from Item.
Definition at line 89 of file item_subselect.h.
References Item::null_value, and Item::val_int().
00090 { 00091 val_int(); 00092 return null_value; 00093 }
Here is the call graph for this function:

| table_map Item_subselect::not_null_tables | ( | ) | const [inline, virtual] |
| enum_parsing_place Item_subselect::place | ( | ) | [inline] |
Definition at line 123 of file item_subselect.h.
References parsing_place.
00123 { return parsing_place; }
| void Item_subselect::print | ( | String * | str | ) | [virtual] |
Reimplemented from Item.
Reimplemented in Item_maxmin_subselect, Item_exists_subselect, Item_in_subselect, and Item_allany_subselect.
Definition at line 293 of file item_subselect.cc.
References String::append(), engine, and subselect_engine::print().
Referenced by Item_allany_subselect::print(), Item_in_subselect::print(), Item_exists_subselect::print(), and Item_maxmin_subselect::print().
Here is the call graph for this function:

Here is the caller graph for this function:

| virtual void Item_subselect::reset | ( | void | ) | [inline, virtual] |
Reimplemented in Item_singlerow_subselect, Item_exists_subselect, and Item_in_subselect.
Definition at line 81 of file item_subselect.h.
References Item::null_value.
Referenced by cleanup(), subselect_single_select_engine::exec(), and Item_subselect().
00082 { 00083 null_value= 1; 00084 }
Here is the caller graph for this function:

| virtual void Item_subselect::reset_value_registration | ( | ) | [inline, virtual] |
Reimplemented in Item_maxmin_subselect.
Definition at line 122 of file item_subselect.h.
Referenced by subselect_single_select_engine::exec().
Here is the caller graph for this function:

| Item_subselect::trans_res Item_subselect::select_transformer | ( | JOIN * | join | ) | [virtual] |
Reimplemented in Item_singlerow_subselect, Item_in_subselect, and Item_allany_subselect.
Definition at line 127 of file item_subselect.cc.
References DBUG_ENTER, DBUG_RETURN, and RES_OK.
Referenced by JOIN::prepare().
00128 { 00129 DBUG_ENTER("Item_subselect::select_transformer"); 00130 DBUG_RETURN(RES_OK); 00131 }
Here is the caller graph for this function:

| virtual subs_type Item_subselect::substype | ( | ) | [inline, virtual] |
Reimplemented in Item_singlerow_subselect, Item_exists_subselect, Item_in_subselect, and Item_allany_subselect.
Definition at line 69 of file item_subselect.h.
References UNKNOWN_SUBS.
Referenced by setup_wild().
00069 { return UNKNOWN_SUBS; }
Here is the caller graph for this function:

| Item::Type Item_subselect::type | ( | ) | const [virtual] |
Implements Item.
Definition at line 252 of file item_subselect.cc.
References Item::SUBSELECT_ITEM.
00253 { 00254 return SUBSELECT_ITEM; 00255 }
| void Item_subselect::update_used_tables | ( | ) | [virtual] |
Reimplemented from Item.
Definition at line 282 of file item_subselect.cc.
References const_item_cache, engine, subselect_engine::uncacheable(), subselect_engine::upper_select_const_tables(), and used_tables_cache.
00283 { 00284 if (!engine->uncacheable()) 00285 { 00286 // did all used tables become static? 00287 if (!(used_tables_cache & ~engine->upper_select_const_tables())) 00288 const_item_cache= 1; 00289 } 00290 }
Here is the call graph for this function:

| table_map Item_subselect::used_tables | ( | ) | const [virtual] |
Reimplemented from Item_result_field.
Definition at line 264 of file item_subselect.cc.
References engine, subselect_engine::uncacheable(), and used_tables_cache.
00265 { 00266 return (table_map) (engine->uncacheable() ? used_tables_cache : 0L); 00267 }
Here is the call graph for this function:

| bool Item_subselect::walk | ( | Item_processor | processor, | |
| bool | walk_subquery, | |||
| byte * | arg | |||
| ) | [virtual] |
Reimplemented from Item.
Definition at line 199 of file item_subselect.cc.
References order, unit, and Item::walk().
00201 { 00202 00203 if (walk_subquery) 00204 { 00205 for (SELECT_LEX *lex= unit->first_select(); lex; lex= lex->next_select()) 00206 { 00207 List_iterator<Item> li(lex->item_list); 00208 Item *item; 00209 ORDER *order; 00210 00211 if (lex->where && (lex->where)->walk(processor, walk_subquery, argument)) 00212 return 1; 00213 if (lex->having && (lex->having)->walk(processor, walk_subquery, 00214 argument)) 00215 return 1; 00216 00217 while ((item=li++)) 00218 { 00219 if (item->walk(processor, walk_subquery, argument)) 00220 return 1; 00221 } 00222 for (order= (ORDER*) lex->order_list.first ; order; order= order->next) 00223 { 00224 if ((*order->item)->walk(processor, walk_subquery, argument)) 00225 return 1; 00226 } 00227 for (order= (ORDER*) lex->group_list.first ; order; order= order->next) 00228 { 00229 if ((*order->item)->walk(processor, walk_subquery, argument)) 00230 return 1; 00231 } 00232 } 00233 } 00234 return (this->*processor)(argument); 00235 }
Here is the call graph for this function:

friend class Item_in_optimizer [friend] |
Definition at line 127 of file item_subselect.h.
Referenced by Item_in_subselect::select_in_like_transformer().
| void mark_select_range_as_dependent | ( | THD * | , | |
| st_select_lex * | , | |||
| st_select_lex * | , | |||
| Field * | , | |||
| Item * | , | |||
| Item_ident * | ||||
| ) | [friend] |
friend class select_subselect [friend] |
Definition at line 126 of file item_subselect.h.
Definition at line 61 of file item_subselect.h.
Referenced by fix_fields(), Item_in_subselect::select_in_like_transformer(), and Item_singlerow_subselect::select_transformer().
bool Item_subselect::const_item_cache [protected] |
Definition at line 55 of file item_subselect.h.
Referenced by const_item(), fix_fields(), Item_ref::fix_fields(), get_const_item_cache(), Item_maxmin_subselect::Item_maxmin_subselect(), mark_select_range_as_dependent(), and update_used_tables().
subselect_engine* Item_subselect::engine [protected] |
Definition at line 43 of file item_subselect.h.
Referenced by change_engine(), Item_singlerow_subselect::check_cols(), cleanup(), Item_singlerow_subselect::cols(), exec(), fix_fields(), Item_in_optimizer::fix_fields(), Item_exists_subselect::fix_length_and_dec(), Item_singlerow_subselect::fix_length_and_dec(), fix_length_and_dec(), init(), is_evaluated(), print(), Item_singlerow_subselect::result_type(), update_used_tables(), used_tables(), and ~Item_subselect().
Definition at line 59 of file item_subselect.h.
Referenced by change_engine(), subselect_single_select_engine::exec(), and exec().
bool Item_subselect::have_to_be_excluded [protected] |
Definition at line 53 of file item_subselect.h.
Referenced by fix_fields(), Item_singlerow_subselect::select_transformer(), and Item_in_subselect::single_value_transformer().
uint Item_subselect::max_columns [protected] |
Definition at line 49 of file item_subselect.h.
Referenced by fix_fields(), Item_exists_subselect::fix_length_and_dec(), Item_singlerow_subselect::fix_length_and_dec(), Item_allany_subselect::Item_allany_subselect(), Item_exists_subselect::Item_exists_subselect(), Item_in_subselect::Item_in_subselect(), Item_maxmin_subselect::Item_maxmin_subselect(), Item_singlerow_subselect::Item_singlerow_subselect(), and Item_singlerow_subselect::null_inside().
subselect_engine* Item_subselect::old_engine [protected] |
enum_parsing_place Item_subselect::parsing_place [protected] |
Definition at line 51 of file item_subselect.h.
Referenced by Item_ref::fix_fields(), init(), and place().
Item* Item_subselect::substitution [protected] |
Definition at line 39 of file item_subselect.h.
Referenced by fix_fields(), Item_in_subselect::row_value_transformer(), Item_singlerow_subselect::select_transformer(), and Item_in_subselect::single_value_transformer().
THD* Item_subselect::thd [protected] |
Definition at line 37 of file item_subselect.h.
Referenced by fix_fields(), Item_maxmin_subselect::Item_maxmin_subselect(), Item_in_subselect::row_value_transformer(), Item_in_subselect::select_in_like_transformer(), Item_singlerow_subselect::select_transformer(), and Item_in_subselect::single_value_transformer().
st_select_lex_unit* Item_subselect::unit [protected] |
table_map Item_subselect::used_tables_cache [protected] |
Definition at line 47 of file item_subselect.h.
Referenced by fix_fields(), Item_ref::fix_fields(), get_used_tables_cache(), Item_maxmin_subselect::Item_maxmin_subselect(), mark_select_range_as_dependent(), update_used_tables(), and used_tables().
my_bool Item_subselect::value_assigned [private] |
1.4.7

