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