390.1.2
by Monty Taylor
Fixed copyright headers in drizzled/ |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
4 |
* Copyright (C) 2008 Sun Microsystems
|
|
5 |
*
|
|
6 |
* This program is free software; you can redistribute it and/or modify
|
|
7 |
* it under the terms of the GNU General Public License as published by
|
|
8 |
* the Free Software Foundation; version 2 of the License.
|
|
9 |
*
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program; if not, write to the Free Software
|
|
17 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
18 |
*/
|
|
1
by brian
clean slate |
19 |
|
20 |
class Protocol; |
|
327.2.4
by Brian Aker
Refactoring table.h |
21 |
struct TableList; |
1
by brian
clean slate |
22 |
void item_init(void); /* Init item functions */ |
23 |
class Item_field; |
|
24 |
||
25 |
/*
|
|
26 |
"Declared Type Collation"
|
|
27 |
A combination of collation and its derivation.
|
|
28 |
||
29 |
Flags for collation aggregation modes:
|
|
30 |
MY_COLL_ALLOW_SUPERSET_CONV - allow conversion to a superset
|
|
31 |
MY_COLL_ALLOW_COERCIBLE_CONV - allow conversion of a coercible value
|
|
32 |
(i.e. constant).
|
|
33 |
MY_COLL_ALLOW_CONV - allow any kind of conversion
|
|
34 |
(combination of the above two)
|
|
35 |
MY_COLL_DISALLOW_NONE - don't allow return DERIVATION_NONE
|
|
36 |
(e.g. when aggregating for comparison)
|
|
37 |
MY_COLL_CMP_CONV - combination of MY_COLL_ALLOW_CONV
|
|
38 |
and MY_COLL_DISALLOW_NONE
|
|
39 |
*/
|
|
40 |
||
41 |
#define MY_COLL_ALLOW_SUPERSET_CONV 1
|
|
42 |
#define MY_COLL_ALLOW_COERCIBLE_CONV 2
|
|
43 |
#define MY_COLL_ALLOW_CONV 3
|
|
44 |
#define MY_COLL_DISALLOW_NONE 4
|
|
45 |
#define MY_COLL_CMP_CONV 7
|
|
46 |
||
47 |
class DTCollation { |
|
48 |
public: |
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
49 |
const CHARSET_INFO *collation; |
1
by brian
clean slate |
50 |
enum Derivation derivation; |
51 |
uint repertoire; |
|
52 |
||
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
53 |
void set_repertoire_from_charset(const CHARSET_INFO * const cs) |
1
by brian
clean slate |
54 |
{
|
55 |
repertoire= cs->state & MY_CS_PUREASCII ? |
|
56 |
MY_REPERTOIRE_ASCII : MY_REPERTOIRE_UNICODE30; |
|
57 |
}
|
|
58 |
DTCollation() |
|
59 |
{
|
|
60 |
collation= &my_charset_bin; |
|
61 |
derivation= DERIVATION_NONE; |
|
62 |
repertoire= MY_REPERTOIRE_UNICODE30; |
|
63 |
}
|
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
64 |
DTCollation(const CHARSET_INFO * const collation_arg, Derivation derivation_arg) |
1
by brian
clean slate |
65 |
{
|
66 |
collation= collation_arg; |
|
67 |
derivation= derivation_arg; |
|
68 |
set_repertoire_from_charset(collation_arg); |
|
69 |
}
|
|
70 |
void set(DTCollation &dt) |
|
71 |
{
|
|
72 |
collation= dt.collation; |
|
73 |
derivation= dt.derivation; |
|
74 |
repertoire= dt.repertoire; |
|
75 |
}
|
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
76 |
void set(const CHARSET_INFO * const collation_arg, Derivation derivation_arg) |
1
by brian
clean slate |
77 |
{
|
78 |
collation= collation_arg; |
|
79 |
derivation= derivation_arg; |
|
80 |
set_repertoire_from_charset(collation_arg); |
|
81 |
}
|
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
82 |
void set(const CHARSET_INFO * const collation_arg, |
1
by brian
clean slate |
83 |
Derivation derivation_arg, |
84 |
uint repertoire_arg) |
|
85 |
{
|
|
86 |
collation= collation_arg; |
|
87 |
derivation= derivation_arg; |
|
88 |
repertoire= repertoire_arg; |
|
89 |
}
|
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
90 |
void set(const CHARSET_INFO * const collation_arg) |
1
by brian
clean slate |
91 |
{
|
92 |
collation= collation_arg; |
|
93 |
set_repertoire_from_charset(collation_arg); |
|
94 |
}
|
|
95 |
void set(Derivation derivation_arg) |
|
96 |
{ derivation= derivation_arg; } |
|
97 |
bool aggregate(DTCollation &dt, uint flags= 0); |
|
98 |
bool set(DTCollation &dt1, DTCollation &dt2, uint flags= 0) |
|
99 |
{ set(dt1); return aggregate(dt2, flags); } |
|
100 |
const char *derivation_name() const |
|
101 |
{
|
|
102 |
switch(derivation) |
|
103 |
{
|
|
104 |
case DERIVATION_IGNORABLE: return "IGNORABLE"; |
|
105 |
case DERIVATION_COERCIBLE: return "COERCIBLE"; |
|
106 |
case DERIVATION_IMPLICIT: return "IMPLICIT"; |
|
107 |
case DERIVATION_SYSCONST: return "SYSCONST"; |
|
108 |
case DERIVATION_EXPLICIT: return "EXPLICIT"; |
|
109 |
case DERIVATION_NONE: return "NONE"; |
|
110 |
default: return "UNKNOWN"; |
|
111 |
}
|
|
112 |
}
|
|
113 |
};
|
|
114 |
||
115 |
/*************************************************************************/
|
|
116 |
/*
|
|
117 |
A framework to easily handle different return types for hybrid items
|
|
118 |
(hybrid item is an item whose operand can be of any type, e.g. integer,
|
|
119 |
real, decimal).
|
|
120 |
*/
|
|
121 |
||
122 |
struct Hybrid_type_traits; |
|
123 |
||
124 |
struct Hybrid_type |
|
125 |
{
|
|
152
by Brian Aker
longlong replacement |
126 |
int64_t integer; |
1
by brian
clean slate |
127 |
|
128 |
double real; |
|
129 |
/*
|
|
130 |
Use two decimal buffers interchangeably to speed up += operation
|
|
131 |
which has no native support in decimal library.
|
|
132 |
Hybrid_type+= arg is implemented as dec_buf[1]= dec_buf[0] + arg.
|
|
133 |
The third decimal is used as a handy temporary storage.
|
|
134 |
*/
|
|
135 |
my_decimal dec_buf[3]; |
|
136 |
int used_dec_buf_no; |
|
137 |
||
138 |
/*
|
|
139 |
Traits moved to a separate class to
|
|
140 |
a) be able to easily change object traits in runtime
|
|
141 |
b) they work as a differentiator for the union above
|
|
142 |
*/
|
|
143 |
const Hybrid_type_traits *traits; |
|
144 |
||
145 |
Hybrid_type() {} |
|
146 |
/* XXX: add traits->copy() when needed */
|
|
147 |
Hybrid_type(const Hybrid_type &rhs) :traits(rhs.traits) {} |
|
148 |
};
|
|
149 |
||
150 |
||
151 |
/* Hybryd_type_traits interface + default implementation for REAL_RESULT */
|
|
152 |
||
153 |
struct Hybrid_type_traits |
|
154 |
{
|
|
155 |
virtual Item_result type() const { return REAL_RESULT; } |
|
156 |
||
157 |
virtual void |
|
158 |
fix_length_and_dec(Item *item, Item *arg) const; |
|
159 |
||
160 |
/* Hybrid_type operations. */
|
|
161 |
virtual void set_zero(Hybrid_type *val) const { val->real= 0.0; } |
|
162 |
virtual void add(Hybrid_type *val, Field *f) const |
|
163 |
{ val->real+= f->val_real(); } |
|
151
by Brian Aker
Ulonglong to uint64_t |
164 |
virtual void div(Hybrid_type *val, uint64_t u) const |
165 |
{ val->real/= uint64_t2double(u); } |
|
1
by brian
clean slate |
166 |
|
152
by Brian Aker
longlong replacement |
167 |
virtual int64_t val_int(Hybrid_type *val, |
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
168 |
bool unsigned_flag __attribute__((unused))) const |
152
by Brian Aker
longlong replacement |
169 |
{ return (int64_t) rint(val->real); } |
1
by brian
clean slate |
170 |
virtual double val_real(Hybrid_type *val) const { return val->real; } |
171 |
virtual my_decimal *val_decimal(Hybrid_type *val, my_decimal *buf) const; |
|
206
by Brian Aker
Removed final uint dead types. |
172 |
virtual String *val_str(Hybrid_type *val, String *buf, uint8_t decimals) const; |
1
by brian
clean slate |
173 |
static const Hybrid_type_traits *instance(); |
174 |
Hybrid_type_traits() {} |
|
175 |
virtual ~Hybrid_type_traits() {} |
|
176 |
};
|
|
177 |
||
178 |
||
179 |
struct Hybrid_type_traits_decimal: public Hybrid_type_traits |
|
180 |
{
|
|
181 |
virtual Item_result type() const { return DECIMAL_RESULT; } |
|
182 |
||
183 |
virtual void |
|
184 |
fix_length_and_dec(Item *arg, Item *item) const; |
|
185 |
||
186 |
/* Hybrid_type operations. */
|
|
187 |
virtual void set_zero(Hybrid_type *val) const; |
|
188 |
virtual void add(Hybrid_type *val, Field *f) const; |
|
151
by Brian Aker
Ulonglong to uint64_t |
189 |
virtual void div(Hybrid_type *val, uint64_t u) const; |
1
by brian
clean slate |
190 |
|
152
by Brian Aker
longlong replacement |
191 |
virtual int64_t val_int(Hybrid_type *val, bool unsigned_flag) const; |
1
by brian
clean slate |
192 |
virtual double val_real(Hybrid_type *val) const; |
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
193 |
virtual my_decimal *val_decimal(Hybrid_type *val, |
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
194 |
my_decimal *buf __attribute__((unused))) const |
1
by brian
clean slate |
195 |
{ return &val->dec_buf[val->used_dec_buf_no]; } |
206
by Brian Aker
Removed final uint dead types. |
196 |
virtual String *val_str(Hybrid_type *val, String *buf, uint8_t decimals) const; |
1
by brian
clean slate |
197 |
static const Hybrid_type_traits_decimal *instance(); |
198 |
Hybrid_type_traits_decimal() {}; |
|
199 |
};
|
|
200 |
||
201 |
||
202 |
struct Hybrid_type_traits_integer: public Hybrid_type_traits |
|
203 |
{
|
|
204 |
virtual Item_result type() const { return INT_RESULT; } |
|
205 |
||
206 |
virtual void |
|
207 |
fix_length_and_dec(Item *arg, Item *item) const; |
|
208 |
||
209 |
/* Hybrid_type operations. */
|
|
210 |
virtual void set_zero(Hybrid_type *val) const |
|
211 |
{ val->integer= 0; } |
|
212 |
virtual void add(Hybrid_type *val, Field *f) const |
|
213 |
{ val->integer+= f->val_int(); } |
|
151
by Brian Aker
Ulonglong to uint64_t |
214 |
virtual void div(Hybrid_type *val, uint64_t u) const |
152
by Brian Aker
longlong replacement |
215 |
{ val->integer/= (int64_t) u; } |
1
by brian
clean slate |
216 |
|
152
by Brian Aker
longlong replacement |
217 |
virtual int64_t val_int(Hybrid_type *val, |
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
218 |
bool unsigned_flag __attribute__((unused))) const |
1
by brian
clean slate |
219 |
{ return val->integer; } |
220 |
virtual double val_real(Hybrid_type *val) const |
|
221 |
{ return (double) val->integer; } |
|
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
222 |
virtual my_decimal *val_decimal(Hybrid_type *val, |
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
223 |
my_decimal *buf __attribute__((unused))) const |
1
by brian
clean slate |
224 |
{
|
225 |
int2my_decimal(E_DEC_FATAL_ERROR, val->integer, 0, &val->dec_buf[2]); |
|
226 |
return &val->dec_buf[2]; |
|
227 |
}
|
|
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
228 |
virtual String *val_str(Hybrid_type *val, String *buf, |
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
229 |
uint8_t decimals __attribute__((unused))) const |
1
by brian
clean slate |
230 |
{ buf->set(val->integer, &my_charset_bin); return buf;} |
231 |
static const Hybrid_type_traits_integer *instance(); |
|
232 |
Hybrid_type_traits_integer() {}; |
|
233 |
};
|
|
234 |
||
235 |
||
236 |
void dummy_error_processor(THD *thd, void *data); |
|
237 |
||
238 |
void view_error_processor(THD *thd, void *data); |
|
239 |
||
240 |
/*
|
|
241 |
Instances of Name_resolution_context store the information necesary for
|
|
242 |
name resolution of Items and other context analysis of a query made in
|
|
243 |
fix_fields().
|
|
244 |
||
245 |
This structure is a part of SELECT_LEX, a pointer to this structure is
|
|
246 |
assigned when an item is created (which happens mostly during parsing
|
|
247 |
(sql_yacc.yy)), but the structure itself will be initialized after parsing
|
|
248 |
is complete
|
|
249 |
||
250 |
TODO: move subquery of INSERT ... SELECT and CREATE ... SELECT to
|
|
251 |
separate SELECT_LEX which allow to remove tricks of changing this
|
|
252 |
structure before and after INSERT/CREATE and its SELECT to make correct
|
|
253 |
field name resolution.
|
|
254 |
*/
|
|
255 |
struct Name_resolution_context: Sql_alloc |
|
256 |
{
|
|
257 |
/*
|
|
258 |
The name resolution context to search in when an Item cannot be
|
|
259 |
resolved in this context (the context of an outer select)
|
|
260 |
*/
|
|
261 |
Name_resolution_context *outer_context; |
|
262 |
||
263 |
/*
|
|
264 |
List of tables used to resolve the items of this context. Usually these
|
|
265 |
are tables from the FROM clause of SELECT statement. The exceptions are
|
|
266 |
INSERT ... SELECT and CREATE ... SELECT statements, where SELECT
|
|
267 |
subquery is not moved to a separate SELECT_LEX. For these types of
|
|
268 |
statements we have to change this member dynamically to ensure correct
|
|
269 |
name resolution of different parts of the statement.
|
|
270 |
*/
|
|
327.2.4
by Brian Aker
Refactoring table.h |
271 |
TableList *table_list; |
1
by brian
clean slate |
272 |
/*
|
273 |
In most cases the two table references below replace 'table_list' above
|
|
274 |
for the purpose of name resolution. The first and last name resolution
|
|
275 |
table references allow us to search only in a sub-tree of the nested
|
|
276 |
join tree in a FROM clause. This is needed for NATURAL JOIN, JOIN ... USING
|
|
277 |
and JOIN ... ON.
|
|
278 |
*/
|
|
327.2.4
by Brian Aker
Refactoring table.h |
279 |
TableList *first_name_resolution_table; |
1
by brian
clean slate |
280 |
/*
|
281 |
Last table to search in the list of leaf table references that begins
|
|
282 |
with first_name_resolution_table.
|
|
283 |
*/
|
|
327.2.4
by Brian Aker
Refactoring table.h |
284 |
TableList *last_name_resolution_table; |
1
by brian
clean slate |
285 |
|
286 |
/*
|
|
287 |
SELECT_LEX item belong to, in case of merged VIEW it can differ from
|
|
288 |
SELECT_LEX where item was created, so we can't use table_list/field_list
|
|
289 |
from there
|
|
290 |
*/
|
|
291 |
st_select_lex *select_lex; |
|
292 |
||
293 |
/*
|
|
294 |
Processor of errors caused during Item name resolving, now used only to
|
|
295 |
hide underlying tables in errors about views (i.e. it substitute some
|
|
296 |
errors for views)
|
|
297 |
*/
|
|
298 |
void (*error_processor)(THD *, void *); |
|
299 |
void *error_processor_data; |
|
300 |
||
301 |
/*
|
|
163
by Brian Aker
Merge Monty's code. |
302 |
When true items are resolved in this context both against the
|
303 |
SELECT list and this->table_list. If false, items are resolved
|
|
1
by brian
clean slate |
304 |
only against this->table_list.
|
305 |
*/
|
|
306 |
bool resolve_in_select_list; |
|
307 |
||
308 |
/*
|
|
309 |
Security context of this name resolution context. It's used for views
|
|
310 |
and is non-zero only if the view is defined with SQL SECURITY DEFINER.
|
|
311 |
*/
|
|
312 |
Security_context *security_ctx; |
|
313 |
||
314 |
Name_resolution_context() |
|
315 |
:outer_context(0), table_list(0), select_lex(0), |
|
316 |
error_processor_data(0), |
|
317 |
security_ctx(0) |
|
318 |
{}
|
|
319 |
||
320 |
void init() |
|
321 |
{
|
|
163
by Brian Aker
Merge Monty's code. |
322 |
resolve_in_select_list= false; |
1
by brian
clean slate |
323 |
error_processor= &dummy_error_processor; |
324 |
first_name_resolution_table= NULL; |
|
325 |
last_name_resolution_table= NULL; |
|
326 |
}
|
|
327 |
||
327.2.4
by Brian Aker
Refactoring table.h |
328 |
void resolve_in_table_list_only(TableList *tables) |
1
by brian
clean slate |
329 |
{
|
330 |
table_list= first_name_resolution_table= tables; |
|
163
by Brian Aker
Merge Monty's code. |
331 |
resolve_in_select_list= false; |
1
by brian
clean slate |
332 |
}
|
333 |
||
334 |
void process_error(THD *thd) |
|
335 |
{
|
|
336 |
(*error_processor)(thd, error_processor_data); |
|
337 |
}
|
|
338 |
};
|
|
339 |
||
340 |
||
341 |
/*
|
|
342 |
Store and restore the current state of a name resolution context.
|
|
343 |
*/
|
|
344 |
||
345 |
class Name_resolution_context_state |
|
346 |
{
|
|
347 |
private: |
|
327.2.4
by Brian Aker
Refactoring table.h |
348 |
TableList *save_table_list; |
349 |
TableList *save_first_name_resolution_table; |
|
350 |
TableList *save_next_name_resolution_table; |
|
1
by brian
clean slate |
351 |
bool save_resolve_in_select_list; |
327.2.4
by Brian Aker
Refactoring table.h |
352 |
TableList *save_next_local; |
1
by brian
clean slate |
353 |
|
354 |
public: |
|
355 |
Name_resolution_context_state() {} /* Remove gcc warning */ |
|
356 |
||
357 |
public: |
|
358 |
/* Save the state of a name resolution context. */
|
|
327.2.4
by Brian Aker
Refactoring table.h |
359 |
void save_state(Name_resolution_context *context, TableList *table_list) |
1
by brian
clean slate |
360 |
{
|
361 |
save_table_list= context->table_list; |
|
362 |
save_first_name_resolution_table= context->first_name_resolution_table; |
|
363 |
save_resolve_in_select_list= context->resolve_in_select_list; |
|
364 |
save_next_local= table_list->next_local; |
|
365 |
save_next_name_resolution_table= table_list->next_name_resolution_table; |
|
366 |
}
|
|
367 |
||
368 |
/* Restore a name resolution context from saved state. */
|
|
327.2.4
by Brian Aker
Refactoring table.h |
369 |
void restore_state(Name_resolution_context *context, TableList *table_list) |
1
by brian
clean slate |
370 |
{
|
371 |
table_list->next_local= save_next_local; |
|
372 |
table_list->next_name_resolution_table= save_next_name_resolution_table; |
|
373 |
context->table_list= save_table_list; |
|
374 |
context->first_name_resolution_table= save_first_name_resolution_table; |
|
375 |
context->resolve_in_select_list= save_resolve_in_select_list; |
|
376 |
}
|
|
377 |
||
327.2.4
by Brian Aker
Refactoring table.h |
378 |
TableList *get_first_name_resolution_table() |
1
by brian
clean slate |
379 |
{
|
380 |
return save_first_name_resolution_table; |
|
381 |
}
|
|
382 |
};
|
|
383 |
||
384 |
||
385 |
/*
|
|
386 |
This enum is used to report information about monotonicity of function
|
|
387 |
represented by Item* tree.
|
|
388 |
Monotonicity is defined only for Item* trees that represent table
|
|
389 |
partitioning expressions (i.e. have no subselects/user vars/PS parameters
|
|
390 |
etc etc). An Item* tree is assumed to have the same monotonicity properties
|
|
391 |
as its correspoinding function F:
|
|
392 |
||
152
by Brian Aker
longlong replacement |
393 |
[signed] int64_t F(field1, field2, ...) {
|
1
by brian
clean slate |
394 |
put values of field_i into table record buffer;
|
395 |
return item->val_int();
|
|
396 |
}
|
|
397 |
||
398 |
NOTE
|
|
399 |
At the moment function monotonicity is not well defined (and so may be
|
|
400 |
incorrect) for Item trees with parameters/return types that are different
|
|
401 |
from INT_RESULT, may be NULL, or are unsigned.
|
|
402 |
It will be possible to address this issue once the related partitioning bugs
|
|
403 |
(BUG#16002, BUG#15447, BUG#13436) are fixed.
|
|
404 |
*/
|
|
405 |
||
406 |
typedef enum monotonicity_info |
|
407 |
{
|
|
408 |
NON_MONOTONIC, /* none of the below holds */ |
|
409 |
MONOTONIC_INCREASING, /* F() is unary and (x < y) => (F(x) <= F(y)) */ |
|
410 |
MONOTONIC_STRICT_INCREASING /* F() is unary and (x < y) => (F(x) < F(y)) */ |
|
411 |
} enum_monotonicity_info; |
|
412 |
||
413 |
/*************************************************************************/
|
|
414 |
typedef bool (Item::*Item_processor) (uchar *arg); |
|
415 |
/*
|
|
416 |
Analyzer function
|
|
417 |
SYNOPSIS
|
|
418 |
argp in/out IN: Analysis parameter
|
|
419 |
OUT: Parameter to be passed to the transformer
|
|
420 |
||
421 |
RETURN
|
|
163
by Brian Aker
Merge Monty's code. |
422 |
true Invoke the transformer
|
423 |
false Don't do it
|
|
1
by brian
clean slate |
424 |
|
425 |
*/
|
|
426 |
typedef bool (Item::*Item_analyzer) (uchar **argp); |
|
427 |
typedef Item* (Item::*Item_transformer) (uchar *arg); |
|
428 |
typedef void (*Cond_traverser) (const Item *item, void *arg); |
|
429 |
||
430 |
||
431 |
class Item |
|
432 |
{
|
|
433 |
Item(const Item &); /* Prevent use of these */ |
|
434 |
void operator=(Item &); |
|
435 |
/* Cache of the result of is_expensive(). */
|
|
206
by Brian Aker
Removed final uint dead types. |
436 |
int8_t is_expensive_cache; |
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
437 |
virtual bool is_expensive_processor(uchar *arg __attribute__((unused))) |
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
438 |
{ return 0; } |
1
by brian
clean slate |
439 |
|
440 |
public: |
|
441 |
static void *operator new(size_t size) |
|
442 |
{ return sql_alloc(size); } |
|
443 |
static void *operator new(size_t size, MEM_ROOT *mem_root) |
|
444 |
{ return alloc_root(mem_root, size); } |
|
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
445 |
static void operator delete(void *ptr __attribute__((unused)), |
446 |
size_t size __attribute__((unused))) |
|
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
447 |
{ TRASH(ptr, size); } |
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
448 |
static void operator delete(void *ptr __attribute__((unused)), |
449 |
MEM_ROOT *mem_root __attribute__((unused))) |
|
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
450 |
{}
|
1
by brian
clean slate |
451 |
|
452 |
enum Type {FIELD_ITEM= 0, FUNC_ITEM, SUM_FUNC_ITEM, STRING_ITEM, |
|
453 |
INT_ITEM, REAL_ITEM, NULL_ITEM, VARBIN_ITEM, |
|
454 |
COPY_STR_ITEM, FIELD_AVG_ITEM, DEFAULT_VALUE_ITEM, |
|
455 |
PROC_ITEM,COND_ITEM, REF_ITEM, FIELD_STD_ITEM, |
|
456 |
FIELD_VARIANCE_ITEM, INSERT_VALUE_ITEM, |
|
457 |
SUBSELECT_ITEM, ROW_ITEM, CACHE_ITEM, TYPE_HOLDER, |
|
327.1.4
by Brian Aker
Remove dead bits from enum field |
458 |
PARAM_ITEM, DECIMAL_ITEM, |
1
by brian
clean slate |
459 |
VIEW_FIXER_ITEM}; |
460 |
||
461 |
enum cond_result { COND_UNDEF,COND_OK,COND_TRUE,COND_FALSE }; |
|
462 |
||
463 |
enum traverse_order { POSTFIX, PREFIX }; |
|
464 |
||
465 |
/* Reuse size, only used by SP local variable assignment, otherwize 0 */
|
|
466 |
uint rsize; |
|
467 |
||
468 |
/*
|
|
469 |
str_values's main purpose is to be used to cache the value in
|
|
470 |
save_in_field
|
|
471 |
*/
|
|
472 |
String str_value; |
|
473 |
char * name; /* Name from select */ |
|
474 |
/* Original item name (if it was renamed)*/
|
|
475 |
char * orig_name; |
|
476 |
Item *next; |
|
203
by Brian Aker
Small cleanup around uint32 types (need to merge). |
477 |
uint32_t max_length; |
1
by brian
clean slate |
478 |
uint name_length; /* Length of name */ |
206
by Brian Aker
Removed final uint dead types. |
479 |
int8_t marker; |
480 |
uint8_t decimals; |
|
275
by Brian Aker
Full removal of my_bool from central server. |
481 |
bool maybe_null; /* If item may be null */ |
482 |
bool null_value; /* if item is null */ |
|
483 |
bool unsigned_flag; |
|
484 |
bool with_sum_func; |
|
485 |
bool fixed; /* If item fixed with fix_fields */ |
|
486 |
bool is_autogenerated_name; /* indicate was name of this Item |
|
1
by brian
clean slate |
487 |
autogenerated or set by user */
|
488 |
DTCollation collation; |
|
275
by Brian Aker
Full removal of my_bool from central server. |
489 |
bool with_subselect; /* If this item is a subselect or some |
1
by brian
clean slate |
490 |
of its arguments is or contains a
|
491 |
subselect. Computed by fix_fields. */
|
|
492 |
Item_result cmp_context; /* Comparison context */ |
|
493 |
// alloc & destruct is done as start of select using sql_alloc
|
|
494 |
Item(); |
|
495 |
/*
|
|
496 |
Constructor used by Item_field, Item_ref & aggregate (sum) functions.
|
|
497 |
Used for duplicating lists in processing queries with temporary
|
|
498 |
tables
|
|
499 |
Also it used for Item_cond_and/Item_cond_or for creating
|
|
500 |
top AND/OR structure of WHERE clause to protect it of
|
|
501 |
optimisation changes in prepared statements
|
|
502 |
*/
|
|
503 |
Item(THD *thd, Item *item); |
|
504 |
virtual ~Item() |
|
505 |
{
|
|
506 |
#ifdef EXTRA_DEBUG
|
|
507 |
name=0; |
|
508 |
#endif
|
|
509 |
} /*lint -e1509 */ |
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
510 |
void set_name(const char *str, uint length, const CHARSET_INFO * const cs); |
1
by brian
clean slate |
511 |
void rename(char *new_name); |
512 |
void init_make_field(Send_field *tmp_field,enum enum_field_types type); |
|
513 |
virtual void cleanup(); |
|
514 |
virtual void make_field(Send_field *field); |
|
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
515 |
Field *make_string_field(Table *table); |
1
by brian
clean slate |
516 |
virtual bool fix_fields(THD *, Item **); |
517 |
/*
|
|
518 |
Fix after some tables has been pulled out. Basically re-calculate all
|
|
519 |
attributes that are dependent on the tables.
|
|
520 |
*/
|
|
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
521 |
virtual void fix_after_pullout(st_select_lex *new_parent __attribute__((unused)), |
522 |
Item **ref __attribute__((unused))) {}; |
|
1
by brian
clean slate |
523 |
|
524 |
/*
|
|
525 |
should be used in case where we are sure that we do not need
|
|
526 |
complete fix_fields() procedure.
|
|
527 |
*/
|
|
528 |
inline void quick_fix_field() { fixed= 1; } |
|
529 |
/* Function returns 1 on overflow and -1 on fatal errors */
|
|
530 |
int save_in_field_no_warnings(Field *field, bool no_conversions); |
|
531 |
virtual int save_in_field(Field *field, bool no_conversions); |
|
532 |
virtual void save_org_in_field(Field *field) |
|
533 |
{ (void) save_in_field(field, 1); } |
|
534 |
virtual int save_safe_in_field(Field *field) |
|
535 |
{ return save_in_field(field, 1); } |
|
536 |
virtual bool send(Protocol *protocol, String *str); |
|
537 |
virtual bool eq(const Item *, bool binary_cmp) const; |
|
538 |
virtual Item_result result_type() const { return REAL_RESULT; } |
|
539 |
virtual Item_result cast_to_int_type() const { return result_type(); } |
|
540 |
virtual enum_field_types string_field_type() const; |
|
541 |
virtual enum_field_types field_type() const; |
|
542 |
virtual enum Type type() const =0; |
|
543 |
||
544 |
/*
|
|
545 |
Return information about function monotonicity. See comment for
|
|
546 |
enum_monotonicity_info for details. This function can only be called
|
|
547 |
after fix_fields() call.
|
|
548 |
*/
|
|
549 |
virtual enum_monotonicity_info get_monotonicity_info() const |
|
550 |
{ return NON_MONOTONIC; } |
|
551 |
||
552 |
/*
|
|
553 |
Convert "func_arg $CMP$ const" half-interval into "FUNC(func_arg) $CMP2$ const2"
|
|
554 |
||
555 |
SYNOPSIS
|
|
556 |
val_int_endpoint()
|
|
163
by Brian Aker
Merge Monty's code. |
557 |
left_endp false <=> The interval is "x < const" or "x <= const"
|
558 |
true <=> The interval is "x > const" or "x >= const"
|
|
1
by brian
clean slate |
559 |
|
163
by Brian Aker
Merge Monty's code. |
560 |
incl_endp IN true <=> the comparison is '<' or '>'
|
561 |
false <=> the comparison is '<=' or '>='
|
|
1
by brian
clean slate |
562 |
OUT The same but for the "F(x) $CMP$ F(const)" comparison
|
563 |
||
564 |
DESCRIPTION
|
|
565 |
This function is defined only for unary monotonic functions. The caller
|
|
566 |
supplies the source half-interval
|
|
567 |
||
568 |
x $CMP$ const
|
|
569 |
||
570 |
The value of const is supplied implicitly as the value this item's
|
|
571 |
argument, the form of $CMP$ comparison is specified through the
|
|
572 |
function's arguments. The calle returns the result interval
|
|
573 |
|
|
574 |
F(x) $CMP2$ F(const)
|
|
575 |
|
|
576 |
passing back F(const) as the return value, and the form of $CMP2$
|
|
577 |
through the out parameter. NULL values are assumed to be comparable and
|
|
578 |
be less than any non-NULL values.
|
|
579 |
||
580 |
RETURN
|
|
581 |
The output range bound, which equal to the value of val_int()
|
|
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
582 |
- If the value of the function is NULL then the bound is the
|
163
by Brian Aker
Merge Monty's code. |
583 |
smallest possible value of INT64_MIN
|
1
by brian
clean slate |
584 |
*/
|
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
585 |
virtual int64_t val_int_endpoint(bool left_endp __attribute__((unused)), |
586 |
bool *incl_endp __attribute__((unused))) |
|
51.1.55
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE - 1st clean pass on item.h/cc |
587 |
{ assert(0); return 0; } |
1
by brian
clean slate |
588 |
|
589 |
||
590 |
/* valXXX methods must return NULL or 0 or 0.0 if null_value is set. */
|
|
591 |
/*
|
|
592 |
Return double precision floating point representation of item.
|
|
593 |
||
594 |
SYNOPSIS
|
|
595 |
val_real()
|
|
596 |
||
597 |
RETURN
|
|
163
by Brian Aker
Merge Monty's code. |
598 |
In case of NULL value return 0.0 and set null_value flag to true.
|
599 |
If value is not null null_value flag will be reset to false.
|
|
1
by brian
clean slate |
600 |
*/
|
601 |
virtual double val_real()=0; |
|
602 |
/*
|
|
603 |
Return integer representation of item.
|
|
604 |
||
605 |
SYNOPSIS
|
|
606 |
val_int()
|
|
607 |
||
608 |
RETURN
|
|
163
by Brian Aker
Merge Monty's code. |
609 |
In case of NULL value return 0 and set null_value flag to true.
|
610 |
If value is not null null_value flag will be reset to false.
|
|
1
by brian
clean slate |
611 |
*/
|
152
by Brian Aker
longlong replacement |
612 |
virtual int64_t val_int()=0; |
1
by brian
clean slate |
613 |
/*
|
614 |
This is just a shortcut to avoid the cast. You should still use
|
|
615 |
unsigned_flag to check the sign of the item.
|
|
616 |
*/
|
|
151
by Brian Aker
Ulonglong to uint64_t |
617 |
inline uint64_t val_uint() { return (uint64_t) val_int(); } |
1
by brian
clean slate |
618 |
/*
|
619 |
Return string representation of this item object.
|
|
620 |
||
621 |
SYNOPSIS
|
|
622 |
val_str()
|
|
623 |
str an allocated buffer this or any nested Item object can use to
|
|
624 |
store return value of this method.
|
|
625 |
||
626 |
NOTE
|
|
627 |
Buffer passed via argument should only be used if the item itself
|
|
628 |
doesn't have an own String buffer. In case when the item maintains
|
|
629 |
it's own string buffer, it's preferable to return it instead to
|
|
630 |
minimize number of mallocs/memcpys.
|
|
631 |
The caller of this method can modify returned string, but only in case
|
|
632 |
when it was allocated on heap, (is_alloced() is true). This allows
|
|
633 |
the caller to efficiently use a buffer allocated by a child without
|
|
634 |
having to allocate a buffer of it's own. The buffer, given to
|
|
635 |
val_str() as argument, belongs to the caller and is later used by the
|
|
636 |
caller at it's own choosing.
|
|
637 |
A few implications from the above:
|
|
638 |
- unless you return a string object which only points to your buffer
|
|
639 |
but doesn't manages it you should be ready that it will be
|
|
640 |
modified.
|
|
641 |
- even for not allocated strings (is_alloced() == false) the caller
|
|
642 |
can change charset (see Item_func_{typecast/binary}. XXX: is this
|
|
643 |
a bug?
|
|
644 |
- still you should try to minimize data copying and return internal
|
|
645 |
object whenever possible.
|
|
646 |
||
647 |
RETURN
|
|
648 |
In case of NULL value return 0 (NULL pointer) and set null_value flag
|
|
163
by Brian Aker
Merge Monty's code. |
649 |
to true.
|
650 |
If value is not null null_value flag will be reset to false.
|
|
1
by brian
clean slate |
651 |
*/
|
652 |
virtual String *val_str(String *str)=0; |
|
653 |
/*
|
|
654 |
Return decimal representation of item with fixed point.
|
|
655 |
||
656 |
SYNOPSIS
|
|
657 |
val_decimal()
|
|
658 |
decimal_buffer buffer which can be used by Item for returning value
|
|
659 |
(but can be not)
|
|
660 |
||
661 |
NOTE
|
|
662 |
Returned value should not be changed if it is not the same which was
|
|
663 |
passed via argument.
|
|
664 |
||
665 |
RETURN
|
|
666 |
Return pointer on my_decimal (it can be other then passed via argument)
|
|
163
by Brian Aker
Merge Monty's code. |
667 |
if value is not NULL (null_value flag will be reset to false).
|
1
by brian
clean slate |
668 |
In case of NULL value it return 0 pointer and set null_value flag
|
163
by Brian Aker
Merge Monty's code. |
669 |
to true.
|
1
by brian
clean slate |
670 |
*/
|
671 |
virtual my_decimal *val_decimal(my_decimal *decimal_buffer)= 0; |
|
672 |
/*
|
|
673 |
Return boolean value of item.
|
|
674 |
||
675 |
RETURN
|
|
163
by Brian Aker
Merge Monty's code. |
676 |
false value is false or NULL
|
677 |
true value is true (not equal to 0)
|
|
1
by brian
clean slate |
678 |
*/
|
679 |
virtual bool val_bool(); |
|
680 |
virtual String *val_nodeset(String*) { return 0; } |
|
681 |
/* Helper functions, see item_sum.cc */
|
|
682 |
String *val_string_from_real(String *str); |
|
683 |
String *val_string_from_int(String *str); |
|
684 |
String *val_string_from_decimal(String *str); |
|
685 |
my_decimal *val_decimal_from_real(my_decimal *decimal_value); |
|
686 |
my_decimal *val_decimal_from_int(my_decimal *decimal_value); |
|
687 |
my_decimal *val_decimal_from_string(my_decimal *decimal_value); |
|
688 |
my_decimal *val_decimal_from_date(my_decimal *decimal_value); |
|
689 |
my_decimal *val_decimal_from_time(my_decimal *decimal_value); |
|
152
by Brian Aker
longlong replacement |
690 |
int64_t val_int_from_decimal(); |
1
by brian
clean slate |
691 |
double val_real_from_decimal(); |
692 |
||
693 |
int save_time_in_field(Field *field); |
|
694 |
int save_date_in_field(Field *field); |
|
695 |
int save_str_value_in_field(Field *field, String *result); |
|
696 |
||
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
697 |
virtual Field *get_tmp_table_field(void) { return 0; } |
1
by brian
clean slate |
698 |
/* This is also used to create fields in CREATE ... SELECT: */
|
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
699 |
virtual Field *tmp_table_field(Table *t_arg __attribute__((unused))) |
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
700 |
{ return 0; } |
701 |
virtual const char *full_name(void) const { return name ? name : "???"; } |
|
1
by brian
clean slate |
702 |
|
703 |
/*
|
|
704 |
*result* family of methods is analog of *val* family (see above) but
|
|
705 |
return value of result_field of item if it is present. If Item have not
|
|
706 |
result field, it return val(). This methods set null_value flag in same
|
|
707 |
way as *val* methods do it.
|
|
708 |
*/
|
|
709 |
virtual double val_result() { return val_real(); } |
|
152
by Brian Aker
longlong replacement |
710 |
virtual int64_t val_int_result() { return val_int(); } |
1
by brian
clean slate |
711 |
virtual String *str_result(String* tmp) { return val_str(tmp); } |
712 |
virtual my_decimal *val_decimal_result(my_decimal *val) |
|
713 |
{ return val_decimal(val); } |
|
714 |
virtual bool val_bool_result() { return val_bool(); } |
|
715 |
||
716 |
/* bit map of tables used by item */
|
|
717 |
virtual table_map used_tables() const { return (table_map) 0L; } |
|
718 |
/*
|
|
719 |
Return table map of tables that can't be NULL tables (tables that are
|
|
720 |
used in a context where if they would contain a NULL row generated
|
|
721 |
by a LEFT or RIGHT join, the item would not be true).
|
|
722 |
This expression is used on WHERE item to determinate if a LEFT JOIN can be
|
|
723 |
converted to a normal join.
|
|
724 |
Generally this function should return used_tables() if the function
|
|
725 |
would return null if any of the arguments are null
|
|
726 |
As this is only used in the beginning of optimization, the value don't
|
|
727 |
have to be updated in update_used_tables()
|
|
728 |
*/
|
|
729 |
virtual table_map not_null_tables() const { return used_tables(); } |
|
730 |
/*
|
|
731 |
Returns true if this is a simple constant item like an integer, not
|
|
732 |
a constant expression. Used in the optimizer to propagate basic constants.
|
|
733 |
*/
|
|
734 |
virtual bool basic_const_item() const { return 0; } |
|
735 |
/* cloning of constant items (0 if it is not const) */
|
|
736 |
virtual Item *clone_item() { return 0; } |
|
737 |
virtual cond_result eq_cmp_result() const { return COND_OK; } |
|
738 |
inline uint float_length(uint decimals_par) const |
|
739 |
{ return decimals != NOT_FIXED_DEC ? (DBL_DIG+2+decimals_par) : DBL_DIG+8;} |
|
740 |
virtual uint decimal_precision() const; |
|
741 |
inline int decimal_int_part() const |
|
742 |
{ return my_decimal_int_part(decimal_precision(), decimals); } |
|
743 |
/*
|
|
744 |
Returns true if this is constant (during query execution, i.e. its value
|
|
745 |
will not change until next fix_fields) and its value is known.
|
|
746 |
*/
|
|
747 |
virtual bool const_item() const { return used_tables() == 0; } |
|
748 |
/*
|
|
749 |
Returns true if this is constant but its value may be not known yet.
|
|
750 |
(Can be used for parameters of prep. stmts or of stored procedures.)
|
|
751 |
*/
|
|
752 |
virtual bool const_during_execution() const |
|
753 |
{ return (used_tables() & ~PARAM_TABLE_BIT) == 0; } |
|
754 |
||
755 |
/**
|
|
756 |
This method is used for to:
|
|
757 |
- to generate a view definition query (SELECT-statement);
|
|
758 |
- to generate a SQL-query for EXPLAIN EXTENDED;
|
|
759 |
- to generate a SQL-query to be shown in INFORMATION_SCHEMA;
|
|
760 |
- debug.
|
|
761 |
||
762 |
For more information about view definition query, INFORMATION_SCHEMA
|
|
763 |
query and why they should be generated from the Item-tree, @see
|
|
764 |
mysql_register_view().
|
|
765 |
*/
|
|
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
766 |
virtual inline void print(String *str, |
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
767 |
enum_query_type query_type __attribute__((unused))) |
1
by brian
clean slate |
768 |
{
|
769 |
str->append(full_name()); |
|
770 |
}
|
|
771 |
||
772 |
void print_item_w_name(String *, enum_query_type query_type); |
|
773 |
virtual void update_used_tables() {} |
|
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
774 |
virtual void split_sum_func(THD *thd __attribute__((unused)), |
775 |
Item **ref_pointer_array __attribute__((unused)), |
|
776 |
List<Item> &fields __attribute__((unused))) {} |
|
1
by brian
clean slate |
777 |
/* Called for items that really have to be split */
|
778 |
void split_sum_func2(THD *thd, Item **ref_pointer_array, List<Item> &fields, |
|
779 |
Item **ref, bool skip_registered); |
|
236.1.24
by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME. |
780 |
virtual bool get_date(DRIZZLE_TIME *ltime,uint fuzzydate); |
781 |
virtual bool get_time(DRIZZLE_TIME *ltime); |
|
782 |
virtual bool get_date_result(DRIZZLE_TIME *ltime,uint fuzzydate) |
|
1
by brian
clean slate |
783 |
{ return get_date(ltime,fuzzydate); } |
784 |
/*
|
|
785 |
The method allows to determine nullness of a complex expression
|
|
786 |
without fully evaluating it, instead of calling val/result*() then
|
|
787 |
checking null_value. Used in Item_func_isnull/Item_func_isnotnull
|
|
788 |
and Item_sum_count/Item_sum_count_distinct.
|
|
789 |
Any new item which can be NULL must implement this method.
|
|
790 |
*/
|
|
791 |
virtual bool is_null() { return 0; } |
|
792 |
||
793 |
/*
|
|
794 |
Make sure the null_value member has a correct value.
|
|
795 |
*/
|
|
796 |
virtual void update_null_value () { (void) val_int(); } |
|
797 |
||
798 |
/*
|
|
799 |
Inform the item that there will be no distinction between its result
|
|
163
by Brian Aker
Merge Monty's code. |
800 |
being false or NULL.
|
1
by brian
clean slate |
801 |
|
802 |
NOTE
|
|
803 |
This function will be called for eg. Items that are top-level AND-parts
|
|
804 |
of the WHERE clause. Items implementing this function (currently
|
|
805 |
Item_cond_and and subquery-related item) enable special optimizations
|
|
806 |
when they are "top level".
|
|
807 |
*/
|
|
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
808 |
virtual void top_level_item(void) {} |
1
by brian
clean slate |
809 |
/*
|
810 |
set field of temporary table for Item which can be switched on temporary
|
|
811 |
table during query processing (grouping and so on)
|
|
812 |
*/
|
|
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
813 |
virtual void set_result_field(Field *field __attribute__((unused))) {} |
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
814 |
virtual bool is_result_field(void) { return 0; } |
815 |
virtual bool is_bool_func(void) { return 0; } |
|
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
816 |
virtual void save_in_result_field(bool no_conversions __attribute__((unused))) |
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
817 |
{}
|
1
by brian
clean slate |
818 |
/*
|
819 |
set value of aggregate function in case of no rows for grouping were found
|
|
820 |
*/
|
|
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
821 |
virtual void no_rows_in_result(void) {} |
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
822 |
virtual Item *copy_or_same(THD *thd __attribute__((unused))) |
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
823 |
{ return this; } |
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
824 |
virtual Item *copy_andor_structure(THD *thd __attribute__((unused))) |
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
825 |
{ return this; } |
826 |
virtual Item *real_item(void) { return this; } |
|
1
by brian
clean slate |
827 |
virtual Item *get_tmp_table_item(THD *thd) { return copy_or_same(thd); } |
828 |
||
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
829 |
static const CHARSET_INFO *default_charset(); |
830 |
virtual const CHARSET_INFO *compare_collation() { return NULL; } |
|
1
by brian
clean slate |
831 |
|
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
832 |
virtual bool walk(Item_processor processor __attribute__((unused)), |
833 |
bool walk_subquery __attribute__((unused)), |
|
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
834 |
uchar *arg) |
1
by brian
clean slate |
835 |
{
|
836 |
return (this->*processor)(arg); |
|
837 |
}
|
|
838 |
||
839 |
virtual Item* transform(Item_transformer transformer, uchar *arg); |
|
840 |
||
841 |
/*
|
|
842 |
This function performs a generic "compilation" of the Item tree.
|
|
843 |
The process of compilation is assumed to go as follows:
|
|
844 |
|
|
845 |
compile()
|
|
846 |
{
|
|
847 |
if (this->*some_analyzer(...))
|
|
848 |
{
|
|
849 |
compile children if any;
|
|
850 |
this->*some_transformer(...);
|
|
851 |
}
|
|
852 |
}
|
|
853 |
||
854 |
i.e. analysis is performed top-down while transformation is done
|
|
855 |
bottom-up.
|
|
856 |
*/
|
|
857 |
virtual Item* compile(Item_analyzer analyzer, uchar **arg_p, |
|
858 |
Item_transformer transformer, uchar *arg_t) |
|
859 |
{
|
|
860 |
if ((this->*analyzer) (arg_p)) |
|
861 |
return ((this->*transformer) (arg_t)); |
|
862 |
return 0; |
|
863 |
}
|
|
864 |
||
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
865 |
virtual void traverse_cond(Cond_traverser traverser __attribute__((unused)), |
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
866 |
void *arg, |
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
867 |
traverse_order order __attribute__((unused))) |
1
by brian
clean slate |
868 |
{
|
869 |
(*traverser)(this, arg); |
|
870 |
}
|
|
871 |
||
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
872 |
virtual bool remove_dependence_processor(uchar * arg __attribute__((unused))) |
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
873 |
{ return 0; } |
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
874 |
virtual bool remove_fixed(uchar * arg __attribute__((unused))) |
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
875 |
{
|
876 |
fixed= 0; |
|
877 |
return 0; |
|
878 |
}
|
|
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
879 |
virtual bool cleanup_processor(uchar *arg __attribute__((unused))); |
880 |
virtual bool collect_item_field_processor(uchar * arg __attribute__((unused))) |
|
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
881 |
{ return 0; } |
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
882 |
virtual bool find_item_in_field_list_processor(uchar *arg __attribute__((unused))) |
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
883 |
{ return 0; } |
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
884 |
virtual bool change_context_processor(uchar *context __attribute__((unused))) |
885 |
{ return 0; } |
|
886 |
virtual bool reset_query_id_processor(uchar *query_id_arg __attribute__((unused))) |
|
887 |
{ return 0; } |
|
888 |
virtual bool register_field_in_read_map(uchar *arg __attribute__((unused))) |
|
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
889 |
{ return 0; } |
1
by brian
clean slate |
890 |
virtual bool subst_argument_checker(uchar **arg) |
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
891 |
{
|
1
by brian
clean slate |
892 |
if (*arg) |
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
893 |
*arg= NULL; |
894 |
return true; |
|
1
by brian
clean slate |
895 |
}
|
896 |
||
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
897 |
virtual Item *equal_fields_propagator(uchar * arg __attribute__((unused))) { return this; } |
898 |
virtual bool set_no_const_sub(uchar *arg __attribute__((unused))) { return false; } |
|
899 |
virtual Item *replace_equal_field(uchar * arg __attribute__((unused))) { return this; } |
|
1
by brian
clean slate |
900 |
|
901 |
/*
|
|
902 |
For SP local variable returns pointer to Item representing its
|
|
903 |
current value and pointer to current Item otherwise.
|
|
904 |
*/
|
|
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
905 |
virtual Item *this_item(void) { return this; } |
906 |
virtual const Item *this_item(void) const { return this; } |
|
1
by brian
clean slate |
907 |
|
908 |
/*
|
|
909 |
For SP local variable returns address of pointer to Item representing its
|
|
910 |
current value and pointer passed via parameter otherwise.
|
|
911 |
*/
|
|
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
912 |
virtual Item **this_item_addr(THD *thd __attribute__((unused)), Item **addr_arg) { return addr_arg; } |
1
by brian
clean slate |
913 |
|
914 |
// Row emulation
|
|
915 |
virtual uint cols() { return 1; } |
|
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
916 |
virtual Item* element_index(uint i __attribute__((unused))) { return this; } |
917 |
virtual Item** addr(uint i __attribute__((unused))) { return 0; } |
|
1
by brian
clean slate |
918 |
virtual bool check_cols(uint c); |
919 |
// It is not row => null inside is impossible
|
|
920 |
virtual bool null_inside() { return 0; } |
|
921 |
// used in row subselects to get value of elements
|
|
922 |
virtual void bring_value() {} |
|
923 |
||
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
924 |
Field *tmp_table_field_from_field_type(Table *table, bool fixed_length); |
1
by brian
clean slate |
925 |
virtual Item_field *filed_for_view_update() { return 0; } |
926 |
||
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
927 |
virtual Item *neg_transformer(THD *thd __attribute__((unused))) { return NULL; } |
928 |
virtual Item *update_value_transformer(uchar *select_arg __attribute__((unused))) { return this; } |
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
929 |
virtual Item *safe_charset_converter(const CHARSET_INFO * const tocs); |
1
by brian
clean slate |
930 |
void delete_self() |
931 |
{
|
|
932 |
cleanup(); |
|
933 |
delete this; |
|
934 |
}
|
|
935 |
||
936 |
/*
|
|
163
by Brian Aker
Merge Monty's code. |
937 |
result_as_int64_t() must return true for Items representing DATE/TIME
|
1
by brian
clean slate |
938 |
functions and DATE/TIME table fields.
|
939 |
Those Items have result_type()==STRING_RESULT (and not INT_RESULT), but
|
|
940 |
their values should be compared as integers (because the integer
|
|
941 |
representation is more precise than the string one).
|
|
942 |
*/
|
|
163
by Brian Aker
Merge Monty's code. |
943 |
virtual bool result_as_int64_t() { return false; } |
1
by brian
clean slate |
944 |
bool is_datetime(); |
945 |
||
946 |
/*
|
|
947 |
Test whether an expression is expensive to compute. Used during
|
|
948 |
optimization to avoid computing expensive expressions during this
|
|
949 |
phase. Also used to force temp tables when sorting on expensive
|
|
950 |
functions.
|
|
951 |
TODO:
|
|
952 |
Normally we should have a method:
|
|
953 |
cost Item::execution_cost(),
|
|
954 |
where 'cost' is either 'double' or some structure of various cost
|
|
955 |
parameters.
|
|
956 |
*/
|
|
957 |
virtual bool is_expensive() |
|
958 |
{
|
|
959 |
if (is_expensive_cache < 0) |
|
960 |
is_expensive_cache= walk(&Item::is_expensive_processor, 0, (uchar*)0); |
|
961 |
return test(is_expensive_cache); |
|
962 |
}
|
|
963 |
String *check_well_formed_result(String *str, bool send_error= 0); |
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
964 |
bool eq_by_collation(Item *item, bool binary_cmp, const CHARSET_INFO * const cs); |
1
by brian
clean slate |
965 |
};
|
966 |
||
967 |
||
968 |
class Item_basic_constant :public Item |
|
969 |
{
|
|
970 |
public: |
|
971 |
/* to prevent drop fixed flag (no need parent cleanup call) */
|
|
972 |
void cleanup() |
|
973 |
{
|
|
974 |
/*
|
|
975 |
Restore the original field name as it might not have been allocated
|
|
976 |
in the statement memory. If the name is auto generated, it must be
|
|
977 |
done again between subsequent executions of a prepared statement.
|
|
978 |
*/
|
|
979 |
if (orig_name) |
|
980 |
name= orig_name; |
|
981 |
}
|
|
982 |
};
|
|
983 |
||
984 |
bool agg_item_collations(DTCollation &c, const char *name, |
|
985 |
Item **items, uint nitems, uint flags, int item_sep); |
|
986 |
bool agg_item_collations_for_comparison(DTCollation &c, const char *name, |
|
987 |
Item **items, uint nitems, uint flags); |
|
988 |
bool agg_item_charsets(DTCollation &c, const char *name, |
|
989 |
Item **items, uint nitems, uint flags, int item_sep); |
|
990 |
||
991 |
||
992 |
class Item_num: public Item_basic_constant |
|
993 |
{
|
|
994 |
public: |
|
995 |
Item_num() {} /* Remove gcc warning */ |
|
996 |
virtual Item_num *neg()= 0; |
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
997 |
Item *safe_charset_converter(const CHARSET_INFO * const tocs); |
1
by brian
clean slate |
998 |
};
|
999 |
||
1000 |
#define NO_CACHED_FIELD_INDEX ((uint)(-1))
|
|
1001 |
||
1002 |
class st_select_lex; |
|
1003 |
class Item_ident :public Item |
|
1004 |
{
|
|
1005 |
protected: |
|
1006 |
/*
|
|
1007 |
We have to store initial values of db_name, table_name and field_name
|
|
1008 |
to be able to restore them during cleanup() because they can be
|
|
1009 |
updated during fix_fields() to values from Field object and life-time
|
|
1010 |
of those is shorter than life-time of Item_field.
|
|
1011 |
*/
|
|
1012 |
const char *orig_db_name; |
|
1013 |
const char *orig_table_name; |
|
1014 |
const char *orig_field_name; |
|
1015 |
||
1016 |
public: |
|
1017 |
Name_resolution_context *context; |
|
1018 |
const char *db_name; |
|
1019 |
const char *table_name; |
|
1020 |
const char *field_name; |
|
1021 |
bool alias_name_used; /* true if item was resolved against alias */ |
|
1022 |
/*
|
|
1023 |
Cached value of index for this field in table->field array, used by prep.
|
|
1024 |
stmts for speeding up their re-execution. Holds NO_CACHED_FIELD_INDEX
|
|
1025 |
if index value is not known.
|
|
1026 |
*/
|
|
1027 |
uint cached_field_index; |
|
1028 |
/*
|
|
1029 |
Cached pointer to table which contains this field, used for the same reason
|
|
1030 |
by prep. stmt. too in case then we have not-fully qualified field.
|
|
1031 |
0 - means no cached value.
|
|
1032 |
*/
|
|
327.2.4
by Brian Aker
Refactoring table.h |
1033 |
TableList *cached_table; |
1
by brian
clean slate |
1034 |
st_select_lex *depended_from; |
1035 |
Item_ident(Name_resolution_context *context_arg, |
|
1036 |
const char *db_name_arg, const char *table_name_arg, |
|
1037 |
const char *field_name_arg); |
|
1038 |
Item_ident(THD *thd, Item_ident *item); |
|
1039 |
const char *full_name() const; |
|
1040 |
void cleanup(); |
|
1041 |
bool remove_dependence_processor(uchar * arg); |
|
1042 |
virtual void print(String *str, enum_query_type query_type); |
|
1043 |
virtual bool change_context_processor(uchar *cntx) |
|
163
by Brian Aker
Merge Monty's code. |
1044 |
{ context= (Name_resolution_context *)cntx; return false; } |
1
by brian
clean slate |
1045 |
friend bool insert_fields(THD *thd, Name_resolution_context *context, |
1046 |
const char *db_name, |
|
1047 |
const char *table_name, List_iterator<Item> *it, |
|
1048 |
bool any_privileges); |
|
1049 |
};
|
|
1050 |
||
1051 |
||
1052 |
class Item_ident_for_show :public Item |
|
1053 |
{
|
|
1054 |
public: |
|
1055 |
Field *field; |
|
1056 |
const char *db_name; |
|
1057 |
const char *table_name; |
|
1058 |
||
1059 |
Item_ident_for_show(Field *par_field, const char *db_arg, |
|
1060 |
const char *table_name_arg) |
|
1061 |
:field(par_field), db_name(db_arg), table_name(table_name_arg) |
|
1062 |
{}
|
|
1063 |
||
1064 |
enum Type type() const { return FIELD_ITEM; } |
|
1065 |
double val_real() { return field->val_real(); } |
|
152
by Brian Aker
longlong replacement |
1066 |
int64_t val_int() { return field->val_int(); } |
1
by brian
clean slate |
1067 |
String *val_str(String *str) { return field->val_str(str); } |
1068 |
my_decimal *val_decimal(my_decimal *dec) { return field->val_decimal(dec); } |
|
1069 |
void make_field(Send_field *tmp_field); |
|
1070 |
};
|
|
1071 |
||
1072 |
||
1073 |
class Item_equal; |
|
1074 |
class COND_EQUAL; |
|
1075 |
||
1076 |
class Item_field :public Item_ident |
|
1077 |
{
|
|
1078 |
protected: |
|
1079 |
void set_field(Field *field); |
|
1080 |
public: |
|
1081 |
Field *field,*result_field; |
|
1082 |
Item_equal *item_equal; |
|
1083 |
bool no_const_subst; |
|
1084 |
/*
|
|
163
by Brian Aker
Merge Monty's code. |
1085 |
if any_privileges set to true then here real effective privileges will
|
1
by brian
clean slate |
1086 |
be stored
|
1087 |
*/
|
|
1088 |
uint have_privileges; |
|
1089 |
/* field need any privileges (for VIEW creation) */
|
|
1090 |
bool any_privileges; |
|
1091 |
Item_field(Name_resolution_context *context_arg, |
|
1092 |
const char *db_arg,const char *table_name_arg, |
|
1093 |
const char *field_name_arg); |
|
1094 |
/*
|
|
1095 |
Constructor needed to process subselect with temporary tables (see Item)
|
|
1096 |
*/
|
|
1097 |
Item_field(THD *thd, Item_field *item); |
|
1098 |
/*
|
|
1099 |
Constructor used inside setup_wild(), ensures that field, table,
|
|
1100 |
and database names will live as long as Item_field (this is important
|
|
1101 |
in prepared statements).
|
|
1102 |
*/
|
|
1103 |
Item_field(THD *thd, Name_resolution_context *context_arg, Field *field); |
|
1104 |
/*
|
|
1105 |
If this constructor is used, fix_fields() won't work, because
|
|
1106 |
db_name, table_name and column_name are unknown. It's necessary to call
|
|
1107 |
reset_field() before fix_fields() for all fields created this way.
|
|
1108 |
*/
|
|
1109 |
Item_field(Field *field); |
|
1110 |
enum Type type() const { return FIELD_ITEM; } |
|
1111 |
bool eq(const Item *item, bool binary_cmp) const; |
|
1112 |
double val_real(); |
|
152
by Brian Aker
longlong replacement |
1113 |
int64_t val_int(); |
1
by brian
clean slate |
1114 |
my_decimal *val_decimal(my_decimal *); |
1115 |
String *val_str(String*); |
|
1116 |
double val_result(); |
|
152
by Brian Aker
longlong replacement |
1117 |
int64_t val_int_result(); |
1
by brian
clean slate |
1118 |
String *str_result(String* tmp); |
1119 |
my_decimal *val_decimal_result(my_decimal *); |
|
1120 |
bool val_bool_result(); |
|
1121 |
bool send(Protocol *protocol, String *str_arg); |
|
1122 |
void reset_field(Field *f); |
|
1123 |
bool fix_fields(THD *, Item **); |
|
1124 |
void fix_after_pullout(st_select_lex *new_parent, Item **ref); |
|
1125 |
void make_field(Send_field *tmp_field); |
|
1126 |
int save_in_field(Field *field,bool no_conversions); |
|
1127 |
void save_org_in_field(Field *field); |
|
1128 |
table_map used_tables() const; |
|
1129 |
enum Item_result result_type () const |
|
1130 |
{
|
|
1131 |
return field->result_type(); |
|
1132 |
}
|
|
1133 |
Item_result cast_to_int_type() const |
|
1134 |
{
|
|
1135 |
return field->cast_to_int_type(); |
|
1136 |
}
|
|
1137 |
enum_field_types field_type() const |
|
1138 |
{
|
|
1139 |
return field->type(); |
|
1140 |
}
|
|
1141 |
enum_monotonicity_info get_monotonicity_info() const |
|
1142 |
{
|
|
1143 |
return MONOTONIC_STRICT_INCREASING; |
|
1144 |
}
|
|
152
by Brian Aker
longlong replacement |
1145 |
int64_t val_int_endpoint(bool left_endp, bool *incl_endp); |
1
by brian
clean slate |
1146 |
Field *get_tmp_table_field() { return result_field; } |
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
1147 |
Field *tmp_table_field(Table *t_arg __attribute__((unused))) { return result_field; } |
236.1.24
by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME. |
1148 |
bool get_date(DRIZZLE_TIME *ltime,uint fuzzydate); |
1149 |
bool get_date_result(DRIZZLE_TIME *ltime,uint fuzzydate); |
|
1150 |
bool get_time(DRIZZLE_TIME *ltime); |
|
1
by brian
clean slate |
1151 |
bool is_null() { return field->is_null(); } |
1152 |
void update_null_value(); |
|
1153 |
Item *get_tmp_table_item(THD *thd); |
|
1154 |
bool collect_item_field_processor(uchar * arg); |
|
1155 |
bool find_item_in_field_list_processor(uchar *arg); |
|
1156 |
bool register_field_in_read_map(uchar *arg); |
|
1157 |
void cleanup(); |
|
152
by Brian Aker
longlong replacement |
1158 |
bool result_as_int64_t() |
1
by brian
clean slate |
1159 |
{
|
152
by Brian Aker
longlong replacement |
1160 |
return field->can_be_compared_as_int64_t(); |
1
by brian
clean slate |
1161 |
}
|
1162 |
Item_equal *find_item_equal(COND_EQUAL *cond_equal); |
|
1163 |
bool subst_argument_checker(uchar **arg); |
|
1164 |
Item *equal_fields_propagator(uchar *arg); |
|
1165 |
bool set_no_const_sub(uchar *arg); |
|
1166 |
Item *replace_equal_field(uchar *arg); |
|
203
by Brian Aker
Small cleanup around uint32 types (need to merge). |
1167 |
inline uint32_t max_disp_length() { return field->max_display_length(); } |
1
by brian
clean slate |
1168 |
Item_field *filed_for_view_update() { return this; } |
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
1169 |
Item *safe_charset_converter(const CHARSET_INFO * const tocs); |
1
by brian
clean slate |
1170 |
int fix_outer_field(THD *thd, Field **field, Item **reference); |
1171 |
virtual Item *update_value_transformer(uchar *select_arg); |
|
1172 |
virtual void print(String *str, enum_query_type query_type); |
|
1173 |
||
1174 |
friend class Item_default_value; |
|
1175 |
friend class Item_insert_value; |
|
1176 |
friend class st_select_lex_unit; |
|
1177 |
};
|
|
1178 |
||
1179 |
class Item_null :public Item_basic_constant |
|
1180 |
{
|
|
1181 |
public: |
|
1182 |
Item_null(char *name_par=0) |
|
1183 |
{
|
|
163
by Brian Aker
Merge Monty's code. |
1184 |
maybe_null= null_value= true; |
1
by brian
clean slate |
1185 |
max_length= 0; |
1186 |
name= name_par ? name_par : (char*) "NULL"; |
|
1187 |
fixed= 1; |
|
1188 |
collation.set(&my_charset_bin, DERIVATION_IGNORABLE); |
|
1189 |
}
|
|
1190 |
enum Type type() const { return NULL_ITEM; } |
|
1191 |
bool eq(const Item *item, bool binary_cmp) const; |
|
1192 |
double val_real(); |
|
152
by Brian Aker
longlong replacement |
1193 |
int64_t val_int(); |
1
by brian
clean slate |
1194 |
String *val_str(String *str); |
1195 |
my_decimal *val_decimal(my_decimal *); |
|
1196 |
int save_in_field(Field *field, bool no_conversions); |
|
1197 |
int save_safe_in_field(Field *field); |
|
1198 |
bool send(Protocol *protocol, String *str); |
|
1199 |
enum Item_result result_type () const { return STRING_RESULT; } |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1200 |
enum_field_types field_type() const { return DRIZZLE_TYPE_NULL; } |
1
by brian
clean slate |
1201 |
bool basic_const_item() const { return 1; } |
1202 |
Item *clone_item() { return new Item_null(name); } |
|
1203 |
bool is_null() { return 1; } |
|
1204 |
||
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
1205 |
virtual inline void print(String *str, |
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
1206 |
enum_query_type query_type __attribute__((unused))) |
1
by brian
clean slate |
1207 |
{
|
1208 |
str->append(STRING_WITH_LEN("NULL")); |
|
1209 |
}
|
|
1210 |
||
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
1211 |
Item *safe_charset_converter(const CHARSET_INFO * const tocs); |
1
by brian
clean slate |
1212 |
};
|
1213 |
||
1214 |
class Item_null_result :public Item_null |
|
1215 |
{
|
|
1216 |
public: |
|
1217 |
Field *result_field; |
|
1218 |
Item_null_result() : Item_null(), result_field(0) {} |
|
1219 |
bool is_result_field() { return result_field != 0; } |
|
1220 |
void save_in_result_field(bool no_conversions) |
|
1221 |
{
|
|
1222 |
save_in_field(result_field, no_conversions); |
|
1223 |
}
|
|
1224 |
};
|
|
1225 |
||
1226 |
/* Item represents one placeholder ('?') of prepared statement */
|
|
1227 |
||
1228 |
class Item_param :public Item |
|
1229 |
{
|
|
1230 |
char cnvbuf[MAX_FIELD_WIDTH]; |
|
1231 |
String cnvstr; |
|
1232 |
Item *cnvitem; |
|
1233 |
||
1234 |
public: |
|
1235 |
enum enum_item_param_state |
|
1236 |
{
|
|
1237 |
NO_VALUE, NULL_VALUE, INT_VALUE, REAL_VALUE, |
|
1238 |
STRING_VALUE, TIME_VALUE, LONG_DATA_VALUE, |
|
1239 |
DECIMAL_VALUE
|
|
1240 |
} state; |
|
1241 |
||
1242 |
/*
|
|
1243 |
A buffer for string and long data values. Historically all allocated
|
|
1244 |
values returned from val_str() were treated as eligible to
|
|
1245 |
modification. I. e. in some cases Item_func_concat can append it's
|
|
1246 |
second argument to return value of the first one. Because of that we
|
|
1247 |
can't return the original buffer holding string data from val_str(),
|
|
1248 |
and have to have one buffer for data and another just pointing to
|
|
1249 |
the data. This is the latter one and it's returned from val_str().
|
|
1250 |
Can not be declared inside the union as it's not a POD type.
|
|
1251 |
*/
|
|
1252 |
String str_value_ptr; |
|
1253 |
my_decimal decimal_value; |
|
1254 |
union
|
|
1255 |
{
|
|
152
by Brian Aker
longlong replacement |
1256 |
int64_t integer; |
1
by brian
clean slate |
1257 |
double real; |
1258 |
/*
|
|
1259 |
Character sets conversion info for string values.
|
|
1260 |
Character sets of client and connection defined at bind time are used
|
|
1261 |
for all conversions, even if one of them is later changed (i.e.
|
|
1262 |
between subsequent calls to mysql_stmt_execute).
|
|
1263 |
*/
|
|
1264 |
struct CONVERSION_INFO |
|
1265 |
{
|
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
1266 |
const CHARSET_INFO *character_set_client; |
1267 |
const CHARSET_INFO *character_set_of_placeholder; |
|
1
by brian
clean slate |
1268 |
/*
|
1269 |
This points at character set of connection if conversion
|
|
1270 |
to it is required (i. e. if placeholder typecode is not BLOB).
|
|
1271 |
Otherwise it's equal to character_set_client (to simplify
|
|
1272 |
check in convert_str_value()).
|
|
1273 |
*/
|
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
1274 |
const CHARSET_INFO *final_character_set_of_str_value; |
1
by brian
clean slate |
1275 |
} cs_info; |
236.1.24
by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME. |
1276 |
DRIZZLE_TIME time; |
1
by brian
clean slate |
1277 |
} value; |
1278 |
||
1279 |
/* Cached values for virtual methods to save us one switch. */
|
|
1280 |
enum Item_result item_result_type; |
|
1281 |
enum Type item_type; |
|
1282 |
||
1283 |
/*
|
|
1284 |
Used when this item is used in a temporary table.
|
|
1285 |
This is NOT placeholder metadata sent to client, as this value
|
|
1286 |
is assigned after sending metadata (in setup_one_conversion_function).
|
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1287 |
For example in case of 'SELECT ?' you'll get DRIZZLE_TYPE_STRING both
|
1
by brian
clean slate |
1288 |
in result set and placeholders metadata, no matter what type you will
|
1289 |
supply for this placeholder in mysql_stmt_execute.
|
|
1290 |
*/
|
|
1291 |
enum enum_field_types param_type; |
|
1292 |
/*
|
|
1293 |
Offset of placeholder inside statement text. Used to create
|
|
1294 |
no-placeholders version of this statement for the binary log.
|
|
1295 |
*/
|
|
1296 |
uint pos_in_query; |
|
1297 |
||
1298 |
Item_param(uint pos_in_query_arg); |
|
1299 |
||
1300 |
enum Item_result result_type () const { return item_result_type; } |
|
1301 |
enum Type type() const { return item_type; } |
|
1302 |
enum_field_types field_type() const { return param_type; } |
|
1303 |
||
1304 |
double val_real(); |
|
152
by Brian Aker
longlong replacement |
1305 |
int64_t val_int(); |
1
by brian
clean slate |
1306 |
my_decimal *val_decimal(my_decimal*); |
1307 |
String *val_str(String*); |
|
236.1.24
by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME. |
1308 |
bool get_time(DRIZZLE_TIME *tm); |
1309 |
bool get_date(DRIZZLE_TIME *tm, uint fuzzydate); |
|
1
by brian
clean slate |
1310 |
int save_in_field(Field *field, bool no_conversions); |
1311 |
||
1312 |
void set_null(); |
|
203
by Brian Aker
Small cleanup around uint32 types (need to merge). |
1313 |
void set_int(int64_t i, uint32_t max_length_arg); |
1
by brian
clean slate |
1314 |
void set_double(double i); |
287.3.11
by Monty Taylor
Rolled back a couple of overly anxious consts. |
1315 |
void set_decimal(char *str, ulong length); |
1
by brian
clean slate |
1316 |
bool set_str(const char *str, ulong length); |
1317 |
bool set_longdata(const char *str, ulong length); |
|
398.1.1
by Monty Taylor
Remove typedef enum enum_drizzle_timestamp_type timestamp_type; |
1318 |
void set_time(DRIZZLE_TIME *tm, enum enum_drizzle_timestamp_type type, |
1319 |
uint32_t max_length_arg); |
|
1
by brian
clean slate |
1320 |
bool set_from_user_var(THD *thd, const user_var_entry *entry); |
1321 |
void reset(); |
|
1322 |
/*
|
|
1323 |
Assign placeholder value from bind data.
|
|
1324 |
Note, that 'len' has different semantics in embedded library (as we
|
|
1325 |
don't need to check that packet is not broken there). See
|
|
1326 |
sql_prepare.cc for details.
|
|
1327 |
*/
|
|
1328 |
void (*set_param_func)(Item_param *param, uchar **pos, ulong len); |
|
1329 |
||
1330 |
const String *query_val_str(String *str) const; |
|
1331 |
||
1332 |
bool convert_str_value(THD *thd); |
|
1333 |
||
1334 |
/*
|
|
1335 |
If value for parameter was not set we treat it as non-const
|
|
1336 |
so noone will use parameters value in fix_fields still
|
|
1337 |
parameter is constant during execution.
|
|
1338 |
*/
|
|
1339 |
virtual table_map used_tables() const |
|
1340 |
{ return state != NO_VALUE ? (table_map)0 : PARAM_TABLE_BIT; } |
|
1341 |
virtual void print(String *str, enum_query_type query_type); |
|
1342 |
bool is_null() |
|
51.1.55
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE - 1st clean pass on item.h/cc |
1343 |
{ assert(state != NO_VALUE); return state == NULL_VALUE; } |
1
by brian
clean slate |
1344 |
bool basic_const_item() const; |
1345 |
/*
|
|
1346 |
This method is used to make a copy of a basic constant item when
|
|
1347 |
propagating constants in the optimizer. The reason to create a new
|
|
1348 |
item and not use the existing one is not precisely known (2005/04/16).
|
|
1349 |
Probably we are trying to preserve tree structure of items, in other
|
|
1350 |
words, avoid pointing at one item from two different nodes of the tree.
|
|
1351 |
Return a new basic constant item if parameter value is a basic
|
|
1352 |
constant, assert otherwise. This method is called only if
|
|
163
by Brian Aker
Merge Monty's code. |
1353 |
basic_const_item returned true.
|
1
by brian
clean slate |
1354 |
*/
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
1355 |
Item *safe_charset_converter(const CHARSET_INFO * const tocs); |
1
by brian
clean slate |
1356 |
Item *clone_item(); |
1357 |
/*
|
|
1358 |
Implement by-value equality evaluation if parameter value
|
|
1359 |
is set and is a basic constant (integer, real or string).
|
|
163
by Brian Aker
Merge Monty's code. |
1360 |
Otherwise return false.
|
1
by brian
clean slate |
1361 |
*/
|
1362 |
bool eq(const Item *item, bool binary_cmp) const; |
|
1363 |
/** Item is a argument to a limit clause. */
|
|
1364 |
bool limit_clause_param; |
|
1365 |
};
|
|
1366 |
||
1367 |
||
1368 |
class Item_int :public Item_num |
|
1369 |
{
|
|
1370 |
public: |
|
152
by Brian Aker
longlong replacement |
1371 |
int64_t value; |
205
by Brian Aker
uint32 -> uin32_t |
1372 |
Item_int(int32_t i,uint length= MY_INT32_NUM_DECIMAL_DIGITS) |
152
by Brian Aker
longlong replacement |
1373 |
:value((int64_t) i) |
1
by brian
clean slate |
1374 |
{ max_length=length; fixed= 1; } |
152
by Brian Aker
longlong replacement |
1375 |
Item_int(int64_t i,uint length= MY_INT64_NUM_DECIMAL_DIGITS) |
1
by brian
clean slate |
1376 |
:value(i) |
1377 |
{ max_length=length; fixed= 1; } |
|
151
by Brian Aker
Ulonglong to uint64_t |
1378 |
Item_int(uint64_t i, uint length= MY_INT64_NUM_DECIMAL_DIGITS) |
152
by Brian Aker
longlong replacement |
1379 |
:value((int64_t)i) |
1
by brian
clean slate |
1380 |
{ max_length=length; fixed= 1; unsigned_flag= 1; } |
152
by Brian Aker
longlong replacement |
1381 |
Item_int(const char *str_arg,int64_t i,uint length) :value(i) |
1
by brian
clean slate |
1382 |
{ max_length=length; name=(char*) str_arg; fixed= 1; } |
1383 |
Item_int(const char *str_arg, uint length=64); |
|
1384 |
enum Type type() const { return INT_ITEM; } |
|
1385 |
enum Item_result result_type () const { return INT_RESULT; } |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1386 |
enum_field_types field_type() const { return DRIZZLE_TYPE_LONGLONG; } |
152
by Brian Aker
longlong replacement |
1387 |
int64_t val_int() { assert(fixed == 1); return value; } |
51.1.55
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE - 1st clean pass on item.h/cc |
1388 |
double val_real() { assert(fixed == 1); return (double) value; } |
1
by brian
clean slate |
1389 |
my_decimal *val_decimal(my_decimal *); |
1390 |
String *val_str(String*); |
|
1391 |
int save_in_field(Field *field, bool no_conversions); |
|
1392 |
bool basic_const_item() const { return 1; } |
|
1393 |
Item *clone_item() { return new Item_int(name,value,max_length); } |
|
1394 |
virtual void print(String *str, enum_query_type query_type); |
|
1395 |
Item_num *neg() { value= -value; return this; } |
|
1396 |
uint decimal_precision() const |
|
1397 |
{ return (uint)(max_length - test(value < 0)); } |
|
1398 |
bool eq(const Item *, bool binary_cmp) const; |
|
1399 |
};
|
|
1400 |
||
1401 |
||
1402 |
class Item_uint :public Item_int |
|
1403 |
{
|
|
1404 |
public: |
|
1405 |
Item_uint(const char *str_arg, uint length); |
|
151
by Brian Aker
Ulonglong to uint64_t |
1406 |
Item_uint(uint64_t i) :Item_int((uint64_t) i, 10) {} |
152
by Brian Aker
longlong replacement |
1407 |
Item_uint(const char *str_arg, int64_t i, uint length); |
1
by brian
clean slate |
1408 |
double val_real() |
151
by Brian Aker
Ulonglong to uint64_t |
1409 |
{ assert(fixed == 1); return uint64_t2double((uint64_t)value); } |
1
by brian
clean slate |
1410 |
String *val_str(String*); |
1411 |
Item *clone_item() { return new Item_uint(name, value, max_length); } |
|
1412 |
int save_in_field(Field *field, bool no_conversions); |
|
1413 |
virtual void print(String *str, enum_query_type query_type); |
|
1414 |
Item_num *neg (); |
|
1415 |
uint decimal_precision() const { return max_length; } |
|
1416 |
};
|
|
1417 |
||
1418 |
||
1419 |
/* decimal (fixed point) constant */
|
|
1420 |
class Item_decimal :public Item_num |
|
1421 |
{
|
|
1422 |
protected: |
|
1423 |
my_decimal decimal_value; |
|
1424 |
public: |
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
1425 |
Item_decimal(const char *str_arg, uint length, const CHARSET_INFO * const charset); |
1
by brian
clean slate |
1426 |
Item_decimal(const char *str, const my_decimal *val_arg, |
1427 |
uint decimal_par, uint length); |
|
1428 |
Item_decimal(my_decimal *value_par); |
|
152
by Brian Aker
longlong replacement |
1429 |
Item_decimal(int64_t val, bool unsig); |
1
by brian
clean slate |
1430 |
Item_decimal(double val, int precision, int scale); |
1431 |
Item_decimal(const uchar *bin, int precision, int scale); |
|
1432 |
||
1433 |
enum Type type() const { return DECIMAL_ITEM; } |
|
1434 |
enum Item_result result_type () const { return DECIMAL_RESULT; } |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1435 |
enum_field_types field_type() const { return DRIZZLE_TYPE_NEWDECIMAL; } |
152
by Brian Aker
longlong replacement |
1436 |
int64_t val_int(); |
1
by brian
clean slate |
1437 |
double val_real(); |
1438 |
String *val_str(String*); |
|
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
1439 |
my_decimal *val_decimal(my_decimal *val __attribute__((unused))) |
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
1440 |
{ return &decimal_value; } |
1
by brian
clean slate |
1441 |
int save_in_field(Field *field, bool no_conversions); |
1442 |
bool basic_const_item() const { return 1; } |
|
1443 |
Item *clone_item() |
|
1444 |
{
|
|
1445 |
return new Item_decimal(name, &decimal_value, decimals, max_length); |
|
1446 |
}
|
|
1447 |
virtual void print(String *str, enum_query_type query_type); |
|
1448 |
Item_num *neg() |
|
1449 |
{
|
|
1450 |
my_decimal_neg(&decimal_value); |
|
1451 |
unsigned_flag= !decimal_value.sign(); |
|
1452 |
return this; |
|
1453 |
}
|
|
1454 |
uint decimal_precision() const { return decimal_value.precision(); } |
|
1455 |
bool eq(const Item *, bool binary_cmp) const; |
|
1456 |
void set_decimal_value(my_decimal *value_par); |
|
1457 |
};
|
|
1458 |
||
1459 |
||
1460 |
class Item_float :public Item_num |
|
1461 |
{
|
|
1462 |
char *presentation; |
|
1463 |
public: |
|
1464 |
double value; |
|
1465 |
// Item_real() :value(0) {}
|
|
1466 |
Item_float(const char *str_arg, uint length); |
|
1467 |
Item_float(const char *str,double val_arg,uint decimal_par,uint length) |
|
1468 |
:value(val_arg) |
|
1469 |
{
|
|
1470 |
presentation= name=(char*) str; |
|
206
by Brian Aker
Removed final uint dead types. |
1471 |
decimals=(uint8_t) decimal_par; |
1
by brian
clean slate |
1472 |
max_length=length; |
1473 |
fixed= 1; |
|
1474 |
}
|
|
1475 |
Item_float(double value_par, uint decimal_par) :presentation(0), value(value_par) |
|
1476 |
{
|
|
206
by Brian Aker
Removed final uint dead types. |
1477 |
decimals= (uint8_t) decimal_par; |
1
by brian
clean slate |
1478 |
fixed= 1; |
1479 |
}
|
|
1480 |
int save_in_field(Field *field, bool no_conversions); |
|
1481 |
enum Type type() const { return REAL_ITEM; } |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1482 |
enum_field_types field_type() const { return DRIZZLE_TYPE_DOUBLE; } |
51.1.55
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE - 1st clean pass on item.h/cc |
1483 |
double val_real() { assert(fixed == 1); return value; } |
152
by Brian Aker
longlong replacement |
1484 |
int64_t val_int() |
1
by brian
clean slate |
1485 |
{
|
51.1.55
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE - 1st clean pass on item.h/cc |
1486 |
assert(fixed == 1); |
163
by Brian Aker
Merge Monty's code. |
1487 |
if (value <= (double) INT64_MIN) |
1
by brian
clean slate |
1488 |
{
|
163
by Brian Aker
Merge Monty's code. |
1489 |
return INT64_MIN; |
1
by brian
clean slate |
1490 |
}
|
163
by Brian Aker
Merge Monty's code. |
1491 |
else if (value >= (double) (uint64_t) INT64_MAX) |
1
by brian
clean slate |
1492 |
{
|
163
by Brian Aker
Merge Monty's code. |
1493 |
return INT64_MAX; |
1
by brian
clean slate |
1494 |
}
|
152
by Brian Aker
longlong replacement |
1495 |
return (int64_t) rint(value); |
1
by brian
clean slate |
1496 |
}
|
1497 |
String *val_str(String*); |
|
1498 |
my_decimal *val_decimal(my_decimal *); |
|
1499 |
bool basic_const_item() const { return 1; } |
|
1500 |
Item *clone_item() |
|
1501 |
{ return new Item_float(name, value, decimals, max_length); } |
|
1502 |
Item_num *neg() { value= -value; return this; } |
|
1503 |
virtual void print(String *str, enum_query_type query_type); |
|
1504 |
bool eq(const Item *, bool binary_cmp) const; |
|
1505 |
};
|
|
1506 |
||
1507 |
||
1508 |
class Item_static_float_func :public Item_float |
|
1509 |
{
|
|
1510 |
const char *func_name; |
|
1511 |
public: |
|
1512 |
Item_static_float_func(const char *str, double val_arg, uint decimal_par, |
|
1513 |
uint length) |
|
461
by Monty Taylor
Removed NullS. bu-bye. |
1514 |
:Item_float(NULL, val_arg, decimal_par, length), func_name(str) |
1
by brian
clean slate |
1515 |
{}
|
1516 |
||
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
1517 |
virtual inline void print(String *str, |
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
1518 |
enum_query_type query_type __attribute__((unused))) |
1
by brian
clean slate |
1519 |
{
|
1520 |
str->append(func_name); |
|
1521 |
}
|
|
1522 |
||
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
1523 |
Item *safe_charset_converter(const CHARSET_INFO * const tocs); |
1
by brian
clean slate |
1524 |
};
|
1525 |
||
1526 |
||
1527 |
class Item_string :public Item_basic_constant |
|
1528 |
{
|
|
1529 |
public: |
|
1530 |
Item_string(const char *str,uint length, |
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
1531 |
const CHARSET_INFO * const cs, Derivation dv= DERIVATION_COERCIBLE, |
1
by brian
clean slate |
1532 |
uint repertoire= MY_REPERTOIRE_UNICODE30) |
163
by Brian Aker
Merge Monty's code. |
1533 |
: m_cs_specified(false) |
1
by brian
clean slate |
1534 |
{
|
1535 |
str_value.set_or_copy_aligned(str, length, cs); |
|
1536 |
collation.set(cs, dv, repertoire); |
|
1537 |
/*
|
|
1538 |
We have to have a different max_length than 'length' here to
|
|
1539 |
ensure that we get the right length if we do use the item
|
|
1540 |
to create a new table. In this case max_length must be the maximum
|
|
1541 |
number of chars for a string of this type because we in Create_field::
|
|
1542 |
divide the max_length with mbmaxlen).
|
|
1543 |
*/
|
|
1544 |
max_length= str_value.numchars()*cs->mbmaxlen; |
|
1545 |
set_name(str, length, cs); |
|
1546 |
decimals=NOT_FIXED_DEC; |
|
1547 |
// it is constant => can be used without fix_fields (and frequently used)
|
|
1548 |
fixed= 1; |
|
1549 |
}
|
|
1550 |
/* Just create an item and do not fill string representation */
|
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
1551 |
Item_string(const CHARSET_INFO * const cs, Derivation dv= DERIVATION_COERCIBLE) |
163
by Brian Aker
Merge Monty's code. |
1552 |
: m_cs_specified(false) |
1
by brian
clean slate |
1553 |
{
|
1554 |
collation.set(cs, dv); |
|
1555 |
max_length= 0; |
|
1556 |
set_name(NULL, 0, cs); |
|
1557 |
decimals= NOT_FIXED_DEC; |
|
1558 |
fixed= 1; |
|
1559 |
}
|
|
1560 |
Item_string(const char *name_par, const char *str, uint length, |
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
1561 |
const CHARSET_INFO * const cs, Derivation dv= DERIVATION_COERCIBLE, |
1
by brian
clean slate |
1562 |
uint repertoire= MY_REPERTOIRE_UNICODE30) |
163
by Brian Aker
Merge Monty's code. |
1563 |
: m_cs_specified(false) |
1
by brian
clean slate |
1564 |
{
|
1565 |
str_value.set_or_copy_aligned(str, length, cs); |
|
1566 |
collation.set(cs, dv, repertoire); |
|
1567 |
max_length= str_value.numchars()*cs->mbmaxlen; |
|
1568 |
set_name(name_par, 0, cs); |
|
1569 |
decimals=NOT_FIXED_DEC; |
|
1570 |
// it is constant => can be used without fix_fields (and frequently used)
|
|
1571 |
fixed= 1; |
|
1572 |
}
|
|
1573 |
/*
|
|
1574 |
This is used in stored procedures to avoid memory leaks and
|
|
1575 |
does a deep copy of its argument.
|
|
1576 |
*/
|
|
1577 |
void set_str_with_copy(const char *str_arg, uint length_arg) |
|
1578 |
{
|
|
1579 |
str_value.copy(str_arg, length_arg, collation.collation); |
|
1580 |
max_length= str_value.numchars() * collation.collation->mbmaxlen; |
|
1581 |
}
|
|
1582 |
void set_repertoire_from_value() |
|
1583 |
{
|
|
1584 |
collation.repertoire= my_string_repertoire(str_value.charset(), |
|
1585 |
str_value.ptr(), |
|
1586 |
str_value.length()); |
|
1587 |
}
|
|
1588 |
enum Type type() const { return STRING_ITEM; } |
|
1589 |
double val_real(); |
|
152
by Brian Aker
longlong replacement |
1590 |
int64_t val_int(); |
1
by brian
clean slate |
1591 |
String *val_str(String*) |
1592 |
{
|
|
51.1.55
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE - 1st clean pass on item.h/cc |
1593 |
assert(fixed == 1); |
1
by brian
clean slate |
1594 |
return (String*) &str_value; |
1595 |
}
|
|
1596 |
my_decimal *val_decimal(my_decimal *); |
|
1597 |
int save_in_field(Field *field, bool no_conversions); |
|
1598 |
enum Item_result result_type () const { return STRING_RESULT; } |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1599 |
enum_field_types field_type() const { return DRIZZLE_TYPE_VARCHAR; } |
1
by brian
clean slate |
1600 |
bool basic_const_item() const { return 1; } |
1601 |
bool eq(const Item *item, bool binary_cmp) const; |
|
1602 |
Item *clone_item() |
|
1603 |
{
|
|
1604 |
return new Item_string(name, str_value.ptr(), |
|
1605 |
str_value.length(), collation.collation); |
|
1606 |
}
|
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
1607 |
Item *safe_charset_converter(const CHARSET_INFO * const tocs); |
1
by brian
clean slate |
1608 |
inline void append(char *str, uint length) |
1609 |
{
|
|
1610 |
str_value.append(str, length); |
|
1611 |
max_length= str_value.numchars() * collation.collation->mbmaxlen; |
|
1612 |
}
|
|
1613 |
virtual void print(String *str, enum_query_type query_type); |
|
1614 |
||
1615 |
/**
|
|
163
by Brian Aker
Merge Monty's code. |
1616 |
Return true if character-set-introducer was explicitly specified in the
|
1
by brian
clean slate |
1617 |
original query for this item (text literal).
|
1618 |
||
1619 |
This operation is to be called from Item_string::print(). The idea is
|
|
1620 |
that when a query is generated (re-constructed) from the Item-tree,
|
|
1621 |
character-set-introducers should appear only for those literals, where
|
|
1622 |
they were explicitly specified by the user. Otherwise, that may lead to
|
|
1623 |
loss collation information (character set introducers implies default
|
|
1624 |
collation for the literal).
|
|
1625 |
||
1626 |
Basically, that makes sense only for views and hopefully will be gone
|
|
1627 |
one day when we start using original query as a view definition.
|
|
1628 |
||
1629 |
@return This operation returns the value of m_cs_specified attribute.
|
|
163
by Brian Aker
Merge Monty's code. |
1630 |
@retval true if character set introducer was explicitly specified in
|
1
by brian
clean slate |
1631 |
the original query.
|
163
by Brian Aker
Merge Monty's code. |
1632 |
@retval false otherwise.
|
1
by brian
clean slate |
1633 |
*/
|
1634 |
inline bool is_cs_specified() const |
|
1635 |
{
|
|
1636 |
return m_cs_specified; |
|
1637 |
}
|
|
1638 |
||
1639 |
/**
|
|
1640 |
Set the value of m_cs_specified attribute.
|
|
1641 |
||
1642 |
m_cs_specified attribute shows whether character-set-introducer was
|
|
1643 |
explicitly specified in the original query for this text literal or
|
|
1644 |
not. The attribute makes sense (is used) only for views.
|
|
1645 |
||
1646 |
This operation is to be called from the parser during parsing an input
|
|
1647 |
query.
|
|
1648 |
*/
|
|
1649 |
inline void set_cs_specified(bool cs_specified) |
|
1650 |
{
|
|
1651 |
m_cs_specified= cs_specified; |
|
1652 |
}
|
|
1653 |
||
1654 |
private: |
|
1655 |
bool m_cs_specified; |
|
1656 |
};
|
|
1657 |
||
1658 |
||
1659 |
class Item_static_string_func :public Item_string |
|
1660 |
{
|
|
1661 |
const char *func_name; |
|
1662 |
public: |
|
1663 |
Item_static_string_func(const char *name_par, const char *str, uint length, |
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
1664 |
const CHARSET_INFO * const cs, |
1
by brian
clean slate |
1665 |
Derivation dv= DERIVATION_COERCIBLE) |
461
by Monty Taylor
Removed NullS. bu-bye. |
1666 |
:Item_string(NULL, str, length, cs, dv), func_name(name_par) |
1
by brian
clean slate |
1667 |
{}
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
1668 |
Item *safe_charset_converter(const CHARSET_INFO * const tocs); |
1
by brian
clean slate |
1669 |
|
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
1670 |
virtual inline void print(String *str, |
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
1671 |
enum_query_type query_type __attribute__((unused))) |
1
by brian
clean slate |
1672 |
{
|
1673 |
str->append(func_name); |
|
1674 |
}
|
|
1675 |
};
|
|
1676 |
||
1677 |
||
1678 |
/* for show tables */
|
|
1679 |
class Item_return_date_time :public Item_string |
|
1680 |
{
|
|
1681 |
enum_field_types date_time_field_type; |
|
1682 |
public: |
|
1683 |
Item_return_date_time(const char *name_arg, enum_field_types field_type_arg) |
|
1684 |
:Item_string(name_arg, 0, &my_charset_bin), |
|
1685 |
date_time_field_type(field_type_arg) |
|
1686 |
{ } |
|
1687 |
enum_field_types field_type() const { return date_time_field_type; } |
|
1688 |
};
|
|
1689 |
||
1690 |
||
1691 |
class Item_blob :public Item_string |
|
1692 |
{
|
|
1693 |
public: |
|
1694 |
Item_blob(const char *name, uint length) : |
|
1695 |
Item_string(name, length, &my_charset_bin) |
|
1696 |
{ max_length= length; } |
|
1697 |
enum Type type() const { return TYPE_HOLDER; } |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1698 |
enum_field_types field_type() const { return DRIZZLE_TYPE_BLOB; } |
1
by brian
clean slate |
1699 |
};
|
1700 |
||
1701 |
||
1702 |
/**
|
|
1703 |
Item_empty_string -- is a utility class to put an item into List<Item>
|
|
1704 |
which is then used in protocol.send_fields() when sending SHOW output to
|
|
1705 |
the client.
|
|
1706 |
*/
|
|
1707 |
||
1708 |
class Item_empty_string :public Item_string |
|
1709 |
{
|
|
1710 |
public: |
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
1711 |
Item_empty_string(const char *header,uint length, const CHARSET_INFO * cs= NULL) : |
1
by brian
clean slate |
1712 |
Item_string("",0, cs ? cs : &my_charset_utf8_general_ci) |
1713 |
{ name=(char*) header; max_length= cs ? length * cs->mbmaxlen : length; } |
|
1714 |
void make_field(Send_field *field); |
|
1715 |
};
|
|
1716 |
||
1717 |
||
1718 |
class Item_return_int :public Item_int |
|
1719 |
{
|
|
1720 |
enum_field_types int_field_type; |
|
1721 |
public: |
|
1722 |
Item_return_int(const char *name_arg, uint length, |
|
152
by Brian Aker
longlong replacement |
1723 |
enum_field_types field_type_arg, int64_t value= 0) |
1
by brian
clean slate |
1724 |
:Item_int(name_arg, value, length), int_field_type(field_type_arg) |
1725 |
{
|
|
1726 |
unsigned_flag=1; |
|
1727 |
}
|
|
1728 |
enum_field_types field_type() const { return int_field_type; } |
|
1729 |
};
|
|
1730 |
||
1731 |
||
1732 |
class Item_hex_string: public Item_basic_constant |
|
1733 |
{
|
|
1734 |
public: |
|
1735 |
Item_hex_string() {} |
|
1736 |
Item_hex_string(const char *str,uint str_length); |
|
1737 |
enum Type type() const { return VARBIN_ITEM; } |
|
1738 |
double val_real() |
|
1739 |
{
|
|
51.1.55
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE - 1st clean pass on item.h/cc |
1740 |
assert(fixed == 1); |
151
by Brian Aker
Ulonglong to uint64_t |
1741 |
return (double) (uint64_t) Item_hex_string::val_int(); |
1
by brian
clean slate |
1742 |
}
|
152
by Brian Aker
longlong replacement |
1743 |
int64_t val_int(); |
1
by brian
clean slate |
1744 |
bool basic_const_item() const { return 1; } |
51.1.55
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE - 1st clean pass on item.h/cc |
1745 |
String *val_str(String*) { assert(fixed == 1); return &str_value; } |
1
by brian
clean slate |
1746 |
my_decimal *val_decimal(my_decimal *); |
1747 |
int save_in_field(Field *field, bool no_conversions); |
|
1748 |
enum Item_result result_type () const { return STRING_RESULT; } |
|
1749 |
enum Item_result cast_to_int_type() const { return INT_RESULT; } |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
1750 |
enum_field_types field_type() const { return DRIZZLE_TYPE_VARCHAR; } |
1
by brian
clean slate |
1751 |
virtual void print(String *str, enum_query_type query_type); |
1752 |
bool eq(const Item *item, bool binary_cmp) const; |
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
1753 |
virtual Item *safe_charset_converter(const CHARSET_INFO * const tocs); |
1
by brian
clean slate |
1754 |
};
|
1755 |
||
1756 |
||
1757 |
class Item_bin_string: public Item_hex_string |
|
1758 |
{
|
|
1759 |
public: |
|
1760 |
Item_bin_string(const char *str,uint str_length); |
|
1761 |
};
|
|
1762 |
||
1763 |
class Item_result_field :public Item /* Item with result field */ |
|
1764 |
{
|
|
1765 |
public: |
|
1766 |
Field *result_field; /* Save result here */ |
|
1767 |
Item_result_field() :result_field(0) {} |
|
1768 |
// Constructor used for Item_sum/Item_cond_and/or (see Item comment)
|
|
1769 |
Item_result_field(THD *thd, Item_result_field *item): |
|
1770 |
Item(thd, item), result_field(item->result_field) |
|
1771 |
{}
|
|
1772 |
~Item_result_field() {} /* Required with gcc 2.95 */ |
|
1773 |
Field *get_tmp_table_field() { return result_field; } |
|
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
1774 |
Field *tmp_table_field(Table *t_arg __attribute__((unused))) |
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
1775 |
{ return result_field; } |
1
by brian
clean slate |
1776 |
table_map used_tables() const { return 1; } |
1777 |
virtual void fix_length_and_dec()=0; |
|
1778 |
void set_result_field(Field *field) { result_field= field; } |
|
1779 |
bool is_result_field() { return 1; } |
|
1780 |
void save_in_result_field(bool no_conversions) |
|
1781 |
{
|
|
1782 |
save_in_field(result_field, no_conversions); |
|
1783 |
}
|
|
1784 |
void cleanup(); |
|
1785 |
};
|
|
1786 |
||
1787 |
||
1788 |
class Item_ref :public Item_ident |
|
1789 |
{
|
|
1790 |
protected: |
|
1791 |
void set_properties(); |
|
1792 |
public: |
|
1793 |
enum Ref_Type { REF, DIRECT_REF, VIEW_REF, OUTER_REF }; |
|
1794 |
Field *result_field; /* Save result here */ |
|
1795 |
Item **ref; |
|
1796 |
Item_ref(Name_resolution_context *context_arg, |
|
1797 |
const char *db_arg, const char *table_name_arg, |
|
1798 |
const char *field_name_arg) |
|
1799 |
:Item_ident(context_arg, db_arg, table_name_arg, field_name_arg), |
|
1800 |
result_field(0), ref(0) {} |
|
1801 |
/*
|
|
1802 |
This constructor is used in two scenarios:
|
|
1803 |
A) *item = NULL
|
|
1804 |
No initialization is performed, fix_fields() call will be necessary.
|
|
1805 |
|
|
1806 |
B) *item points to an Item this Item_ref will refer to. This is
|
|
1807 |
used for GROUP BY. fix_fields() will not be called in this case,
|
|
1808 |
so we call set_properties to make this item "fixed". set_properties
|
|
1809 |
performs a subset of action Item_ref::fix_fields does, and this subset
|
|
1810 |
is enough for Item_ref's used in GROUP BY.
|
|
1811 |
|
|
1812 |
TODO we probably fix a superset of problems like in BUG#6658. Check this
|
|
1813 |
with Bar, and if we have a more broader set of problems like this.
|
|
1814 |
*/
|
|
1815 |
Item_ref(Name_resolution_context *context_arg, Item **item, |
|
1816 |
const char *table_name_arg, const char *field_name_arg, |
|
163
by Brian Aker
Merge Monty's code. |
1817 |
bool alias_name_used_arg= false); |
1
by brian
clean slate |
1818 |
|
1819 |
/* Constructor need to process subselect with temporary tables (see Item) */
|
|
1820 |
Item_ref(THD *thd, Item_ref *item) |
|
1821 |
:Item_ident(thd, item), result_field(item->result_field), ref(item->ref) {} |
|
1822 |
enum Type type() const { return REF_ITEM; } |
|
1823 |
bool eq(const Item *item, bool binary_cmp) const |
|
1824 |
{
|
|
1825 |
Item *it= ((Item *) item)->real_item(); |
|
1826 |
return ref && (*ref)->eq(it, binary_cmp); |
|
1827 |
}
|
|
1828 |
double val_real(); |
|
152
by Brian Aker
longlong replacement |
1829 |
int64_t val_int(); |
1
by brian
clean slate |
1830 |
my_decimal *val_decimal(my_decimal *); |
1831 |
bool val_bool(); |
|
1832 |
String *val_str(String* tmp); |
|
1833 |
bool is_null(); |
|
236.1.24
by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME. |
1834 |
bool get_date(DRIZZLE_TIME *ltime,uint fuzzydate); |
1
by brian
clean slate |
1835 |
double val_result(); |
152
by Brian Aker
longlong replacement |
1836 |
int64_t val_int_result(); |
1
by brian
clean slate |
1837 |
String *str_result(String* tmp); |
1838 |
my_decimal *val_decimal_result(my_decimal *); |
|
1839 |
bool val_bool_result(); |
|
1840 |
bool send(Protocol *prot, String *tmp); |
|
1841 |
void make_field(Send_field *field); |
|
1842 |
bool fix_fields(THD *, Item **); |
|
1843 |
void fix_after_pullout(st_select_lex *new_parent, Item **ref); |
|
1844 |
int save_in_field(Field *field, bool no_conversions); |
|
1845 |
void save_org_in_field(Field *field); |
|
1846 |
enum Item_result result_type () const { return (*ref)->result_type(); } |
|
1847 |
enum_field_types field_type() const { return (*ref)->field_type(); } |
|
1848 |
Field *get_tmp_table_field() |
|
1849 |
{ return result_field ? result_field : (*ref)->get_tmp_table_field(); } |
|
1850 |
Item *get_tmp_table_item(THD *thd); |
|
1851 |
table_map used_tables() const |
|
1852 |
{
|
|
1853 |
return depended_from ? OUTER_REF_TABLE_BIT : (*ref)->used_tables(); |
|
1854 |
}
|
|
1855 |
void update_used_tables() |
|
1856 |
{
|
|
1857 |
if (!depended_from) |
|
1858 |
(*ref)->update_used_tables(); |
|
1859 |
}
|
|
1860 |
table_map not_null_tables() const { return (*ref)->not_null_tables(); } |
|
1861 |
void set_result_field(Field *field) { result_field= field; } |
|
1862 |
bool is_result_field() { return 1; } |
|
1863 |
void save_in_result_field(bool no_conversions) |
|
1864 |
{
|
|
1865 |
(*ref)->save_in_field(result_field, no_conversions); |
|
1866 |
}
|
|
1867 |
Item *real_item() |
|
1868 |
{
|
|
1869 |
return ref ? (*ref)->real_item() : this; |
|
1870 |
}
|
|
1871 |
bool walk(Item_processor processor, bool walk_subquery, uchar *arg) |
|
1872 |
{ return (*ref)->walk(processor, walk_subquery, arg); } |
|
1873 |
virtual void print(String *str, enum_query_type query_type); |
|
152
by Brian Aker
longlong replacement |
1874 |
bool result_as_int64_t() |
1
by brian
clean slate |
1875 |
{
|
152
by Brian Aker
longlong replacement |
1876 |
return (*ref)->result_as_int64_t(); |
1
by brian
clean slate |
1877 |
}
|
1878 |
void cleanup(); |
|
1879 |
Item_field *filed_for_view_update() |
|
1880 |
{ return (*ref)->filed_for_view_update(); } |
|
1881 |
virtual Ref_Type ref_type() { return REF; } |
|
1882 |
||
1883 |
// Row emulation: forwarding of ROW-related calls to ref
|
|
1884 |
uint cols() |
|
1885 |
{
|
|
1886 |
return ref && result_type() == ROW_RESULT ? (*ref)->cols() : 1; |
|
1887 |
}
|
|
1888 |
Item* element_index(uint i) |
|
1889 |
{
|
|
1890 |
return ref && result_type() == ROW_RESULT ? (*ref)->element_index(i) : this; |
|
1891 |
}
|
|
1892 |
Item** addr(uint i) |
|
1893 |
{
|
|
1894 |
return ref && result_type() == ROW_RESULT ? (*ref)->addr(i) : 0; |
|
1895 |
}
|
|
1896 |
bool check_cols(uint c) |
|
1897 |
{
|
|
1898 |
return ref && result_type() == ROW_RESULT ? (*ref)->check_cols(c) |
|
1899 |
: Item::check_cols(c); |
|
1900 |
}
|
|
1901 |
bool null_inside() |
|
1902 |
{
|
|
1903 |
return ref && result_type() == ROW_RESULT ? (*ref)->null_inside() : 0; |
|
1904 |
}
|
|
1905 |
void bring_value() |
|
1906 |
{
|
|
1907 |
if (ref && result_type() == ROW_RESULT) |
|
1908 |
(*ref)->bring_value(); |
|
1909 |
}
|
|
1910 |
||
1911 |
};
|
|
1912 |
||
1913 |
||
1914 |
/*
|
|
1915 |
The same as Item_ref, but get value from val_* family of method to get
|
|
1916 |
value of item on which it referred instead of result* family.
|
|
1917 |
*/
|
|
1918 |
class Item_direct_ref :public Item_ref |
|
1919 |
{
|
|
1920 |
public: |
|
1921 |
Item_direct_ref(Name_resolution_context *context_arg, Item **item, |
|
1922 |
const char *table_name_arg, |
|
1923 |
const char *field_name_arg, |
|
163
by Brian Aker
Merge Monty's code. |
1924 |
bool alias_name_used_arg= false) |
1
by brian
clean slate |
1925 |
:Item_ref(context_arg, item, table_name_arg, |
1926 |
field_name_arg, alias_name_used_arg) |
|
1927 |
{}
|
|
1928 |
/* Constructor need to process subselect with temporary tables (see Item) */
|
|
1929 |
Item_direct_ref(THD *thd, Item_direct_ref *item) : Item_ref(thd, item) {} |
|
1930 |
||
1931 |
double val_real(); |
|
152
by Brian Aker
longlong replacement |
1932 |
int64_t val_int(); |
1
by brian
clean slate |
1933 |
String *val_str(String* tmp); |
1934 |
my_decimal *val_decimal(my_decimal *); |
|
1935 |
bool val_bool(); |
|
1936 |
bool is_null(); |
|
236.1.24
by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME. |
1937 |
bool get_date(DRIZZLE_TIME *ltime,uint fuzzydate); |
1
by brian
clean slate |
1938 |
virtual Ref_Type ref_type() { return DIRECT_REF; } |
1939 |
};
|
|
1940 |
||
1941 |
/*
|
|
1942 |
Class for view fields, the same as Item_direct_ref, but call fix_fields
|
|
1943 |
of reference if it is not called yet
|
|
1944 |
*/
|
|
1945 |
class Item_direct_view_ref :public Item_direct_ref |
|
1946 |
{
|
|
1947 |
public: |
|
1948 |
Item_direct_view_ref(Name_resolution_context *context_arg, Item **item, |
|
1949 |
const char *table_name_arg, |
|
1950 |
const char *field_name_arg) |
|
1951 |
:Item_direct_ref(context_arg, item, table_name_arg, field_name_arg) {} |
|
1952 |
/* Constructor need to process subselect with temporary tables (see Item) */
|
|
1953 |
Item_direct_view_ref(THD *thd, Item_direct_ref *item) |
|
1954 |
:Item_direct_ref(thd, item) {} |
|
1955 |
||
1956 |
bool fix_fields(THD *, Item **); |
|
1957 |
bool eq(const Item *item, bool binary_cmp) const; |
|
1958 |
Item *get_tmp_table_item(THD *thd) |
|
1959 |
{
|
|
1960 |
Item *item= Item_ref::get_tmp_table_item(thd); |
|
1961 |
item->name= name; |
|
1962 |
return item; |
|
1963 |
}
|
|
1964 |
virtual Ref_Type ref_type() { return VIEW_REF; } |
|
1965 |
};
|
|
1966 |
||
1967 |
||
1968 |
/*
|
|
1969 |
Class for outer fields.
|
|
1970 |
An object of this class is created when the select where the outer field was
|
|
1971 |
resolved is a grouping one. After it has been fixed the ref field will point
|
|
1972 |
to either an Item_ref or an Item_direct_ref object which will be used to
|
|
1973 |
access the field.
|
|
1974 |
See also comments for the fix_inner_refs() and the
|
|
1975 |
Item_field::fix_outer_field() functions.
|
|
1976 |
*/
|
|
1977 |
||
1978 |
class Item_sum; |
|
1979 |
class Item_outer_ref :public Item_direct_ref |
|
1980 |
{
|
|
1981 |
public: |
|
1982 |
Item *outer_ref; |
|
1983 |
/* The aggregate function under which this outer ref is used, if any. */
|
|
1984 |
Item_sum *in_sum_func; |
|
1985 |
/*
|
|
163
by Brian Aker
Merge Monty's code. |
1986 |
true <=> that the outer_ref is already present in the select list
|
1
by brian
clean slate |
1987 |
of the outer select.
|
1988 |
*/
|
|
1989 |
bool found_in_select_list; |
|
1990 |
Item_outer_ref(Name_resolution_context *context_arg, |
|
1991 |
Item_field *outer_field_arg) |
|
1992 |
:Item_direct_ref(context_arg, 0, outer_field_arg->table_name, |
|
1993 |
outer_field_arg->field_name), |
|
1994 |
outer_ref(outer_field_arg), in_sum_func(0), |
|
1995 |
found_in_select_list(0) |
|
1996 |
{
|
|
1997 |
ref= &outer_ref; |
|
1998 |
set_properties(); |
|
1999 |
fixed= 0; |
|
2000 |
}
|
|
2001 |
Item_outer_ref(Name_resolution_context *context_arg, Item **item, |
|
2002 |
const char *table_name_arg, const char *field_name_arg, |
|
2003 |
bool alias_name_used_arg) |
|
2004 |
:Item_direct_ref(context_arg, item, table_name_arg, field_name_arg, |
|
2005 |
alias_name_used_arg), |
|
2006 |
outer_ref(0), in_sum_func(0), found_in_select_list(1) |
|
2007 |
{}
|
|
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
2008 |
void save_in_result_field(bool no_conversions __attribute__((unused))) |
1
by brian
clean slate |
2009 |
{
|
2010 |
outer_ref->save_org_in_field(result_field); |
|
2011 |
}
|
|
2012 |
bool fix_fields(THD *, Item **); |
|
2013 |
void fix_after_pullout(st_select_lex *new_parent, Item **ref); |
|
2014 |
table_map used_tables() const |
|
2015 |
{
|
|
2016 |
return (*ref)->const_item() ? 0 : OUTER_REF_TABLE_BIT; |
|
2017 |
}
|
|
2018 |
virtual Ref_Type ref_type() { return OUTER_REF; } |
|
2019 |
};
|
|
2020 |
||
2021 |
||
2022 |
class Item_in_subselect; |
|
2023 |
||
2024 |
||
2025 |
/*
|
|
2026 |
An object of this class:
|
|
2027 |
- Converts val_XXX() calls to ref->val_XXX_result() calls, like Item_ref.
|
|
163
by Brian Aker
Merge Monty's code. |
2028 |
- Sets owner->was_null=true if it has returned a NULL value from any
|
1
by brian
clean slate |
2029 |
val_XXX() function. This allows to inject an Item_ref_null_helper
|
2030 |
object into subquery and then check if the subquery has produced a row
|
|
2031 |
with NULL value.
|
|
2032 |
*/
|
|
2033 |
||
2034 |
class Item_ref_null_helper: public Item_ref |
|
2035 |
{
|
|
2036 |
protected: |
|
2037 |
Item_in_subselect* owner; |
|
2038 |
public: |
|
2039 |
Item_ref_null_helper(Name_resolution_context *context_arg, |
|
2040 |
Item_in_subselect* master, Item **item, |
|
2041 |
const char *table_name_arg, const char *field_name_arg) |
|
2042 |
:Item_ref(context_arg, item, table_name_arg, field_name_arg), |
|
2043 |
owner(master) {} |
|
2044 |
double val_real(); |
|
152
by Brian Aker
longlong replacement |
2045 |
int64_t val_int(); |
1
by brian
clean slate |
2046 |
String* val_str(String* s); |
2047 |
my_decimal *val_decimal(my_decimal *); |
|
2048 |
bool val_bool(); |
|
236.1.24
by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME. |
2049 |
bool get_date(DRIZZLE_TIME *ltime, uint fuzzydate); |
1
by brian
clean slate |
2050 |
virtual void print(String *str, enum_query_type query_type); |
2051 |
/*
|
|
2052 |
we add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE
|
|
2053 |
*/
|
|
2054 |
table_map used_tables() const |
|
2055 |
{
|
|
2056 |
return (depended_from ? |
|
2057 |
OUTER_REF_TABLE_BIT : |
|
2058 |
(*ref)->used_tables() | RAND_TABLE_BIT); |
|
2059 |
}
|
|
2060 |
};
|
|
2061 |
||
2062 |
/*
|
|
2063 |
The following class is used to optimize comparing of date and bigint columns
|
|
2064 |
We need to save the original item ('ref') to be able to call
|
|
2065 |
ref->save_in_field(). This is used to create index search keys.
|
|
2066 |
|
|
2067 |
An instance of Item_int_with_ref may have signed or unsigned integer value.
|
|
2068 |
|
|
2069 |
*/
|
|
2070 |
||
2071 |
class Item_int_with_ref :public Item_int |
|
2072 |
{
|
|
2073 |
Item *ref; |
|
2074 |
public: |
|
275
by Brian Aker
Full removal of my_bool from central server. |
2075 |
Item_int_with_ref(int64_t i, Item *ref_arg, bool unsigned_arg) : |
1
by brian
clean slate |
2076 |
Item_int(i), ref(ref_arg) |
2077 |
{
|
|
2078 |
unsigned_flag= unsigned_arg; |
|
2079 |
}
|
|
2080 |
int save_in_field(Field *field, bool no_conversions) |
|
2081 |
{
|
|
2082 |
return ref->save_in_field(field, no_conversions); |
|
2083 |
}
|
|
2084 |
Item *clone_item(); |
|
2085 |
virtual Item *real_item() { return ref; } |
|
2086 |
};
|
|
2087 |
||
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
2088 |
#ifdef DRIZZLE_SERVER
|
1
by brian
clean slate |
2089 |
#include "item_sum.h" |
2090 |
#include "item_func.h" |
|
2091 |
#include "item_row.h" |
|
2092 |
#include "item_cmpfunc.h" |
|
2093 |
#include "item_strfunc.h" |
|
2094 |
#include "item_timefunc.h" |
|
2095 |
#include "item_subselect.h" |
|
2096 |
#endif
|
|
2097 |
||
2098 |
class Item_copy_string :public Item |
|
2099 |
{
|
|
2100 |
enum enum_field_types cached_field_type; |
|
2101 |
public: |
|
2102 |
Item *item; |
|
2103 |
Item_copy_string(Item *i) :item(i) |
|
2104 |
{
|
|
275
by Brian Aker
Full removal of my_bool from central server. |
2105 |
null_value= maybe_null= item->maybe_null; |
1
by brian
clean slate |
2106 |
decimals=item->decimals; |
2107 |
max_length=item->max_length; |
|
2108 |
name=item->name; |
|
2109 |
cached_field_type= item->field_type(); |
|
2110 |
}
|
|
2111 |
enum Type type() const { return COPY_STR_ITEM; } |
|
2112 |
enum Item_result result_type () const { return STRING_RESULT; } |
|
2113 |
enum_field_types field_type() const { return cached_field_type; } |
|
2114 |
double val_real() |
|
2115 |
{
|
|
2116 |
int err_not_used; |
|
2117 |
char *end_not_used; |
|
2118 |
return (null_value ? 0.0 : |
|
398.1.8
by Monty Taylor
Enabled -Wlong-long. |
2119 |
my_strntod(str_value.charset(), (char*) str_value.ptr(), |
2120 |
str_value.length(), &end_not_used, &err_not_used)); |
|
1
by brian
clean slate |
2121 |
}
|
152
by Brian Aker
longlong replacement |
2122 |
int64_t val_int() |
1
by brian
clean slate |
2123 |
{
|
2124 |
int err; |
|
398.1.8
by Monty Taylor
Enabled -Wlong-long. |
2125 |
return null_value ? 0 : my_strntoll(str_value.charset(),str_value.ptr(), |
2126 |
str_value.length(),10, (char**) 0, |
|
2127 |
&err); |
|
1
by brian
clean slate |
2128 |
}
|
2129 |
String *val_str(String*); |
|
2130 |
my_decimal *val_decimal(my_decimal *); |
|
2131 |
void make_field(Send_field *field) { item->make_field(field); } |
|
2132 |
void copy(); |
|
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
2133 |
int save_in_field(Field *field, |
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
2134 |
bool no_conversions __attribute__((unused))) |
1
by brian
clean slate |
2135 |
{
|
2136 |
return save_str_value_in_field(field, &str_value); |
|
2137 |
}
|
|
2138 |
table_map used_tables() const { return (table_map) 1L; } |
|
2139 |
bool const_item() const { return 0; } |
|
2140 |
bool is_null() { return null_value; } |
|
2141 |
};
|
|
2142 |
||
2143 |
||
2144 |
class Cached_item :public Sql_alloc |
|
2145 |
{
|
|
2146 |
public: |
|
275
by Brian Aker
Full removal of my_bool from central server. |
2147 |
bool null_value; |
1
by brian
clean slate |
2148 |
Cached_item() :null_value(0) {} |
2149 |
virtual bool cmp(void)=0; |
|
2150 |
virtual ~Cached_item(); /*line -e1509 */ |
|
2151 |
};
|
|
2152 |
||
2153 |
class Cached_item_str :public Cached_item |
|
2154 |
{
|
|
2155 |
Item *item; |
|
2156 |
String value,tmp_value; |
|
2157 |
public: |
|
2158 |
Cached_item_str(THD *thd, Item *arg); |
|
2159 |
bool cmp(void); |
|
2160 |
~Cached_item_str(); // Deallocate String:s |
|
2161 |
};
|
|
2162 |
||
2163 |
||
2164 |
class Cached_item_real :public Cached_item |
|
2165 |
{
|
|
2166 |
Item *item; |
|
2167 |
double value; |
|
2168 |
public: |
|
2169 |
Cached_item_real(Item *item_par) :item(item_par),value(0.0) {} |
|
2170 |
bool cmp(void); |
|
2171 |
};
|
|
2172 |
||
2173 |
class Cached_item_int :public Cached_item |
|
2174 |
{
|
|
2175 |
Item *item; |
|
152
by Brian Aker
longlong replacement |
2176 |
int64_t value; |
1
by brian
clean slate |
2177 |
public: |
2178 |
Cached_item_int(Item *item_par) :item(item_par),value(0) {} |
|
2179 |
bool cmp(void); |
|
2180 |
};
|
|
2181 |
||
2182 |
||
2183 |
class Cached_item_decimal :public Cached_item |
|
2184 |
{
|
|
2185 |
Item *item; |
|
2186 |
my_decimal value; |
|
2187 |
public: |
|
2188 |
Cached_item_decimal(Item *item_par); |
|
2189 |
bool cmp(void); |
|
2190 |
};
|
|
2191 |
||
2192 |
class Cached_item_field :public Cached_item |
|
2193 |
{
|
|
2194 |
uchar *buff; |
|
2195 |
Field *field; |
|
2196 |
uint length; |
|
2197 |
||
2198 |
public: |
|
2199 |
Cached_item_field(Field *arg_field) : field(arg_field) |
|
2200 |
{
|
|
2201 |
field= arg_field; |
|
2202 |
/* TODO: take the memory allocation below out of the constructor. */
|
|
2203 |
buff= (uchar*) sql_calloc(length=field->pack_length()); |
|
2204 |
}
|
|
2205 |
bool cmp(void); |
|
2206 |
};
|
|
2207 |
||
2208 |
class Item_default_value : public Item_field |
|
2209 |
{
|
|
2210 |
public: |
|
2211 |
Item *arg; |
|
2212 |
Item_default_value(Name_resolution_context *context_arg) |
|
2213 |
:Item_field(context_arg, (const char *)NULL, (const char *)NULL, |
|
2214 |
(const char *)NULL), |
|
2215 |
arg(NULL) {} |
|
2216 |
Item_default_value(Name_resolution_context *context_arg, Item *a) |
|
2217 |
:Item_field(context_arg, (const char *)NULL, (const char *)NULL, |
|
2218 |
(const char *)NULL), |
|
2219 |
arg(a) {} |
|
2220 |
enum Type type() const { return DEFAULT_VALUE_ITEM; } |
|
2221 |
bool eq(const Item *item, bool binary_cmp) const; |
|
2222 |
bool fix_fields(THD *, Item **); |
|
2223 |
virtual void print(String *str, enum_query_type query_type); |
|
2224 |
int save_in_field(Field *field_arg, bool no_conversions); |
|
2225 |
table_map used_tables() const { return (table_map)0L; } |
|
2226 |
||
2227 |
bool walk(Item_processor processor, bool walk_subquery, uchar *args) |
|
2228 |
{
|
|
2229 |
return arg->walk(processor, walk_subquery, args) || |
|
2230 |
(this->*processor)(args); |
|
2231 |
}
|
|
2232 |
||
2233 |
Item *transform(Item_transformer transformer, uchar *args); |
|
2234 |
};
|
|
2235 |
||
2236 |
/*
|
|
2237 |
Item_insert_value -- an implementation of VALUES() function.
|
|
2238 |
You can use the VALUES(col_name) function in the UPDATE clause
|
|
2239 |
to refer to column values from the INSERT portion of the INSERT
|
|
2240 |
... UPDATE statement. In other words, VALUES(col_name) in the
|
|
2241 |
UPDATE clause refers to the value of col_name that would be
|
|
2242 |
inserted, had no duplicate-key conflict occurred.
|
|
2243 |
In all other places this function returns NULL.
|
|
2244 |
*/
|
|
2245 |
||
2246 |
class Item_insert_value : public Item_field |
|
2247 |
{
|
|
2248 |
public: |
|
2249 |
Item *arg; |
|
2250 |
Item_insert_value(Name_resolution_context *context_arg, Item *a) |
|
2251 |
:Item_field(context_arg, (const char *)NULL, (const char *)NULL, |
|
2252 |
(const char *)NULL), |
|
2253 |
arg(a) {} |
|
2254 |
bool eq(const Item *item, bool binary_cmp) const; |
|
2255 |
bool fix_fields(THD *, Item **); |
|
2256 |
virtual void print(String *str, enum_query_type query_type); |
|
2257 |
int save_in_field(Field *field_arg, bool no_conversions) |
|
2258 |
{
|
|
2259 |
return Item_field::save_in_field(field_arg, no_conversions); |
|
2260 |
}
|
|
2261 |
/*
|
|
2262 |
We use RAND_TABLE_BIT to prevent Item_insert_value from
|
|
2263 |
being treated as a constant and precalculated before execution
|
|
2264 |
*/
|
|
2265 |
table_map used_tables() const { return RAND_TABLE_BIT; } |
|
2266 |
||
2267 |
bool walk(Item_processor processor, bool walk_subquery, uchar *args) |
|
2268 |
{
|
|
2269 |
return arg->walk(processor, walk_subquery, args) || |
|
2270 |
(this->*processor)(args); |
|
2271 |
}
|
|
2272 |
};
|
|
2273 |
||
2274 |
||
2275 |
class Item_cache: public Item_basic_constant |
|
2276 |
{
|
|
2277 |
protected: |
|
2278 |
Item *example; |
|
2279 |
table_map used_table_map; |
|
2280 |
/*
|
|
2281 |
Field that this object will get value from. This is set/used by
|
|
2282 |
index-based subquery engines to detect and remove the equality injected
|
|
2283 |
by IN->EXISTS transformation.
|
|
2284 |
For all other uses of Item_cache, cached_field doesn't matter.
|
|
2285 |
*/
|
|
2286 |
Field *cached_field; |
|
2287 |
enum enum_field_types cached_field_type; |
|
2288 |
public: |
|
2289 |
Item_cache(): |
|
241
by Brian Aker
First pass of CHAR removal. |
2290 |
example(0), used_table_map(0), cached_field(0), cached_field_type(DRIZZLE_TYPE_VARCHAR) |
1
by brian
clean slate |
2291 |
{
|
2292 |
fixed= 1; |
|
2293 |
null_value= 1; |
|
2294 |
}
|
|
2295 |
Item_cache(enum_field_types field_type_arg): |
|
2296 |
example(0), used_table_map(0), cached_field(0), cached_field_type(field_type_arg) |
|
2297 |
{
|
|
2298 |
fixed= 1; |
|
2299 |
null_value= 1; |
|
2300 |
}
|
|
2301 |
||
2302 |
void set_used_tables(table_map map) { used_table_map= map; } |
|
2303 |
||
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
2304 |
virtual bool allocate(uint i __attribute__((unused))) |
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
2305 |
{ return 0; } |
1
by brian
clean slate |
2306 |
virtual bool setup(Item *item) |
2307 |
{
|
|
2308 |
example= item; |
|
2309 |
max_length= item->max_length; |
|
2310 |
decimals= item->decimals; |
|
2311 |
collation.set(item->collation); |
|
2312 |
unsigned_flag= item->unsigned_flag; |
|
2313 |
if (item->type() == FIELD_ITEM) |
|
2314 |
cached_field= ((Item_field *)item)->field; |
|
2315 |
return 0; |
|
2316 |
};
|
|
2317 |
virtual void store(Item *)= 0; |
|
2318 |
enum Type type() const { return CACHE_ITEM; } |
|
2319 |
enum_field_types field_type() const { return cached_field_type; } |
|
2320 |
static Item_cache* get_cache(const Item *item); |
|
2321 |
table_map used_tables() const { return used_table_map; } |
|
2322 |
virtual void keep_array() {} |
|
2323 |
virtual void print(String *str, enum_query_type query_type); |
|
2324 |
bool eq_def(Field *field) |
|
2325 |
{
|
|
163
by Brian Aker
Merge Monty's code. |
2326 |
return cached_field ? cached_field->eq_def (field) : false; |
1
by brian
clean slate |
2327 |
}
|
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
2328 |
bool eq(const Item *item, |
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
2329 |
bool binary_cmp __attribute__((unused))) const |
1
by brian
clean slate |
2330 |
{
|
2331 |
return this == item; |
|
2332 |
}
|
|
2333 |
};
|
|
2334 |
||
2335 |
||
2336 |
class Item_cache_int: public Item_cache |
|
2337 |
{
|
|
2338 |
protected: |
|
152
by Brian Aker
longlong replacement |
2339 |
int64_t value; |
1
by brian
clean slate |
2340 |
public: |
2341 |
Item_cache_int(): Item_cache(), value(0) {} |
|
2342 |
Item_cache_int(enum_field_types field_type_arg): |
|
2343 |
Item_cache(field_type_arg), value(0) {} |
|
2344 |
||
2345 |
void store(Item *item); |
|
152
by Brian Aker
longlong replacement |
2346 |
void store(Item *item, int64_t val_arg); |
51.1.55
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE - 1st clean pass on item.h/cc |
2347 |
double val_real() { assert(fixed == 1); return (double) value; } |
152
by Brian Aker
longlong replacement |
2348 |
int64_t val_int() { assert(fixed == 1); return value; } |
1
by brian
clean slate |
2349 |
String* val_str(String *str); |
2350 |
my_decimal *val_decimal(my_decimal *); |
|
2351 |
enum Item_result result_type() const { return INT_RESULT; } |
|
163
by Brian Aker
Merge Monty's code. |
2352 |
bool result_as_int64_t() { return true; } |
1
by brian
clean slate |
2353 |
};
|
2354 |
||
2355 |
||
2356 |
class Item_cache_real: public Item_cache |
|
2357 |
{
|
|
2358 |
double value; |
|
2359 |
public: |
|
2360 |
Item_cache_real(): Item_cache(), value(0) {} |
|
2361 |
||
2362 |
void store(Item *item); |
|
51.1.55
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE - 1st clean pass on item.h/cc |
2363 |
double val_real() { assert(fixed == 1); return value; } |
152
by Brian Aker
longlong replacement |
2364 |
int64_t val_int(); |
1
by brian
clean slate |
2365 |
String* val_str(String *str); |
2366 |
my_decimal *val_decimal(my_decimal *); |
|
2367 |
enum Item_result result_type() const { return REAL_RESULT; } |
|
2368 |
};
|
|
2369 |
||
2370 |
||
2371 |
class Item_cache_decimal: public Item_cache |
|
2372 |
{
|
|
2373 |
protected: |
|
2374 |
my_decimal decimal_value; |
|
2375 |
public: |
|
2376 |
Item_cache_decimal(): Item_cache() {} |
|
2377 |
||
2378 |
void store(Item *item); |
|
2379 |
double val_real(); |
|
152
by Brian Aker
longlong replacement |
2380 |
int64_t val_int(); |
1
by brian
clean slate |
2381 |
String* val_str(String *str); |
2382 |
my_decimal *val_decimal(my_decimal *); |
|
2383 |
enum Item_result result_type() const { return DECIMAL_RESULT; } |
|
2384 |
};
|
|
2385 |
||
2386 |
||
2387 |
class Item_cache_str: public Item_cache |
|
2388 |
{
|
|
2389 |
char buffer[STRING_BUFFER_USUAL_SIZE]; |
|
2390 |
String *value, value_buff; |
|
2391 |
bool is_varbinary; |
|
2392 |
||
2393 |
public: |
|
2394 |
Item_cache_str(const Item *item) : |
|
2395 |
Item_cache(), value(0), |
|
2396 |
is_varbinary(item->type() == FIELD_ITEM && |
|
2397 |
((const Item_field *) item)->field->type() == |
|
212.2.2
by Patrick Galbraith
Renamed FIELD_TYPE to DRIZZLE_TYPE |
2398 |
DRIZZLE_TYPE_VARCHAR && |
1
by brian
clean slate |
2399 |
!((const Item_field *) item)->field->has_charset()) |
2400 |
{}
|
|
2401 |
void store(Item *item); |
|
2402 |
double val_real(); |
|
152
by Brian Aker
longlong replacement |
2403 |
int64_t val_int(); |
51.1.55
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE - 1st clean pass on item.h/cc |
2404 |
String* val_str(String *) { assert(fixed == 1); return value; } |
1
by brian
clean slate |
2405 |
my_decimal *val_decimal(my_decimal *); |
2406 |
enum Item_result result_type() const { return STRING_RESULT; } |
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
2407 |
const CHARSET_INFO *charset() const { return value->charset(); }; |
1
by brian
clean slate |
2408 |
int save_in_field(Field *field, bool no_conversions); |
2409 |
};
|
|
2410 |
||
2411 |
class Item_cache_row: public Item_cache |
|
2412 |
{
|
|
2413 |
Item_cache **values; |
|
2414 |
uint item_count; |
|
2415 |
bool save_array; |
|
2416 |
public: |
|
2417 |
Item_cache_row() |
|
2418 |
:Item_cache(), values(0), item_count(2), save_array(0) {} |
|
2419 |
||
2420 |
/*
|
|
2421 |
'allocate' used only in row transformer, to preallocate space for row
|
|
2422 |
cache.
|
|
2423 |
*/
|
|
2424 |
bool allocate(uint num); |
|
2425 |
/*
|
|
2426 |
'setup' is needed only by row => it not called by simple row subselect
|
|
2427 |
(only by IN subselect (in subselect optimizer))
|
|
2428 |
*/
|
|
2429 |
bool setup(Item *item); |
|
2430 |
void store(Item *item); |
|
2431 |
void illegal_method_call(const char *); |
|
2432 |
void make_field(Send_field *) |
|
2433 |
{
|
|
2434 |
illegal_method_call((const char*)"make_field"); |
|
2435 |
};
|
|
2436 |
double val_real() |
|
2437 |
{
|
|
2438 |
illegal_method_call((const char*)"val"); |
|
2439 |
return 0; |
|
2440 |
};
|
|
152
by Brian Aker
longlong replacement |
2441 |
int64_t val_int() |
1
by brian
clean slate |
2442 |
{
|
2443 |
illegal_method_call((const char*)"val_int"); |
|
2444 |
return 0; |
|
2445 |
};
|
|
2446 |
String *val_str(String *) |
|
2447 |
{
|
|
2448 |
illegal_method_call((const char*)"val_str"); |
|
2449 |
return 0; |
|
2450 |
};
|
|
212.1.3
by Monty Taylor
Renamed __attribute__((__unused__)) to __attribute__((unused)). |
2451 |
my_decimal *val_decimal(my_decimal *val __attribute__((unused))) |
1
by brian
clean slate |
2452 |
{
|
2453 |
illegal_method_call((const char*)"val_decimal"); |
|
2454 |
return 0; |
|
2455 |
};
|
|
2456 |
||
2457 |
enum Item_result result_type() const { return ROW_RESULT; } |
|
2458 |
||
2459 |
uint cols() { return item_count; } |
|
2460 |
Item *element_index(uint i) { return values[i]; } |
|
2461 |
Item **addr(uint i) { return (Item **) (values + i); } |
|
2462 |
bool check_cols(uint c); |
|
2463 |
bool null_inside(); |
|
2464 |
void bring_value(); |
|
2465 |
void keep_array() { save_array= 1; } |
|
2466 |
void cleanup() |
|
2467 |
{
|
|
2468 |
Item_cache::cleanup(); |
|
2469 |
if (save_array) |
|
212.6.1
by Mats Kindahl
Replacing all bzero() calls with memset() calls and removing the bzero.c file. |
2470 |
memset(values, 0, item_count*sizeof(Item**)); |
1
by brian
clean slate |
2471 |
else
|
2472 |
values= 0; |
|
51.1.55
by Jay Pipes
Removed/replaced DBUG symbols and standardized TRUE/FALSE - 1st clean pass on item.h/cc |
2473 |
return; |
1
by brian
clean slate |
2474 |
}
|
2475 |
};
|
|
2476 |
||
2477 |
||
2478 |
/*
|
|
2479 |
Item_type_holder used to store type. name, length of Item for UNIONS &
|
|
2480 |
derived tables.
|
|
2481 |
||
2482 |
Item_type_holder do not need cleanup() because its time of live limited by
|
|
2483 |
single SP/PS execution.
|
|
2484 |
*/
|
|
2485 |
class Item_type_holder: public Item |
|
2486 |
{
|
|
2487 |
protected: |
|
2488 |
TYPELIB *enum_set_typelib; |
|
2489 |
enum_field_types fld_type; |
|
2490 |
||
2491 |
void get_full_info(Item *item); |
|
2492 |
||
2493 |
/* It is used to count decimal precision in join_types */
|
|
2494 |
int prev_decimal_int_part; |
|
2495 |
public: |
|
2496 |
Item_type_holder(THD*, Item*); |
|
2497 |
||
2498 |
Item_result result_type() const; |
|
2499 |
enum_field_types field_type() const { return fld_type; }; |
|
2500 |
enum Type type() const { return TYPE_HOLDER; } |
|
2501 |
double val_real(); |
|
152
by Brian Aker
longlong replacement |
2502 |
int64_t val_int(); |
1
by brian
clean slate |
2503 |
my_decimal *val_decimal(my_decimal *); |
2504 |
String *val_str(String*); |
|
2505 |
bool join_types(THD *thd, Item *); |
|
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
2506 |
Field *make_field_by_type(Table *table); |
203
by Brian Aker
Small cleanup around uint32 types (need to merge). |
2507 |
static uint32_t display_length(Item *item); |
1
by brian
clean slate |
2508 |
static enum_field_types get_real_type(Item *); |
2509 |
};
|
|
2510 |
||
2511 |
||
2512 |
class st_select_lex; |
|
2513 |
void mark_select_range_as_dependent(THD *thd, |
|
2514 |
st_select_lex *last_select, |
|
2515 |
st_select_lex *current_sel, |
|
2516 |
Field *found_field, Item *found_item, |
|
2517 |
Item_ident *resolved_item); |
|
2518 |
||
2519 |
extern Cached_item *new_Cached_item(THD *thd, Item *item, |
|
2520 |
bool use_result_field); |
|
2521 |
extern void resolve_const_item(THD *thd, Item **ref, Item *cmp_item); |
|
2522 |
extern bool field_is_equal_to_item(Field *field,Item *item); |