CUBRID Engine  latest
xasl_regu_alloc.hpp
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  * xasl_regu_alloc - allocate/initialize XASL structures (for XASL generation)
21  */
22 
23 #ifndef _XASL_REGU_ALLOC_HPP_
24 #define _XASL_REGU_ALLOC_HPP_
25 
26 #if defined (SERVER_MODE)
27 #error Does not belong to server module
28 #endif /* defined (SERVER_MODE) */
29 
30 #include "dbtype_def.h" // OID, DB_TYPE
31 #include "storage_common.h" // HFID
32 #include "xasl.h" // PROC_TYPE, TARGET_TYPE
33 
34 // forward definitions
35 struct access_spec_node;
36 struct arith_list_node;
37 struct db_value;
38 struct function_node;
39 struct indx_info;
40 struct key_range;
41 struct qfile_list_id;
42 class regu_variable_node;
44 struct selupd_list;
45 struct sort_list;
46 struct tp_domain;
47 struct update_assignment;
48 struct upddel_class_info;
49 struct xasl_node;
50 
51 namespace cubxasl
52 {
53  struct aggregate_list_node;
54  struct analytic_list_node;
55  struct pred_expr;
56 }
57 
58 template <typename T>
59 void regu_init (T &t);
60 
61 void regu_init (db_value &dbval);
62 void regu_init (regu_variable_node &regu);
63 void regu_init (regu_variable_list_node &regu_varlist);
64 void regu_init (cubxasl::pred_expr &pr);
65 void regu_init (indx_info &ii);
66 void regu_init (tp_domain &dom);
67 void regu_init (selupd_list &selupd);
68 void regu_init (key_range &kr);
69 void regu_init (OID &oid);
70 void regu_init (HFID &hfid);
71 void regu_init (upddel_class_info &upddel);
72 void regu_init (update_assignment &assign);
73 void regu_init (arith_list_node &arith);
74 void regu_init (function_node &fnode);
77 void regu_init (xasl_node &node);
78 void regu_init (sort_list &sl);
79 void regu_init (qfile_list_id &list_id);
80 void regu_init (access_spec_node &spec);
81 
82 template <typename T>
83 void regu_alloc (T *&ptr);
84 
85 template <typename T>
86 void regu_array_alloc (T **ptr, size_t size);
87 
88 /* for regu_machead_array () */
89 int *regu_int_array_alloc (int size);
90 OID *regu_oid_array_alloc (int size);
91 
92 void regu_dbval_type_init (db_value *ptr, DB_TYPE type);
93 
96 
98 // inline/template implementation
100 
101 #include "parser_support.h"
102 
103 template <typename T>
104 void
105 regu_init (T &t)
106 {
107  t = T ();
108 }
109 
110 template <typename T>
111 void
112 regu_alloc (T *&ptr)
113 {
114  ptr = reinterpret_cast<T *> (pt_alloc_packing_buf ((int) sizeof (T)));
115  if (ptr == NULL)
116  {
118  return;
119  }
120  regu_init (*ptr);
121 }
122 
123 template <typename T>
124 void
125 regu_array_alloc (T **ptr, size_t size)
126 {
127  if (size == 0)
128  {
129  *ptr = NULL;
130  return;
131  }
132  *ptr = reinterpret_cast<T *> (pt_alloc_packing_buf ((int) (sizeof (T) * size)));
133  if (*ptr == NULL)
134  {
136  return;
137  }
138  for (size_t idx = 0; idx < size; idx++)
139  {
140  regu_init ((*ptr)[idx]);
141  }
142 }
143 
144 #endif /* _XASL_REGU_ALLOC_HPP_ */
void regu_array_alloc(T **ptr, size_t size)
access_spec_node * regu_spec_alloc(TARGET_TYPE type)
OID * regu_oid_array_alloc(int size)
DB_TYPE
Definition: dbtype_def.h:670
void regu_alloc(T *&ptr)
char * pt_alloc_packing_buf(int size)
xasl_node * regu_xasl_node_alloc(PROC_TYPE type)
void regu_init(T &t)
void regu_set_error_with_zero_args(int err_type)
#define NULL
Definition: freelistheap.h:34
int * regu_int_array_alloc(int size)
#define ER_REGU_NO_SPACE
Definition: error_code.h:192
PROC_TYPE
Definition: xasl.h:172
void regu_dbval_type_init(db_value *ptr, DB_TYPE type)
TARGET_TYPE
Definition: xasl.h:675