~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/pars0pars.h

  • Committer: Brian Aker
  • Date: 2009-10-15 00:22:33 UTC
  • mto: (1183.1.11 merge)
  • mto: This revision was merged to the branch mainline in revision 1198.
  • Revision ID: brian@gaz-20091015002233-fa4ao2mbc67wls91
First pass of information engine. OMG, ponies... is it so much easier to
deal with creating and engine.

The list table iterator though... its ass, needs to go. We should also
abstract out share. Very few engines need a custom one. Just say'in

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (c) 1996, 2010, Innobase Oy. 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 as published by the Free Software
7
 
Foundation; version 2 of the License.
8
 
 
9
 
This program is distributed in the hope that it will be useful, but WITHOUT
10
 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
 
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
 
 
13
 
You should have received a copy of the GNU General Public License along with
14
 
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/**************************************************//**
20
 
@file include/pars0pars.h
21
 
SQL parser
22
 
 
23
 
Created 11/19/1996 Heikki Tuuri
24
 
*******************************************************/
25
 
 
26
 
#ifndef pars0pars_h
27
 
#define pars0pars_h
28
 
 
29
 
#include "univ.i"
30
 
#include "que0types.h"
31
 
#include "usr0types.h"
32
 
#include "pars0types.h"
33
 
#include "row0types.h"
34
 
#include "trx0types.h"
35
 
#include "ut0vec.h"
36
 
 
37
 
/** Type of the user functions. The first argument is always InnoDB-supplied
38
 
and varies in type, while 'user_arg' is a user-supplied argument. The
39
 
meaning of the return type also varies. See the individual use cases, e.g.
40
 
the FETCH statement, for details on them. */
41
 
typedef void* (*pars_user_func_cb_t)(void* arg, void* user_arg);
42
 
 
43
 
/** If the following is set TRUE, the parser will emit debugging
44
 
information */
45
 
extern int      yydebug;
46
 
 
47
 
#ifdef UNIV_SQL_DEBUG
48
 
/** If the following is set TRUE, the lexer will print the SQL string
49
 
as it tokenizes it */
50
 
extern ibool    pars_print_lexed;
51
 
#endif /* UNIV_SQL_DEBUG */
52
 
 
53
 
/* Global variable used while parsing a single procedure or query : the code is
54
 
NOT re-entrant */
55
 
extern sym_tab_t*       pars_sym_tab_global;
56
 
 
57
 
extern pars_res_word_t  pars_to_char_token;
58
 
extern pars_res_word_t  pars_to_number_token;
59
 
extern pars_res_word_t  pars_to_binary_token;
60
 
extern pars_res_word_t  pars_binary_to_number_token;
61
 
extern pars_res_word_t  pars_substr_token;
62
 
extern pars_res_word_t  pars_replstr_token;
63
 
extern pars_res_word_t  pars_concat_token;
64
 
extern pars_res_word_t  pars_length_token;
65
 
extern pars_res_word_t  pars_instr_token;
66
 
extern pars_res_word_t  pars_sysdate_token;
67
 
extern pars_res_word_t  pars_printf_token;
68
 
extern pars_res_word_t  pars_assert_token;
69
 
extern pars_res_word_t  pars_rnd_token;
70
 
extern pars_res_word_t  pars_rnd_str_token;
71
 
extern pars_res_word_t  pars_count_token;
72
 
extern pars_res_word_t  pars_sum_token;
73
 
extern pars_res_word_t  pars_distinct_token;
74
 
extern pars_res_word_t  pars_binary_token;
75
 
extern pars_res_word_t  pars_blob_token;
76
 
extern pars_res_word_t  pars_int_token;
77
 
extern pars_res_word_t  pars_char_token;
78
 
extern pars_res_word_t  pars_float_token;
79
 
extern pars_res_word_t  pars_update_token;
80
 
extern pars_res_word_t  pars_asc_token;
81
 
extern pars_res_word_t  pars_desc_token;
82
 
extern pars_res_word_t  pars_open_token;
83
 
extern pars_res_word_t  pars_close_token;
84
 
extern pars_res_word_t  pars_share_token;
85
 
extern pars_res_word_t  pars_unique_token;
86
 
extern pars_res_word_t  pars_clustered_token;
87
 
 
88
 
extern ulint            pars_star_denoter;
89
 
 
90
 
/* Procedure parameter types */
91
 
#define PARS_INPUT      0
92
 
#define PARS_OUTPUT     1
93
 
#define PARS_NOT_PARAM  2
94
 
 
95
 
int
96
 
yyparse(void);
97
 
 
98
 
/*************************************************************//**
99
 
Parses an SQL string returning the query graph.
100
 
@return own: the query graph */
101
 
UNIV_INTERN
102
 
que_t*
103
 
pars_sql(
104
 
/*=====*/
105
 
        pars_info_t*    info,   /*!< in: extra information, or NULL */
106
 
        const char*     str);   /*!< in: SQL string */
107
 
/*************************************************************//**
108
 
Retrieves characters to the lexical analyzer. */
109
 
UNIV_INTERN
110
 
void
111
 
pars_get_lex_chars(
112
 
/*===============*/
113
 
        char*   buf,            /*!< in/out: buffer where to copy */
114
 
        int*    result,         /*!< out: number of characters copied or EOF */
115
 
        int     max_size);      /*!< in: maximum number of characters which fit
116
 
                                in the buffer */
117
 
/*************************************************************//**
118
 
Called by yyparse on error. */
119
 
UNIV_INTERN
120
 
void
121
 
yyerror(
122
 
/*====*/
123
 
        const char*     s);     /*!< in: error message string */
124
 
/*********************************************************************//**
125
 
Parses a variable declaration.
126
 
@return own: symbol table node of type SYM_VAR */
127
 
UNIV_INTERN
128
 
sym_node_t*
129
 
pars_variable_declaration(
130
 
/*======================*/
131
 
        sym_node_t*     node,   /*!< in: symbol table node allocated for the
132
 
                                id of the variable */
133
 
        pars_res_word_t* type); /*!< in: pointer to a type token */
134
 
/*********************************************************************//**
135
 
Parses a function expression.
136
 
@return own: function node in a query tree */
137
 
UNIV_INTERN
138
 
func_node_t*
139
 
pars_func(
140
 
/*======*/
141
 
        que_node_t*     res_word,/*!< in: function name reserved word */
142
 
        que_node_t*     arg);   /*!< in: first argument in the argument list */
143
 
/*********************************************************************//**
144
 
Parses an operator expression.
145
 
@return own: function node in a query tree */
146
 
UNIV_INTERN
147
 
func_node_t*
148
 
pars_op(
149
 
/*====*/
150
 
        int             func,   /*!< in: operator token code */
151
 
        que_node_t*     arg1,   /*!< in: first argument */
152
 
        que_node_t*     arg2);  /*!< in: second argument or NULL for an unary
153
 
                                operator */
154
 
/*********************************************************************//**
155
 
Parses an ORDER BY clause. Order by a single column only is supported.
156
 
@return own: order-by node in a query tree */
157
 
UNIV_INTERN
158
 
order_node_t*
159
 
pars_order_by(
160
 
/*==========*/
161
 
        sym_node_t*     column, /*!< in: column name */
162
 
        pars_res_word_t* asc);  /*!< in: &pars_asc_token or pars_desc_token */
163
 
/*********************************************************************//**
164
 
Parses a select list; creates a query graph node for the whole SELECT
165
 
statement.
166
 
@return own: select node in a query tree */
167
 
UNIV_INTERN
168
 
sel_node_t*
169
 
pars_select_list(
170
 
/*=============*/
171
 
        que_node_t*     select_list,    /*!< in: select list */
172
 
        sym_node_t*     into_list);     /*!< in: variables list or NULL */
173
 
/*********************************************************************//**
174
 
Parses a cursor declaration.
175
 
@return sym_node */
176
 
UNIV_INTERN
177
 
que_node_t*
178
 
pars_cursor_declaration(
179
 
/*====================*/
180
 
        sym_node_t*     sym_node,       /*!< in: cursor id node in the symbol
181
 
                                        table */
182
 
        sel_node_t*     select_node);   /*!< in: select node */
183
 
/*********************************************************************//**
184
 
Parses a function declaration.
185
 
@return sym_node */
186
 
UNIV_INTERN
187
 
que_node_t*
188
 
pars_function_declaration(
189
 
/*======================*/
190
 
        sym_node_t*     sym_node);      /*!< in: function id node in the symbol
191
 
                                        table */
192
 
/*********************************************************************//**
193
 
Parses a select statement.
194
 
@return own: select node in a query tree */
195
 
UNIV_INTERN
196
 
sel_node_t*
197
 
pars_select_statement(
198
 
/*==================*/
199
 
        sel_node_t*     select_node,    /*!< in: select node already containing
200
 
                                        the select list */
201
 
        sym_node_t*     table_list,     /*!< in: table list */
202
 
        que_node_t*     search_cond,    /*!< in: search condition or NULL */
203
 
        pars_res_word_t* for_update,    /*!< in: NULL or &pars_update_token */
204
 
        pars_res_word_t* consistent_read,/*!< in: NULL or
205
 
                                                &pars_consistent_token */
206
 
        order_node_t*   order_by);      /*!< in: NULL or an order-by node */
207
 
/*********************************************************************//**
208
 
Parses a column assignment in an update.
209
 
@return column assignment node */
210
 
UNIV_INTERN
211
 
col_assign_node_t*
212
 
pars_column_assignment(
213
 
/*===================*/
214
 
        sym_node_t*     column, /*!< in: column to assign */
215
 
        que_node_t*     exp);   /*!< in: value to assign */
216
 
/*********************************************************************//**
217
 
Parses a delete or update statement start.
218
 
@return own: update node in a query tree */
219
 
UNIV_INTERN
220
 
upd_node_t*
221
 
pars_update_statement_start(
222
 
/*========================*/
223
 
        ibool           is_delete,      /*!< in: TRUE if delete */
224
 
        sym_node_t*     table_sym,      /*!< in: table name node */
225
 
        col_assign_node_t* col_assign_list);/*!< in: column assignment list, NULL
226
 
                                        if delete */
227
 
/*********************************************************************//**
228
 
Parses an update or delete statement.
229
 
@return own: update node in a query tree */
230
 
UNIV_INTERN
231
 
upd_node_t*
232
 
pars_update_statement(
233
 
/*==================*/
234
 
        upd_node_t*     node,           /*!< in: update node */
235
 
        sym_node_t*     cursor_sym,     /*!< in: pointer to a cursor entry in
236
 
                                        the symbol table or NULL */
237
 
        que_node_t*     search_cond);   /*!< in: search condition or NULL */
238
 
/*********************************************************************//**
239
 
Parses an insert statement.
240
 
@return own: update node in a query tree */
241
 
UNIV_INTERN
242
 
ins_node_t*
243
 
pars_insert_statement(
244
 
/*==================*/
245
 
        sym_node_t*     table_sym,      /*!< in: table name node */
246
 
        que_node_t*     values_list,    /*!< in: value expression list or NULL */
247
 
        sel_node_t*     select);        /*!< in: select condition or NULL */
248
 
/*********************************************************************//**
249
 
Parses a procedure parameter declaration.
250
 
@return own: symbol table node of type SYM_VAR */
251
 
UNIV_INTERN
252
 
sym_node_t*
253
 
pars_parameter_declaration(
254
 
/*=======================*/
255
 
        sym_node_t*     node,   /*!< in: symbol table node allocated for the
256
 
                                id of the parameter */
257
 
        ulint           param_type,
258
 
                                /*!< in: PARS_INPUT or PARS_OUTPUT */
259
 
        pars_res_word_t* type); /*!< in: pointer to a type token */
260
 
/*********************************************************************//**
261
 
Parses an elsif element.
262
 
@return elsif node */
263
 
UNIV_INTERN
264
 
elsif_node_t*
265
 
pars_elsif_element(
266
 
/*===============*/
267
 
        que_node_t*     cond,           /*!< in: if-condition */
268
 
        que_node_t*     stat_list);     /*!< in: statement list */
269
 
/*********************************************************************//**
270
 
Parses an if-statement.
271
 
@return if-statement node */
272
 
UNIV_INTERN
273
 
if_node_t*
274
 
pars_if_statement(
275
 
/*==============*/
276
 
        que_node_t*     cond,           /*!< in: if-condition */
277
 
        que_node_t*     stat_list,      /*!< in: statement list */
278
 
        que_node_t*     else_part);     /*!< in: else-part statement list */
279
 
/*********************************************************************//**
280
 
Parses a for-loop-statement.
281
 
@return for-statement node */
282
 
UNIV_INTERN
283
 
for_node_t*
284
 
pars_for_statement(
285
 
/*===============*/
286
 
        sym_node_t*     loop_var,       /*!< in: loop variable */
287
 
        que_node_t*     loop_start_limit,/*!< in: loop start expression */
288
 
        que_node_t*     loop_end_limit, /*!< in: loop end expression */
289
 
        que_node_t*     stat_list);     /*!< in: statement list */
290
 
/*********************************************************************//**
291
 
Parses a while-statement.
292
 
@return while-statement node */
293
 
UNIV_INTERN
294
 
while_node_t*
295
 
pars_while_statement(
296
 
/*=================*/
297
 
        que_node_t*     cond,           /*!< in: while-condition */
298
 
        que_node_t*     stat_list);     /*!< in: statement list */
299
 
/*********************************************************************//**
300
 
Parses an exit statement.
301
 
@return exit statement node */
302
 
UNIV_INTERN
303
 
exit_node_t*
304
 
pars_exit_statement(void);
305
 
/*=====================*/
306
 
/*********************************************************************//**
307
 
Parses a return-statement.
308
 
@return return-statement node */
309
 
UNIV_INTERN
310
 
return_node_t*
311
 
pars_return_statement(void);
312
 
/*=======================*/
313
 
/*********************************************************************//**
314
 
Parses a procedure call.
315
 
@return function node */
316
 
UNIV_INTERN
317
 
func_node_t*
318
 
pars_procedure_call(
319
 
/*================*/
320
 
        que_node_t*     res_word,/*!< in: procedure name reserved word */
321
 
        que_node_t*     args);  /*!< in: argument list */
322
 
/*********************************************************************//**
323
 
Parses an assignment statement.
324
 
@return assignment statement node */
325
 
UNIV_INTERN
326
 
assign_node_t*
327
 
pars_assignment_statement(
328
 
/*======================*/
329
 
        sym_node_t*     var,    /*!< in: variable to assign */
330
 
        que_node_t*     val);   /*!< in: value to assign */
331
 
/*********************************************************************//**
332
 
Parses a fetch statement. into_list or user_func (but not both) must be
333
 
non-NULL.
334
 
@return fetch statement node */
335
 
UNIV_INTERN
336
 
fetch_node_t*
337
 
pars_fetch_statement(
338
 
/*=================*/
339
 
        sym_node_t*     cursor,         /*!< in: cursor node */
340
 
        sym_node_t*     into_list,      /*!< in: variables to set, or NULL */
341
 
        sym_node_t*     user_func);     /*!< in: user function name, or NULL */
342
 
/*********************************************************************//**
343
 
Parses an open or close cursor statement.
344
 
@return fetch statement node */
345
 
UNIV_INTERN
346
 
open_node_t*
347
 
pars_open_statement(
348
 
/*================*/
349
 
        ulint           type,   /*!< in: ROW_SEL_OPEN_CURSOR
350
 
                                or ROW_SEL_CLOSE_CURSOR */
351
 
        sym_node_t*     cursor);        /*!< in: cursor node */
352
 
/*********************************************************************//**
353
 
Parses a row_printf-statement.
354
 
@return row_printf-statement node */
355
 
UNIV_INTERN
356
 
row_printf_node_t*
357
 
pars_row_printf_statement(
358
 
/*======================*/
359
 
        sel_node_t*     sel_node);      /*!< in: select node */
360
 
/*********************************************************************//**
361
 
Parses a commit statement.
362
 
@return own: commit node struct */
363
 
UNIV_INTERN
364
 
commit_node_t*
365
 
pars_commit_statement(void);
366
 
/*=======================*/
367
 
/*********************************************************************//**
368
 
Parses a rollback statement.
369
 
@return own: rollback node struct */
370
 
UNIV_INTERN
371
 
roll_node_t*
372
 
pars_rollback_statement(void);
373
 
/*=========================*/
374
 
/*********************************************************************//**
375
 
Parses a column definition at a table creation.
376
 
@return column sym table node */
377
 
UNIV_INTERN
378
 
sym_node_t*
379
 
pars_column_def(
380
 
/*============*/
381
 
        sym_node_t*             sym_node,       /*!< in: column node in the
382
 
                                                symbol table */
383
 
        pars_res_word_t*        type,           /*!< in: data type */
384
 
        sym_node_t*             len,            /*!< in: length of column, or
385
 
                                                NULL */
386
 
        void*                   is_unsigned,    /*!< in: if not NULL, column
387
 
                                                is of type UNSIGNED. */
388
 
        void*                   is_not_null);   /*!< in: if not NULL, column
389
 
                                                is of type NOT NULL. */
390
 
/*********************************************************************//**
391
 
Parses a table creation operation.
392
 
@return table create subgraph */
393
 
UNIV_INTERN
394
 
tab_node_t*
395
 
pars_create_table(
396
 
/*==============*/
397
 
        sym_node_t*     table_sym,      /*!< in: table name node in the symbol
398
 
                                        table */
399
 
        sym_node_t*     column_defs,    /*!< in: list of column names */
400
 
        void*           not_fit_in_memory);/*!< in: a non-NULL pointer means that
401
 
                                        this is a table which in simulations
402
 
                                        should be simulated as not fitting
403
 
                                        in memory; thread is put to sleep
404
 
                                        to simulate disk accesses; NOTE that
405
 
                                        this flag is not stored to the data
406
 
                                        dictionary on disk, and the database
407
 
                                        will forget about non-NULL value if
408
 
                                        it has to reload the table definition
409
 
                                        from disk */
410
 
/*********************************************************************//**
411
 
Parses an index creation operation.
412
 
@return index create subgraph */
413
 
UNIV_INTERN
414
 
ind_node_t*
415
 
pars_create_index(
416
 
/*==============*/
417
 
        pars_res_word_t* unique_def,    /*!< in: not NULL if a unique index */
418
 
        pars_res_word_t* clustered_def, /*!< in: not NULL if a clustered index */
419
 
        sym_node_t*     index_sym,      /*!< in: index name node in the symbol
420
 
                                        table */
421
 
        sym_node_t*     table_sym,      /*!< in: table name node in the symbol
422
 
                                        table */
423
 
        sym_node_t*     column_list);   /*!< in: list of column names */
424
 
/*********************************************************************//**
425
 
Parses a procedure definition.
426
 
@return query fork node */
427
 
UNIV_INTERN
428
 
que_fork_t*
429
 
pars_procedure_definition(
430
 
/*======================*/
431
 
        sym_node_t*     sym_node,       /*!< in: procedure id node in the symbol
432
 
                                        table */
433
 
        sym_node_t*     param_list,     /*!< in: parameter declaration list */
434
 
        que_node_t*     stat_list);     /*!< in: statement list */
435
 
 
436
 
/*************************************************************//**
437
 
Parses a stored procedure call, when this is not within another stored
438
 
procedure, that is, the client issues a procedure call directly.
439
 
In MySQL/InnoDB, stored InnoDB procedures are invoked via the
440
 
parsed procedure tree, not via InnoDB SQL, so this function is not used.
441
 
@return query graph */
442
 
UNIV_INTERN
443
 
que_fork_t*
444
 
pars_stored_procedure_call(
445
 
/*=======================*/
446
 
        sym_node_t*     sym_node);      /*!< in: stored procedure name */
447
 
/******************************************************************//**
448
 
Completes a query graph by adding query thread and fork nodes
449
 
above it and prepares the graph for running. The fork created is of
450
 
type QUE_FORK_MYSQL_INTERFACE.
451
 
@return query thread node to run */
452
 
UNIV_INTERN
453
 
que_thr_t*
454
 
pars_complete_graph_for_exec(
455
 
/*=========================*/
456
 
        que_node_t*     node,   /*!< in: root node for an incomplete
457
 
                                query graph */
458
 
        trx_t*          trx,    /*!< in: transaction handle */
459
 
        mem_heap_t*     heap);  /*!< in: memory heap from which allocated */
460
 
 
461
 
/****************************************************************//**
462
 
Create parser info struct.
463
 
@return own: info struct */
464
 
UNIV_INTERN
465
 
pars_info_t*
466
 
pars_info_create(void);
467
 
/*==================*/
468
 
 
469
 
/****************************************************************//**
470
 
Free info struct and everything it contains. */
471
 
UNIV_INTERN
472
 
void
473
 
pars_info_free(
474
 
/*===========*/
475
 
        pars_info_t*    info);  /*!< in, own: info struct */
476
 
 
477
 
/****************************************************************//**
478
 
Add bound literal. */
479
 
UNIV_INTERN
480
 
void
481
 
pars_info_add_literal(
482
 
/*==================*/
483
 
        pars_info_t*    info,           /*!< in: info struct */
484
 
        const char*     name,           /*!< in: name */
485
 
        const void*     address,        /*!< in: address */
486
 
        ulint           length,         /*!< in: length of data */
487
 
        ulint           type,           /*!< in: type, e.g. DATA_FIXBINARY */
488
 
        ulint           prtype);        /*!< in: precise type, e.g.
489
 
                                        DATA_UNSIGNED */
490
 
 
491
 
/****************************************************************//**
492
 
Equivalent to pars_info_add_literal(info, name, str, strlen(str),
493
 
DATA_VARCHAR, DATA_ENGLISH). */
494
 
UNIV_INTERN
495
 
void
496
 
pars_info_add_str_literal(
497
 
/*======================*/
498
 
        pars_info_t*    info,           /*!< in: info struct */
499
 
        const char*     name,           /*!< in: name */
500
 
        const char*     str);           /*!< in: string */
501
 
 
502
 
/****************************************************************//**
503
 
Equivalent to:
504
 
 
505
 
char buf[4];
506
 
mach_write_to_4(buf, val);
507
 
pars_info_add_literal(info, name, buf, 4, DATA_INT, 0);
508
 
 
509
 
except that the buffer is dynamically allocated from the info struct's
510
 
heap. */
511
 
UNIV_INTERN
512
 
void
513
 
pars_info_add_int4_literal(
514
 
/*=======================*/
515
 
        pars_info_t*    info,           /*!< in: info struct */
516
 
        const char*     name,           /*!< in: name */
517
 
        lint            val);           /*!< in: value */
518
 
 
519
 
/****************************************************************//**
520
 
Equivalent to:
521
 
 
522
 
char buf[8];
523
 
mach_write_to_8(buf, val);
524
 
pars_info_add_literal(info, name, buf, 8, DATA_FIXBINARY, 0);
525
 
 
526
 
except that the buffer is dynamically allocated from the info struct's
527
 
heap. */
528
 
UNIV_INTERN
529
 
void
530
 
pars_info_add_ull_literal(
531
 
/*======================*/
532
 
        pars_info_t*    info,           /*!< in: info struct */
533
 
        const char*     name,           /*!< in: name */
534
 
        ib_uint64_t     val);           /*!< in: value */
535
 
/****************************************************************//**
536
 
Add user function. */
537
 
UNIV_INTERN
538
 
void
539
 
pars_info_add_function(
540
 
/*===================*/
541
 
        pars_info_t*            info,   /*!< in: info struct */
542
 
        const char*             name,   /*!< in: function name */
543
 
        pars_user_func_cb_t     func,   /*!< in: function address */
544
 
        void*                   arg);   /*!< in: user-supplied argument */
545
 
 
546
 
/****************************************************************//**
547
 
Add bound id. */
548
 
UNIV_INTERN
549
 
void
550
 
pars_info_add_id(
551
 
/*=============*/
552
 
        pars_info_t*    info,           /*!< in: info struct */
553
 
        const char*     name,           /*!< in: name */
554
 
        const char*     id);            /*!< in: id */
555
 
 
556
 
/****************************************************************//**
557
 
Get user function with the given name.
558
 
@return user func, or NULL if not found */
559
 
UNIV_INTERN
560
 
pars_user_func_t*
561
 
pars_info_get_user_func(
562
 
/*====================*/
563
 
        pars_info_t*            info,   /*!< in: info struct */
564
 
        const char*             name);  /*!< in: function name to find*/
565
 
 
566
 
/****************************************************************//**
567
 
Get bound literal with the given name.
568
 
@return bound literal, or NULL if not found */
569
 
UNIV_INTERN
570
 
pars_bound_lit_t*
571
 
pars_info_get_bound_lit(
572
 
/*====================*/
573
 
        pars_info_t*            info,   /*!< in: info struct */
574
 
        const char*             name);  /*!< in: bound literal name to find */
575
 
 
576
 
/****************************************************************//**
577
 
Get bound id with the given name.
578
 
@return bound id, or NULL if not found */
579
 
UNIV_INTERN
580
 
pars_bound_id_t*
581
 
pars_info_get_bound_id(
582
 
/*===================*/
583
 
        pars_info_t*            info,   /*!< in: info struct */
584
 
        const char*             name);  /*!< in: bound id name to find */
585
 
 
586
 
/******************************************************************//**
587
 
Release any resources used by the lexer. */
588
 
UNIV_INTERN
589
 
void
590
 
pars_lexer_close(void);
591
 
/*==================*/
592
 
 
593
 
/** Extra information supplied for pars_sql(). */
594
 
struct pars_info_struct {
595
 
        mem_heap_t*     heap;           /*!< our own memory heap */
596
 
 
597
 
        ib_vector_t*    funcs;          /*!< user functions, or NUll
598
 
                                        (pars_user_func_t*) */
599
 
        ib_vector_t*    bound_lits;     /*!< bound literals, or NULL
600
 
                                        (pars_bound_lit_t*) */
601
 
        ib_vector_t*    bound_ids;      /*!< bound ids, or NULL
602
 
                                        (pars_bound_id_t*) */
603
 
 
604
 
        ibool           graph_owns_us;  /*!< if TRUE (which is the default),
605
 
                                        que_graph_free() will free us */
606
 
};
607
 
 
608
 
/** User-supplied function and argument. */
609
 
struct pars_user_func_struct {
610
 
        const char*             name;   /*!< function name */
611
 
        pars_user_func_cb_t     func;   /*!< function address */
612
 
        void*                   arg;    /*!< user-supplied argument */
613
 
};
614
 
 
615
 
/** Bound literal. */
616
 
struct pars_bound_lit_struct {
617
 
        const char*     name;           /*!< name */
618
 
        const void*     address;        /*!< address */
619
 
        ulint           length;         /*!< length of data */
620
 
        ulint           type;           /*!< type, e.g. DATA_FIXBINARY */
621
 
        ulint           prtype;         /*!< precise type, e.g. DATA_UNSIGNED */
622
 
};
623
 
 
624
 
/** Bound identifier. */
625
 
struct pars_bound_id_struct {
626
 
        const char*     name;           /*!< name */
627
 
        const char*     id;             /*!< identifier */
628
 
};
629
 
 
630
 
/** Struct used to denote a reserved word in a parsing tree */
631
 
struct pars_res_word_struct{
632
 
        int     code;   /*!< the token code for the reserved word from
633
 
                        pars0grm.h */
634
 
};
635
 
 
636
 
/** A predefined function or operator node in a parsing tree; this construct
637
 
is also used for some non-functions like the assignment ':=' */
638
 
struct func_node_struct{
639
 
        que_common_t    common; /*!< type: QUE_NODE_FUNC */
640
 
        int             func;   /*!< token code of the function name */
641
 
        ulint           class;  /*!< class of the function */
642
 
        que_node_t*     args;   /*!< argument(s) of the function */
643
 
        UT_LIST_NODE_T(func_node_t) cond_list;
644
 
                                /*!< list of comparison conditions; defined
645
 
                                only for comparison operator nodes except,
646
 
                                presently, for OPT_SCROLL_TYPE ones */
647
 
        UT_LIST_NODE_T(func_node_t) func_node_list;
648
 
                                /*!< list of function nodes in a parsed
649
 
                                query graph */
650
 
};
651
 
 
652
 
/** An order-by node in a select */
653
 
struct order_node_struct{
654
 
        que_common_t    common; /*!< type: QUE_NODE_ORDER */
655
 
        sym_node_t*     column; /*!< order-by column */
656
 
        ibool           asc;    /*!< TRUE if ascending, FALSE if descending */
657
 
};
658
 
 
659
 
/** Procedure definition node */
660
 
struct proc_node_struct{
661
 
        que_common_t    common;         /*!< type: QUE_NODE_PROC */
662
 
        sym_node_t*     proc_id;        /*!< procedure name symbol in the symbol
663
 
                                        table of this same procedure */
664
 
        sym_node_t*     param_list;     /*!< input and output parameters */
665
 
        que_node_t*     stat_list;      /*!< statement list */
666
 
        sym_tab_t*      sym_tab;        /*!< symbol table of this procedure */
667
 
};
668
 
 
669
 
/** elsif-element node */
670
 
struct elsif_node_struct{
671
 
        que_common_t    common;         /*!< type: QUE_NODE_ELSIF */
672
 
        que_node_t*     cond;           /*!< if condition */
673
 
        que_node_t*     stat_list;      /*!< statement list */
674
 
};
675
 
 
676
 
/** if-statement node */
677
 
struct if_node_struct{
678
 
        que_common_t    common;         /*!< type: QUE_NODE_IF */
679
 
        que_node_t*     cond;           /*!< if condition */
680
 
        que_node_t*     stat_list;      /*!< statement list */
681
 
        que_node_t*     else_part;      /*!< else-part statement list */
682
 
        elsif_node_t*   elsif_list;     /*!< elsif element list */
683
 
};
684
 
 
685
 
/** while-statement node */
686
 
struct while_node_struct{
687
 
        que_common_t    common;         /*!< type: QUE_NODE_WHILE */
688
 
        que_node_t*     cond;           /*!< while condition */
689
 
        que_node_t*     stat_list;      /*!< statement list */
690
 
};
691
 
 
692
 
/** for-loop-statement node */
693
 
struct for_node_struct{
694
 
        que_common_t    common;         /*!< type: QUE_NODE_FOR */
695
 
        sym_node_t*     loop_var;       /*!< loop variable: this is the
696
 
                                        dereferenced symbol from the
697
 
                                        variable declarations, not the
698
 
                                        symbol occurrence in the for loop
699
 
                                        definition */
700
 
        que_node_t*     loop_start_limit;/*!< initial value of loop variable */
701
 
        que_node_t*     loop_end_limit; /*!< end value of loop variable */
702
 
        lint            loop_end_value; /*!< evaluated value for the end value:
703
 
                                        it is calculated only when the loop
704
 
                                        is entered, and will not change within
705
 
                                        the loop */
706
 
        que_node_t*     stat_list;      /*!< statement list */
707
 
};
708
 
 
709
 
/** exit statement node */
710
 
struct exit_node_struct{
711
 
        que_common_t    common;         /*!< type: QUE_NODE_EXIT */
712
 
};
713
 
 
714
 
/** return-statement node */
715
 
struct return_node_struct{
716
 
        que_common_t    common;         /*!< type: QUE_NODE_RETURN */
717
 
};
718
 
 
719
 
/** Assignment statement node */
720
 
struct assign_node_struct{
721
 
        que_common_t    common;         /*!< type: QUE_NODE_ASSIGNMENT */
722
 
        sym_node_t*     var;            /*!< variable to set */
723
 
        que_node_t*     val;            /*!< value to assign */
724
 
};
725
 
 
726
 
/** Column assignment node */
727
 
struct col_assign_node_struct{
728
 
        que_common_t    common;         /*!< type: QUE_NODE_COL_ASSIGN */
729
 
        sym_node_t*     col;            /*!< column to set */
730
 
        que_node_t*     val;            /*!< value to assign */
731
 
};
732
 
 
733
 
/** Classes of functions */
734
 
/* @{ */
735
 
#define PARS_FUNC_ARITH         1       /*!< +, -, *, / */
736
 
#define PARS_FUNC_LOGICAL       2       /*!< AND, OR, NOT */
737
 
#define PARS_FUNC_CMP           3       /*!< comparison operators */
738
 
#define PARS_FUNC_PREDEFINED    4       /*!< TO_NUMBER, SUBSTR, ... */
739
 
#define PARS_FUNC_AGGREGATE     5       /*!< COUNT, DISTINCT, SUM */
740
 
#define PARS_FUNC_OTHER         6       /*!< these are not real functions,
741
 
                                        e.g., := */
742
 
/* @} */
743
 
 
744
 
#ifndef UNIV_NONINL
745
 
#include "pars0pars.ic"
746
 
#endif
747
 
 
748
 
#endif