~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/pars/pars0sym.c

Merge Joe, plus I updated the tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (C) 1997, 2009, Innobase Oy. All Rights Reserved.
 
3
Copyright (c) 1997, 2009, Innobase Oy. All Rights Reserved.
4
4
 
5
5
This program is free software; you can redistribute it and/or modify it under
6
6
the terms of the GNU General Public License as published by the Free Software
11
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
12
 
13
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
 
14
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 
15
Place, Suite 330, Boston, MA 02111-1307 USA
16
16
 
17
17
*****************************************************************************/
18
18
 
34
34
#include "data0data.h"
35
35
#ifndef PARS0GRM_H
36
36
# define PARS0GRM_H
37
 
# include "pars0grm.hh"
 
37
# include "pars0grm.h"
38
38
#endif
39
39
#include "pars0pars.h"
40
40
#include "que0que.h"
52
52
{
53
53
        sym_tab_t*      sym_tab;
54
54
 
55
 
        sym_tab = static_cast<sym_tab_t *>(mem_heap_alloc(heap, sizeof(sym_tab_t)));
 
55
        sym_tab = mem_heap_alloc(heap, sizeof(sym_tab_t));
56
56
 
57
57
        UT_LIST_INIT(sym_tab->sym_list);
58
58
        UT_LIST_INIT(sym_tab->func_node_list);
103
103
/******************************************************************//**
104
104
Adds an integer literal to a symbol table.
105
105
@return symbol table node */
106
 
#ifdef __cplusplus
107
 
extern "C"
108
 
#endif
109
106
UNIV_INTERN
110
107
sym_node_t*
111
108
sym_tab_add_int_lit(
116
113
        sym_node_t*     node;
117
114
        byte*           data;
118
115
 
119
 
        node = static_cast<sym_node_t *>(mem_heap_alloc(sym_tab->heap, sizeof(sym_node_t)));
 
116
        node = mem_heap_alloc(sym_tab->heap, sizeof(sym_node_t));
120
117
 
121
118
        node->common.type = QUE_NODE_SYMBOL;
122
119
 
127
124
 
128
125
        dtype_set(dfield_get_type(&node->common.val), DATA_INT, 0, 4);
129
126
 
130
 
        data = static_cast<byte *>(mem_heap_alloc(sym_tab->heap, 4));
 
127
        data = mem_heap_alloc(sym_tab->heap, 4);
131
128
        mach_write_to_4(data, val);
132
129
 
133
130
        dfield_set_data(&(node->common.val), data, 4);
146
143
/******************************************************************//**
147
144
Adds a string literal to a symbol table.
148
145
@return symbol table node */
149
 
#ifdef __cplusplus
150
 
extern "C"
151
 
#endif
152
146
UNIV_INTERN
153
147
sym_node_t*
154
148
sym_tab_add_str_lit(
161
155
        sym_node_t*     node;
162
156
        byte*           data;
163
157
 
164
 
        node = static_cast<sym_node_t *>(mem_heap_alloc(sym_tab->heap, sizeof(sym_node_t)));
 
158
        node = mem_heap_alloc(sym_tab->heap, sizeof(sym_node_t));
165
159
 
166
160
        node->common.type = QUE_NODE_SYMBOL;
167
161
 
174
168
                  DATA_VARCHAR, DATA_ENGLISH, 0);
175
169
 
176
170
        if (len) {
177
 
                data = static_cast<byte *>(mem_heap_alloc(sym_tab->heap, len));
 
171
                data = mem_heap_alloc(sym_tab->heap, len);
178
172
                ut_memcpy(data, str, len);
179
173
        } else {
180
174
                data = NULL;
196
190
/******************************************************************//**
197
191
Add a bound literal to a symbol table.
198
192
@return symbol table node */
199
 
#ifdef __cplusplus
200
 
extern "C"
201
 
#endif
202
193
UNIV_INTERN
203
194
sym_node_t*
204
195
sym_tab_add_bound_lit(
214
205
        blit = pars_info_get_bound_lit(sym_tab->info, name);
215
206
        ut_a(blit);
216
207
 
217
 
        node = static_cast<sym_node_t *>(mem_heap_alloc(sym_tab->heap, sizeof(sym_node_t)));
 
208
        node = mem_heap_alloc(sym_tab->heap, sizeof(sym_node_t));
218
209
 
219
210
        node->common.type = QUE_NODE_SYMBOL;
220
211
 
275
266
/******************************************************************//**
276
267
Adds an SQL null literal to a symbol table.
277
268
@return symbol table node */
278
 
#ifdef __cplusplus
279
 
extern "C"
280
 
#endif
281
269
UNIV_INTERN
282
270
sym_node_t*
283
271
sym_tab_add_null_lit(
286
274
{
287
275
        sym_node_t*     node;
288
276
 
289
 
        node = static_cast<sym_node_t *>(mem_heap_alloc(sym_tab->heap, sizeof(sym_node_t)));
 
277
        node = mem_heap_alloc(sym_tab->heap, sizeof(sym_node_t));
290
278
 
291
279
        node->common.type = QUE_NODE_SYMBOL;
292
280
 
313
301
/******************************************************************//**
314
302
Adds an identifier to a symbol table.
315
303
@return symbol table node */
316
 
#ifdef __cplusplus
317
 
extern "C"
318
 
#endif
319
304
UNIV_INTERN
320
305
sym_node_t*
321
306
sym_tab_add_id(
326
311
{
327
312
        sym_node_t*     node;
328
313
 
329
 
        node = static_cast<sym_node_t *>(mem_heap_alloc(sym_tab->heap, sizeof(sym_node_t)));
 
314
        node = mem_heap_alloc(sym_tab->heap, sizeof(sym_node_t));
330
315
 
331
316
        node->common.type = QUE_NODE_SYMBOL;
332
317
 
352
337
/******************************************************************//**
353
338
Add a bound identifier to a symbol table.
354
339
@return symbol table node */
355
 
#ifdef __cplusplus
356
 
extern "C"
357
 
#endif
358
340
UNIV_INTERN
359
341
sym_node_t*
360
342
sym_tab_add_bound_id(
368
350
        bid = pars_info_get_bound_id(sym_tab->info, name);
369
351
        ut_a(bid);
370
352
 
371
 
        node = static_cast<sym_node_t *>(mem_heap_alloc(sym_tab->heap, sizeof(sym_node_t)));
 
353
        node = mem_heap_alloc(sym_tab->heap, sizeof(sym_node_t));
372
354
 
373
355
        node->common.type = QUE_NODE_SYMBOL;
374
356