YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense alongwiththisprogram;ifnot,writetotheFreeSoftware
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
sp_rcontext::~sp_rcontext()
{ delete m_var_table; // Leave m_handlers, m_handler_call_stack, m_var_items, m_cstack // and m_case_expr_holders untouched. // They are allocated in mem roots and will be freed accordingly.
}
sp_rcontext *sp_rcontext::create(THD *thd,
sp_head *owner, const sp_pcontext *root_parsing_ctx,
Field *return_value_fld,
Row_definition_list &field_def_lst)
{
SELECT_LEX *save_current_select;
sp_rcontext *ctx= new (thd->mem_root) sp_rcontext(owner,
root_parsing_ctx,
return_value_fld,
thd->in_sub_stmt); if (!ctx) return NULL;
/* Reset current_select as it's checked in Item_ident::Item_ident */
save_current_select= thd->lex->current_select;
thd->lex->current_select= 0;
/* Createadeepcopy. Usede.g.for"TYPEISRECORD"variables.
*/
Row_definition_list *Row_definition_list::deep_copy(THD *thd) const
{
Row_definition_list *row= new (thd->mem_root) Row_definition_list(); if (unlikely(row == NULL)) return nullptr;
// Create a deep copy of the elements
List_iterator<Spvar_definition> it(*const_cast<Row_definition_list*>(this)); for (Spvar_definition *def= it++; def; def= it++)
{
Spvar_definition *new_def= new (thd->mem_root) Spvar_definition(*def); if (unlikely(new_def == NULL) ||
row->push_back(new_def, thd->mem_root)) return nullptr;
} return row;
}
TABLE_LIST *table_list;
Field *src;
LEX *save_lex= thd->lex; bool rc= true;
sp_lex_local lex(thd, thd->lex);
thd->lex= &lex;
lex.context_analysis_only= CONTEXT_ANALYSIS_ONLY_VIEW; // Make %TYPE variables see temporary tables that shadow permanent tables
thd->temporary_tables= open_tables_state_backup.temporary_tables;
lex.context_analysis_only= CONTEXT_ANALYSIS_ONLY_VIEW; // Make %ROWTYPE variables see temporary tables that shadow permanent tables
thd->temporary_tables= open_tables_state_backup.temporary_tables;
if ((table_list=
lex.first_select_lex()->add_table_to_list(thd, this, NULL, 0,
TL_READ_NO_INSERT,
MDL_SHARED_READ)) &&
!check_table_access(thd, SELECT_ACL, table_list, TRUE, UINT_MAX, FALSE) &&
!open_tables_only_view_structure(thd, table_list,
thd->mdl_context.has_locks()))
{ for (Field **src= lex.query_tables->table->field; *src; src++)
{ /* MakefieldnamesontheTHDmemoryroot, asthetablewillbeclosedandfreedsoon, intheendofthismethod.
*/ const Lex_ident_column tmp= src[0]->field_name;
Spvar_definition *def; if ((rc= check_column_grant_for_type_ref(thd, table_list, tmp, src[0])) ||
(rc= !(src[0]->field_name.str= thd->strmake(tmp.str, tmp.length))) ||
(rc= !(def= new (thd->mem_root) Spvar_definition(thd, *src)))) break;
src[0]->field_name.str= tmp.str; // Restore field name, just in case.
def->flags&= (uint) ~NOT_NULL_FLAG; if ((rc= def->sp_prepare_create_field(thd, thd->mem_root))) break;
defs.push_back(def, thd->mem_root);
}
}
// Here we need to find the last warning/note from the stack. // In MySQL most substantial warning is the last one. // (We could have used a reverse iterator here if one existed)
while ((c= it++))
{ if (c->get_level() == Sql_condition::WARN_LEVEL_WARN ||
c->get_level() == Sql_condition::WARN_LEVEL_NOTE)
{ const sp_handler *handler= cur_spi->m_ctx->find_handler(*c); if (handler)
{
found_handler= handler;
found_condition= c;
}
}
}
}
if (!found_handler)
DBUG_RETURN(false);
// At this point, we know that: // - there is a pending SQL-condition (error or warning); // - there is an SQL-handler for it.
DBUG_ASSERT(found_condition);
sp_instr_hpush_jump *handler_entry= NULL; for (size_t i= 0; i < m_handlers.elements(); ++i)
{
sp_instr_hpush_jump *h= m_handlers.at(i);
if (h->get_handler() == found_handler)
{
handler_entry= h; break;
}
}
Forexample: CREATEPROCEDUREp() BEGIN DECLAREvINTDEFAULT'get';--raisesSQL-warninghere DECLAREEXITHANDLER...--thishandlerdoesnotcatchthewarning END
*/ if (!handler_entry)
DBUG_RETURN(false);
// Mark active conditions so that they can be deleted when the handler exits.
da->mark_sql_conditions_for_removal();
/* End aborted result set. */ if (end_partial_result_set)
thd->protocol->end_partial_result_set(thd);
/* Reset error state. */
thd->clear_error();
thd->reset_killed(); // Some errors set thd->killed, (e.g. "bad data").
/* Add a frame to handler-call-stack. */
Sql_condition_info *cond_info= new (callers_arena->mem_root) Sql_condition_info(found_condition,
callers_arena);
Handler_call_frame *frame= new (callers_arena->mem_root) Handler_call_frame(cond_info, continue_ip);
m_handler_call_stack.append(frame);
bool sp_rcontext::set_case_expr(THD *thd, int case_expr_id,
Item **case_expr_item_ptr)
{
Item *case_expr_item= thd->sp_prepare_func_item(case_expr_item_ptr, 1); if (!case_expr_item) returntrue;
if (!m_case_expr_holders[case_expr_id] ||
m_case_expr_holders[case_expr_id]->result_type() !=
case_expr_item->result_type())
{ if (!(m_case_expr_holders[case_expr_id]=
create_case_expr_holder(thd, case_expr_item))) returntrue; // A data type not allowed in CASE WHEN, or EOM
}
/* Attempt to fetch one row */ if (server_side_cursor->is_open())
{
server_side_cursor->fetch(&result, 1); if (thd->is_error()) return -1; // e.g. data type conversion failed
}
/* Ifthecursorwaspointingafterthelastrow,thefetchwill closeitinsteadofsendinganyrows.
*/ if (! server_side_cursor->is_open())
{
m_found= false; if (!error_on_no_data) return0;
my_message(ER_SP_FETCH_NO_DATA, ER_THD(thd, ER_SP_FETCH_NO_DATA), MYF(0)); return -1;
}
bool sp_cursor::Select_fetch_into_spvars::send_data_with_return_type(
List<Item> &items)
{
DBUG_ASSERT(m_return_type); // Fetch into the virtual table first if (m_return_type->sp_set_from_select_list(thd, items)) returntrue;
// Now send the fetched data from the virtual table into the tagret list const sp_fetch_target *target_head= m_fetch_target_list->head();
sp_rcontext *target_head_rctx= thd->get_rcontext(*target_head);
Item *target_head_item=
target_head_rctx->get_variable(target_head->offset()); if (m_fetch_target_list->elements == 1 &&
target_head_item &&
target_head_item->type_handler() == &type_handler_row &&
target_head_item->cols() == items.elements)
{ // Send to a ROW variable
Virtual_tmp_table *trg_table= target_head_rctx->
virtual_tmp_table_for_row(target_head->offset()); if (m_return_type->sp_save_in_vtable(thd, trg_table)) returntrue;
} else
{ // Send to a scalar variable list if (m_return_type->sp_save_in_target_list(thd, *m_fetch_target_list)) returntrue;
} returnfalse;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-10-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.