~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/eval0eval.ic

  • Committer: Brian Aker
  • Date: 2010-04-05 23:46:43 UTC
  • Revision ID: brian@gaz-20100405234643-0he3xnj902rc70r8
Fixing tests to work with PBXT.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
*****************************************************************************/
18
18
 
19
 
/******************************************************
 
19
/**************************************************//**
 
20
@file include/eval0eval.ic
20
21
SQL evaluator: evaluates simple data structures, like expressions, in
21
22
a query graph
22
23
 
30
31
# include "pars0grm.h"
31
32
#endif
32
33
 
33
 
/*********************************************************************
 
34
/*****************************************************************//**
34
35
Evaluates a function node. */
35
36
UNIV_INTERN
36
37
void
37
38
eval_func(
38
39
/*======*/
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 */
46
48
UNIV_INTERN
47
49
byte*
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 */
55
 
 
56
 
 
57
 
/*********************************************************************
58
 
Allocates a new buffer if needed. */
 
55
        ulint           size);  /*!< in: buffer size */
 
56
 
 
57
 
 
58
/*****************************************************************//**
 
59
Allocates a new buffer if needed.
 
60
@return pointer to buffer */
59
61
UNIV_INLINE
60
62
byte*
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 */
68
69
{
69
70
        dfield_t*       dfield;
70
71
        byte*           data;
82
83
        return(data);
83
84
}
84
85
 
85
 
/*********************************************************************
 
86
/*****************************************************************//**
86
87
Evaluates a symbol table symbol. */
87
88
UNIV_INLINE
88
89
void
89
90
eval_sym(
90
91
/*=====*/
91
 
        sym_node_t*     sym_node)       /* in: symbol table node */
 
92
        sym_node_t*     sym_node)       /*!< in: symbol table node */
92
93
{
93
94
 
94
95
        ut_ad(que_node_get_type(sym_node) == QUE_NODE_SYMBOL);
102
103
        }
103
104
}
104
105
 
105
 
/*********************************************************************
 
106
/*****************************************************************//**
106
107
Evaluates an expression. */
107
108
UNIV_INLINE
108
109
void
109
110
eval_exp(
110
111
/*=====*/
111
 
        que_node_t*     exp_node)       /* in: expression */
 
112
        que_node_t*     exp_node)       /*!< in: expression */
112
113
{
113
114
        if (que_node_get_type(exp_node) == QUE_NODE_SYMBOL) {
114
115
 
120
121
        eval_func(exp_node);
121
122
}
122
123
 
123
 
/*********************************************************************
 
124
/*****************************************************************//**
124
125
Sets an integer value as the value of an expression node. */
125
126
UNIV_INLINE
126
127
void
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 */
131
132
{
132
133
        dfield_t*       dfield;
133
134
        byte*           data;
145
146
        mach_write_to_4(data, (ulint)val);
146
147
}
147
148
 
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 */
150
152
UNIV_INLINE
151
153
lint
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 */
156
157
{
157
158
        dfield_t*       dfield;
158
159
 
163
164
        return((int)mach_read_from_4(dfield_get_data(dfield)));
164
165
}
165
166
 
166
 
/*********************************************************************
167
 
Gets a iboolean value from a query node. */
 
167
/*****************************************************************//**
 
168
Gets a iboolean value from a query node.
 
169
@return iboolean value */
168
170
UNIV_INLINE
169
171
ibool
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 */
174
175
{
175
176
        dfield_t*       dfield;
176
177
        byte*           data;
184
185
        return(mach_read_from_1(data));
185
186
}
186
187
 
187
 
/*********************************************************************
 
188
/*****************************************************************//**
188
189
Sets a iboolean value as the value of a function node. */
189
190
UNIV_INLINE
190
191
void
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 */
195
196
{
196
197
        dfield_t*       dfield;
197
198
        byte*           data;
211
212
        mach_write_to_1(data, val);
212
213
}
213
214
 
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. */
217
218
UNIV_INLINE
218
219
void
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 */
224
225
{
225
226
        byte*           data;
226
227
 
235
236
        ut_memcpy(data, str, len);
236
237
}
237
238
 
238
 
/*********************************************************************
 
239
/*****************************************************************//**
239
240
Copies a query node value to another node. */
240
241
UNIV_INLINE
241
242
void
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 */
246
247
{
247
248
        dfield_t*       dfield2;
248
249