17
17
*****************************************************************************/
19
/******************************************************
19
/**************************************************//**
20
@file include/eval0eval.ic
20
21
SQL evaluator: evaluates simple data structures, like expressions, in
30
31
# include "pars0grm.h"
33
/*********************************************************************
34
/*****************************************************************//**
34
35
Evaluates a function node. */
39
func_node_t* func_node); /* in: function node */
40
/*********************************************************************
40
func_node_t* func_node); /*!< in: function node */
41
/*****************************************************************//**
41
42
Allocate a buffer from global dynamic memory for a value of a que_node.
42
43
NOTE that this memory must be explicitly freed when the query graph is
43
44
freed. If the node already has allocated buffer, that buffer is freed
44
45
here. NOTE that this is the only function where dynamic memory should be
45
allocated for a query node val field. */
46
allocated for a query node val field.
47
@return pointer to allocated buffer */
48
50
eval_node_alloc_val_buf(
49
51
/*====================*/
50
/* out: pointer to allocated buffer */
51
que_node_t* node, /* in: query graph node; sets the val field
52
que_node_t* node, /*!< in: query graph node; sets the val field
52
53
data field to point to the new buffer, and
53
54
len field equal to size */
54
ulint size); /* in: buffer size */
57
/*********************************************************************
58
Allocates a new buffer if needed. */
55
ulint size); /*!< in: buffer size */
58
/*****************************************************************//**
59
Allocates a new buffer if needed.
60
@return pointer to buffer */
61
63
eval_node_ensure_val_buf(
62
64
/*=====================*/
63
/* out: pointer to buffer */
64
que_node_t* node, /* in: query graph node; sets the val field
65
que_node_t* node, /*!< in: query graph node; sets the val field
65
66
data field to point to the new buffer, and
66
67
len field equal to size */
67
ulint size) /* in: buffer size */
68
ulint size) /*!< in: buffer size */
85
/*********************************************************************
86
/*****************************************************************//**
86
87
Evaluates a symbol table symbol. */
91
sym_node_t* sym_node) /* in: symbol table node */
92
sym_node_t* sym_node) /*!< in: symbol table node */
94
95
ut_ad(que_node_get_type(sym_node) == QUE_NODE_SYMBOL);
105
/*********************************************************************
106
/*****************************************************************//**
106
107
Evaluates an expression. */
111
que_node_t* exp_node) /* in: expression */
112
que_node_t* exp_node) /*!< in: expression */
113
114
if (que_node_get_type(exp_node) == QUE_NODE_SYMBOL) {
120
121
eval_func(exp_node);
123
/*********************************************************************
124
/*****************************************************************//**
124
125
Sets an integer value as the value of an expression node. */
127
128
eval_node_set_int_val(
128
129
/*==================*/
129
que_node_t* node, /* in: expression node */
130
lint val) /* in: value to set */
130
que_node_t* node, /*!< in: expression node */
131
lint val) /*!< in: value to set */
132
133
dfield_t* dfield;
145
146
mach_write_to_4(data, (ulint)val);
148
/*********************************************************************
149
Gets an integer non-SQL null value from an expression node. */
149
/*****************************************************************//**
150
Gets an integer non-SQL null value from an expression node.
151
@return integer value */
152
154
eval_node_get_int_val(
153
155
/*==================*/
154
/* out: integer value */
155
que_node_t* node) /* in: expression node */
156
que_node_t* node) /*!< in: expression node */
157
158
dfield_t* dfield;
163
164
return((int)mach_read_from_4(dfield_get_data(dfield)));
166
/*********************************************************************
167
Gets a iboolean value from a query node. */
167
/*****************************************************************//**
168
Gets a iboolean value from a query node.
169
@return iboolean value */
170
172
eval_node_get_ibool_val(
171
173
/*====================*/
172
/* out: iboolean value */
173
que_node_t* node) /* in: query graph node */
174
que_node_t* node) /*!< in: query graph node */
175
176
dfield_t* dfield;
184
185
return(mach_read_from_1(data));
187
/*********************************************************************
188
/*****************************************************************//**
188
189
Sets a iboolean value as the value of a function node. */
191
192
eval_node_set_ibool_val(
192
193
/*====================*/
193
func_node_t* func_node, /* in: function node */
194
ibool val) /* in: value to set */
194
func_node_t* func_node, /*!< in: function node */
195
ibool val) /*!< in: value to set */
196
197
dfield_t* dfield;
211
212
mach_write_to_1(data, val);
214
/*********************************************************************
215
/*****************************************************************//**
215
216
Copies a binary string value as the value of a query graph node. Allocates a
216
217
new buffer if necessary. */
219
220
eval_node_copy_and_alloc_val(
220
221
/*=========================*/
221
que_node_t* node, /* in: query graph node */
222
const byte* str, /* in: binary string */
223
ulint len) /* in: string length or UNIV_SQL_NULL */
222
que_node_t* node, /*!< in: query graph node */
223
const byte* str, /*!< in: binary string */
224
ulint len) /*!< in: string length or UNIV_SQL_NULL */
235
236
ut_memcpy(data, str, len);
238
/*********************************************************************
239
/*****************************************************************//**
239
240
Copies a query node value to another node. */
242
243
eval_node_copy_val(
243
244
/*===============*/
244
que_node_t* node1, /* in: node to copy to */
245
que_node_t* node2) /* in: node to copy from */
245
que_node_t* node1, /*!< in: node to copy to */
246
que_node_t* node2) /*!< in: node to copy from */
247
248
dfield_t* dfield2;