MySQL 8.3.0
Source Code Documentation
sp_head Class Reference

sp_head represents one instance of a stored program. More...

#include <sp_head.h>

Public Types

enum  {
  HAS_RETURN = 1 , MULTI_RESULTS = 8 , CONTAINS_DYNAMIC_SQL = 16 , IS_INVOKED = 32 ,
  HAS_SET_AUTOCOMMIT_STMT , HAS_COMMIT_OR_ROLLBACK = 128 , LOG_SLOW_STATEMENTS = 256 , LOG_GENERAL_LOG = 512 ,
  HAS_SQLCOM_RESET = 1024 , HAS_SQLCOM_FLUSH = 2048 , MODIFIES_DATA = 4096 , HAS_TEMP_TABLE_DDL = 8192
}
 Possible values of m_flags. More...
 

Public Member Functions

bool is_invoked () const
 Is this routine being executed? More...
 
bool is_sql () const
 
int64 sp_cache_version () const
 Get the value of the SP cache version, as remembered when the routine was inserted into the cache. More...
 
void set_sp_cache_version (int64 sp_cache_version)
 Set the value of the SP cache version. More...
 
Stored_program_creation_ctxget_creation_ctx ()
 
void set_creation_ctx (Stored_program_creation_ctx *creation_ctx)
 
void set_body_start (THD *thd, const char *begin_ptr)
 Set the body-definition start position. More...
 
void set_body_end (THD *thd)
 Set the statement-definition (body-definition) end position. More...
 
bool setup_trigger_fields (THD *thd, Table_trigger_field_support *tfs, GRANT_INFO *subject_table_grant, bool need_fix_fields)
 
void mark_used_trigger_fields (TABLE *subject_table)
 
bool has_updated_trigger_fields (const MY_BITMAP *used_fields) const
 Check whether any table's fields are used in trigger. More...
 
bool execute_trigger (THD *thd, const LEX_CSTRING &db_name, const LEX_CSTRING &table_name, GRANT_INFO *grant_info)
 Execute trigger stored program. More...
 
bool execute_function (THD *thd, Item **args, uint argcount, Field *return_fld)
 Execute a function. More...
 
bool execute_procedure (THD *thd, mem_root_deque< Item * > *args)
 Execute a procedure. More...
 
bool add_instr (THD *thd, sp_instr *instr)
 Add instruction to SP. More...
 
bool modifies_data () const
 Returns true if any substatement in the routine directly (not through another routine) modifies data/changes table. More...
 
bool has_temp_table_ddl () const
 
uint instructions ()
 
sp_instrlast_instruction ()
 
bool reset_lex (THD *thd)
 Reset LEX-object during parsing, before we parse a sub statement. More...
 
bool restore_lex (THD *thd)
 Restore LEX-object during parsing, after we have parsed a sub statement. More...
 
char * name (uint *lenp=nullptr) const
 
Fieldcreate_result_field (THD *thd, size_t field_max_length, const char *field_name, TABLE *table) const
 Create Field-object corresponding to the RETURN field of a stored function. More...
 
void returns_type (THD *thd, String *result) const
 
void set_info (longlong created, longlong modified, st_sp_chistics *chistics, sql_mode_t sql_mode)
 
void set_definer (const char *definer, size_t definerlen)
 
void set_definer (const LEX_CSTRING &user_name, const LEX_CSTRING &host_name)
 
void optimize ()
 Do some minimal optimization of the code: More...
 
void add_mark_lead (uint ip, List< sp_instr > *leads)
 Helper used during flow analysis during code optimization. More...
 
sp_instrget_instr (uint i)
 Get SP-instruction at given index. More...
 
void add_used_tables_to_table_list (THD *thd, Table_ref ***query_tables_last_ptr, enum_sql_command sql_command, Table_ref *belong_to_view)
 Add tables used by routine to the table list. More...
 
bool is_not_allowed_in_function (const char *where)
 Check if this stored routine contains statements disallowed in a stored function or trigger, and set an appropriate error message if this is the case. More...
 
bool show_routine_code (THD *thd)
 Return the routine instructions as a result set. More...
 
void propagate_attributes (Query_tables_list *prelocking_ctx)
 
sp_pcontextget_root_parsing_context () const
 
MEM_ROOTget_persistent_mem_root () const
 
bool check_show_access (THD *thd, bool *full_access)
 Check if a user has access right to a SP. More...
 
bool set_security_ctx (THD *thd, Security_context **save_ctx)
 Change routine security context, and check if there is an EXECUTE privilege in new context. More...
 
bool init_external_routine (my_service< const mysql_service_external_program_execution_t > &service)
 Initialize and parse an external routine. More...
 

Static Public Member Functions

static void destroy (sp_head *sp)
 

Public Attributes

enum_sp_type m_type
 Stored program type. More...
 
uint m_flags
 Stored program flags. More...
 
PSI_sp_sharem_sp_share
 Instrumentation interface for SP. More...
 
Create_field m_return_field_def
 Definition of the RETURN-field (from the RETURNS-clause). More...
 
sp_parser_data m_parser_data
 Attributes used during the parsing stage only. More...
 
st_sp_chisticsm_chistics
 Stored program characteristics. More...
 
LEX_CSTRING code
 Code if language is not SQL. More...
 
sql_mode_t m_sql_mode
 The value of sql_mode system variable at the CREATE-time. More...
 
LEX_STRING m_qname
 Fully qualified name (<db name>.<sp name>). More...
 
bool m_explicit_name
 Prepend the db name? *‍/. More...
 
LEX_STRING m_db
 
LEX_STRING m_name
 
LEX_STRING m_params
 
LEX_CSTRING m_body
 
LEX_CSTRING m_body_utf8
 
LEX_STRING m_definer_user
 
LEX_STRING m_definer_host
 
longlong m_created
 
longlong m_modified
 
ulong m_recursion_level
 Recursion level of the current SP instance. More...
 
sp_headm_next_cached_sp
 A list of different recursion level instances for the same procedure. More...
 
sp_headm_first_instance
 Pointer to the first element of the above list. More...
 
sp_headm_first_free_instance
 Pointer to the first free (non-INVOKED) routine in the list of cached instances for this SP. More...
 
sp_headm_last_cached_sp
 Pointer to the last element in the list of instances of the SP. More...
 
malloc_unordered_map< std::string, Sroutine_hash_entry * > m_sroutines
 Set containing names of stored routines used by this routine. More...
 
Security_context m_security_ctx
 
SQL_I_List< SQL_I_List< Item_trigger_field > > m_list_of_trig_fields_item_lists
 List of item (Item_trigger_field objects)'s lists representing fields in old/new version of row in trigger. More...
 
SQL_I_List< Item_trigger_fieldm_cur_instr_trig_field_items
 List of all the Item_trigger_field items created while parsing sp instruction. More...
 
st_trg_chistics m_trg_chistics
 Trigger characteristics. More...
 
class Table_trigger_dispatcherm_trg_list
 The Table_trigger_dispatcher instance, where this trigger belongs to. More...
 
external_program_handle m_language_stored_program
 language component related state of this sp. More...
 

Private Member Functions

 sp_head (MEM_ROOT &&mem_root, enum_sp_type type)
 Use sp_start_parsing() to create instances of sp_head. More...
 
 ~sp_head ()
 Use destroy() to destoy instances of sp_head. More...
 
void init_sp_name (THD *thd, sp_name *spname)
 Copy sp name from parser. More...
 
bool execute (THD *thd, bool merge_da_on_success)
 Execute the routine. More...
 
bool execute_external_routine (THD *thd)
 Execute external routine. More...
 
void opt_mark ()
 Perform a forward flow analysis in the generated code. More...
 
bool merge_table_list (THD *thd, Table_ref *table, LEX *lex_for_tmp_check)
 Merge the list of tables used by some query into the multi-set of tables used by routine. More...
 
 sp_head (const sp_head &)
 
void operator= (sp_head &)
 

Private Attributes

MEM_ROOT main_mem_root
 SP-persistent memory root (for instructions and expressions). More...
 
sp_pcontextm_root_parsing_ctx
 Root parsing context (topmost BEGIN..END block) of this SP. More...
 
Mem_root_array< sp_instr * > m_instructions
 The SP-instructions. More...
 
collation_unordered_map< std::string, SP_TABLE * > m_sptabs
 Multi-set representing optimized list of tables to be locked by this routine. More...
 
std::vector< SP_TABLE * > m_sptabs_sorted
 
int64 m_sp_cache_version
 Version of the stored routine cache at the moment when the routine was added to it. More...
 
Stored_program_creation_ctxm_creation_ctx
 Snapshot of several system variables at CREATE-time. More...
 
uint32 unsafe_flags
 Flags of LEX::enum_binlog_stmt_unsafe. More...
 

Friends

sp_headsp_start_parsing (THD *thd, enum_sp_type sp_type, sp_name *sp_name)
 Start parsing of a stored program. More...
 

Detailed Description

sp_head represents one instance of a stored program.

It might be of any type (stored procedure, function, trigger, event).

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Possible values of m_flags.

Enumerator
HAS_RETURN 
MULTI_RESULTS 
CONTAINS_DYNAMIC_SQL 
IS_INVOKED 
HAS_SET_AUTOCOMMIT_STMT 
HAS_COMMIT_OR_ROLLBACK 
LOG_SLOW_STATEMENTS 
LOG_GENERAL_LOG 
HAS_SQLCOM_RESET 
HAS_SQLCOM_FLUSH 
MODIFIES_DATA 

Marks routines that directly (i.e.

not by calling other routines) change tables. Note that this flag is set automatically based on type of statements used in the stored routine and is different from routine characteristic provided by user in a form of CONTAINS SQL, READS SQL DATA, MODIFIES SQL DATA clauses. The latter are accepted by parser but pretty much ignored after that. We don't rely on them: a) for compatibility reasons. b) because in CONTAINS SQL case they don't provide enough information anyway.

HAS_TEMP_TABLE_DDL 

Set when a stored program contains sub-statement(s) that creates or drops temporary table(s).

When set, used to mark invoking statement as unsafe to be binlogged in STATEMENT format, when in MIXED mode.

Constructor & Destructor Documentation

◆ sp_head() [1/2]

sp_head::sp_head ( MEM_ROOT &&  mem_root,
enum_sp_type  type 
)
private

Use sp_start_parsing() to create instances of sp_head.

◆ ~sp_head()

sp_head::~sp_head ( )
private

Use destroy() to destoy instances of sp_head.

◆ sp_head() [2/2]

sp_head::sp_head ( const sp_head )
private

Member Function Documentation

◆ add_instr()

bool sp_head::add_instr ( THD thd,
sp_instr instr 
)

Add instruction to SP.

Parameters
thdThread context.
instrInstruction.
Returns
Error status.

◆ add_mark_lead()

void sp_head::add_mark_lead ( uint  ip,
List< sp_instr > *  leads 
)

Helper used during flow analysis during code optimization.

See the implementation of opt_mark().

Parameters
ipthe instruction to add to the leads list
leadsthe list of remaining paths to explore in the graph that represents the code, during flow analysis.

◆ add_used_tables_to_table_list()

void sp_head::add_used_tables_to_table_list ( THD thd,
Table_ref ***  query_tables_last_ptr,
enum_sql_command  sql_command,
Table_ref belong_to_view 
)

Add tables used by routine to the table list.

Converts multi-set of tables used by this routine to table list and adds this list to the end of table list specified by 'query_tables_last_ptr'.

Elements of list will be allocated in PS memroot, so this list will be persistent between PS executions.

Parameters
[in]thdThread context
[in,out]query_tables_last_ptrPointer to the next_global member of last element of the list where tables will be added (or to its root).
[in]sql_commandSQL-command for which we are adding elements to the table list.
[in]belong_to_viewUppermost view which uses this routine, NULL if none.

◆ check_show_access()

bool sp_head::check_show_access ( THD thd,
bool *  full_access 
)

Check if a user has access right to a SP.

Parameters
thdThread context.
[out]full_accessSet to 1 if the user is the owner of the stored program.
Returns
Error status.

◆ create_result_field()

Field * sp_head::create_result_field ( THD thd,
size_t  field_max_length,
const char *  field_name,
TABLE table 
) const

Create Field-object corresponding to the RETURN field of a stored function.

This operation makes sense for stored functions only.

Parameters
thdthread context.
field_max_lengththe max length (in the sense of Item classes).
field_namethe field name (item name).
tablethe field's table.
Returns
newly created and initialized Field-instance, or NULL in case of error.

◆ destroy()

void sp_head::destroy ( sp_head sp)
static

◆ execute()

bool sp_head::execute ( THD thd,
bool  merge_da_on_success 
)
private

Execute the routine.

The main instruction jump loop is there. Assume the parameters already set.

Parameters
thdThread context.
merge_da_on_successFlag specifying if Warning Info should be propagated to the caller on Completion Condition or not.
Returns
Error status.

When inside a substatement (a stored function or trigger statement), clear the metadata observer in THD, if any. Remember the value of the observer here, to be able to restore it when leaving the substatement.

We reset the observer to suppress errors when a substatement uses temporary tables. If a temporary table does not exist at start of the main statement, it's not prelocked and thus is not validated with other prelocked tables.

Later on, when the temporary table is opened, metadata versions mismatch, expectedly.

The proper solution for the problem is to re-validate tables of substatements (Bug#12257, Bug#27011, Bug#32868, Bug#33000), but it's not implemented yet.

◆ execute_external_routine()

bool sp_head::execute_external_routine ( THD thd)
private

Execute external routine.

Parameters
thdThread context.
Returns
Error status.

◆ execute_function()

bool sp_head::execute_function ( THD thd,
Item **  args,
uint  argcount,
Field return_fld 
)

Execute a function.

  • evaluate parameters
  • changes security context for SUID routines
  • switch to new memroot
  • call sp_head::execute
  • restore old memroot
  • evaluate the return value
  • restores security context
Parameters
thdThread context.
argsPassed arguments (these are items from containing statement?)
argcountNumber of passed arguments. We need to check if this is correct.
return_fldSave result here.
Returns
Error status.

◆ execute_procedure()

bool sp_head::execute_procedure ( THD thd,
mem_root_deque< Item * > *  args 
)

Execute a procedure.

The function does the following steps:

  • Set all parameters
  • changes security context for SUID routines
  • call sp_head::execute
  • copy back values of INOUT and OUT parameters
  • restores security context
Parameters
thdThread context.
argsList of values passed as arguments.
Returns
Error status.

◆ execute_trigger()

bool sp_head::execute_trigger ( THD thd,
const LEX_CSTRING db_name,
const LEX_CSTRING table_name,
GRANT_INFO grant_info 
)

Execute trigger stored program.

  • changes security context for triggers
  • switch to new memroot
  • call sp_head::execute
  • restore old memroot
  • restores security context
Parameters
thdThread context
db_namedatabase name
table_nametable name
grant_infoGRANT_INFO structure to be filled with information about definer's privileges on subject table
Returns
Error status.

◆ get_creation_ctx()

Stored_program_creation_ctx * sp_head::get_creation_ctx ( )
inline

◆ get_instr()

sp_instr * sp_head::get_instr ( uint  i)
inline

Get SP-instruction at given index.

NOTE: it is important to have unsigned int here, sometimes we get (-1) passed here, so it gets converted to MAX_INT, and the result of the function call is NULL.

◆ get_persistent_mem_root()

MEM_ROOT * sp_head::get_persistent_mem_root ( ) const
inline
Returns
SP-persistent mem-root. Instructions and expressions are stored in its memory between executions.

◆ get_root_parsing_context()

sp_pcontext * sp_head::get_root_parsing_context ( ) const
inline
Returns
root parsing context for this stored program.

◆ has_temp_table_ddl()

bool sp_head::has_temp_table_ddl ( ) const
inline
Returns
true if stored program has sub-statement(s) to CREATE/DROP temporary table(s).
Return values
trueif HAS_TEMP_TABLE_DDL is set in m_flags.
falseOtherwise.

◆ has_updated_trigger_fields()

bool sp_head::has_updated_trigger_fields ( const MY_BITMAP used_fields) const

Check whether any table's fields are used in trigger.

Parameters
[in]used_fieldsbitmap of fields to check
Returns
Check result
Return values
trueSome table fields are used in trigger
falseNone of table fields are used in trigger

◆ init_external_routine()

bool sp_head::init_external_routine ( my_service< const mysql_service_external_program_execution_t > &  service)

Initialize and parse an external routine.

If m_language_stored_program is already set, nothing will be done.

Parameters
serviceThe_program_execution service that will be used to execute this function
Returns
false on success; true on failure

◆ init_sp_name()

void sp_head::init_sp_name ( THD thd,
sp_name spname 
)
private

Copy sp name from parser.

◆ instructions()

uint sp_head::instructions ( )
inline

◆ is_invoked()

bool sp_head::is_invoked ( ) const
inline

Is this routine being executed?

◆ is_not_allowed_in_function()

bool sp_head::is_not_allowed_in_function ( const char *  where)
inline

Check if this stored routine contains statements disallowed in a stored function or trigger, and set an appropriate error message if this is the case.

◆ is_sql()

bool sp_head::is_sql ( ) const
inline
Returns
true if this is an SQL routine, and false if it is an external routine

◆ last_instruction()

sp_instr * sp_head::last_instruction ( )
inline

◆ mark_used_trigger_fields()

void sp_head::mark_used_trigger_fields ( TABLE subject_table)

◆ merge_table_list()

bool sp_head::merge_table_list ( THD thd,
Table_ref table,
LEX lex_for_tmp_check 
)
private

Merge the list of tables used by some query into the multi-set of tables used by routine.

Parameters
thdThread context.
tableTable list.
lex_for_tmp_checkLEX of the query for which we are merging table list.
Note
This method will use LEX provided to check whenever we are creating temporary table and mark it as such in target multi-set.
Returns
Error status.

◆ modifies_data()

bool sp_head::modifies_data ( ) const
inline

Returns true if any substatement in the routine directly (not through another routine) modifies data/changes table.

See also
Comment for MODIFIES_DATA flag.

◆ name()

char * sp_head::name ( uint *  lenp = nullptr) const
inline

◆ operator=()

void sp_head::operator= ( sp_head )
private

◆ opt_mark()

void sp_head::opt_mark ( )
private

Perform a forward flow analysis in the generated code.

Mark reachable instructions, for the optimizer.

◆ optimize()

void sp_head::optimize ( )

Do some minimal optimization of the code:

  1. Mark used instructions
    1. While doing this, shortcut jumps to jump instructions
    2. Compact the code, removing unused instructions.

This is the main mark and move loop; it relies on the following methods in sp_instr and its subclasses:

  • opt_mark() : Mark instruction as reachable
  • opt_shortcut_jump(): Shortcut jumps to the final destination; used by opt_mark().
  • opt_move() : Update moved instruction
  • set_destination() : Set the new destination (jump instructions only)

◆ propagate_attributes()

void sp_head::propagate_attributes ( Query_tables_list prelocking_ctx)
inline

◆ reset_lex()

bool sp_head::reset_lex ( THD thd)

Reset LEX-object during parsing, before we parse a sub statement.

Parameters
thdThread context.
Returns
Error status.

◆ restore_lex()

bool sp_head::restore_lex ( THD thd)

Restore LEX-object during parsing, after we have parsed a sub statement.

Parameters
thdThread context.
Returns
Error status.

◆ returns_type()

void sp_head::returns_type ( THD thd,
String result 
) const

◆ set_body_end()

void sp_head::set_body_end ( THD thd)

Set the statement-definition (body-definition) end position.

◆ set_body_start()

void sp_head::set_body_start ( THD thd,
const char *  begin_ptr 
)

Set the body-definition start position.

◆ set_creation_ctx()

void sp_head::set_creation_ctx ( Stored_program_creation_ctx creation_ctx)
inline

◆ set_definer() [1/2]

void sp_head::set_definer ( const char *  definer,
size_t  definerlen 
)

◆ set_definer() [2/2]

void sp_head::set_definer ( const LEX_CSTRING user_name,
const LEX_CSTRING host_name 
)

◆ set_info()

void sp_head::set_info ( longlong  created,
longlong  modified,
st_sp_chistics chistics,
sql_mode_t  sql_mode 
)

◆ set_security_ctx()

bool sp_head::set_security_ctx ( THD thd,
Security_context **  save_ctx 
)

Change routine security context, and check if there is an EXECUTE privilege in new context.

If there is no EXECUTE privilege, change the context back and return an error.

Parameters
thdThread context.
[out]save_ctxWhere to save the old security context.
Returns
Error status.

◆ set_sp_cache_version()

void sp_head::set_sp_cache_version ( int64  sp_cache_version)
inline

Set the value of the SP cache version.

◆ setup_trigger_fields()

bool sp_head::setup_trigger_fields ( THD thd,
Table_trigger_field_support tfs,
GRANT_INFO subject_table_grant,
bool  need_fix_fields 
)

◆ show_routine_code()

bool sp_head::show_routine_code ( THD thd)

Return the routine instructions as a result set.

Returns
Error status.

◆ sp_cache_version()

int64 sp_head::sp_cache_version ( ) const
inline

Get the value of the SP cache version, as remembered when the routine was inserted into the cache.

Friends And Related Function Documentation

◆ sp_start_parsing

sp_head * sp_start_parsing ( THD thd,
enum_sp_type  sp_type,
sp_name sp_name 
)
friend

Start parsing of a stored program.

This function encapsulates all the steps necessary to initialize sp_head to start parsing SP.

Every successful call of sp_start_parsing() must finish with sp_finish_parsing().

Parameters
thdThread context.
sp_typeThe stored program type
sp_nameThe stored program name
Returns
properly initialized sp_head-instance in case of success, or NULL is case of out-of-memory error.

Member Data Documentation

◆ code

LEX_CSTRING sp_head::code

Code if language is not SQL.

◆ m_body

LEX_CSTRING sp_head::m_body

◆ m_body_utf8

LEX_CSTRING sp_head::m_body_utf8

◆ m_chistics

st_sp_chistics* sp_head::m_chistics

Stored program characteristics.

◆ m_created

longlong sp_head::m_created

◆ m_creation_ctx

Stored_program_creation_ctx* sp_head::m_creation_ctx
private

Snapshot of several system variables at CREATE-time.

◆ m_cur_instr_trig_field_items

SQL_I_List<Item_trigger_field> sp_head::m_cur_instr_trig_field_items

List of all the Item_trigger_field items created while parsing sp instruction.

After parsing, in add_instr method this list is moved to per instruction Item_trigger_field list "sp_lex_instr::m_trig_field_list".

◆ m_db

LEX_STRING sp_head::m_db

◆ m_definer_host

LEX_STRING sp_head::m_definer_host

◆ m_definer_user

LEX_STRING sp_head::m_definer_user

◆ m_explicit_name

bool sp_head::m_explicit_name

Prepend the db name? *‍/.

◆ m_first_free_instance

sp_head* sp_head::m_first_free_instance

Pointer to the first free (non-INVOKED) routine in the list of cached instances for this SP.

This pointer is set only for the first SP in the list of instances (see above m_first_cached_sp pointer). The pointer equal to 0 if we have no free instances. For non-first instance value of this pointer meaningless (point to itself);

◆ m_first_instance

sp_head* sp_head::m_first_instance

Pointer to the first element of the above list.

◆ m_flags

uint sp_head::m_flags

Stored program flags.

◆ m_instructions

Mem_root_array<sp_instr *> sp_head::m_instructions
private

The SP-instructions.

◆ m_language_stored_program

external_program_handle sp_head::m_language_stored_program

language component related state of this sp.

◆ m_last_cached_sp

sp_head* sp_head::m_last_cached_sp

Pointer to the last element in the list of instances of the SP.

For non-first instance value of this pointer meaningless (point to itself);

◆ m_list_of_trig_fields_item_lists

SQL_I_List<SQL_I_List<Item_trigger_field> > sp_head::m_list_of_trig_fields_item_lists

List of item (Item_trigger_field objects)'s lists representing fields in old/new version of row in trigger.

We use this list for checking whether all such fields are valid or not at trigger creation time and for binding these fields to TABLE object at table open (although for latter pointer to table being opened is probably enough).

◆ m_modified

longlong sp_head::m_modified

◆ m_name

LEX_STRING sp_head::m_name

◆ m_next_cached_sp

sp_head* sp_head::m_next_cached_sp

A list of different recursion level instances for the same procedure.

For every recursion level we have an sp_head instance. This instances connected in the list. The list ordered by increasing recursion level (m_recursion_level).

◆ m_params

LEX_STRING sp_head::m_params

◆ m_parser_data

sp_parser_data sp_head::m_parser_data

Attributes used during the parsing stage only.

◆ m_qname

LEX_STRING sp_head::m_qname

Fully qualified name (<db name>.<sp name>).

◆ m_recursion_level

ulong sp_head::m_recursion_level

Recursion level of the current SP instance.

The levels are numbered from 0.

◆ m_return_field_def

Create_field sp_head::m_return_field_def

Definition of the RETURN-field (from the RETURNS-clause).

It's used (and valid) for stored functions only.

◆ m_root_parsing_ctx

sp_pcontext* sp_head::m_root_parsing_ctx
private

Root parsing context (topmost BEGIN..END block) of this SP.

◆ m_security_ctx

Security_context sp_head::m_security_ctx

◆ m_sp_cache_version

int64 sp_head::m_sp_cache_version
private

Version of the stored routine cache at the moment when the routine was added to it.

Is used only for functions and procedures, not used for triggers or events. When sp_head is created, its version is 0. When it's added to the cache, the version is assigned the global value 'Cversion'. If later on Cversion is incremented, we know that the routine is obsolete and should not be used – sp_cache_flush_obsolete() will purge it.

◆ m_sp_share

PSI_sp_share* sp_head::m_sp_share

Instrumentation interface for SP.

◆ m_sptabs

collation_unordered_map<std::string, SP_TABLE *> sp_head::m_sptabs
private

Multi-set representing optimized list of tables to be locked by this routine.

Does not include tables which are used by invoked routines.

Note
For prelocking-free SPs this multiset is constructed too. We do so because the same instance of sp_head may be called both in prelocked mode and in non-prelocked mode.

◆ m_sptabs_sorted

std::vector<SP_TABLE *> sp_head::m_sptabs_sorted
private

◆ m_sql_mode

sql_mode_t sp_head::m_sql_mode

The value of sql_mode system variable at the CREATE-time.

It should be stored along with the character sets in the Stored_program_creation_ctx.

◆ m_sroutines

malloc_unordered_map<std::string, Sroutine_hash_entry *> sp_head::m_sroutines

Set containing names of stored routines used by this routine.

Note that unlike elements of similar set for statement elements of this set are not linked in one list. Because of this we are able save memory by using for this set same objects that are used in 'sroutines' sets for statements of which this stored routine consists.

See Sroutine_hash_entry for explanation why this hash uses binary key comparison.

◆ m_trg_chistics

st_trg_chistics sp_head::m_trg_chistics

Trigger characteristics.

◆ m_trg_list

class Table_trigger_dispatcher* sp_head::m_trg_list

The Table_trigger_dispatcher instance, where this trigger belongs to.

◆ m_type

enum_sp_type sp_head::m_type

Stored program type.

◆ main_mem_root

MEM_ROOT sp_head::main_mem_root
private

SP-persistent memory root (for instructions and expressions).

◆ unsafe_flags

uint32 sp_head::unsafe_flags
private

Flags of LEX::enum_binlog_stmt_unsafe.


The documentation for this class was generated from the following files: