MySQL  8.0.18
Source Code Documentation
sp_parser_data Class Reference

sp_parser_data provides a scope for attributes used at the SP-parsing stage only. More...

#include <sp_head.h>

Classes

struct  Backpatch_info
 

Public Member Functions

 sp_parser_data ()
 
void start_parsing_sp_body (THD *thd, sp_head *sp)
 Start parsing a stored program body statement. More...
 
void finish_parsing_sp_body (THD *thd)
 Finish parsing of a stored program body statement. More...
 
bool is_parsing_sp_body () const
 
void process_new_sp_instr (THD *thd, sp_instr *i)
 
const char * get_current_stmt_start_ptr () const
 
void set_current_stmt_start_ptr (const char *stmt_start_ptr)
 
const char * get_option_start_ptr () const
 
void set_option_start_ptr (const char *option_start_ptr)
 
const char * get_parameter_start_ptr () const
 
void set_parameter_start_ptr (const char *ptr)
 
const char * get_parameter_end_ptr () const
 
void set_parameter_end_ptr (const char *ptr)
 
const char * get_body_start_ptr () const
 
void set_body_start_ptr (const char *ptr)
 
void push_lex (LEX *lex)
 
LEXpop_lex ()
 
bool add_backpatch_entry (sp_branch_instr *i, sp_label *label)
 Put the instruction on the backpatch list, associated with the label. More...
 
void do_backpatch (sp_label *label, uint dest)
 Update all instruction with the given label in the backpatch list to the given instruction pointer. More...
 
bool new_cont_backpatch ()
 Start a new backpatch level for the SP-instruction requiring continue destination. More...
 
bool add_cont_backpatch_entry (sp_lex_branch_instr *i)
 Add a SP-instruction to the current level. More...
 
void do_cont_backpatch (uint dest)
 Backpatch (and pop) the current level to the given instruction pointer. More...
 

Private Attributes

const char * m_current_stmt_start_ptr
 Start of the current statement's query string. More...
 
const char * m_option_start_ptr
 Start of the SET-expression query string. More...
 
List< LEXm_lex_stack
 Stack of LEX-objects. More...
 
const char * m_param_start_ptr
 Position in the CREATE PROCEDURE- or CREATE FUNCTION-statement's query string corresponding to the start of parameter declarations (stored procedure or stored function parameters). More...
 
const char * m_param_end_ptr
 Position in the CREATE PROCEDURE- or CREATE FUNCTION-statement's query string corresponding to the end of parameter declarations (stored procedure or stored function parameters). More...
 
const char * m_body_start_ptr
 Position in the CREATE-/ALTER-stored-program statement's query string corresponding to the start of the first SQL-statement. More...
 
List< Backpatch_infom_backpatch
 Instructions needing backpatching. More...
 
List< sp_lex_branch_instrm_cont_backpatch
 We need a special list for backpatching of instructions with a continue destination (in the case of a continue handler catching an error in the test), since it would otherwise interfere with the normal backpatch mechanism - e.g. More...
 
uint m_cont_level
 The current continue backpatch level. More...
 
MEM_ROOTm_saved_memroot
 THD's memroot. More...
 
Itemm_saved_item_list
 THD's item list. More...
 

Detailed Description

sp_parser_data provides a scope for attributes used at the SP-parsing stage only.

Constructor & Destructor Documentation

◆ sp_parser_data()

sp_parser_data::sp_parser_data ( )
inline

Member Function Documentation

◆ add_backpatch_entry()

bool sp_parser_data::add_backpatch_entry ( sp_branch_instr i,
sp_label label 
)

Put the instruction on the backpatch list, associated with the label.

Parameters
iThe SP-instruction.
labelThe label.
Returns
Error flag.

◆ add_cont_backpatch_entry()

bool sp_parser_data::add_cont_backpatch_entry ( sp_lex_branch_instr i)

Add a SP-instruction to the current level.

Parameters
iThe SP-instruction.
Returns
Error flag.

◆ do_backpatch()

void sp_parser_data::do_backpatch ( sp_label label,
uint  dest 
)

Update all instruction with the given label in the backpatch list to the given instruction pointer.

Parameters
labelThe label.
destThe instruction pointer.

◆ do_cont_backpatch()

void sp_parser_data::do_cont_backpatch ( uint  dest)

Backpatch (and pop) the current level to the given instruction pointer.

Parameters
destThe instruction pointer.

◆ finish_parsing_sp_body()

void sp_parser_data::finish_parsing_sp_body ( THD thd)
inline

Finish parsing of a stored program body statement.

This method switches THD::mem_root and THD::m_item_list back when SP-body parsing is completed.

Parameters
thdThread context.

◆ get_body_start_ptr()

const char* sp_parser_data::get_body_start_ptr ( ) const
inline

◆ get_current_stmt_start_ptr()

const char* sp_parser_data::get_current_stmt_start_ptr ( ) const
inline

◆ get_option_start_ptr()

const char* sp_parser_data::get_option_start_ptr ( ) const
inline

◆ get_parameter_end_ptr()

const char* sp_parser_data::get_parameter_end_ptr ( ) const
inline

◆ get_parameter_start_ptr()

const char* sp_parser_data::get_parameter_start_ptr ( ) const
inline

◆ is_parsing_sp_body()

bool sp_parser_data::is_parsing_sp_body ( ) const
inline
Return values
trueif SP-body statement is being parsed.
falseotherwise.

◆ new_cont_backpatch()

bool sp_parser_data::new_cont_backpatch ( )
inline

Start a new backpatch level for the SP-instruction requiring continue destination.

If the SP-instruction is NULL, the level is just increased.

Note
Only subclasses of sp_lex_branch_instr need backpatching of continue destinations (and no other classes do):
  • sp_instr_jump_if_not
  • sp_instr_set_case_expr
  • sp_instr_jump_case_when

That's why the methods below accept sp_lex_branch_instr to make this relationship clear. And these two functions are the only places where set_cont_dest() is used, so set_cont_dest() is also a member of sp_lex_branch_instr.

Returns
false always.

◆ pop_lex()

LEX* sp_parser_data::pop_lex ( )
inline

◆ process_new_sp_instr()

void sp_parser_data::process_new_sp_instr ( THD thd,
sp_instr i 
)

◆ push_lex()

void sp_parser_data::push_lex ( LEX lex)
inline

◆ set_body_start_ptr()

void sp_parser_data::set_body_start_ptr ( const char *  ptr)
inline

◆ set_current_stmt_start_ptr()

void sp_parser_data::set_current_stmt_start_ptr ( const char *  stmt_start_ptr)
inline

◆ set_option_start_ptr()

void sp_parser_data::set_option_start_ptr ( const char *  option_start_ptr)
inline

◆ set_parameter_end_ptr()

void sp_parser_data::set_parameter_end_ptr ( const char *  ptr)
inline

◆ set_parameter_start_ptr()

void sp_parser_data::set_parameter_start_ptr ( const char *  ptr)
inline

◆ start_parsing_sp_body()

void sp_parser_data::start_parsing_sp_body ( THD thd,
sp_head sp 
)

Start parsing a stored program body statement.

This method switches THD::mem_root and THD::m_item_list in order to parse SP-body. The current values are kept to be restored after the body statement is parsed.

Parameters
thdThread context.
spStored Program being parsed.

Member Data Documentation

◆ m_backpatch

List<Backpatch_info> sp_parser_data::m_backpatch
private

Instructions needing backpatching.

◆ m_body_start_ptr

const char* sp_parser_data::m_body_start_ptr
private

Position in the CREATE-/ALTER-stored-program statement's query string corresponding to the start of the first SQL-statement.

◆ m_cont_backpatch

List<sp_lex_branch_instr> sp_parser_data::m_cont_backpatch
private

We need a special list for backpatching of instructions with a continue destination (in the case of a continue handler catching an error in the test), since it would otherwise interfere with the normal backpatch mechanism - e.g.

jump_if_not instructions have two different destinations which are to be patched differently. Since these occur in a more restricted way (always the same "level" in the code), we don't need the label.

◆ m_cont_level

uint sp_parser_data::m_cont_level
private

The current continue backpatch level.

◆ m_current_stmt_start_ptr

const char* sp_parser_data::m_current_stmt_start_ptr
private

Start of the current statement's query string.

◆ m_lex_stack

List<LEX> sp_parser_data::m_lex_stack
private

Stack of LEX-objects.

It's needed to handle processing of sub-statements.

◆ m_option_start_ptr

const char* sp_parser_data::m_option_start_ptr
private

Start of the SET-expression query string.

◆ m_param_end_ptr

const char* sp_parser_data::m_param_end_ptr
private

Position in the CREATE PROCEDURE- or CREATE FUNCTION-statement's query string corresponding to the end of parameter declarations (stored procedure or stored function parameters).

◆ m_param_start_ptr

const char* sp_parser_data::m_param_start_ptr
private

Position in the CREATE PROCEDURE- or CREATE FUNCTION-statement's query string corresponding to the start of parameter declarations (stored procedure or stored function parameters).

◆ m_saved_item_list

Item* sp_parser_data::m_saved_item_list
private

THD's item list.

◆ m_saved_memroot

MEM_ROOT* sp_parser_data::m_saved_memroot
private

THD's memroot.


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