CUBRID Engine  latest
xasl_generation.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 
20 /*
21  * xasl_generation.h - Generate XASL from parse tree
22  */
23 
24 #ifndef _XASL_GENERATION_H_
25 #define _XASL_GENERATION_H_
26 
27 #ident "$Id$"
28 
29 #if defined (SERVER_MODE)
30 #error Does not belong to server module
31 #endif /* defined (SERVER_MODE) */
32 
33 #include "dbtype_def.h"
34 #include "object_domain.h"
35 #include "optimizer.h"
36 #include "parser.h"
37 #include "regu_var.hpp"
38 #include "xasl.h"
39 
40 // forward definitions
41 
42 // *INDENT-OFF*
43 namespace cubxasl
44 {
45  struct analytic_list_node;
46  struct pred_expr;
47 } // namespace cubxasl
49 // *INDENT-ON*
50 
51 #define MATCH_ALL 1
52 
53 #define PT_PRED_ARG_INSTNUM_CONTINUE 0x01
54 #define PT_PRED_ARG_GRBYNUM_CONTINUE 0x02
55 #define PT_PRED_ARG_ORDBYNUM_CONTINUE 0x04
56 
57 typedef struct table_info TABLE_INFO;
58 struct table_info
59 {
60  struct table_info *next; /* usual list link */
61  PT_NODE *class_spec; /* SHARED pointer to parse tree entity spec */
62  const char *exposed; /* SHARED pointer to entity spec exposed name */
63  UINTPTR spec_id;
64  PT_NODE *attribute_list; /* is a list of names which appear anywhere in a select statement with the exposed name
65  */
66  VAL_LIST *value_list; /* is a list of DB_VALUES which correspond by position in list to the attributes named
67  * in attribute_list */
68  int is_fetch;
69 };
70 
71 /*
72  * This structure represents the global information needed to be stored
73  * to translate a parse tree into XASL. It is only used in the process of
74  * translation. A new one is "pushed" on the stack every time a query
75  * statement is to be translated, and "popped" when its translation is
76  * complete. Nested select statements will then yield a stack of these
77  * which can be used to resolve attribute names referenced.
78  */
79 typedef enum
81 typedef struct symbol_info SYMBOL_INFO;
83 {
84  SYMBOL_INFO *stack; /* enclosing scope symbol table */
85  TABLE_INFO *table_info; /* list of exposed class names with corresponding attributes and values */
86  PT_NODE *current_class; /* value of a class to resolve */
92  PT_NODE *query_node; /* the query node that is being translated */
93  DB_VALUE **reserved_values; /* db_values array used for reserved attributes */
94 };
95 
96 
97 
100 {
108  const char *class_name;
110 };
111 
114 {
115  // *INDENT-OFF*
117  // *INDENT-ON*
122 };
123 
124 typedef enum
128 
129 typedef struct
130 {
131  UINTPTR spec_id; /* id of entity to be compatible with */
132  PT_NODE *spec; /* to allow for recursion on subquery */
133  PT_NODE *root; /* the root of this compatibility test */
134  COMPATIBLE_LEVEL compatible; /* how compatible is the sub-tree */
136 
137 extern char *query_Plan_dump_filename;
138 extern FILE *query_Plan_dump_fp;
139 
142 extern PRED_EXPR *pt_to_pred_expr_with_arg (PARSER_CONTEXT * parser, PT_NODE * node_list, int *argp);
144 extern REGU_VARIABLE *pt_make_regu_arith (const REGU_VARIABLE * arg1, const REGU_VARIABLE * arg2,
145  const REGU_VARIABLE * arg3, const OPERATOR_TYPE op, const TP_DOMAIN * domain);
148 extern PT_NODE *pt_to_upd_del_query (PARSER_CONTEXT * parser, PT_NODE * select_names, PT_NODE * select_list,
149  PT_NODE * from, PT_NODE * with, PT_NODE * class_specs, PT_NODE * where,
150  PT_NODE * using_index, PT_NODE * order_by, PT_NODE * orderby_for, int server_op,
151  SCAN_OPERATION_TYPE scan_op_type);
154 extern XASL_NODE *pt_to_update_xasl (PARSER_CONTEXT * parser, PT_NODE * statement, PT_NODE ** non_null_attrs);
156 extern XASL_NODE *pt_append_xasl (XASL_NODE * to, XASL_NODE * from_list);
157 extern XASL_NODE *pt_remove_xasl (XASL_NODE * xasl_list, XASL_NODE * remove);
158 extern ACCESS_SPEC_TYPE *pt_to_spec_list (PARSER_CONTEXT * parser, PT_NODE * flat, PT_NODE * where_key_part,
159  PT_NODE * where_part, QO_PLAN * plan, QO_XASL_INDEX_INFO * indx,
160  PT_NODE * src_derived_table, PT_NODE * where_hash_part);
161 extern XASL_NODE *pt_to_fetch_proc (PARSER_CONTEXT * parser, PT_NODE * spec, PT_NODE * pred);
162 extern VAL_LIST *pt_to_val_list (PARSER_CONTEXT * parser, UINTPTR id);
163 extern SORT_LIST *pt_to_orderby (PARSER_CONTEXT * parser, PT_NODE * order_list, PT_NODE * root);
165 extern XASL_NODE *ptqo_to_scan_proc (PARSER_CONTEXT * parser, QO_PLAN * plan, XASL_NODE * xasl, PT_NODE * spec,
166  PT_NODE * where_key_part, PT_NODE * where_part, QO_XASL_INDEX_INFO * info,
167  PT_NODE * where_hash_part);
169  XASL_NODE * listfile, PT_NODE * namelist, PT_NODE * pred, int *poslist);
172  JOIN_TYPE join_type);
173 extern void pt_set_dptr (PARSER_CONTEXT * parser, PT_NODE * node, XASL_NODE * xasl, UINTPTR id);
174 extern PT_NODE *pt_flush_classes (PARSER_CONTEXT * parser, PT_NODE * tree, void *arg, int *continue_walk);
175 
176 extern int pt_is_single_tuple (PARSER_CONTEXT * parser, PT_NODE * select_node);
178  PT_NODE * root, PT_NODE ** referred_node);
180  PT_NODE * root);
181 extern void pt_set_numbering_node_etc (PARSER_CONTEXT * parser, PT_NODE * node_list, DB_VALUE ** instnum_valp,
182  DB_VALUE ** ordbynum_valp);
183 extern PT_NODE *pt_get_numbering_node_etc (PARSER_CONTEXT * parser, PT_NODE * node, void *arg, int *continue_walk);
184 extern void pt_set_level_node_etc (PARSER_CONTEXT * parser, PT_NODE * node_list, DB_VALUE ** level_valp);
185 extern void pt_set_isleaf_node_etc (PARSER_CONTEXT * parser, PT_NODE * node_list, DB_VALUE ** isleaf_valp);
186 extern void pt_set_iscycle_node_etc (PARSER_CONTEXT * parser, PT_NODE * node_list, DB_VALUE ** iscycle_valp);
187 extern void pt_set_connect_by_operator_node_etc (PARSER_CONTEXT * parser, PT_NODE * node_list, XASL_NODE * xasl);
188 extern void pt_set_qprior_node_etc (PARSER_CONTEXT * parser, PT_NODE * node_list, XASL_NODE * xasl);
189 extern XASL_NODE *pt_gen_simple_merge_plan (PARSER_CONTEXT * parser, PT_NODE * select_node, QO_PLAN * plan,
190  XASL_NODE * xasl);
192 extern FUNC_PRED *pt_to_func_pred (PARSER_CONTEXT * parser, PT_NODE * spec, PT_NODE * expr);
195 extern XASL_NODE *pt_to_merge_xasl (PARSER_CONTEXT * parser, PT_NODE * statement, PT_NODE ** non_null_upd_attrs,
196  PT_NODE ** non_null_ins_attrs, PT_NODE * default_expr_attrs);
197 extern int pt_copy_upddel_hints_to_select (PARSER_CONTEXT * parser, PT_NODE * node, PT_NODE * select_stmt);
198 extern PT_NODE *pt_set_orderby_for_sort_limit_plan (PARSER_CONTEXT * parser, PT_NODE * statement, PT_NODE * name_list);
199 extern SORT_NULLS pt_to_null_ordering (PT_NODE * sort_spec);
200 
201 extern int pt_find_omitted_default_expr (PARSER_CONTEXT * parser, DB_OBJECT * class_obj, PT_NODE * specified_attrs,
202  PT_NODE ** default_expr_attrs);
205 #endif /* _XASL_GENERATION_H_ */
REGU_VARIABLE_LIST regu_list
const char * class_name
int pt_copy_upddel_hints_to_select(PARSER_CONTEXT *parser, PT_NODE *node, PT_NODE *select_stmt)
COMPATIBLE_LEVEL compatible
VAL_LIST * value_list
void pt_set_iscycle_node_etc(PARSER_CONTEXT *parser, PT_NODE *node_list, DB_VALUE **iscycle_valp)
XASL_NODE * pt_skeleton_buildlist_proc(PARSER_CONTEXT *parser, PT_NODE *namelist)
SORT_NULLS
Definition: query_list.h:404
OUTPTR_LIST * out_list
XASL_NODE * ptqo_to_merge_list_proc(PARSER_CONTEXT *parser, XASL_NODE *left, XASL_NODE *right, JOIN_TYPE join_type)
struct table_info * next
REGU_VARIABLE * pt_to_regu_variable(PARSER_CONTEXT *p, PT_NODE *node, UNBOX unbox)
PT_NODE * sort_lists
void pt_to_pos_descr_groupby(PARSER_CONTEXT *parser, QFILE_TUPLE_VALUE_POSITION *pos_p, PT_NODE *node, PT_NODE *root)
XASL_NODE * pt_gen_simple_merge_plan(PARSER_CONTEXT *parser, PT_NODE *select_node, QO_PLAN *plan, XASL_NODE *xasl)
enum pt_type_enum PT_TYPE_ENUM
Definition: parse_tree.h:962
PT_NODE * select_node
XASL_NODE * pt_to_update_xasl(PARSER_CONTEXT *parser, PT_NODE *statement, PT_NODE **non_null_attrs)
cubxasl::analytic_list_node * head_list
VAL_LIST * val_list
int pt_is_single_tuple(PARSER_CONTEXT *parser, PT_NODE *select_node)
SYMBOL_INFO * stack
PT_NODE * pt_to_upd_del_query(PARSER_CONTEXT *parser, PT_NODE *select_names, PT_NODE *select_list, PT_NODE *from, PT_NODE *with, PT_NODE *class_specs, PT_NODE *where, PT_NODE *using_index, PT_NODE *order_by, PT_NODE *orderby_for, int server_op, SCAN_OPERATION_TYPE scan_op_type)
PT_NODE * attribute_list
PT_NODE * pt_to_merge_update_query(PARSER_CONTEXT *parser, PT_NODE *select_list, PT_MERGE_INFO *info)
HEAP_CACHE_ATTRINFO * cache_attrinfo
PRED_EXPR * pt_to_pred_expr_with_arg(PARSER_CONTEXT *parser, PT_NODE *node_list, int *argp)
UNBOX
AGGREGATE_TYPE * head_list
DB_VALUE ** reserved_values
VAL_LIST * listfile_value_list
JOIN_TYPE
Definition: query_list.h:32
int listfile_attr_offset
TABLE_INFO * table_info
XASL_NODE * pt_to_merge_xasl(PARSER_CONTEXT *parser, PT_NODE *statement, PT_NODE **non_null_upd_attrs, PT_NODE **non_null_ins_attrs, PT_NODE *default_expr_attrs)
PT_NODE * select_list
void pt_set_level_node_etc(PARSER_CONTEXT *parser, PT_NODE *node_list, DB_VALUE **level_valp)
SORT_LIST * pt_to_orderby(PARSER_CONTEXT *parser, PT_NODE *order_list, PT_NODE *root)
XASL_NODE * pt_remove_xasl(XASL_NODE *xasl_list, XASL_NODE *remove)
XASL_NODE * ptqo_to_list_scan_proc(PARSER_CONTEXT *parser, XASL_NODE *xasl, PROC_TYPE type, XASL_NODE *listfile, PT_NODE *namelist, PT_NODE *pred, int *poslist)
OPERATOR_TYPE
char * query_Plan_dump_filename
TP_DOMAIN * pt_xasl_type_enum_to_domain(const PT_TYPE_ENUM type)
PT_NODE * query_node
int pt_find_omitted_default_expr(PARSER_CONTEXT *parser, DB_OBJECT *class_obj, PT_NODE *specified_attrs, PT_NODE **default_expr_attrs)
const char * exposed
COMPATIBLE_LEVEL
SP_PARSER_CTX * parser
XASL_NODE * pt_to_instnum_pred(PARSER_CONTEXT *parser, XASL_NODE *xasl, PT_NODE *pred)
void pt_set_numbering_node_etc(PARSER_CONTEXT *parser, PT_NODE *node_list, DB_VALUE **instnum_valp, DB_VALUE **ordbynum_valp)
void pt_set_connect_by_operator_node_etc(PARSER_CONTEXT *parser, PT_NODE *node_list, XASL_NODE *xasl)
FILE * query_Plan_dump_fp
PT_NODE * current_class
PT_NODE * out_names
DB_VALUE ** grbynum_valp
PT_NODE * pt_set_orderby_for_sort_limit_plan(PARSER_CONTEXT *parser, PT_NODE *statement, PT_NODE *name_list)
XASL_NODE * pt_to_delete_xasl(PARSER_CONTEXT *parser, PT_NODE *node)
SCAN_OPERATION_TYPE
PRED_EXPR_WITH_CONTEXT * pt_to_pred_with_context(PARSER_CONTEXT *parser, PT_NODE *filter_pred, PT_NODE *spec)
REGU_VARIABLE * pt_make_regu_arith(const REGU_VARIABLE *arg1, const REGU_VARIABLE *arg2, const REGU_VARIABLE *arg3, const OPERATOR_TYPE op, const TP_DOMAIN *domain)
void pt_to_pos_descr(PARSER_CONTEXT *parser, QFILE_TUPLE_VALUE_POSITION *pos_p, PT_NODE *node, PT_NODE *root, PT_NODE **referred_node)
XASL_NODE * ptqo_to_scan_proc(PARSER_CONTEXT *parser, QO_PLAN *plan, XASL_NODE *xasl, PT_NODE *spec, PT_NODE *where_key_part, PT_NODE *where_part, QO_XASL_INDEX_INFO *info, PT_NODE *where_hash_part)
void pt_set_qprior_node_etc(PARSER_CONTEXT *parser, PT_NODE *node_list, XASL_NODE *xasl)
VAL_LIST * pt_to_val_list(PARSER_CONTEXT *parser, UINTPTR id)
UINTPTR spec_id
TP_DOMAIN * pt_xasl_node_to_domain(PARSER_CONTEXT *parser, const PT_NODE *node)
PT_NODE * pt_flush_classes(PARSER_CONTEXT *parser, PT_NODE *tree, void *arg, int *continue_walk)
XASL_NODE * pt_append_xasl(XASL_NODE *to, XASL_NODE *from_list)
class regu_variable_node REGU_VARIABLE
Definition: regu_var.hpp:64
PT_NODE * pt_to_merge_insert_query(PARSER_CONTEXT *parser, PT_NODE *select_list, PT_MERGE_INFO *info)
VAL_LIST * value_list
PRED_EXPR * pt_to_pred_expr(PARSER_CONTEXT *parser, PT_NODE *node)
PROC_TYPE
Definition: xasl.h:172
PT_NODE * class_spec
SORT_NULLS pt_to_null_ordering(PT_NODE *sort_spec)
void pt_set_dptr(PARSER_CONTEXT *parser, PT_NODE *node, XASL_NODE *xasl, UINTPTR id)
int pt_append_omitted_on_update_expr_assignments(PARSER_CONTEXT *parser, PT_NODE *assigns, PT_NODE *from)
PT_NODE * pt_get_numbering_node_etc(PARSER_CONTEXT *parser, PT_NODE *node, void *arg, int *continue_walk)
PT_NODE * current_listfile
XASL_NODE * parser_generate_xasl(PARSER_CONTEXT *p, PT_NODE *node)
XASL_NODE * pt_to_insert_xasl(PARSER_CONTEXT *parser, PT_NODE *node)
UNBOX listfile_unbox
FUNC_PRED * pt_to_func_pred(PARSER_CONTEXT *parser, PT_NODE *spec, PT_NODE *expr)
ACCESS_SPEC_TYPE * pt_to_spec_list(PARSER_CONTEXT *parser, PT_NODE *flat, PT_NODE *where_key_part, PT_NODE *where_part, QO_PLAN *plan, QO_XASL_INDEX_INFO *indx, PT_NODE *src_derived_table, PT_NODE *where_hash_part)
REGU_VARIABLE_LIST scan_regu_list
SORT_LIST * ptqo_single_orderby(PARSER_CONTEXT *parser)
XASL_NODE * parser_generate_do_stmt_xasl(PARSER_CONTEXT *p, PT_NODE *node)
XASL_NODE * pt_to_fetch_proc(PARSER_CONTEXT *parser, PT_NODE *spec, PT_NODE *pred)
const char ** p
Definition: dynamic_load.c:945
void pt_set_isleaf_node_etc(PARSER_CONTEXT *parser, PT_NODE *node_list, DB_VALUE **isleaf_valp)