~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

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