~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2009-04-14 19:16:51 UTC
  • mto: (997.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 994.
  • Revision ID: mordred@inaugust.com-20090414191651-ltbww6hpqks8k7qk
Clarified instructions in README.

Show diffs side-by-side

added added

removed removed

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