1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
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.
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.
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
20
#ifndef DRIZZLED_ITEM_H
21
#define DRIZZLED_ITEM_H
23
#include <drizzled/dtcollation.h>
24
#include <mysys/drizzle_time.h>
25
#include <drizzled/my_decimal.h>
26
#include <drizzled/sql_bitmap.h>
27
#include <drizzled/sql_list.h>
28
#include <drizzled/sql_alloc.h>
1
/* Copyright (C) 2000-2006 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
17
#ifdef USE_PRAGMA_INTERFACE
18
#pragma interface /* gcc class implementation */
23
void item_init(void); /* Init item functions */
33
class Name_resolution_context;
39
class Item_in_subselect;
43
void item_init(void); /* Init item functions */
46
void dummy_error_processor(Session *session, void *data);
47
void view_error_processor(Session *session, void *data);
50
/*************************************************************************/
27
"Declared Type Collation"
28
A combination of collation and its derivation.
30
Flags for collation aggregation modes:
31
MY_COLL_ALLOW_SUPERSET_CONV - allow conversion to a superset
32
MY_COLL_ALLOW_COERCIBLE_CONV - allow conversion of a coercible value
34
MY_COLL_ALLOW_CONV - allow any kind of conversion
35
(combination of the above two)
36
MY_COLL_DISALLOW_NONE - don't allow return DERIVATION_NONE
37
(e.g. when aggregating for comparison)
38
MY_COLL_CMP_CONV - combination of MY_COLL_ALLOW_CONV
39
and MY_COLL_DISALLOW_NONE
42
#define MY_COLL_ALLOW_SUPERSET_CONV 1
43
#define MY_COLL_ALLOW_COERCIBLE_CONV 2
44
#define MY_COLL_ALLOW_CONV 3
45
#define MY_COLL_DISALLOW_NONE 4
46
#define MY_COLL_CMP_CONV 7
50
CHARSET_INFO *collation;
51
enum Derivation derivation;
54
void set_repertoire_from_charset(CHARSET_INFO *cs)
56
repertoire= cs->state & MY_CS_PUREASCII ?
57
MY_REPERTOIRE_ASCII : MY_REPERTOIRE_UNICODE30;
61
collation= &my_charset_bin;
62
derivation= DERIVATION_NONE;
63
repertoire= MY_REPERTOIRE_UNICODE30;
65
DTCollation(CHARSET_INFO *collation_arg, Derivation derivation_arg)
67
collation= collation_arg;
68
derivation= derivation_arg;
69
set_repertoire_from_charset(collation_arg);
71
void set(DTCollation &dt)
73
collation= dt.collation;
74
derivation= dt.derivation;
75
repertoire= dt.repertoire;
77
void set(CHARSET_INFO *collation_arg, Derivation derivation_arg)
79
collation= collation_arg;
80
derivation= derivation_arg;
81
set_repertoire_from_charset(collation_arg);
83
void set(CHARSET_INFO *collation_arg,
84
Derivation derivation_arg,
87
collation= collation_arg;
88
derivation= derivation_arg;
89
repertoire= repertoire_arg;
91
void set(CHARSET_INFO *collation_arg)
93
collation= collation_arg;
94
set_repertoire_from_charset(collation_arg);
96
void set(Derivation derivation_arg)
97
{ derivation= derivation_arg; }
98
bool aggregate(DTCollation &dt, uint flags= 0);
99
bool set(DTCollation &dt1, DTCollation &dt2, uint flags= 0)
100
{ set(dt1); return aggregate(dt2, flags); }
101
const char *derivation_name() const
105
case DERIVATION_IGNORABLE: return "IGNORABLE";
106
case DERIVATION_COERCIBLE: return "COERCIBLE";
107
case DERIVATION_IMPLICIT: return "IMPLICIT";
108
case DERIVATION_SYSCONST: return "SYSCONST";
109
case DERIVATION_EXPLICIT: return "EXPLICIT";
110
case DERIVATION_NONE: return "NONE";
111
default: return "UNKNOWN";
116
/*************************************************************************/
118
A framework to easily handle different return types for hybrid items
119
(hybrid item is an item whose operand can be of any type, e.g. integer,
123
struct Hybrid_type_traits;
131
Use two decimal buffers interchangeably to speed up += operation
132
which has no native support in decimal library.
133
Hybrid_type+= arg is implemented as dec_buf[1]= dec_buf[0] + arg.
134
The third decimal is used as a handy temporary storage.
136
my_decimal dec_buf[3];
140
Traits moved to a separate class to
141
a) be able to easily change object traits in runtime
142
b) they work as a differentiator for the union above
144
const Hybrid_type_traits *traits;
147
/* XXX: add traits->copy() when needed */
148
Hybrid_type(const Hybrid_type &rhs) :traits(rhs.traits) {}
152
/* Hybryd_type_traits interface + default implementation for REAL_RESULT */
154
struct Hybrid_type_traits
156
virtual Item_result type() const { return REAL_RESULT; }
159
fix_length_and_dec(Item *item, Item *arg) const;
161
/* Hybrid_type operations. */
162
virtual void set_zero(Hybrid_type *val) const { val->real= 0.0; }
163
virtual void add(Hybrid_type *val, Field *f) const
164
{ val->real+= f->val_real(); }
165
virtual void div(Hybrid_type *val, uint64_t u) const
166
{ val->real/= uint64_t2double(u); }
168
virtual int64_t val_int(Hybrid_type *val,
169
bool unsigned_flag __attribute__((unused))) const
170
{ return (int64_t) rint(val->real); }
171
virtual double val_real(Hybrid_type *val) const { return val->real; }
172
virtual my_decimal *val_decimal(Hybrid_type *val, my_decimal *buf) const;
173
virtual String *val_str(Hybrid_type *val, String *buf, uint8_t decimals) const;
174
static const Hybrid_type_traits *instance();
175
Hybrid_type_traits() {}
176
virtual ~Hybrid_type_traits() {}
180
struct Hybrid_type_traits_decimal: public Hybrid_type_traits
182
virtual Item_result type() const { return DECIMAL_RESULT; }
185
fix_length_and_dec(Item *arg, Item *item) const;
187
/* Hybrid_type operations. */
188
virtual void set_zero(Hybrid_type *val) const;
189
virtual void add(Hybrid_type *val, Field *f) const;
190
virtual void div(Hybrid_type *val, uint64_t u) const;
192
virtual int64_t val_int(Hybrid_type *val, bool unsigned_flag) const;
193
virtual double val_real(Hybrid_type *val) const;
194
virtual my_decimal *val_decimal(Hybrid_type *val,
195
my_decimal *buf __attribute__((unused))) const
196
{ return &val->dec_buf[val->used_dec_buf_no]; }
197
virtual String *val_str(Hybrid_type *val, String *buf, uint8_t decimals) const;
198
static const Hybrid_type_traits_decimal *instance();
199
Hybrid_type_traits_decimal() {};
203
struct Hybrid_type_traits_integer: public Hybrid_type_traits
205
virtual Item_result type() const { return INT_RESULT; }
208
fix_length_and_dec(Item *arg, Item *item) const;
210
/* Hybrid_type operations. */
211
virtual void set_zero(Hybrid_type *val) const
213
virtual void add(Hybrid_type *val, Field *f) const
214
{ val->integer+= f->val_int(); }
215
virtual void div(Hybrid_type *val, uint64_t u) const
216
{ val->integer/= (int64_t) u; }
218
virtual int64_t val_int(Hybrid_type *val,
219
bool unsigned_flag __attribute__((unused))) const
220
{ return val->integer; }
221
virtual double val_real(Hybrid_type *val) const
222
{ return (double) val->integer; }
223
virtual my_decimal *val_decimal(Hybrid_type *val,
224
my_decimal *buf __attribute__((unused))) const
226
int2my_decimal(E_DEC_FATAL_ERROR, val->integer, 0, &val->dec_buf[2]);
227
return &val->dec_buf[2];
229
virtual String *val_str(Hybrid_type *val, String *buf,
230
uint8_t decimals __attribute__((unused))) const
231
{ buf->set(val->integer, &my_charset_bin); return buf;}
232
static const Hybrid_type_traits_integer *instance();
233
Hybrid_type_traits_integer() {};
237
void dummy_error_processor(THD *thd, void *data);
239
void view_error_processor(THD *thd, void *data);
242
Instances of Name_resolution_context store the information necesary for
243
name resolution of Items and other context analysis of a query made in
246
This structure is a part of SELECT_LEX, a pointer to this structure is
247
assigned when an item is created (which happens mostly during parsing
248
(sql_yacc.yy)), but the structure itself will be initialized after parsing
251
TODO: move subquery of INSERT ... SELECT and CREATE ... SELECT to
252
separate SELECT_LEX which allow to remove tricks of changing this
253
structure before and after INSERT/CREATE and its SELECT to make correct
254
field name resolution.
256
struct Name_resolution_context: Sql_alloc
259
The name resolution context to search in when an Item cannot be
260
resolved in this context (the context of an outer select)
262
Name_resolution_context *outer_context;
265
List of tables used to resolve the items of this context. Usually these
266
are tables from the FROM clause of SELECT statement. The exceptions are
267
INSERT ... SELECT and CREATE ... SELECT statements, where SELECT
268
subquery is not moved to a separate SELECT_LEX. For these types of
269
statements we have to change this member dynamically to ensure correct
270
name resolution of different parts of the statement.
272
TABLE_LIST *table_list;
274
In most cases the two table references below replace 'table_list' above
275
for the purpose of name resolution. The first and last name resolution
276
table references allow us to search only in a sub-tree of the nested
277
join tree in a FROM clause. This is needed for NATURAL JOIN, JOIN ... USING
280
TABLE_LIST *first_name_resolution_table;
282
Last table to search in the list of leaf table references that begins
283
with first_name_resolution_table.
285
TABLE_LIST *last_name_resolution_table;
288
SELECT_LEX item belong to, in case of merged VIEW it can differ from
289
SELECT_LEX where item was created, so we can't use table_list/field_list
292
st_select_lex *select_lex;
295
Processor of errors caused during Item name resolving, now used only to
296
hide underlying tables in errors about views (i.e. it substitute some
299
void (*error_processor)(THD *, void *);
300
void *error_processor_data;
303
When true items are resolved in this context both against the
304
SELECT list and this->table_list. If false, items are resolved
305
only against this->table_list.
307
bool resolve_in_select_list;
310
Security context of this name resolution context. It's used for views
311
and is non-zero only if the view is defined with SQL SECURITY DEFINER.
313
Security_context *security_ctx;
315
Name_resolution_context()
316
:outer_context(0), table_list(0), select_lex(0),
317
error_processor_data(0),
323
resolve_in_select_list= false;
324
error_processor= &dummy_error_processor;
325
first_name_resolution_table= NULL;
326
last_name_resolution_table= NULL;
329
void resolve_in_table_list_only(TABLE_LIST *tables)
331
table_list= first_name_resolution_table= tables;
332
resolve_in_select_list= false;
335
void process_error(THD *thd)
337
(*error_processor)(thd, error_processor_data);
343
Store and restore the current state of a name resolution context.
346
class Name_resolution_context_state
349
TABLE_LIST *save_table_list;
350
TABLE_LIST *save_first_name_resolution_table;
351
TABLE_LIST *save_next_name_resolution_table;
352
bool save_resolve_in_select_list;
353
TABLE_LIST *save_next_local;
356
Name_resolution_context_state() {} /* Remove gcc warning */
359
/* Save the state of a name resolution context. */
360
void save_state(Name_resolution_context *context, TABLE_LIST *table_list)
362
save_table_list= context->table_list;
363
save_first_name_resolution_table= context->first_name_resolution_table;
364
save_resolve_in_select_list= context->resolve_in_select_list;
365
save_next_local= table_list->next_local;
366
save_next_name_resolution_table= table_list->next_name_resolution_table;
369
/* Restore a name resolution context from saved state. */
370
void restore_state(Name_resolution_context *context, TABLE_LIST *table_list)
372
table_list->next_local= save_next_local;
373
table_list->next_name_resolution_table= save_next_name_resolution_table;
374
context->table_list= save_table_list;
375
context->first_name_resolution_table= save_first_name_resolution_table;
376
context->resolve_in_select_list= save_resolve_in_select_list;
379
TABLE_LIST *get_first_name_resolution_table()
381
return save_first_name_resolution_table;
387
This enum is used to report information about monotonicity of function
388
represented by Item* tree.
389
Monotonicity is defined only for Item* trees that represent table
390
partitioning expressions (i.e. have no subselects/user vars/PS parameters
391
etc etc). An Item* tree is assumed to have the same monotonicity properties
392
as its correspoinding function F:
394
[signed] int64_t F(field1, field2, ...) {
395
put values of field_i into table record buffer;
396
return item->val_int();
400
At the moment function monotonicity is not well defined (and so may be
401
incorrect) for Item trees with parameters/return types that are different
402
from INT_RESULT, may be NULL, or are unsigned.
403
It will be possible to address this issue once the related partitioning bugs
404
(BUG#16002, BUG#15447, BUG#13436) are fixed.
407
typedef enum monotonicity_info
409
NON_MONOTONIC, /* none of the below holds */
410
MONOTONIC_INCREASING, /* F() is unary and (x < y) => (F(x) <= F(y)) */
411
MONOTONIC_STRICT_INCREASING /* F() is unary and (x < y) => (F(x) < F(y)) */
412
} enum_monotonicity_info;
414
/*************************************************************************/
415
typedef bool (Item::*Item_processor) (uchar *arg);
54
419
argp in/out IN: Analysis parameter
55
420
OUT: Parameter to be passed to the transformer
58
423
true Invoke the transformer
62
typedef bool (Item::*Item_analyzer) (unsigned char **argp);
63
typedef Item* (Item::*Item_transformer) (unsigned char *arg);
427
typedef bool (Item::*Item_analyzer) (uchar **argp);
428
typedef Item* (Item::*Item_transformer) (uchar *arg);
64
429
typedef void (*Cond_traverser) (const Item *item, void *arg);
65
typedef bool (Item::*Item_processor) (unsigned char *arg);
68
class Item: public Sql_alloc
70
/* Prevent use of these */
434
Item(const Item &); /* Prevent use of these */
72
435
void operator=(Item &);
74
436
/* Cache of the result of is_expensive(). */
75
437
int8_t is_expensive_cache;
76
virtual bool is_expensive_processor(unsigned char *arg);
438
virtual bool is_expensive_processor(uchar *arg __attribute__((unused)))
442
static void *operator new(size_t size)
443
{ return sql_alloc(size); }
444
static void *operator new(size_t size, MEM_ROOT *mem_root)
445
{ return alloc_root(mem_root, size); }
446
static void operator delete(void *ptr __attribute__((unused)),
447
size_t size __attribute__((unused)))
448
{ TRASH(ptr, size); }
449
static void operator delete(void *ptr __attribute__((unused)),
450
MEM_ROOT *mem_root __attribute__((unused)))
80
enum Type {FIELD_ITEM= 0,
453
enum Type {FIELD_ITEM= 0, FUNC_ITEM, SUM_FUNC_ITEM, STRING_ITEM,
454
INT_ITEM, REAL_ITEM, NULL_ITEM, VARBIN_ITEM,
455
COPY_STR_ITEM, FIELD_AVG_ITEM, DEFAULT_VALUE_ITEM,
456
PROC_ITEM,COND_ITEM, REF_ITEM, FIELD_STD_ITEM,
457
FIELD_VARIANCE_ITEM, INSERT_VALUE_ITEM,
458
SUBSELECT_ITEM, ROW_ITEM, CACHE_ITEM, TYPE_HOLDER,
459
PARAM_ITEM, TRIGGER_FIELD_ITEM, DECIMAL_ITEM,
460
XPATH_NODESET, XPATH_NODESET_CMP,
104
463
enum cond_result { COND_UNDEF,COND_OK,COND_TRUE,COND_FALSE };
106
465
enum traverse_order { POSTFIX, PREFIX };
108
467
/* Reuse size, only used by SP local variable assignment, otherwize 0 */
112
471
str_values's main purpose is to be used to cache the value in
115
474
String str_value;
117
/* Name from select */
475
char * name; /* Name from select */
120
476
/* Original item name (if it was renamed)*/
121
477
char * orig_name;
123
479
uint32_t max_length;
126
uint32_t name_length;
480
uint name_length; /* Length of name */
129
482
uint8_t decimals;
130
bool maybe_null; /* If item may be null */
131
bool null_value; /* if item is null */
134
bool fixed; /* If item fixed with fix_fields */
135
bool is_autogenerated_name; /* indicate was name of this Item
483
my_bool maybe_null; /* If item may be null */
484
my_bool null_value; /* if item is null */
485
my_bool unsigned_flag;
486
my_bool with_sum_func;
487
my_bool fixed; /* If item fixed with fix_fields */
488
my_bool is_autogenerated_name; /* indicate was name of this Item
136
489
autogenerated or set by user */
137
490
DTCollation collation;
138
bool with_subselect; /* If this item is a subselect or some
491
my_bool with_subselect; /* If this item is a subselect or some
139
492
of its arguments is or contains a
140
493
subselect. Computed by fix_fields. */
141
494
Item_result cmp_context; /* Comparison context */
507
856
i.e. analysis is performed top-down while transformation is done
510
virtual Item* compile(Item_analyzer analyzer, unsigned char **arg_p,
511
Item_transformer transformer, unsigned char *arg_t);
513
virtual void traverse_cond(Cond_traverser traverser,
515
traverse_order order);
517
virtual bool remove_dependence_processor(unsigned char * arg);
518
virtual bool remove_fixed(unsigned char * arg);
519
virtual bool cleanup_processor(unsigned char *arg);
520
virtual bool collect_item_field_processor(unsigned char * arg);
521
virtual bool find_item_in_field_list_processor(unsigned char *arg);
522
virtual bool change_context_processor(unsigned char *context);
523
virtual bool reset_query_id_processor(unsigned char *query_id_arg);
524
virtual bool register_field_in_read_map(unsigned char *arg);
527
The next function differs from the previous one that a bitmap to be updated
528
is passed as unsigned char *arg.
530
virtual bool register_field_in_bitmap(unsigned char *arg);
531
virtual bool subst_argument_checker(unsigned char **arg);
534
Check if an expression/function is allowed for a virtual column
536
check_vcol_func_processor()
539
TRUE Function not accepted
540
FALSE Function accepted
542
virtual bool check_vcol_func_processor(unsigned char *arg);
543
virtual Item *equal_fields_propagator(unsigned char * arg);
544
virtual bool set_no_const_sub(unsigned char *arg);
545
virtual Item *replace_equal_field(unsigned char * arg);
859
virtual Item* compile(Item_analyzer analyzer, uchar **arg_p,
860
Item_transformer transformer, uchar *arg_t)
862
if ((this->*analyzer) (arg_p))
863
return ((this->*transformer) (arg_t));
867
virtual void traverse_cond(Cond_traverser traverser __attribute__((unused)),
869
traverse_order order __attribute__((unused)))
871
(*traverser)(this, arg);
874
virtual bool remove_dependence_processor(uchar * arg __attribute__((unused)))
876
virtual bool remove_fixed(uchar * arg __attribute__((unused)))
881
virtual bool cleanup_processor(uchar *arg __attribute__((unused)));
882
virtual bool collect_item_field_processor(uchar * arg __attribute__((unused)))
884
virtual bool find_item_in_field_list_processor(uchar *arg __attribute__((unused)))
886
virtual bool change_context_processor(uchar *context __attribute__((unused)))
888
virtual bool reset_query_id_processor(uchar *query_id_arg __attribute__((unused)))
890
virtual bool register_field_in_read_map(uchar *arg __attribute__((unused)))
892
virtual bool subst_argument_checker(uchar **arg)
899
virtual Item *equal_fields_propagator(uchar * arg __attribute__((unused))) { return this; }
900
virtual bool set_no_const_sub(uchar *arg __attribute__((unused))) { return false; }
901
virtual Item *replace_equal_field(uchar * arg __attribute__((unused))) { return this; }
549
904
For SP local variable returns pointer to Item representing its
550
905
current value and pointer to current Item otherwise.
552
virtual Item *this_item(void);
553
virtual const Item *this_item(void) const;
907
virtual Item *this_item(void) { return this; }
908
virtual const Item *this_item(void) const { return this; }
556
911
For SP local variable returns address of pointer to Item representing its
557
912
current value and pointer passed via parameter otherwise.
559
virtual Item **this_item_addr(Session *session, Item **addr_arg);
914
virtual Item **this_item_addr(THD *thd __attribute__((unused)), Item **addr_arg) { return addr_arg; }
562
virtual uint32_t cols();
563
virtual Item* element_index(uint32_t i);
564
virtual Item** addr(uint32_t i);
565
virtual bool check_cols(uint32_t c);
917
virtual uint cols() { return 1; }
918
virtual Item* element_index(uint i __attribute__((unused))) { return this; }
919
virtual Item** addr(uint i __attribute__((unused))) { return 0; }
920
virtual bool check_cols(uint c);
566
921
// It is not row => null inside is impossible
567
virtual bool null_inside();
922
virtual bool null_inside() { return 0; }
568
923
// used in row subselects to get value of elements
569
virtual void bring_value();
571
Field *tmp_table_field_from_field_type(Table *table, bool fixed_length);
572
virtual Item_field *filed_for_view_update();
574
virtual Item *neg_transformer(Session *session);
575
virtual Item *update_value_transformer(unsigned char *select_arg);
576
virtual Item *safe_charset_converter(const CHARSET_INFO * const tocs);
924
virtual void bring_value() {}
926
Field *tmp_table_field_from_field_type(TABLE *table, bool fixed_length);
927
virtual Item_field *filed_for_view_update() { return 0; }
929
virtual Item *neg_transformer(THD *thd __attribute__((unused))) { return NULL; }
930
virtual Item *update_value_transformer(uchar *select_arg __attribute__((unused))) { return this; }
931
virtual Item *safe_charset_converter(CHARSET_INFO *tocs);
580
939
result_as_int64_t() must return true for Items representing DATE/TIME
1901
2390
char buffer[STRING_BUFFER_USUAL_SIZE];
1902
2391
String *value, value_buff;
1903
2392
bool is_varbinary;
1906
Item_cache_str(const Item *item);
2395
Item_cache_str(const Item *item) :
2396
Item_cache(), value(0),
2397
is_varbinary(item->type() == FIELD_ITEM &&
2398
((const Item_field *) item)->field->type() ==
2399
DRIZZLE_TYPE_VARCHAR &&
2400
!((const Item_field *) item)->field->has_charset())
1907
2402
void store(Item *item);
1908
2403
double val_real();
1909
2404
int64_t val_int();
1910
2405
String* val_str(String *) { assert(fixed == 1); return value; }
1911
2406
my_decimal *val_decimal(my_decimal *);
1912
2407
enum Item_result result_type() const { return STRING_RESULT; }
1913
const CHARSET_INFO *charset() const { return value->charset(); };
2408
CHARSET_INFO *charset() const { return value->charset(); };
1914
2409
int save_in_field(Field *field, bool no_conversions);
1919
void mark_select_range_as_dependent(Session *session,
2412
class Item_cache_row: public Item_cache
2414
Item_cache **values;
2419
:Item_cache(), values(0), item_count(2), save_array(0) {}
2422
'allocate' used only in row transformer, to preallocate space for row
2425
bool allocate(uint num);
2427
'setup' is needed only by row => it not called by simple row subselect
2428
(only by IN subselect (in subselect optimizer))
2430
bool setup(Item *item);
2431
void store(Item *item);
2432
void illegal_method_call(const char *);
2433
void make_field(Send_field *)
2435
illegal_method_call((const char*)"make_field");
2439
illegal_method_call((const char*)"val");
2444
illegal_method_call((const char*)"val_int");
2447
String *val_str(String *)
2449
illegal_method_call((const char*)"val_str");
2452
my_decimal *val_decimal(my_decimal *val __attribute__((unused)))
2454
illegal_method_call((const char*)"val_decimal");
2458
enum Item_result result_type() const { return ROW_RESULT; }
2460
uint cols() { return item_count; }
2461
Item *element_index(uint i) { return values[i]; }
2462
Item **addr(uint i) { return (Item **) (values + i); }
2463
bool check_cols(uint c);
2466
void keep_array() { save_array= 1; }
2469
Item_cache::cleanup();
2471
memset(values, 0, item_count*sizeof(Item**));
2480
Item_type_holder used to store type. name, length of Item for UNIONS &
2483
Item_type_holder do not need cleanup() because its time of live limited by
2484
single SP/PS execution.
2486
class Item_type_holder: public Item
2489
TYPELIB *enum_set_typelib;
2490
enum_field_types fld_type;
2492
void get_full_info(Item *item);
2494
/* It is used to count decimal precision in join_types */
2495
int prev_decimal_int_part;
2497
Item_type_holder(THD*, Item*);
2499
Item_result result_type() const;
2500
enum_field_types field_type() const { return fld_type; };
2501
enum Type type() const { return TYPE_HOLDER; }
2504
my_decimal *val_decimal(my_decimal *);
2505
String *val_str(String*);
2506
bool join_types(THD *thd, Item *);
2507
Field *make_field_by_type(TABLE *table);
2508
static uint32_t display_length(Item *item);
2509
static enum_field_types get_real_type(Item *);
2513
class st_select_lex;
2514
void mark_select_range_as_dependent(THD *thd,
1920
2515
st_select_lex *last_select,
1921
2516
st_select_lex *current_sel,
1922
2517
Field *found_field, Item *found_item,
1923
2518
Item_ident *resolved_item);
1925
extern void resolve_const_item(Session *session, Item **ref, Item *cmp_item);
2520
extern Cached_item *new_Cached_item(THD *thd, Item *item,
2521
bool use_result_field);
2522
extern void resolve_const_item(THD *thd, Item **ref, Item *cmp_item);
1926
2523
extern bool field_is_equal_to_item(Field *field,Item *item);
1929
Create field for temporary table.
1931
@param session Thread handler
1932
@param table Temporary table
1933
@param item Item to create a field for
1934
@param type Type of item (normally item->type)
1935
@param copy_func If set and item is a function, store copy of item
1937
@param from_field if field will be created using other field as example,
1938
pointer example field will be written here
1939
@param default_field If field has a default value field, store it here
1940
@param group 1 if we are going to do a relative group by on result
1941
@param modify_item 1 if item->result_field should point to new item.
1942
This is relevent for how fill_record() is going to
1944
If modify_item is 1 then fill_record() will update
1945
the record in the original table.
1946
If modify_item is 0 then fill_record() will update
1948
@param convert_blob_length If >0 create a varstring(convert_blob_length)
1949
field instead of blob.
1957
/* TODO: This is here for now because it needs the Item::Type. It should live
1958
in Field or Table once item.h is clean enough to actually include */
1959
Field *create_tmp_field(Session *session, Table *table, Item *item,
1961
Item ***copy_func, Field **from_field,
1963
bool group, bool modify_item,
1964
bool table_cant_handle_bit_fields,
1965
bool make_copy_field,
1966
uint32_t convert_blob_length);
1968
#endif /* DRIZZLED_ITEM_H */