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


Public Member Functions | |
| Item_singlerow_subselect (st_select_lex *select_lex) | |
| Item_singlerow_subselect () | |
| void | cleanup () |
| subs_type | substype () |
| void | reset () |
| trans_res | select_transformer (JOIN *join) |
| void | store (uint i, Item *item) |
| double | val_real () |
| longlong | val_int () |
| String * | val_str (String *) |
| my_decimal * | val_decimal (my_decimal *) |
| bool | val_bool () |
| enum Item_result | result_type () const |
| void | fix_length_and_dec () |
| uint | cols () |
| Item * | el (uint i) |
| Item ** | addr (uint i) |
| bool | check_cols (uint c) |
| bool | null_inside () |
| void | bring_value () |
Protected Attributes | |
| Item_cache * | value |
| Item_cache ** | row |
Friends | |
| class | select_singlerow_subselect |
Definition at line 139 of file item_subselect.h.
| Item_singlerow_subselect::Item_singlerow_subselect | ( | st_select_lex * | select_lex | ) |
Definition at line 301 of file item_subselect.cc.
References DBUG_ENTER, DBUG_VOID_RETURN, Item_subselect::init(), Item_subselect::max_columns, Item::maybe_null, and select_singlerow_subselect.
00302 :Item_subselect(), value(0) 00303 { 00304 DBUG_ENTER("Item_singlerow_subselect::Item_singlerow_subselect"); 00305 init(select_lex, new select_singlerow_subselect(this)); 00306 maybe_null= 1; 00307 max_columns= UINT_MAX; 00308 DBUG_VOID_RETURN; 00309 }
Here is the call graph for this function:

| Item_singlerow_subselect::Item_singlerow_subselect | ( | ) | [inline] |
| void Item_singlerow_subselect::bring_value | ( | ) | [virtual] |
Reimplemented from Item.
Definition at line 485 of file item_subselect.cc.
References Item_subselect::exec().
00486 { 00487 exec(); 00488 }
Here is the call graph for this function:

Reimplemented from Item.
Definition at line 465 of file item_subselect.cc.
References subselect_engine::cols(), Item_subselect::engine, ER_OPERAND_COLUMNS, my_error(), and MYF.
00466 { 00467 if (c != engine->cols()) 00468 { 00469 my_error(ER_OPERAND_COLUMNS, MYF(0), c); 00470 return 1; 00471 } 00472 return 0; 00473 }
Here is the call graph for this function:

| void Item_singlerow_subselect::cleanup | ( | ) | [virtual] |
Reimplemented from Item_subselect.
Reimplemented in Item_maxmin_subselect.
Definition at line 113 of file item_subselect.cc.
References Item_subselect::cleanup(), DBUG_ENTER, DBUG_VOID_RETURN, row, and value.
Referenced by Item_maxmin_subselect::cleanup().
00114 { 00115 DBUG_ENTER("Item_singlerow_subselect::cleanup"); 00116 value= 0; row= 0; 00117 Item_subselect::cleanup(); 00118 DBUG_VOID_RETURN; 00119 }
Here is the call graph for this function:

Here is the caller graph for this function:

| uint Item_singlerow_subselect::cols | ( | ) | [virtual] |
Reimplemented from Item.
Definition at line 460 of file item_subselect.cc.
References subselect_engine::cols(), and Item_subselect::engine.
Here is the call graph for this function:

Reimplemented from Item.
Definition at line 162 of file item_subselect.h.
References my_reinterpret_cast, and row.
00162 { return my_reinterpret_cast(Item*)(row[i]); }
| void Item_singlerow_subselect::fix_length_and_dec | ( | ) | [virtual] |
Reimplemented from Item_subselect.
Definition at line 437 of file item_subselect.cc.
References subselect_engine::cols(), Item_subselect::engine, subselect_engine::fix_length_and_dec(), Item_subselect::max_columns, subselect_engine::may_be_null(), Item::maybe_null, subselect_engine::no_tables(), row, sql_alloc(), Item::unsigned_flag, and value.
00438 { 00439 if ((max_columns= engine->cols()) == 1) 00440 { 00441 engine->fix_length_and_dec(row= &value); 00442 } 00443 else 00444 { 00445 if (!(row= (Item_cache**) sql_alloc(sizeof(Item_cache*)*max_columns))) 00446 return; 00447 engine->fix_length_and_dec(row); 00448 value= *row; 00449 } 00450 unsigned_flag= value->unsigned_flag; 00451 /* 00452 If there are not tables in subquery then ability to have NULL value 00453 depends on SELECT list (if single row subquery have tables then it 00454 always can be NULL if there are not records fetched). 00455 */ 00456 if (engine->no_tables()) 00457 maybe_null= engine->may_be_null(); 00458 }
Here is the call graph for this function:

| bool Item_singlerow_subselect::null_inside | ( | ) | [virtual] |
Reimplemented from Item.
Definition at line 475 of file item_subselect.cc.
References Item_subselect::max_columns, Item::null_value, and row.
00476 { 00477 for (uint i= 0; i < max_columns ; i++) 00478 { 00479 if (row[i]->null_value) 00480 return 1; 00481 } 00482 return 0; 00483 }
| void Item_singlerow_subselect::reset | ( | ) | [virtual] |
Reimplemented from Item_subselect.
Definition at line 365 of file item_subselect.cc.
References Item::null_value, and value.
Referenced by val_bool(), val_decimal(), val_int(), val_real(), and val_str().
00366 { 00367 null_value= 1; 00368 if (value) 00369 value->null_value= 1; 00370 }
Here is the caller graph for this function:

| enum Item_result Item_singlerow_subselect::result_type | ( | ) | const [virtual] |
Reimplemented from Item.
Definition at line 432 of file item_subselect.cc.
References Item_subselect::engine, and subselect_engine::type().
Here is the call graph for this function:

| Item_subselect::trans_res Item_singlerow_subselect::select_transformer | ( | JOIN * | join | ) | [virtual] |
Reimplemented from Item_subselect.
Definition at line 374 of file item_subselect.cc.
References Item_subselect::changed, JOIN::conds, DBUG_ASSERT, ER, ER_SELECT_REDUCED, Item::FIELD_ITEM, Item_subselect::have_to_be_excluded, JOIN::having, MYSQL_ERRMSG_SIZE, push_warning(), Item::REF_ITEM, Item::remove_dependence_processor(), Item_subselect::RES_OK, Item_subselect::RES_REDUCE, JOIN::select_lex, Item_subselect::substitution, Item_subselect::thd, Item::walk(), and MYSQL_ERROR::WARN_LEVEL_NOTE.
00375 { 00376 if (changed) 00377 return RES_OK; 00378 00379 SELECT_LEX *select_lex= join->select_lex; 00380 Query_arena *arena= thd->stmt_arena; 00381 00382 if (!select_lex->master_unit()->first_select()->next_select() && 00383 !select_lex->table_list.elements && 00384 select_lex->item_list.elements == 1 && 00385 !select_lex->item_list.head()->with_sum_func && 00386 /* 00387 We cant change name of Item_field or Item_ref, because it will 00388 prevent it's correct resolving, but we should save name of 00389 removed item => we do not make optimization if top item of 00390 list is field or reference. 00391 TODO: solve above problem 00392 */ 00393 !(select_lex->item_list.head()->type() == FIELD_ITEM || 00394 select_lex->item_list.head()->type() == REF_ITEM) && 00395 /* 00396 switch off this optimization for prepare statement, 00397 because we do not rollback this changes 00398 TODO: make rollback for it, or special name resolving mode in 5.0. 00399 */ 00400 !arena->is_stmt_prepare_or_first_sp_execute() 00401 ) 00402 { 00403 00404 have_to_be_excluded= 1; 00405 if (thd->lex->describe) 00406 { 00407 char warn_buff[MYSQL_ERRMSG_SIZE]; 00408 sprintf(warn_buff, ER(ER_SELECT_REDUCED), select_lex->select_number); 00409 push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, 00410 ER_SELECT_REDUCED, warn_buff); 00411 } 00412 substitution= select_lex->item_list.head(); 00413 /* 00414 as far as we moved content to upper level, field which depend of 00415 'upper' select is not really dependent => we remove this dependence 00416 */ 00417 substitution->walk(&Item::remove_dependence_processor, 0, 00418 (byte *) select_lex->outer_select()); 00419 /* SELECT without FROM clause can't have WHERE or HAVING clause */ 00420 DBUG_ASSERT(join->conds == 0 && join->having == 0); 00421 return RES_REDUCE; 00422 } 00423 return RES_OK; 00424 }
Here is the call graph for this function:

Definition at line 427 of file item_subselect.cc.
References row, and Item_cache::store().
Here is the call graph for this function:

| subs_type Item_singlerow_subselect::substype | ( | ) | [inline, virtual] |
Reimplemented from Item_subselect.
Definition at line 148 of file item_subselect.h.
References Item_subselect::SINGLEROW_SUBS.
00148 { return SINGLEROW_SUBS; }
| bool Item_singlerow_subselect::val_bool | ( | ) | [virtual] |
Reimplemented from Item.
Definition at line 550 of file item_subselect.cc.
References Item_subselect::exec(), Item::null_value, reset(), Item::val_bool(), and value.
00551 { 00552 if (!exec() && !value->null_value) 00553 { 00554 null_value= 0; 00555 return value->val_bool(); 00556 } 00557 else 00558 { 00559 reset(); 00560 return 0; 00561 } 00562 }
Here is the call graph for this function:

| my_decimal * Item_singlerow_subselect::val_decimal | ( | my_decimal * | ) | [virtual] |
Implements Item.
Definition at line 535 of file item_subselect.cc.
References Item_subselect::exec(), Item::null_value, reset(), Item::val_decimal(), and value.
00536 { 00537 if (!exec() && !value->null_value) 00538 { 00539 null_value= 0; 00540 return value->val_decimal(decimal_value); 00541 } 00542 else 00543 { 00544 reset(); 00545 return 0; 00546 } 00547 }
Here is the call graph for this function:

| longlong Item_singlerow_subselect::val_int | ( | ) | [virtual] |
Implements Item.
Definition at line 505 of file item_subselect.cc.
References DBUG_ASSERT, Item_subselect::exec(), Item::fixed, Item::null_value, reset(), Item::val_int(), and value.
00506 { 00507 DBUG_ASSERT(fixed == 1); 00508 if (!exec() && !value->null_value) 00509 { 00510 null_value= 0; 00511 return value->val_int(); 00512 } 00513 else 00514 { 00515 reset(); 00516 return 0; 00517 } 00518 }
Here is the call graph for this function:

| double Item_singlerow_subselect::val_real | ( | ) | [virtual] |
Implements Item.
Definition at line 490 of file item_subselect.cc.
References DBUG_ASSERT, Item_subselect::exec(), Item::fixed, Item::null_value, reset(), Item::val_real(), and value.
00491 { 00492 DBUG_ASSERT(fixed == 1); 00493 if (!exec() && !value->null_value) 00494 { 00495 null_value= 0; 00496 return value->val_real(); 00497 } 00498 else 00499 { 00500 reset(); 00501 return 0; 00502 } 00503 }
Here is the call graph for this function:

Implements Item.
Definition at line 520 of file item_subselect.cc.
References Item_subselect::exec(), Item::null_value, reset(), Item::val_str(), and value.
00521 { 00522 if (!exec() && !value->null_value) 00523 { 00524 null_value= 0; 00525 return value->val_str(str); 00526 } 00527 else 00528 { 00529 reset(); 00530 return 0; 00531 } 00532 }
Here is the call graph for this function:

friend class select_singlerow_subselect [friend] |
Item_cache ** Item_singlerow_subselect::row [protected] |
Definition at line 142 of file item_subselect.h.
Referenced by addr(), cleanup(), el(), fix_length_and_dec(), null_inside(), and store().
Item_cache* Item_singlerow_subselect::value [protected] |
Definition at line 142 of file item_subselect.h.
Referenced by cleanup(), fix_length_and_dec(), reset(), val_bool(), val_decimal(), val_int(), val_real(), and val_str().
1.4.7

