MySQL 9.0.0
Source Code Documentation
pars0pars.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 1996, 2024, Oracle and/or its affiliates.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License, version 2.0, as published by the
7Free Software Foundation.
8
9This program is designed to work with certain software (including
10but not limited to OpenSSL) that is licensed under separate terms,
11as designated in a particular file or component or in included license
12documentation. The authors of MySQL hereby grant you an additional
13permission to link the program and your derivative works with the
14separately licensed software that they have either included with
15the program or referenced in the documentation.
16
17This program is distributed in the hope that it will be useful, but WITHOUT
18ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
20for more details.
21
22You should have received a copy of the GNU General Public License along with
23this program; if not, write to the Free Software Foundation, Inc.,
2451 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
26*****************************************************************************/
27
28/** @file include/pars0pars.h
29 SQL parser
30
31 Created 11/19/1996 Heikki Tuuri
32 *******************************************************/
33
34#ifndef pars0pars_h
35#define pars0pars_h
36
37#include "pars0types.h"
38#include "que0types.h"
39#include "row0mysql.h"
40#include "row0types.h"
41#include "trx0types.h"
42#include "univ.i"
43#include "usr0types.h"
44#include "ut0vec.h"
45
46/** Type of the user functions. The first argument is always InnoDB-supplied
47and varies in type, while 'user_arg' is a user-supplied argument. The
48meaning of the return type also varies. See the individual use cases, e.g.
49the FETCH statement, for details on them. */
50typedef bool (*pars_user_func_cb_t)(void *arg, void *user_arg);
51
52/** If the following is set true, the parser will emit debugging
53information */
54extern int yydebug;
55
56/* Global variable used while parsing a single procedure or query : the code is
57NOT re-entrant */
59
60/** Mutex to protect the sql parser */
61extern ib_mutex_t pars_mutex;
62
85
87
88/* Procedure parameter types */
89#define PARS_INPUT 0
90#define PARS_OUTPUT 1
91#define PARS_NOT_PARAM 2
92
93int yyparse(void);
94
95/** Initialize for the internal parser */
96void pars_init();
97
98/** Clean up the internal parser */
99void pars_close();
100
101/** Parses an SQL string returning the query graph.
102 @return own: the query graph */
103que_t *pars_sql(pars_info_t *info, /*!< in: extra information, or NULL */
104 const char *str); /*!< in: SQL string */
105
106/** Retrieves characters to the lexical analyzer.
107@param[in,out] buf Buffer where to copy
108@param[in] max_size Maximum number of characters which fit in the buffer
109@return number of characters copied or 0 on EOF
110*/
111int pars_get_lex_chars(char *buf, size_t max_size);
112
113/** Called by yyparse on error. */
114void yyerror(const char *s); /*!< in: error message string */
115/** Parses a variable declaration.
116 @return own: symbol table node of type SYM_VAR */
118 sym_node_t *node, /*!< in: symbol table node allocated for the
119 id of the variable */
120 pars_res_word_t *type); /*!< in: pointer to a type token */
121/** Parses a function expression.
122 @return own: function node in a query tree */
124 que_node_t *res_word, /*!< in: function name reserved word */
125 que_node_t *arg); /*!< in: first argument in the argument list */
126/*************************************************************************
127Rebind a LIKE search string. NOTE: We ignore any '%' characters embedded
128within the search string.
129@return own: function node in a query tree */
130int pars_like_rebind(sym_node_t *node, /* in: The search string node.*/
131 const byte *ptr, /* in: literal to (re) bind */
132 ulint len); /* in: length of literal to (re) bind*/
133/** Parses an operator expression.
134 @return own: function node in a query tree */
135func_node_t *pars_op(int func, /*!< in: operator token code */
136 que_node_t *arg1, /*!< in: first argument */
137 que_node_t *arg2); /*!< in: second argument or NULL for an
138 unary operator */
139/** Parses an ORDER BY clause. Order by a single column only is supported.
140 @return own: order-by node in a query tree */
142 sym_node_t *column, /*!< in: column name */
143 pars_res_word_t *asc); /*!< in: &pars_asc_token or pars_desc_token */
144/** Parses a select list; creates a query graph node for the whole SELECT
145 statement.
146 @return own: select node in a query tree */
148 que_node_t *select_list, /*!< in: select list */
149 sym_node_t *into_list); /*!< in: variables list or NULL */
150/** Parses a cursor declaration.
151 @return sym_node */
153 sym_node_t *sym_node, /*!< in: cursor id node in the symbol
154 table */
155 sel_node_t *select_node); /*!< in: select node */
156/** Parses a function declaration.
157 @return sym_node */
159 sym_node_t *sym_node); /*!< in: function id node in the symbol
160 table */
161/** Parses a select statement.
162 @return own: select node in a query tree */
164 sel_node_t *select_node, /*!< in: select node already containing
165 the select list */
166 sym_node_t *table_list, /*!< in: table list */
167 que_node_t *search_cond, /*!< in: search condition or NULL */
168 pars_res_word_t *for_update, /*!< in: NULL or &pars_update_token */
169 pars_res_word_t *consistent_read, /*!< in: NULL or
170 &pars_consistent_token */
171 order_node_t *order_by); /*!< in: NULL or an order-by node */
172/** Parses a column assignment in an update.
173 @return column assignment node */
175 sym_node_t *column, /*!< in: column to assign */
176 que_node_t *exp); /*!< in: value to assign */
177/** Parses a delete or update statement start.
178 @return own: update node in a query tree */
180 bool is_delete, /*!< in: true if delete */
181 sym_node_t *table_sym, /*!< in: table name node */
182 col_assign_node_t *col_assign_list); /*!< in: column assignment list, NULL
183 if delete */
184/** Parses an update or delete statement.
185 @return own: update node in a query tree */
187 upd_node_t *node, /*!< in: update node */
188 sym_node_t *cursor_sym, /*!< in: pointer to a cursor entry in
189 the symbol table or NULL */
190 que_node_t *search_cond); /*!< in: search condition or NULL */
191/** Parses an insert statement.
192 @return own: update node in a query tree */
194 sym_node_t *table_sym, /*!< in: table name node */
195 que_node_t *values_list, /*!< in: value expression list or NULL */
196 sel_node_t *select); /*!< in: select condition or NULL */
197/** Parses a procedure parameter declaration.
198 @return own: symbol table node of type SYM_VAR */
200 sym_node_t *node, /*!< in: symbol table node allocated for the
201 id of the parameter */
202 ulint param_type,
203 /*!< in: PARS_INPUT or PARS_OUTPUT */
204 pars_res_word_t *type); /*!< in: pointer to a type token */
205/** Parses an elsif element.
206 @return elsif node */
208 que_node_t *cond, /*!< in: if-condition */
209 que_node_t *stat_list); /*!< in: statement list */
210/** Parses an if-statement.
211 @return if-statement node */
213 que_node_t *cond, /*!< in: if-condition */
214 que_node_t *stat_list, /*!< in: statement list */
215 que_node_t *else_part); /*!< in: else-part statement list */
216/** Parses a for-loop-statement.
217 @return for-statement node */
219 sym_node_t *loop_var, /*!< in: loop variable */
220 que_node_t *loop_start_limit, /*!< in: loop start expression */
221 que_node_t *loop_end_limit, /*!< in: loop end expression */
222 que_node_t *stat_list); /*!< in: statement list */
223/** Parses a while-statement.
224 @return while-statement node */
226 que_node_t *cond, /*!< in: while-condition */
227 que_node_t *stat_list); /*!< in: statement list */
228/** Parses an exit statement.
229 @return exit statement node */
231/** Parses a return-statement.
232 @return return-statement node */
234/** Parses an assignment statement.
235 @return assignment statement node */
237 sym_node_t *var, /*!< in: variable to assign */
238 que_node_t *val); /*!< in: value to assign */
239/** Parses a fetch statement. into_list or user_func (but not both) must be
240 non-NULL.
241 @return fetch statement node */
243 sym_node_t *cursor, /*!< in: cursor node */
244 sym_node_t *into_list, /*!< in: variables to set, or NULL */
245 sym_node_t *user_func); /*!< in: user function name, or NULL */
246/** Parses an open or close cursor statement.
247 @return fetch statement node */
248open_node_t *pars_open_statement(ulint type, /*!< in: ROW_SEL_OPEN_CURSOR
249 or ROW_SEL_CLOSE_CURSOR */
250 sym_node_t *cursor); /*!< in: cursor node */
251/** Parses a commit statement.
252 @return own: commit node struct */
254/** Parses a rollback statement.
255 @return own: rollback node struct */
257/** Parses a column definition at a table creation.
258 @return column sym table node */
259sym_node_t *pars_column_def(sym_node_t *sym_node, /*!< in: column node in the
260 symbol table */
261 pars_res_word_t *type, /*!< in: data type */
262 sym_node_t *len, /*!< in: length of column, or
263 NULL */
264 void *is_unsigned, /*!< in: if not NULL, column
265 is of type UNSIGNED. */
266 void *is_not_null); /*!< in: if not NULL, column
267 is of type NOT NULL. */
268
269/** Parses a table creation operation.
270@param[in] table_sym table name node in the symbol table
271@param[in] column_defs list of column names
272@param[in] not_fit_in_memory a non-NULL pointer means that this is a
273 table which in simulations should be
274 simulated as not fitting in memory;
275 thread is put to sleep to simulate disk
276 accesses; NOTE that this flag is not
277 stored to the data dictionary on disk,
278 and the database will forget about
279 non-NULL value if it has to reload the
280 table definition from disk
281@param[in] compact non-NULL if COMPACT table
282@param[in] block_size block size (can be NULL)
283@return table create subgraph */
284tab_node_t *pars_create_table(sym_node_t *table_sym, sym_node_t *column_defs,
285 sym_node_t *compact, sym_node_t *block_size,
286 void *not_fit_in_memory);
287
288/** Parses an index creation operation.
289@param[in] unique_def Not NULL if a unique index.
290@param[in] clustered_def Not NULL if a clustered index.
291@param[in] index_sym Index name node in the symbol table.
292@param[in] table_sym Table name node in the symbol table.
293@param[in] column_list List of column names.
294@return index create subgraph */
296 pars_res_word_t *clustered_def,
297 sym_node_t *index_sym, sym_node_t *table_sym,
298 sym_node_t *column_list);
299/** Parses a procedure definition.
300 @return query fork node */
302 sym_node_t *sym_node, /*!< in: procedure id node in the symbol
303 table */
304 sym_node_t *param_list, /*!< in: parameter declaration list */
305 que_node_t *stat_list); /*!< in: statement list */
306
307/** Completes a query graph by adding query thread and fork nodes
308above it and prepares the graph for running. The fork created is of
309type QUE_FORK_MYSQL_INTERFACE.
310@param[in] node root node for an incomplete query
311 graph, or NULL for dummy graph
312@param[in] trx transaction handle
313@param[in] heap memory heap from which allocated
314@param[in] prebuilt row prebuilt structure
315@return query thread node to run */
317 trx_t *trx,
318 mem_heap_t *heap,
319 row_prebuilt_t *prebuilt);
320
321/** Create parser info struct.
322 @return own: info struct */
324
325/** Free info struct and everything it contains. */
326void pars_info_free(pars_info_t *info); /*!< in, own: info struct */
327
328/** Add bound literal.
329@param[in] info Info struct
330@param[in] name Name
331@param[in] address Address
332@param[in] length Length of data
333@param[in] type Type, e.g. data_fixbinary
334@param[in] prtype Precise type, e.g. data_unsigned */
335void pars_info_add_literal(pars_info_t *info, const char *name,
336 const void *address, ulint length, ulint type,
337 ulint prtype);
338
339/** Equivalent to pars_info_add_literal(info, name, str, strlen(str),
340 DATA_VARCHAR, DATA_ENGLISH).
341@param[in] info Info struct
342@param[in] name Name
343@param[in] str String */
344void pars_info_add_str_literal(pars_info_t *info, const char *name,
345 const char *str);
346
347/********************************************************************
348If the literal value already exists then it rebinds otherwise it
349creates a new entry.*/
350void pars_info_bind_literal(pars_info_t *info, /* in: info struct */
351 const char *name, /* in: name */
352 const void *address, /* in: address */
353 ulint length, /* in: length of data */
354 ulint type, /* in: type, e.g. DATA_FIXBINARY */
355 ulint prtype); /* in: precise type, e.g. */
356
357/** If the literal value already exists then it rebinds otherwise it
358creates a new entry.
359@param[in] info Info struct
360@param[in] name Name
361@param[in] str String
362@param[in] str_len String length */
363void pars_info_bind_varchar_literal(pars_info_t *info, const char *name,
364 const byte *str, ulint str_len);
365
366/** If the literal value already exists then it rebinds otherwise it creates a
367new entry.
368@param[in] info Info struct
369@param[in] name Name
370@param[in] val Value */
371void pars_info_bind_int4_literal(pars_info_t *info, const char *name,
372 const uint32_t *val);
373
374/** If the literal value already exists then it rebinds otherwise it creates a
375new entry.
376@param[in] info Info struct
377@param[in] name Name
378@param[in] val Value */
379void pars_info_bind_int8_literal(pars_info_t *info, const char *name,
380 const uint64_t *val);
381
382/** Add user function.
383@param[in] info Info struct
384@param[in] name Function name
385@param[in] func Function address
386@param[in] arg User-supplied argument */
387void pars_info_bind_function(pars_info_t *info, const char *name,
388 pars_user_func_cb_t func, void *arg);
389
390/** Add bound id.
391@param[in] info info struct
392@param[in] copy_name copy name if true
393@param[in] name name
394@param[in] id id */
395void pars_info_bind_id(pars_info_t *info, bool copy_name, const char *name,
396 const char *id);
397
398/** Equivalent to:
399
400 char buf[4];
401 mach_write_to_4(buf, val);
402 pars_info_add_literal(info, name, buf, 4, DATA_INT, 0);
403
404 except that the buffer is dynamically allocated from the info struct's
405 heap. */
406void pars_info_add_int4_literal(pars_info_t *info, /*!< in: info struct */
407 const char *name, /*!< in: name */
408 lint val); /*!< in: value */
409
410/** Equivalent to:
411
412 char buf[8];
413 mach_write_to_8(buf, val);
414 pars_info_add_literal(info, name, buf, 8, DATA_FIXBINARY, 0);
415
416 except that the buffer is dynamically allocated from the info struct's
417 heap. */
418void pars_info_add_ull_literal(pars_info_t *info, /*!< in: info struct */
419 const char *name, /*!< in: name */
420 uint64_t val); /*!< in: value */
421
422/** If the literal value already exists then it rebinds otherwise it
423 creates a new entry.
424@param[in] info Info struct
425@param[in] name Name
426@param[in] val Value */
427void pars_info_bind_ull_literal(pars_info_t *info, const char *name,
428 const uint64_t *val);
429
430/** Add bound id.
431@param[in] info info struct
432@param[in] name name
433@param[in] id id */
434void pars_info_add_id(pars_info_t *info, const char *name, const char *id);
435
436/** Get bound literal with the given name.
437 @return bound literal, or NULL if not found */
439 pars_info_t *info, /*!< in: info struct */
440 const char *name); /*!< in: bound literal name to find */
441
442/** Get bound identifier with the given name.
443@param[in] info info struct
444@param[in] name bound id name to find
445@return bound id, or NULL if not found */
447
448/** Release any resources used by the lexer. */
450
451/** Extra information supplied for pars_sql(). */
453 mem_heap_t *heap; /*!< our own memory heap */
454
455 ib_vector_t *funcs; /*!< user functions, or NUll
456 (pars_user_func_t*) */
457 ib_vector_t *bound_lits; /*!< bound literals, or NULL
458 (pars_bound_lit_t*) */
459 ib_vector_t *bound_ids; /*!< bound ids, or NULL
460 (pars_bound_id_t*) */
461
462 bool graph_owns_us; /*!< if true (which is the default),
463 que_graph_free() will free us */
464};
465
466/** User-supplied function and argument. */
468 const char *name; /*!< function name */
469 pars_user_func_cb_t func; /*!< function address */
470 void *arg; /*!< user-supplied argument */
471};
472
473/** Bound literal. */
475 const char *name; /*!< name */
476 const void *address; /*!< address */
477 ulint length; /*!< length of data */
478 ulint type; /*!< type, e.g. DATA_FIXBINARY */
479 ulint prtype; /*!< precise type, e.g. DATA_UNSIGNED */
480 sym_node_t *node; /*!< symbol node */
481};
482
483/** Bound identifier. */
485 const char *name; /*!< name */
486 const char *id; /*!< identifier */
487};
488
489/** Struct used to denote a reserved word in a parsing tree */
491 int code; /*!< the token code for the reserved word from
492 pars0grm.h */
493};
494
495/** A predefined function or operator node in a parsing tree; this construct
496is also used for some non-functions like the assignment ':=' */
498 que_common_t common; /*!< type: QUE_NODE_FUNC */
499 int func; /*!< token code of the function name */
500 ulint fclass; /*!< class of the function */
501 que_node_t *args; /*!< argument(s) of the function */
503 /*!< list of comparison conditions; defined
504 only for comparison operator nodes except,
505 presently, for OPT_SCROLL_TYPE ones */
507 /*!< list of function nodes in a parsed
508 query graph */
509};
510
512
514
515/** An order-by node in a select */
517 que_common_t common; /*!< type: QUE_NODE_ORDER */
518 sym_node_t *column; /*!< order-by column */
519 bool asc; /*!< true if ascending, false if descending */
520};
521
522/** Procedure definition node */
524 que_common_t common; /*!< type: QUE_NODE_PROC */
525 sym_node_t *proc_id; /*!< procedure name symbol in the symbol
526 table of this same procedure */
527 sym_node_t *param_list; /*!< input and output parameters */
528 que_node_t *stat_list; /*!< statement list */
529 sym_tab_t *sym_tab; /*!< symbol table of this procedure */
530};
531
532/** elsif-element node */
534 que_common_t common; /*!< type: QUE_NODE_ELSIF */
535 que_node_t *cond; /*!< if condition */
536 que_node_t *stat_list; /*!< statement list */
537};
538
539/** if-statement node */
540struct if_node_t {
541 que_common_t common; /*!< type: QUE_NODE_IF */
542 que_node_t *cond; /*!< if condition */
543 que_node_t *stat_list; /*!< statement list */
544 que_node_t *else_part; /*!< else-part statement list */
545 elsif_node_t *elsif_list; /*!< elsif element list */
546};
547
548/** while-statement node */
550 que_common_t common; /*!< type: QUE_NODE_WHILE */
551 que_node_t *cond; /*!< while condition */
552 que_node_t *stat_list; /*!< statement list */
553};
554
555/** for-loop-statement node */
557 que_common_t common; /*!< type: QUE_NODE_FOR */
558 sym_node_t *loop_var; /*!< loop variable: this is the
559 dereferenced symbol from the
560 variable declarations, not the
561 symbol occurrence in the for loop
562 definition */
563 que_node_t *loop_start_limit; /*!< initial value of loop variable */
564 que_node_t *loop_end_limit; /*!< end value of loop variable */
565 lint loop_end_value; /*!< evaluated value for the end value:
566 it is calculated only when the loop
567 is entered, and will not change within
568 the loop */
569 que_node_t *stat_list; /*!< statement list */
570};
571
572/** exit statement node */
574 que_common_t common; /*!< type: QUE_NODE_EXIT */
575};
576
577/** return-statement node */
579 que_common_t common; /*!< type: QUE_NODE_RETURN */
580};
581
582/** Assignment statement node */
584 que_common_t common; /*!< type: QUE_NODE_ASSIGNMENT */
585 sym_node_t *var; /*!< variable to set */
586 que_node_t *val; /*!< value to assign */
587};
588
589/** Column assignment node */
591 que_common_t common; /*!< type: QUE_NODE_COL_ASSIGN */
592 sym_node_t *col; /*!< column to set */
593 que_node_t *val; /*!< value to assign */
594};
595
596/** Classes of functions */
597/** @{ */
598#define PARS_FUNC_ARITH 1 /*!< +, -, *, / */
599#define PARS_FUNC_LOGICAL 2 /*!< AND, OR, NOT */
600#define PARS_FUNC_CMP 3 /*!< comparison operators */
601#define PARS_FUNC_PREDEFINED 4 /*!< TO_NUMBER, SUBSTR, ... */
602#define PARS_FUNC_AGGREGATE 5 /*!< COUNT, DISTINCT, SUM */
603#define PARS_FUNC_OTHER \
604 6 /*!< these are not real functions, \
605 e.g., := */
606/** @} */
607
608#include "pars0pars.ic"
609
610#endif
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1081
Definition: buf0block_hint.cc:30
constexpr value_type is_unsigned
Definition: classic_protocol_constants.h:273
constexpr value_type for_update
Definition: classic_protocol_constants.h:214
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
pars_res_word_t pars_instr_token
Definition: pars0pars.cc:71
que_node_t * pars_cursor_declaration(sym_node_t *sym_node, sel_node_t *select_node)
Parses a cursor declaration.
Definition: pars0pars.cc:926
pars_bound_id_t * pars_info_get_bound_id(pars_info_t *info, const char *name)
Get bound identifier with the given name.
Definition: pars0pars.cc:2035
que_t * pars_sql(pars_info_t *info, const char *str)
Parses an SQL string returning the query graph.
Definition: pars0pars.cc:1685
sym_node_t * pars_parameter_declaration(sym_node_t *node, ulint param_type, pars_res_word_t *type)
Parses a procedure parameter declaration.
Definition: pars0pars.cc:1272
ulint pars_star_denoter
Global variable used to denote the '*' in SELECT * FROM.
Definition: pars0pars.cc:92
pars_res_word_t pars_sum_token
Definition: pars0pars.cc:74
void pars_info_free(pars_info_t *info)
Free info struct and everything it contains.
Definition: pars0pars.cc:1776
tab_node_t * pars_create_table(sym_node_t *table_sym, sym_node_t *column_defs, sym_node_t *compact, sym_node_t *block_size, void *not_fit_in_memory)
Parses a table creation operation.
Definition: pars0pars.cc:1593
roll_node_t * pars_rollback_statement(void)
Parses a rollback statement.
Definition: pars0pars.cc:1563
pars_res_word_t pars_length_token
Definition: pars0pars.cc:72
void pars_info_bind_int4_literal(pars_info_t *info, const char *name, const uint32_t *val)
If the literal value already exists then it rebinds otherwise it creates a new entry.
Definition: pars0pars.cc:1895
void pars_info_bind_ull_literal(pars_info_t *info, const char *name, const uint64_t *val)
If the literal value already exists then it rebinds otherwise it creates a new entry.
Definition: pars0pars.cc:1956
upd_node_t * pars_update_statement_start(bool is_delete, sym_node_t *table_sym, col_assign_node_t *col_assign_list)
Parses a delete or update statement start.
Definition: pars0pars.cc:958
void pars_info_bind_varchar_literal(pars_info_t *info, const char *name, const byte *str, ulint str_len)
If the literal value already exists then it rebinds otherwise it creates a new entry.
Definition: pars0pars.cc:1856
pars_res_word_t pars_share_token
Definition: pars0pars.cc:87
pars_res_word_t pars_int_token
Definition: pars0pars.cc:78
ins_node_t * pars_insert_statement(sym_node_t *table_sym, que_node_t *values_list, sel_node_t *select)
Parses an insert statement.
Definition: pars0pars.cc:1157
void pars_info_bind_id(pars_info_t *info, bool copy_name, const char *name, const char *id)
Add bound id.
Definition: pars0pars.cc:2006
order_node_t * pars_order_by(sym_node_t *column, pars_res_word_t *asc)
Parses an ORDER BY clause.
Definition: pars0pars.cc:419
for_node_t * pars_for_statement(sym_node_t *loop_var, que_node_t *loop_start_limit, que_node_t *loop_end_limit, que_node_t *stat_list)
Parses a for-loop-statement.
Definition: pars0pars.cc:1400
void pars_close()
Clean up the internal parser.
Definition: pars0pars.cc:101
void pars_info_bind_int8_literal(pars_info_t *info, const char *name, const uint64_t *val)
If the literal value already exists then it rebinds otherwise it creates a new entry.
Definition: pars0pars.cc:1916
bool(* pars_user_func_cb_t)(void *arg, void *user_arg)
Type of the user functions.
Definition: pars0pars.h:50
sel_node_t * pars_select_statement(sel_node_t *select_node, sym_node_t *table_list, que_node_t *search_cond, pars_res_word_t *for_update, pars_res_word_t *consistent_read, order_node_t *order_by)
Parses a select statement.
Definition: pars0pars.cc:848
func_node_t * pars_func(que_node_t *res_word, que_node_t *arg)
Parses a function expression.
Definition: pars0pars.cc:251
sel_node_t * pars_select_list(que_node_t *select_list, sym_node_t *into_list)
Parses a select list; creates a query graph node for the whole SELECT statement.
Definition: pars0pars.cc:794
sym_node_t * pars_column_def(sym_node_t *sym_node, pars_res_word_t *type, sym_node_t *len, void *is_unsigned, void *is_not_null)
Parses a column definition at a table creation.
Definition: pars0pars.cc:1569
func_node_t * pars_op(int func, que_node_t *arg1, que_node_t *arg2)
Parses an operator expression.
Definition: pars0pars.cc:392
void pars_info_add_id(pars_info_t *info, const char *name, const char *id)
Add bound id.
pars_info_t * pars_info_create(void)
Create parser info struct.
Definition: pars0pars.cc:1758
pars_res_word_t pars_float_token
Definition: pars0pars.cc:81
pars_res_word_t pars_desc_token
Definition: pars0pars.cc:84
void pars_info_add_ull_literal(pars_info_t *info, const char *name, uint64_t val)
Equivalent to:
Definition: pars0pars.cc:1940
pars_bound_lit_t * pars_info_get_bound_lit(pars_info_t *info, const char *name)
Get bound literal with the given name.
Definition: pars0pars.cc:2041
pars_res_word_t pars_blob_token
Definition: pars0pars.cc:77
pars_res_word_t pars_unique_token
Definition: pars0pars.cc:88
commit_node_t * pars_commit_statement(void)
Parses a commit statement.
Definition: pars0pars.cc:1557
pars_res_word_t pars_distinct_token
Definition: pars0pars.cc:75
col_assign_node_t * pars_column_assignment(sym_node_t *column, que_node_t *exp)
Parses a column assignment in an update.
Definition: pars0pars.cc:978
open_node_t * pars_open_statement(ulint type, sym_node_t *cursor)
Parses an open or close cursor statement.
Definition: pars0pars.cc:1531
fetch_node_t * pars_fetch_statement(sym_node_t *cursor, sym_node_t *into_list, sym_node_t *user_func)
Parses a fetch statement.
Definition: pars0pars.cc:1482
int yyparse(void)
Definition: pars0grm.cc:1409
if_node_t * pars_if_statement(que_node_t *cond, que_node_t *stat_list, que_node_t *else_part)
Parses an if-statement.
Definition: pars0pars.cc:1329
sym_node_t * pars_variable_declaration(sym_node_t *node, pars_res_word_t *type)
Parses a variable declaration.
Definition: pars0pars.cc:1255
ind_node_t * pars_create_index(pars_res_word_t *unique_def, pars_res_word_t *clustered_def, sym_node_t *index_sym, sym_node_t *table_sym, sym_node_t *column_list)
Parses an index creation operation.
Definition: pars0pars.cc:1598
pars_res_word_t pars_bigint_token
Definition: pars0pars.cc:79
ib_mutex_t pars_mutex
Mutex to protect the sql parser.
Definition: pars0pars.cc:95
pars_res_word_t pars_substr_token
Definition: pars0pars.cc:69
sym_tab_t * pars_sym_tab_global
Definition: pars0pars.cc:63
pars_res_word_t pars_binary_token
Definition: pars0pars.cc:76
que_node_t * pars_function_declaration(sym_node_t *sym_node)
Parses a function declaration.
Definition: pars0pars.cc:943
pars_res_word_t pars_concat_token
Definition: pars0pars.cc:70
int yydebug
If the following is set true, the parser will emit debugging information.
void pars_info_add_str_literal(pars_info_t *info, const char *name, const char *str)
Equivalent to pars_info_add_literal(info, name, str, strlen(str), DATA_VARCHAR, DATA_ENGLISH).
Definition: pars0pars.cc:1818
elsif_node_t * pars_elsif_element(que_node_t *cond, que_node_t *stat_list)
Parses an elsif element.
Definition: pars0pars.cc:1307
int pars_like_rebind(sym_node_t *node, const byte *ptr, ulint len)
Definition: pars0pars.cc:261
exit_node_t * pars_exit_statement(void)
Parses an exit statement.
Definition: pars0pars.cc:1433
return_node_t * pars_return_statement(void)
Parses a return-statement.
Definition: pars0pars.cc:1445
pars_res_word_t pars_count_token
Definition: pars0pars.cc:73
void pars_info_add_literal(pars_info_t *info, const char *name, const void *address, ulint length, ulint type, ulint prtype)
Add bound literal.
Definition: pars0pars.cc:1788
upd_node_t * pars_update_statement(upd_node_t *node, sym_node_t *cursor_sym, que_node_t *search_cond)
Parses an update or delete statement.
Definition: pars0pars.cc:1076
void pars_info_add_int4_literal(pars_info_t *info, const char *name, lint val)
Equivalent to:
Definition: pars0pars.cc:1880
void pars_info_bind_literal(pars_info_t *info, const char *name, const void *address, ulint length, ulint type, ulint prtype)
Definition: pars0pars.cc:1829
pars_res_word_t pars_asc_token
Definition: pars0pars.cc:83
pars_res_word_t pars_to_binary_token
Definition: pars0pars.cc:68
int pars_get_lex_chars(char *buf, size_t max_size)
Retrieves characters to the lexical analyzer.
Definition: pars0pars.cc:1651
pars_res_word_t pars_close_token
Definition: pars0pars.cc:86
void pars_info_bind_function(pars_info_t *info, const char *name, pars_user_func_cb_t func, void *arg)
Add user function.
Definition: pars0pars.cc:1977
while_node_t * pars_while_statement(que_node_t *cond, que_node_t *stat_list)
Parses a while-statement.
Definition: pars0pars.cc:1376
pars_res_word_t pars_char_token
Definition: pars0pars.cc:80
void pars_init()
Initialize for the internal parser.
Definition: pars0pars.cc:98
pars_res_word_t pars_update_token
Definition: pars0pars.cc:82
pars_res_word_t pars_clustered_token
Definition: pars0pars.cc:89
void yyerror(const char *s)
Called by yyparse on error.
Definition: pars0pars.cc:1674
assign_node_t * pars_assignment_statement(sym_node_t *var, que_node_t *val)
Parses an assignment statement.
Definition: pars0pars.cc:1457
que_fork_t * pars_procedure_definition(sym_node_t *sym_node, sym_node_t *param_list, que_node_t *stat_list)
Parses a procedure definition.
Definition: pars0pars.cc:1605
que_thr_t * pars_complete_graph_for_exec(que_node_t *node, trx_t *trx, mem_heap_t *heap, row_prebuilt_t *prebuilt)
Completes a query graph by adding query thread and fork nodes above it and prepares the graph for run...
Definition: pars0pars.cc:1734
void pars_lexer_close(void)
Release any resources used by the lexer.
pars_res_word_t pars_open_token
Definition: pars0pars.cc:85
SQL parser.
SQL parser global types.
Query graph global types.
void que_node_t
Definition: que0types.h:41
required string type
Definition: replication_group_member_actions.proto:34
Interface between Innobase row operations and MySQL.
Row operation global types.
static void copy_name(char(&to)[N], std::string_view from)
Definition: set_var.cc:604
case opt name
Definition: sslopt-case.h:29
Assignment statement node.
Definition: pars0pars.h:583
sym_node_t * var
variable to set
Definition: pars0pars.h:585
que_node_t * val
value to assign
Definition: pars0pars.h:586
que_common_t common
type: QUE_NODE_ASSIGNMENT
Definition: pars0pars.h:584
Column assignment node.
Definition: pars0pars.h:590
que_common_t common
type: QUE_NODE_COL_ASSIGN
Definition: pars0pars.h:591
que_node_t * val
value to assign
Definition: pars0pars.h:593
sym_node_t * col
column to set
Definition: pars0pars.h:592
Commit command node in a query graph.
Definition: trx0trx.h:1346
elsif-element node
Definition: pars0pars.h:533
que_node_t * stat_list
statement list
Definition: pars0pars.h:536
que_common_t common
type: QUE_NODE_ELSIF
Definition: pars0pars.h:534
que_node_t * cond
if condition
Definition: pars0pars.h:535
exit statement node
Definition: pars0pars.h:573
que_common_t common
type: QUE_NODE_EXIT
Definition: pars0pars.h:574
Fetch statement node.
Definition: row0sel.h:376
for-loop-statement node
Definition: pars0pars.h:556
sym_node_t * loop_var
loop variable: this is the dereferenced symbol from the variable declarations, not the symbol occurre...
Definition: pars0pars.h:558
que_node_t * loop_end_limit
end value of loop variable
Definition: pars0pars.h:564
que_node_t * stat_list
statement list
Definition: pars0pars.h:569
que_common_t common
type: QUE_NODE_FOR
Definition: pars0pars.h:557
que_node_t * loop_start_limit
initial value of loop variable
Definition: pars0pars.h:563
lint loop_end_value
evaluated value for the end value: it is calculated only when the loop is entered,...
Definition: pars0pars.h:565
A predefined function or operator node in a parsing tree; this construct is also used for some non-fu...
Definition: pars0pars.h:497
UT_LIST_NODE_T(func_node_t) func_node_list
list of function nodes in a parsed query graph
que_common_t common
type: QUE_NODE_FUNC
Definition: pars0pars.h:498
UT_LIST_NODE_T(func_node_t) cond_list
list of comparison conditions; defined only for comparison operator nodes except, presently,...
que_node_t * args
argument(s) of the function
Definition: pars0pars.h:501
ulint fclass
class of the function
Definition: pars0pars.h:500
int func
token code of the function name
Definition: pars0pars.h:499
Definition: ut0vec.h:213
if-statement node
Definition: pars0pars.h:540
elsif_node_t * elsif_list
elsif element list
Definition: pars0pars.h:545
que_common_t common
type: QUE_NODE_IF
Definition: pars0pars.h:541
que_node_t * stat_list
statement list
Definition: pars0pars.h:543
que_node_t * cond
if condition
Definition: pars0pars.h:542
que_node_t * else_part
else-part statement list
Definition: pars0pars.h:544
Definition: dict0crea.h:148
Definition: row0ins.h:162
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:302
Open or close cursor statement node.
Definition: row0sel.h:400
An order-by node in a select.
Definition: pars0pars.h:516
que_common_t common
type: QUE_NODE_ORDER
Definition: pars0pars.h:517
bool asc
true if ascending, false if descending
Definition: pars0pars.h:519
sym_node_t * column
order-by column
Definition: pars0pars.h:518
Bound identifier.
Definition: pars0pars.h:484
const char * id
identifier
Definition: pars0pars.h:486
const char * name
name
Definition: pars0pars.h:485
Bound literal.
Definition: pars0pars.h:474
const void * address
address
Definition: pars0pars.h:476
const char * name
name
Definition: pars0pars.h:475
ulint type
type, e.g.
Definition: pars0pars.h:478
sym_node_t * node
symbol node
Definition: pars0pars.h:480
ulint length
length of data
Definition: pars0pars.h:477
ulint prtype
precise type, e.g.
Definition: pars0pars.h:479
Extra information supplied for pars_sql().
Definition: pars0pars.h:452
ib_vector_t * funcs
user functions, or NUll (pars_user_func_t*)
Definition: pars0pars.h:455
ib_vector_t * bound_ids
bound ids, or NULL (pars_bound_id_t*)
Definition: pars0pars.h:459
bool graph_owns_us
if true (which is the default), que_graph_free() will free us
Definition: pars0pars.h:462
mem_heap_t * heap
our own memory heap
Definition: pars0pars.h:453
ib_vector_t * bound_lits
bound literals, or NULL (pars_bound_lit_t*)
Definition: pars0pars.h:457
Struct used to denote a reserved word in a parsing tree.
Definition: pars0pars.h:490
int code
the token code for the reserved word from pars0grm.h
Definition: pars0pars.h:491
User-supplied function and argument.
Definition: pars0pars.h:467
pars_user_func_cb_t func
function address
Definition: pars0pars.h:469
const char * name
function name
Definition: pars0pars.h:468
void * arg
user-supplied argument
Definition: pars0pars.h:470
Procedure definition node.
Definition: pars0pars.h:523
que_common_t common
type: QUE_NODE_PROC
Definition: pars0pars.h:524
sym_tab_t * sym_tab
symbol table of this procedure
Definition: pars0pars.h:529
que_node_t * stat_list
statement list
Definition: pars0pars.h:528
sym_node_t * proc_id
procedure name symbol in the symbol table of this same procedure
Definition: pars0pars.h:525
sym_node_t * param_list
input and output parameters
Definition: pars0pars.h:527
Definition: que0types.h:51
Definition: que0que.h:301
Definition: que0que.h:242
return-statement node
Definition: pars0pars.h:578
que_common_t common
type: QUE_NODE_RETURN
Definition: pars0pars.h:579
Rollback command node in a query graph.
Definition: trx0roll.h:156
A struct for (sometimes lazily) prebuilt structures in an Innobase table handle used within MySQL; th...
Definition: row0mysql.h:515
Select statement node.
Definition: row0sel.h:329
Symbol table node.
Definition: pars0sym.h:113
Symbol table.
Definition: pars0sym.h:203
Definition: dict0crea.h:112
Definition: trx0trx.h:684
Definition: row0upd.h:701
while-statement node
Definition: pars0pars.h:549
que_common_t common
type: QUE_NODE_WHILE
Definition: pars0pars.h:550
que_node_t * stat_list
statement list
Definition: pars0pars.h:552
que_node_t * cond
while condition
Definition: pars0pars.h:551
Transaction system global type definitions.
Version control for database, common definitions, and include files.
unsigned long int ulint
Definition: univ.i:406
long int lint
Definition: univ.i:407
Users and sessions global types.
#define UT_LIST_NODE_GETTER_DEFINITION(t, m)
A helper for the UT_LIST_BASE_NODE_T_EXTERN which declares a node getter struct which extracts member...
Definition: ut0lst.h:270
A vector of pointers to data items.