/******************************************************************//**
Creates a symbol table for a single stored procedure or query.
@return own: symbol table */
sym_tab_t*
sym_tab_create( /*===========*/
mem_heap_t* heap); /*!< in: memory heap where to create */ /******************************************************************//**
Frees the memory allocated dynamically AFTER parsing phase for variables
etc. in the symbol table. Does not free the mem heap where the table was
originally created. Frees also SQL explicit cursor definitions. */ void
sym_tab_free_private( /*=================*/
sym_tab_t* sym_tab); /*!< in, own: symbol table */ /******************************************************************//**
Adds an integer literal to a symbol table.
@return symbol table node */
sym_node_t*
sym_tab_add_int_lit( /*================*/
sym_tab_t* sym_tab, /*!< in: symbol table */
ulint val); /*!< in: integer value */ /******************************************************************//**
Adds an string literal to a symbol table.
@return symbol table node */
sym_node_t*
sym_tab_add_str_lit( /*================*/
sym_tab_t* sym_tab, /*!< in: symbol table */ const byte* str, /*!< in: string with no quotes around
it */
ulint len); /*!< in: string length */ /******************************************************************//**
Add a bound literal to a symbol table.
@return symbol table node */
sym_node_t*
sym_tab_add_bound_lit( /*==================*/
sym_tab_t* sym_tab, /*!< in: symbol table */ constchar* name, /*!< in: name of bound literal */
ulint* lit_type); /*!< out: type of literal (PARS_*_LIT) */ /**********************************************************************
Rebind literal to a node in the symbol table. */
sym_node_t*
sym_tab_rebind_lit( /*===============*/ /* out: symbol table node */
sym_node_t* node, /* in: node that is bound to literal*/ constvoid* address, /* in: pointer to data */
ulint length); /* in: length of data */ /******************************************************************//**
Adds an SQL null literal to a symbol table.
@return symbol table node */
sym_node_t*
sym_tab_add_null_lit( /*=================*/
sym_tab_t* sym_tab); /*!< in: symbol table */ /******************************************************************//**
Adds an identifier to a symbol table.
@return symbol table node */
sym_node_t*
sym_tab_add_id( /*===========*/
sym_tab_t* sym_tab, /*!< in: symbol table */
byte* name, /*!< in: identifier name */
ulint len); /*!< in: identifier length */
/******************************************************************//**
Add a bound identifier to a symbol table.
@return symbol table node */
sym_node_t*
sym_tab_add_bound_id( /*===========*/
sym_tab_t* sym_tab, /*!< in: symbol table */ constchar* name); /*!< in: name of bound id */
/** Index of sym_node_t::field_nos corresponding to the clustered index */ #define SYM_CLUST_FIELD_NO 0 /** Index of sym_node_t::field_nos corresponding to a secondary index */ #define SYM_SEC_FIELD_NO 1
/** Types of a symbol table node */ enum sym_tab_entry {
SYM_UNSET, /*!< Unset entry. */
SYM_VAR = 91, /*!< declared parameter or local
variable of a procedure */
SYM_IMPLICIT_VAR, /*!< storage for a intermediate result
of a calculation */
SYM_LIT, /*!< literal */
SYM_TABLE_REF_COUNTED, /*!< database table name, ref counted. Must
be closed explicitly. */
SYM_TABLE, /*!< database table name */
SYM_COLUMN, /*!< database table name */
SYM_CURSOR, /*!< named cursor */
SYM_PROCEDURE_NAME, /*!< stored procedure name */
SYM_INDEX, /*!< database index name */
SYM_FUNCTION /*!< user function name */
};
/** Symbol table node */ struct sym_node_t{
que_common_t common; /*!< node type:
QUE_NODE_SYMBOL */ /* NOTE: if the data field in 'common.val' is not NULL and the symbol tablenodeisnotforatemporarycolumn,thememoryforthevaluehas beenallocatedfromdynamicmemoryanditshouldbefreedwhenthe
symbol table is discarded */
/* 'alias' and 'indirection' are almost the same, but not quite. 'alias'alwayspointstotheprimaryinstanceofthevariable,while 'indirection'doesthesameonlyifweshouldusetheprimary instance'svaluesforthenode'sdata.Thisisusuallythecase,but wheninitializingacursor(e.g.,"DECLARECURSORcISSELECT*FROM tWHEREid=x;"),wecopythevaluesfromtheprimaryinstanceto thecursor'sinstancesothattheyarefixedforthedurationofthe cursor,andset'indirection'toNULL.Ifwedidnot,thevalueof 'x'couldchangebetweenfetchesandthingswouldbreakhorribly.
TODO:Itwouldbecleanertomake'indirection'abooleanfieldand
always use 'alias' to refer to the primary node. */
sym_node_t* indirection; /*!< pointer to anothersymboltable nodewhichcontains thevalueforthis
node, NULL otherwise */
sym_node_t* alias; /*!< pointer to anothersymboltable nodeforwhichthis nodeisanalias,
NULL otherwise */
UT_LIST_NODE_T(sym_node_t) col_var_list; /*!< list of table columnsoralistof inputvariablesforan
explicit cursor */
ibool copy_val; /*!< TRUE if a column anditsvalueshould becopiedtodynamic
memory when fetched */
ulint field_nos[2]; /*!< if a column, in theposition SYM_CLUST_FIELD_NOis thefieldnumberinthe clusteredindex;in theposition SYM_SEC_FIELD_NO thefieldnumberinthe non-clusteredindexto usefirst;ifnotfound fromtheindex,then
ULINT_UNDEFINED */
ibool resolved; /*!< TRUE if the meaningofavariable oracolumnhasbeen resolved;forliterals
this is always TRUE */ enum sym_tab_entry token_type; /*!< type of the
parsed token */ constchar* name; /*!< name of an id */
ulint name_len; /*!< id name length */
dict_table_t* table; /*!< table definition ifatableidora
column id */
ulint col_no; /*!< column number if a
column */
sel_buf_t* prefetch_buf; /*!< NULL, or a buffer forcachedcolumn valuesforprefetched
rows */
sel_node_t* cursor_def; /*!< cursor definition selectnodeifa
named cursor */
ulint param_type; /*!< PARS_INPUT, PARS_OUTPUT,or PARS_NOT_PARAMifnota
procedure parameter */
sym_tab_t* sym_table; /*!< back pointer to
the symbol table */
UT_LIST_NODE_T(sym_node_t) sym_list; /*!< list of symbol
nodes */
sym_node_t* like_node; /* LIKE operator node*/
};
/** Symbol table */ struct sym_tab_t{
que_t* query_graph; /*!< query graph generated by the
parser */ constchar* sql_string; /*!< SQL string to parse */
size_t string_len; /*!< SQL string length */
size_t next_char_pos; /*!< position of the next character in sql_stringtogivetothelexical
analyzer */
pars_info_t* info; /*!< extra information, or NULL */
sym_node_list_t sym_list; /*!< list of symbol nodes in the symbol
table */
UT_LIST_BASE_NODE_T(func_node_t)
func_node_list; /*!< list of function nodes in the
parsed query graph */
mem_heap_t* heap; /*!< memory heap from which we can
allocate space */
};
#endif
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.