~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2008-07-26 16:22:28 UTC
  • mto: (236.1.42 codestyle)
  • mto: This revision was merged to the branch mainline in revision 261.
  • Revision ID: monty@inaugust.com-20080726162228-atatk41l6w4np70m
Added gettext calls in to my_getopt.c and drizzle.c

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