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