Drizzled Public API Documentation

pars0sym.cc
1 /*****************************************************************************
2 
3 Copyright (C) 1997, 2009, 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 /**************************************************/
26 #include "pars0sym.h"
27 
28 #ifdef UNIV_NONINL
29 #include "pars0sym.ic"
30 #endif
31 
32 #include "mem0mem.h"
33 #include "data0type.h"
34 #include "data0data.h"
35 #ifndef PARS0GRM_H
36 # define PARS0GRM_H
37 # include "pars0grm.hh"
38 #endif
39 #include "pars0pars.h"
40 #include "que0que.h"
41 #include "eval0eval.h"
42 #include "row0sel.h"
43 
44 /******************************************************************/
47 UNIV_INTERN
48 sym_tab_t*
50 /*===========*/
51  mem_heap_t* heap)
52 {
53  sym_tab_t* sym_tab;
54 
55  sym_tab = static_cast<sym_tab_t *>(mem_heap_alloc(heap, sizeof(sym_tab_t)));
56 
57  UT_LIST_INIT(sym_tab->sym_list);
58  UT_LIST_INIT(sym_tab->func_node_list);
59 
60  sym_tab->heap = heap;
61 
62  return(sym_tab);
63 }
64 
65 /******************************************************************/
69 UNIV_INTERN
70 void
72 /*=================*/
73  sym_tab_t* sym_tab)
74 {
75  sym_node_t* sym;
76  func_node_t* func;
77 
78  sym = UT_LIST_GET_FIRST(sym_tab->sym_list);
79 
80  while (sym) {
82 
83  if (sym->prefetch_buf) {
85  }
86 
87  if (sym->cursor_def) {
89  }
90 
91  sym = UT_LIST_GET_NEXT(sym_list, sym);
92  }
93 
94  func = UT_LIST_GET_FIRST(sym_tab->func_node_list);
95 
96  while (func) {
98 
99  func = UT_LIST_GET_NEXT(func_node_list, func);
100  }
101 }
102 
103 /******************************************************************/
106 #ifdef __cplusplus
107 extern "C"
108 #endif
109 UNIV_INTERN
110 sym_node_t*
112 /*================*/
113  sym_tab_t* sym_tab,
114  ulint val)
115 {
116  sym_node_t* node;
117  byte* data;
118 
119  node = static_cast<sym_node_t *>(mem_heap_alloc(sym_tab->heap, sizeof(sym_node_t)));
120 
121  node->common.type = QUE_NODE_SYMBOL;
122 
123  node->resolved = TRUE;
124  node->token_type = SYM_LIT;
125 
126  node->indirection = NULL;
127 
128  dtype_set(dfield_get_type(&node->common.val), DATA_INT, 0, 4);
129 
130  data = static_cast<byte *>(mem_heap_alloc(sym_tab->heap, 4));
131  mach_write_to_4(data, val);
132 
133  dfield_set_data(&(node->common.val), data, 4);
134 
135  node->common.val_buf_size = 0;
136  node->prefetch_buf = NULL;
137  node->cursor_def = NULL;
138 
139  UT_LIST_ADD_LAST(sym_list, sym_tab->sym_list, node);
140 
141  node->sym_table = sym_tab;
142 
143  return(node);
144 }
145 
146 /******************************************************************/
149 #ifdef __cplusplus
150 extern "C"
151 #endif
152 UNIV_INTERN
153 sym_node_t*
155 /*================*/
156  sym_tab_t* sym_tab,
157  byte* str,
159  ulint len)
160 {
161  sym_node_t* node;
162  byte* data;
163 
164  node = static_cast<sym_node_t *>(mem_heap_alloc(sym_tab->heap, sizeof(sym_node_t)));
165 
166  node->common.type = QUE_NODE_SYMBOL;
167 
168  node->resolved = TRUE;
169  node->token_type = SYM_LIT;
170 
171  node->indirection = NULL;
172 
173  dtype_set(dfield_get_type(&node->common.val),
174  DATA_VARCHAR, DATA_ENGLISH, 0);
175 
176  if (len) {
177  data = static_cast<byte *>(mem_heap_alloc(sym_tab->heap, len));
178  ut_memcpy(data, str, len);
179  } else {
180  data = NULL;
181  }
182 
183  dfield_set_data(&(node->common.val), data, len);
184 
185  node->common.val_buf_size = 0;
186  node->prefetch_buf = NULL;
187  node->cursor_def = NULL;
188 
189  UT_LIST_ADD_LAST(sym_list, sym_tab->sym_list, node);
190 
191  node->sym_table = sym_tab;
192 
193  return(node);
194 }
195 
196 /******************************************************************/
199 #ifdef __cplusplus
200 extern "C"
201 #endif
202 UNIV_INTERN
203 sym_node_t*
205 /*==================*/
206  sym_tab_t* sym_tab,
207  const char* name,
208  ulint* lit_type)
209 {
210  sym_node_t* node;
211  pars_bound_lit_t* blit;
212  ulint len = 0;
213 
214  blit = pars_info_get_bound_lit(sym_tab->info, name);
215  ut_a(blit);
216 
217  node = static_cast<sym_node_t *>(mem_heap_alloc(sym_tab->heap, sizeof(sym_node_t)));
218 
219  node->common.type = QUE_NODE_SYMBOL;
220 
221  node->resolved = TRUE;
222  node->token_type = SYM_LIT;
223 
224  node->indirection = NULL;
225 
226  switch (blit->type) {
227  case DATA_FIXBINARY:
228  len = blit->length;
229  *lit_type = PARS_FIXBINARY_LIT;
230  break;
231 
232  case DATA_BLOB:
233  *lit_type = PARS_BLOB_LIT;
234  break;
235 
236  case DATA_VARCHAR:
237  *lit_type = PARS_STR_LIT;
238  break;
239 
240  case DATA_CHAR:
241  ut_a(blit->length > 0);
242 
243  len = blit->length;
244  *lit_type = PARS_STR_LIT;
245  break;
246 
247  case DATA_INT:
248  ut_a(blit->length > 0);
249  ut_a(blit->length <= 8);
250 
251  len = blit->length;
252  *lit_type = PARS_INT_LIT;
253  break;
254 
255  default:
256  ut_error;
257  }
258 
259  dtype_set(dfield_get_type(&node->common.val),
260  blit->type, blit->prtype, len);
261 
262  dfield_set_data(&(node->common.val), blit->address, blit->length);
263 
264  node->common.val_buf_size = 0;
265  node->prefetch_buf = NULL;
266  node->cursor_def = NULL;
267 
268  UT_LIST_ADD_LAST(sym_list, sym_tab->sym_list, node);
269 
270  node->sym_table = sym_tab;
271 
272  return(node);
273 }
274 
275 /******************************************************************/
278 #ifdef __cplusplus
279 extern "C"
280 #endif
281 UNIV_INTERN
282 sym_node_t*
284 /*=================*/
285  sym_tab_t* sym_tab)
286 {
287  sym_node_t* node;
288 
289  node = static_cast<sym_node_t *>(mem_heap_alloc(sym_tab->heap, sizeof(sym_node_t)));
290 
291  node->common.type = QUE_NODE_SYMBOL;
292 
293  node->resolved = TRUE;
294  node->token_type = SYM_LIT;
295 
296  node->indirection = NULL;
297 
298  dfield_get_type(&node->common.val)->mtype = DATA_ERROR;
299 
300  dfield_set_null(&node->common.val);
301 
302  node->common.val_buf_size = 0;
303  node->prefetch_buf = NULL;
304  node->cursor_def = NULL;
305 
306  UT_LIST_ADD_LAST(sym_list, sym_tab->sym_list, node);
307 
308  node->sym_table = sym_tab;
309 
310  return(node);
311 }
312 
313 /******************************************************************/
316 #ifdef __cplusplus
317 extern "C"
318 #endif
319 UNIV_INTERN
320 sym_node_t*
322 /*===========*/
323  sym_tab_t* sym_tab,
324  byte* name,
325  ulint len)
326 {
327  sym_node_t* node;
328 
329  node = static_cast<sym_node_t *>(mem_heap_alloc(sym_tab->heap, sizeof(sym_node_t)));
330 
331  node->common.type = QUE_NODE_SYMBOL;
332 
333  node->resolved = FALSE;
334  node->indirection = NULL;
335 
336  node->name = mem_heap_strdupl(sym_tab->heap, (char*) name, len);
337  node->name_len = len;
338 
339  UT_LIST_ADD_LAST(sym_list, sym_tab->sym_list, node);
340 
341  dfield_set_null(&node->common.val);
342 
343  node->common.val_buf_size = 0;
344  node->prefetch_buf = NULL;
345  node->cursor_def = NULL;
346 
347  node->sym_table = sym_tab;
348 
349  return(node);
350 }
351 
352 /******************************************************************/
355 #ifdef __cplusplus
356 extern "C"
357 #endif
358 UNIV_INTERN
359 sym_node_t*
361 /*===========*/
362  sym_tab_t* sym_tab,
363  const char* name)
364 {
365  sym_node_t* node;
366  pars_bound_id_t* bid;
367 
368  bid = pars_info_get_bound_id(sym_tab->info, name);
369  ut_a(bid);
370 
371  node = static_cast<sym_node_t *>(mem_heap_alloc(sym_tab->heap, sizeof(sym_node_t)));
372 
373  node->common.type = QUE_NODE_SYMBOL;
374 
375  node->resolved = FALSE;
376  node->indirection = NULL;
377 
378  node->name = mem_heap_strdup(sym_tab->heap, bid->id);
379  node->name_len = strlen(node->name);
380 
381  UT_LIST_ADD_LAST(sym_list, sym_tab->sym_list, node);
382 
383  dfield_set_null(&node->common.val);
384 
385  node->common.val_buf_size = 0;
386  node->prefetch_buf = NULL;
387  node->cursor_def = NULL;
388 
389  node->sym_table = sym_tab;
390 
391  return(node);
392 }
#define UT_LIST_GET_NEXT(NAME, N)
Definition: ut0lst.h:201
UNIV_INTERN sym_node_t * sym_tab_add_id(sym_tab_t *sym_tab, byte *name, ulint len)
Definition: pars0sym.cc:321
UNIV_INTERN void sel_col_prefetch_buf_free(sel_buf_t *prefetch_buf)
Definition: row0sel.cc:505
UNIV_INTERN sym_node_t * sym_tab_add_str_lit(sym_tab_t *sym_tab, byte *str, ulint len)
Definition: pars0sym.cc:154
enum sym_tab_entry token_type
Definition: pars0sym.h:208
UNIV_INLINE void mach_write_to_4(byte *b, ulint n)
UNIV_INTERN void eval_node_free_val_buf(que_node_t *node)
Definition: eval0eval.cc:93
UNIV_INLINE void * ut_memcpy(void *dest, const void *sour, ulint n)
mem_heap_t * heap
Definition: pars0sym.h:255
sel_node_t * cursor_def
Definition: pars0sym.h:221
ulint name_len
Definition: pars0sym.h:211
const char * id
Definition: pars0pars.h:634
dfield_t val
Definition: que0types.h:51
const void * address
Definition: pars0pars.h:625
UNIV_INTERN sym_tab_t * sym_tab_create(mem_heap_t *heap)
Definition: pars0sym.cc:49
UNIV_INTERN char * mem_heap_strdup(mem_heap_t *heap, const char *str)
Definition: mem0mem.cc:107
UNIV_INTERN sym_node_t * sym_tab_add_null_lit(sym_tab_t *sym_tab)
Definition: pars0sym.cc:283
UNIV_INTERN sym_node_t * sym_tab_add_bound_id(sym_tab_t *sym_tab, const char *name)
Definition: pars0sym.cc:360
UNIV_INLINE void dfield_set_data(dfield_t *field, const void *data, ulint len)
sym_tab_t * sym_table
Definition: pars0sym.h:228
UNIV_INTERN sym_node_t * sym_tab_add_bound_lit(sym_tab_t *sym_tab, const char *name, ulint *lit_type)
Definition: pars0sym.cc:204
UNIV_INLINE char * mem_heap_strdupl(mem_heap_t *heap, const char *str, ulint len)
sel_buf_t * prefetch_buf
Definition: pars0sym.h:217
#define ut_a(EXPR)
Definition: ut0dbg.h:105
UNIV_INTERN void que_graph_free_recursive(que_node_t *node)
Definition: que0que.cc:508
UNIV_INLINE void * mem_heap_alloc(mem_heap_t *heap, ulint n)
sym_node_list_t sym_list
Definition: pars0sym.h:248
#define UT_LIST_ADD_LAST(NAME, BASE, N)
Definition: ut0lst.h:119
#define UT_LIST_GET_FIRST(BASE)
Definition: ut0lst.h:224
UNIV_INTERN void sym_tab_free_private(sym_tab_t *sym_tab)
Definition: pars0sym.cc:71
pars_info_t * info
Definition: pars0sym.h:247
ibool resolved
Definition: pars0sym.h:203
#define UT_LIST_INIT(BASE)
Definition: ut0lst.h:84
#define ut_error
Definition: ut0dbg.h:115
que_common_t common
Definition: pars0sym.h:153
UNIV_INLINE void dfield_set_null(dfield_t *field)
UNIV_INLINE void dtype_set(dtype_t *type, ulint mtype, ulint prtype, ulint len)
const char * name
Definition: pars0sym.h:210
UNIV_INTERN pars_bound_lit_t * pars_info_get_bound_lit(pars_info_t *info, const char *name)
Definition: pars0pars.cc:2152
UNIV_INTERN sym_node_t * sym_tab_add_int_lit(sym_tab_t *sym_tab, ulint val)
Definition: pars0sym.cc:111
sym_node_t * indirection
Definition: pars0sym.h:173
UNIV_INTERN pars_bound_id_t * pars_info_get_bound_id(pars_info_t *info, const char *name)
Definition: pars0pars.cc:2182