Drizzled Public API Documentation

pars0sym.h
Go to the documentation of this file.
00001 /*****************************************************************************
00002 
00003 Copyright (C) 1997, 2009, Innobase Oy. All Rights Reserved.
00004 
00005 This program is free software; you can redistribute it and/or modify it under
00006 the terms of the GNU General Public License as published by the Free Software
00007 Foundation; version 2 of the License.
00008 
00009 This program is distributed in the hope that it will be useful, but WITHOUT
00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
00012 
00013 You should have received a copy of the GNU General Public License along with
00014 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
00015 St, Fifth Floor, Boston, MA 02110-1301 USA
00016 
00017 *****************************************************************************/
00018 
00019 /**************************************************/
00026 #pragma once
00027 #ifndef pars0sym_h
00028 #define pars0sym_h
00029 
00030 #include "univ.i"
00031 #include "que0types.h"
00032 #include "usr0types.h"
00033 #include "dict0types.h"
00034 #include "pars0types.h"
00035 #include "row0types.h"
00036 
00037 /******************************************************************/
00040 UNIV_INTERN
00041 sym_tab_t*
00042 sym_tab_create(
00043 /*===========*/
00044   mem_heap_t* heap);  
00045 /******************************************************************/
00049 UNIV_INTERN
00050 void
00051 sym_tab_free_private(
00052 /*=================*/
00053   sym_tab_t*  sym_tab); 
00054 /******************************************************************/
00057 #ifdef __cplusplus
00058 extern "C"
00059 #endif
00060 UNIV_INTERN
00061 sym_node_t*
00062 sym_tab_add_int_lit(
00063 /*================*/
00064   sym_tab_t*  sym_tab,  
00065   ulint   val);   
00066 /******************************************************************/
00069 #ifdef __cplusplus
00070 extern "C"
00071 #endif
00072 UNIV_INTERN
00073 sym_node_t*
00074 sym_tab_add_str_lit(
00075 /*================*/
00076   sym_tab_t*  sym_tab,  
00077   byte*   str,    
00079   ulint   len);   
00080 /******************************************************************/
00083 #ifdef __cplusplus
00084 extern "C"
00085 #endif
00086 UNIV_INTERN
00087 sym_node_t*
00088 sym_tab_add_bound_lit(
00089 /*==================*/
00090   sym_tab_t*  sym_tab,  
00091   const char* name,   
00092   ulint*    lit_type);  
00093 /******************************************************************/
00096 #ifdef __cplusplus
00097 extern "C"
00098 #endif
00099 UNIV_INTERN
00100 sym_node_t*
00101 sym_tab_add_null_lit(
00102 /*=================*/
00103   sym_tab_t*  sym_tab); 
00104 /******************************************************************/
00107 #ifdef __cplusplus
00108 extern "C"
00109 #endif
00110 UNIV_INTERN
00111 sym_node_t*
00112 sym_tab_add_id(
00113 /*===========*/
00114   sym_tab_t*  sym_tab,  
00115   byte*   name,   
00116   ulint   len);   
00118 /******************************************************************/
00121 #ifdef __cplusplus
00122 extern "C"
00123 #endif
00124 UNIV_INTERN
00125 sym_node_t*
00126 sym_tab_add_bound_id(
00127 /*===========*/
00128   sym_tab_t*  sym_tab,  
00129   const char* name);    
00132 #define SYM_CLUST_FIELD_NO  0
00133 
00134 #define SYM_SEC_FIELD_NO  1
00135 
00137 enum sym_tab_entry {
00138   SYM_VAR = 91,   
00140   SYM_IMPLICIT_VAR, 
00142   SYM_LIT,    
00143   SYM_TABLE,    
00144   SYM_COLUMN,   
00145   SYM_CURSOR,   
00146   SYM_PROCEDURE_NAME, 
00147   SYM_INDEX,    
00148   SYM_FUNCTION    
00149 };
00150 
00152 struct sym_node_struct{
00153   que_common_t      common;   
00155   /* NOTE: if the data field in 'common.val' is not NULL and the symbol
00156   table node is not for a temporary column, the memory for the value has
00157   been allocated from dynamic memory and it should be freed when the
00158   symbol table is discarded */
00159 
00160   /* 'alias' and 'indirection' are almost the same, but not quite.
00161   'alias' always points to the primary instance of the variable, while
00162   'indirection' does the same only if we should use the primary
00163   instance's values for the node's data. This is usually the case, but
00164   when initializing a cursor (e.g., "DECLARE CURSOR c IS SELECT * FROM
00165   t WHERE id = x;"), we copy the values from the primary instance to
00166   the cursor's instance so that they are fixed for the duration of the
00167   cursor, and set 'indirection' to NULL. If we did not, the value of
00168   'x' could change between fetches and things would break horribly.
00169 
00170   TODO: It would be cleaner to make 'indirection' a boolean field and
00171   always use 'alias' to refer to the primary node. */
00172 
00173   sym_node_t*     indirection;  
00178   sym_node_t*     alias;    
00183   UT_LIST_NODE_T(sym_node_t)  col_var_list; 
00187   ibool       copy_val; 
00191   ulint       field_nos[2]; 
00203   ibool       resolved; 
00208   enum sym_tab_entry    token_type; 
00210   const char*     name;   
00211   ulint       name_len; 
00212   dict_table_t*     table;    
00215   ulint       col_no;   
00217   sel_buf_t*      prefetch_buf; 
00221   sel_node_t*     cursor_def; 
00224   ulint       param_type; 
00228   sym_tab_t*      sym_table;  
00230   UT_LIST_NODE_T(sym_node_t)  sym_list; 
00232 };
00233 
00235 struct sym_tab_struct{
00236   que_t*      query_graph;
00239   const char*   sql_string;
00241   size_t      string_len;
00243   int     next_char_pos;
00247   pars_info_t*    info; 
00248   sym_node_list_t   sym_list;
00251   UT_LIST_BASE_NODE_T(func_node_t)
00252         func_node_list;
00255   mem_heap_t*   heap; 
00257 };
00258 
00259 #ifndef UNIV_NONINL
00260 #include "pars0sym.ic"
00261 #endif
00262 
00263 #endif