#include <sp_head.h>
Collaboration diagram for sp_lex_keeper:

Public Member Functions | |
| sp_lex_keeper (LEX *lex, bool lex_resp) | |
| virtual | ~sp_lex_keeper () |
| int | reset_lex_and_exec_core (THD *thd, uint *nextp, bool open_tables, sp_instr *instr) |
| uint | sql_command () const |
| void | disable_query_cache () |
Private Member Functions | |
| sp_lex_keeper (const sp_lex_keeper &) | |
| void | operator= (sp_lex_keeper &) |
Private Attributes | |
| LEX * | m_lex |
| bool | m_lex_resp |
| TABLE_LIST * | prelocking_tables |
| TABLE_LIST ** | lex_query_tables_own_last |
Definition at line 526 of file sp_head.h.
| sp_lex_keeper::sp_lex_keeper | ( | const sp_lex_keeper & | ) | [private] |
| sp_lex_keeper::sp_lex_keeper | ( | LEX * | lex, | |
| bool | lex_resp | |||
| ) | [inline] |
Definition at line 533 of file sp_head.h.
References TRUE.
00534 : m_lex(lex), m_lex_resp(lex_resp), 00535 lex_query_tables_own_last(NULL) 00536 { 00537 lex->sp_lex_in_use= TRUE; 00538 }
| virtual sp_lex_keeper::~sp_lex_keeper | ( | ) | [inline, virtual] |
Definition at line 539 of file sp_head.h.
References lex_end(), m_lex, and m_lex_resp.
00540 { 00541 if (m_lex_resp) 00542 { 00543 lex_end(m_lex); 00544 delete m_lex; 00545 } 00546 }
Here is the call graph for this function:

| void sp_lex_keeper::disable_query_cache | ( | ) | [inline] |
Definition at line 561 of file sp_head.h.
References m_lex.
Referenced by sp_cursor::sp_cursor().
00562 { 00563 m_lex->safe_to_cache_query= 0; 00564 }
Here is the caller graph for this function:

| void sp_lex_keeper::operator= | ( | sp_lex_keeper & | ) | [private] |
| int sp_lex_keeper::reset_lex_and_exec_core | ( | THD * | thd, | |
| uint * | nextp, | |||
| bool | open_tables, | |||
| sp_instr * | instr | |||
| ) |
Definition at line 2357 of file sp_head.cc.
References check_table_access(), close_thread_tables(), DBUG_ASSERT, sp_instr::exec_core(), lex_query_tables_own_last, LOCK_thread_count, m_lex, next_query_id(), NULL, open_and_lock_tables(), prelocking_tables, pthread_mutex_lock, pthread_mutex_unlock, reinit_stmt_before_use(), SELECT_ACL, and VOID.
Referenced by sp_instr_set_case_expr::execute(), sp_instr_copen::execute(), sp_instr_freturn::execute(), sp_instr_jump_if_not::execute(), sp_instr_set_trigger_field::execute(), sp_instr_set::execute(), and sp_instr_stmt::execute().
02359 { 02360 int res= 0; 02361 02362 DBUG_ASSERT(!thd->derived_tables); 02363 DBUG_ASSERT(thd->change_list.is_empty()); 02364 /* 02365 Use our own lex. 02366 We should not save old value since it is saved/restored in 02367 sp_head::execute() when we are entering/leaving routine. 02368 */ 02369 thd->lex= m_lex; 02370 02371 VOID(pthread_mutex_lock(&LOCK_thread_count)); 02372 thd->query_id= next_query_id(); 02373 VOID(pthread_mutex_unlock(&LOCK_thread_count)); 02374 02375 if (thd->prelocked_mode == NON_PRELOCKED) 02376 { 02377 /* 02378 This statement will enter/leave prelocked mode on its own. 02379 Entering prelocked mode changes table list and related members 02380 of LEX, so we'll need to restore them. 02381 */ 02382 if (lex_query_tables_own_last) 02383 { 02384 /* 02385 We've already entered/left prelocked mode with this statement. 02386 Attach the list of tables that need to be prelocked and mark m_lex 02387 as having such list attached. 02388 */ 02389 *lex_query_tables_own_last= prelocking_tables; 02390 m_lex->mark_as_requiring_prelocking(lex_query_tables_own_last); 02391 } 02392 } 02393 02394 reinit_stmt_before_use(thd, m_lex); 02395 /* 02396 If requested check whenever we have access to tables in LEX's table list 02397 and open and lock them before executing instructtions core function. 02398 */ 02399 if (open_tables && 02400 (check_table_access(thd, SELECT_ACL, m_lex->query_tables, 0) || 02401 open_and_lock_tables(thd, m_lex->query_tables))) 02402 res= -1; 02403 02404 if (!res) 02405 res= instr->exec_core(thd, nextp); 02406 02407 m_lex->unit.cleanup(); 02408 02409 thd->proc_info="closing tables"; 02410 close_thread_tables(thd); 02411 thd->proc_info= 0; 02412 02413 if (m_lex->query_tables_own_last) 02414 { 02415 /* 02416 We've entered and left prelocking mode when executing statement 02417 stored in m_lex. 02418 m_lex->query_tables(->next_global)* list now has a 'tail' - a list 02419 of tables that are added for prelocking. (If this is the first 02420 execution, the 'tail' was added by open_tables(), otherwise we've 02421 attached it above in this function). 02422 Now we'll save the 'tail', and detach it. 02423 */ 02424 lex_query_tables_own_last= m_lex->query_tables_own_last; 02425 prelocking_tables= *lex_query_tables_own_last; 02426 *lex_query_tables_own_last= NULL; 02427 m_lex->mark_as_requiring_prelocking(NULL); 02428 } 02429 thd->rollback_item_tree_changes(); 02430 /* Update the state of the active arena. */ 02431 thd->stmt_arena->state= Query_arena::EXECUTED; 02432 02433 02434 /* 02435 Unlike for PS we should not call Item's destructors for newly created 02436 items after execution of each instruction in stored routine. This is 02437 because SP often create Item (like Item_int, Item_string etc...) when 02438 they want to store some value in local variable, pass return value and 02439 etc... So their life time should be longer than one instruction. 02440 02441 cleanup_items() is called in sp_head::execute() 02442 */ 02443 return res || thd->net.report_error; 02444 }
Here is the call graph for this function:

Here is the caller graph for this function:

| uint sp_lex_keeper::sql_command | ( | ) | const [inline] |
Definition at line 556 of file sp_head.h.
References m_lex.
Referenced by sp_instr_stmt::execute(), and sp_instr_stmt::print().
Here is the caller graph for this function:

TABLE_LIST** sp_lex_keeper::lex_query_tables_own_last [private] |
LEX* sp_lex_keeper::m_lex [private] |
Definition at line 567 of file sp_head.h.
Referenced by disable_query_cache(), reset_lex_and_exec_core(), sql_command(), and ~sp_lex_keeper().
bool sp_lex_keeper::m_lex_resp [private] |
TABLE_LIST* sp_lex_keeper::prelocking_tables [private] |
1.4.7

