~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item.h

  • Committer: Monty Taylor
  • Date: 2008-08-04 19:37:18 UTC
  • mto: (261.2.2 codestyle)
  • mto: This revision was merged to the branch mainline in revision 262.
  • Revision ID: monty@inaugust.com-20080804193718-f0rz13uli4429ozb
Changed gettext_noop() to N_()

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
 */
19
 
 
20
 
#ifndef DRIZZLED_ITEM_H
21
 
#define DRIZZLED_ITEM_H
22
 
 
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
 
2
 
 
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.
 
6
 
 
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.
 
11
 
 
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 */
 
15
 
 
16
 
 
17
#ifdef USE_PRAGMA_INTERFACE
 
18
#pragma interface                       /* gcc class implementation */
 
19
#endif
29
20
 
30
21
class Protocol;
31
 
class TableList;
 
22
struct TABLE_LIST;
 
23
void item_init(void);                   /* Init item functions */
32
24
class Item_field;
33
 
class Name_resolution_context;
34
 
class st_select_lex;
35
 
class Item_equal;
36
 
class COND_EQUAL;
37
 
class user_var_entry;
38
 
class Item_sum;
39
 
class Item_in_subselect;
40
 
class Send_field;
41
 
class Field;
42
 
 
43
 
void item_init(void);                   /* Init item functions */
44
 
 
45
 
 
46
 
void dummy_error_processor(Session *session, void *data);
47
 
void view_error_processor(Session *session, void *data);
48
 
 
49
 
 
50
 
/*************************************************************************/
 
25
 
 
26
/*
 
27
   "Declared Type Collation"
 
28
   A combination of collation and its derivation.
 
29
 
 
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
 
33
                                 (i.e. constant).
 
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
 
40
*/
 
41
 
 
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
 
47
 
 
48
class DTCollation {
 
49
public:
 
50
  CHARSET_INFO     *collation;
 
51
  enum Derivation derivation;
 
52
  uint repertoire;
 
53
  
 
54
  void set_repertoire_from_charset(CHARSET_INFO *cs)
 
55
  {
 
56
    repertoire= cs->state & MY_CS_PUREASCII ?
 
57
                MY_REPERTOIRE_ASCII : MY_REPERTOIRE_UNICODE30;
 
58
  }
 
59
  DTCollation()
 
60
  {
 
61
    collation= &my_charset_bin;
 
62
    derivation= DERIVATION_NONE;
 
63
    repertoire= MY_REPERTOIRE_UNICODE30;
 
64
  }
 
65
  DTCollation(CHARSET_INFO *collation_arg, Derivation derivation_arg)
 
66
  {
 
67
    collation= collation_arg;
 
68
    derivation= derivation_arg;
 
69
    set_repertoire_from_charset(collation_arg);
 
70
  }
 
71
  void set(DTCollation &dt)
 
72
  { 
 
73
    collation= dt.collation;
 
74
    derivation= dt.derivation;
 
75
    repertoire= dt.repertoire;
 
76
  }
 
77
  void set(CHARSET_INFO *collation_arg, Derivation derivation_arg)
 
78
  {
 
79
    collation= collation_arg;
 
80
    derivation= derivation_arg;
 
81
    set_repertoire_from_charset(collation_arg);
 
82
  }
 
83
  void set(CHARSET_INFO *collation_arg,
 
84
           Derivation derivation_arg,
 
85
           uint repertoire_arg)
 
86
  {
 
87
    collation= collation_arg;
 
88
    derivation= derivation_arg;
 
89
    repertoire= repertoire_arg;
 
90
  }
 
91
  void set(CHARSET_INFO *collation_arg)
 
92
  {
 
93
    collation= collation_arg;
 
94
    set_repertoire_from_charset(collation_arg);
 
95
  }
 
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
 
102
  {
 
103
    switch(derivation)
 
104
    {
 
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";
 
112
    }
 
113
  }
 
114
};
 
115
 
 
116
/*************************************************************************/
 
117
/*
 
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,
 
120
  real, decimal).
 
121
*/
 
122
 
 
123
struct Hybrid_type_traits;
 
124
 
 
125
struct Hybrid_type
 
126
{
 
127
  int64_t integer;
 
128
 
 
129
  double real;
 
130
  /*
 
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.
 
135
  */
 
136
  my_decimal dec_buf[3];
 
137
  int used_dec_buf_no;
 
138
 
 
139
  /*
 
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
 
143
  */
 
144
  const Hybrid_type_traits *traits;
 
145
 
 
146
  Hybrid_type() {}
 
147
  /* XXX: add traits->copy() when needed */
 
148
  Hybrid_type(const Hybrid_type &rhs) :traits(rhs.traits) {}
 
149
};
 
150
 
 
151
 
 
152
/* Hybryd_type_traits interface + default implementation for REAL_RESULT */
 
153
 
 
154
struct Hybrid_type_traits
 
155
{
 
156
  virtual Item_result type() const { return REAL_RESULT; }
 
157
 
 
158
  virtual void
 
159
  fix_length_and_dec(Item *item, Item *arg) const;
 
160
 
 
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); }
 
167
 
 
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() {}
 
177
};
 
178
 
 
179
 
 
180
struct Hybrid_type_traits_decimal: public Hybrid_type_traits
 
181
{
 
182
  virtual Item_result type() const { return DECIMAL_RESULT; }
 
183
 
 
184
  virtual void
 
185
  fix_length_and_dec(Item *arg, Item *item) const;
 
186
 
 
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;
 
191
 
 
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() {};
 
200
};
 
201
 
 
202
 
 
203
struct Hybrid_type_traits_integer: public Hybrid_type_traits
 
204
{
 
205
  virtual Item_result type() const { return INT_RESULT; }
 
206
 
 
207
  virtual void
 
208
  fix_length_and_dec(Item *arg, Item *item) const;
 
209
 
 
210
  /* Hybrid_type operations. */
 
211
  virtual void set_zero(Hybrid_type *val) const
 
212
  { val->integer= 0; }
 
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; }
 
217
 
 
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
 
225
  {
 
226
    int2my_decimal(E_DEC_FATAL_ERROR, val->integer, 0, &val->dec_buf[2]);
 
227
    return &val->dec_buf[2];
 
228
  }
 
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() {};
 
234
};
 
235
 
 
236
 
 
237
void dummy_error_processor(THD *thd, void *data);
 
238
 
 
239
void view_error_processor(THD *thd, void *data);
 
240
 
 
241
/*
 
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
 
244
  fix_fields().
 
245
 
 
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
 
249
  is complete
 
250
 
 
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.
 
255
*/
 
256
struct Name_resolution_context: Sql_alloc
 
257
{
 
258
  /*
 
259
    The name resolution context to search in when an Item cannot be
 
260
    resolved in this context (the context of an outer select)
 
261
  */
 
262
  Name_resolution_context *outer_context;
 
263
 
 
264
  /*
 
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.
 
271
  */
 
272
  TABLE_LIST *table_list;
 
273
  /*
 
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
 
278
    and JOIN ... ON. 
 
279
  */
 
280
  TABLE_LIST *first_name_resolution_table;
 
281
  /*
 
282
    Last table to search in the list of leaf table references that begins
 
283
    with first_name_resolution_table.
 
284
  */
 
285
  TABLE_LIST *last_name_resolution_table;
 
286
 
 
287
  /*
 
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
 
290
    from there
 
291
  */
 
292
  st_select_lex *select_lex;
 
293
 
 
294
  /*
 
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
 
297
    errors for views)
 
298
  */
 
299
  void (*error_processor)(THD *, void *);
 
300
  void *error_processor_data;
 
301
 
 
302
  /*
 
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.
 
306
  */
 
307
  bool resolve_in_select_list;
 
308
 
 
309
  /*
 
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.
 
312
  */
 
313
  Security_context *security_ctx;
 
314
 
 
315
  Name_resolution_context()
 
316
    :outer_context(0), table_list(0), select_lex(0),
 
317
    error_processor_data(0),
 
318
    security_ctx(0)
 
319
    {}
 
320
 
 
321
  void init()
 
322
  {
 
323
    resolve_in_select_list= false;
 
324
    error_processor= &dummy_error_processor;
 
325
    first_name_resolution_table= NULL;
 
326
    last_name_resolution_table= NULL;
 
327
  }
 
328
 
 
329
  void resolve_in_table_list_only(TABLE_LIST *tables)
 
330
  {
 
331
    table_list= first_name_resolution_table= tables;
 
332
    resolve_in_select_list= false;
 
333
  }
 
334
 
 
335
  void process_error(THD *thd)
 
336
  {
 
337
    (*error_processor)(thd, error_processor_data);
 
338
  }
 
339
};
 
340
 
 
341
 
 
342
/*
 
343
  Store and restore the current state of a name resolution context.
 
344
*/
 
345
 
 
346
class Name_resolution_context_state
 
347
{
 
348
private:
 
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;
 
354
 
 
355
public:
 
356
  Name_resolution_context_state() {}          /* Remove gcc warning */
 
357
 
 
358
public:
 
359
  /* Save the state of a name resolution context. */
 
360
  void save_state(Name_resolution_context *context, TABLE_LIST *table_list)
 
361
  {
 
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;
 
367
  }
 
368
 
 
369
  /* Restore a name resolution context from saved state. */
 
370
  void restore_state(Name_resolution_context *context, TABLE_LIST *table_list)
 
371
  {
 
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;
 
377
  }
 
378
 
 
379
  TABLE_LIST *get_first_name_resolution_table()
 
380
  {
 
381
    return save_first_name_resolution_table;
 
382
  }
 
383
};
 
384
 
 
385
 
 
386
/*
 
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:
 
393
 
 
394
  [signed] int64_t F(field1, field2, ...) {
 
395
    put values of field_i into table record buffer;
 
396
    return item->val_int(); 
 
397
  }
 
398
 
 
399
  NOTE
 
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.
 
405
*/
 
406
 
 
407
typedef enum monotonicity_info 
 
408
{
 
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;
 
413
 
 
414
/*************************************************************************/
 
415
typedef bool (Item::*Item_processor) (uchar *arg);
51
416
/*
52
417
  Analyzer function
53
418
    SYNOPSIS
54
419
      argp   in/out IN:  Analysis parameter
55
420
                    OUT: Parameter to be passed to the transformer
56
421
 
57
 
     RETURN
 
422
    RETURN 
58
423
      true   Invoke the transformer
59
424
      false  Don't do it
60
425
 
61
426
*/
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);
66
 
 
67
 
 
68
 
class Item: public Sql_alloc
 
430
 
 
431
 
 
432
class Item
69
433
{
70
 
  /* Prevent use of these */
71
 
  Item(const Item &);
 
434
  Item(const Item &);                   /* Prevent use of these */
72
435
  void operator=(Item &);
73
 
 
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)))
 
439
  { return 0; }
77
440
 
78
441
public:
 
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)))
 
451
  {}
79
452
 
80
 
  enum Type {FIELD_ITEM= 0, 
81
 
    FUNC_ITEM,
82
 
    SUM_FUNC_ITEM,
83
 
    STRING_ITEM,
84
 
    INT_ITEM,
85
 
    REAL_ITEM,
86
 
    NULL_ITEM,
87
 
    VARBIN_ITEM,
88
 
    COPY_STR_ITEM,
89
 
    FIELD_AVG_ITEM,
90
 
    DEFAULT_VALUE_ITEM,
91
 
    PROC_ITEM,
92
 
    COND_ITEM,
93
 
    REF_ITEM,
94
 
    FIELD_STD_ITEM,
95
 
    FIELD_VARIANCE_ITEM,
96
 
    INSERT_VALUE_ITEM,
97
 
    SUBSELECT_ITEM,
98
 
    ROW_ITEM, CACHE_ITEM,
99
 
    TYPE_HOLDER,
100
 
    PARAM_ITEM,
101
 
    DECIMAL_ITEM
102
 
  };
 
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,
 
461
             VIEW_FIXER_ITEM};
103
462
 
104
463
  enum cond_result { COND_UNDEF,COND_OK,COND_TRUE,COND_FALSE };
105
464
 
106
465
  enum traverse_order { POSTFIX, PREFIX };
107
 
 
 
466
  
108
467
  /* Reuse size, only used by SP local variable assignment, otherwize 0 */
109
 
  uint32_t rsize;
 
468
  uint rsize;
110
469
 
111
470
  /*
112
471
    str_values's main purpose is to be used to cache the value in
113
472
    save_in_field
114
473
  */
115
474
  String str_value;
116
 
 
117
 
  /* Name from select */
118
 
  char * name;
119
 
 
 
475
  char * name;                  /* Name from select */
120
476
  /* Original item name (if it was renamed)*/
121
477
  char * orig_name;
122
478
  Item *next;
123
479
  uint32_t max_length;
124
 
 
125
 
  /* Length of name */
126
 
  uint32_t name_length;
127
 
 
 
480
  uint name_length;                     /* Length of name */
128
481
  int8_t marker;
129
482
  uint8_t decimals;
130
 
  bool maybe_null;                      /* If item may be null */
131
 
  bool null_value;                      /* if item is null */
132
 
  bool unsigned_flag;
133
 
  bool with_sum_func;
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 */
149
502
     top AND/OR structure of WHERE clause to protect it of
150
503
     optimisation changes in prepared statements
151
504
  */
152
 
  Item(Session *session, Item *item);
 
505
  Item(THD *thd, Item *item);
153
506
  virtual ~Item()
154
507
  {
155
508
#ifdef EXTRA_DEBUG
156
509
    name=0;
157
510
#endif
158
 
  }
159
 
  void set_name(const char *str, uint32_t length,
160
 
                const CHARSET_INFO * const cs);
 
511
  }             /*lint -e1509 */
 
512
  void set_name(const char *str, uint length, CHARSET_INFO *cs);
161
513
  void rename(char *new_name);
162
514
  void init_make_field(Send_field *tmp_field,enum enum_field_types type);
163
515
  virtual void cleanup();
164
516
  virtual void make_field(Send_field *field);
165
 
  Field *make_string_field(Table *table);
166
 
  virtual bool fix_fields(Session *, Item **);
167
 
 
 
517
  Field *make_string_field(TABLE *table);
 
518
  virtual bool fix_fields(THD *, Item **);
168
519
  /*
169
520
    Fix after some tables has been pulled out. Basically re-calculate all
170
521
    attributes that are dependent on the tables.
171
522
  */
172
 
  virtual void fix_after_pullout(st_select_lex *new_parent, Item **ref);
 
523
  virtual void fix_after_pullout(st_select_lex *new_parent __attribute__((unused)),
 
524
                                 Item **ref __attribute__((unused))) {};
173
525
 
174
526
  /*
175
527
    should be used in case where we are sure that we do not need
176
 
    complete fix_fields() procedure.  */
 
528
    complete fix_fields() procedure.
 
529
  */
177
530
  inline void quick_fix_field() { fixed= 1; }
178
 
 
179
 
  /*
180
 
  Save value in field, but don't give any warnings
181
 
 
182
 
  NOTES
183
 
   This is used to temporary store and retrieve a value in a column,
184
 
   for example in opt_range to adjust the key value to fit the column.
185
 
  Return: Function returns 1 on overflow and -1 on fatal errors
186
 
  */
 
531
  /* Function returns 1 on overflow and -1 on fatal errors */
187
532
  int save_in_field_no_warnings(Field *field, bool no_conversions);
188
 
 
189
533
  virtual int save_in_field(Field *field, bool no_conversions);
190
534
  virtual void save_org_in_field(Field *field)
191
535
  { (void) save_in_field(field, 1); }
198
542
  virtual enum_field_types string_field_type() const;
199
543
  virtual enum_field_types field_type() const;
200
544
  virtual enum Type type() const =0;
201
 
 
 
545
  
202
546
  /*
203
547
    Return information about function monotonicity. See comment for
204
548
    enum_monotonicity_info for details. This function can only be called
208
552
  { return NON_MONOTONIC; }
209
553
 
210
554
  /*
211
 
    Convert:
212
 
      "func_arg $CMP$ const" half-interval
213
 
    into:
214
 
      "FUNC(func_arg) $CMP2$ const2"
 
555
    Convert "func_arg $CMP$ const" half-interval into "FUNC(func_arg) $CMP2$ const2"
215
556
 
216
557
    SYNOPSIS
217
558
      val_int_endpoint()
231
572
      The value of const is supplied implicitly as the value this item's
232
573
      argument, the form of $CMP$ comparison is specified through the
233
574
      function's arguments. The calle returns the result interval
234
 
 
 
575
         
235
576
         F(x) $CMP2$ F(const)
236
 
 
237
 
      passing back F(const) as the return value, and the form of $CMP2$
 
577
      
 
578
      passing back F(const) as the return value, and the form of $CMP2$ 
238
579
      through the out parameter. NULL values are assumed to be comparable and
239
580
      be less than any non-NULL values.
240
581
 
243
584
        - If the value of the function is NULL then the bound is the
244
585
          smallest possible value of INT64_MIN
245
586
  */
246
 
  virtual int64_t val_int_endpoint(bool left_endp, bool *incl_endp);
 
587
  virtual int64_t val_int_endpoint(bool left_endp __attribute__((unused)),
 
588
                                    bool *incl_endp __attribute__((unused)))
 
589
  { assert(0); return 0; }
247
590
 
248
591
 
249
592
  /* valXXX methods must return NULL or 0 or 0.0 if null_value is set. */
355
698
 
356
699
  virtual Field *get_tmp_table_field(void) { return 0; }
357
700
  /* This is also used to create fields in CREATE ... SELECT: */
358
 
  virtual Field *tmp_table_field(Table *t_arg);
359
 
  virtual const char *full_name(void) const;
 
701
  virtual Field *tmp_table_field(TABLE *t_arg __attribute__((unused)))
 
702
  { return 0; }
 
703
  virtual const char *full_name(void) const { return name ? name : "???"; }
360
704
 
361
705
  /*
362
706
    *result* family of methods is analog of *val* family (see above) but
393
737
  /* cloning of constant items (0 if it is not const) */
394
738
  virtual Item *clone_item() { return 0; }
395
739
  virtual cond_result eq_cmp_result() const { return COND_OK; }
396
 
  inline uint32_t float_length(uint32_t decimals_par) const
 
740
  inline uint float_length(uint decimals_par) const
397
741
  { return decimals != NOT_FIXED_DEC ? (DBL_DIG+2+decimals_par) : DBL_DIG+8;}
398
 
  virtual uint32_t decimal_precision() const;
399
 
  int decimal_int_part() const;
400
 
 
401
 
  /*
 
742
  virtual uint decimal_precision() const;
 
743
  inline int decimal_int_part() const
 
744
  { return my_decimal_int_part(decimal_precision(), decimals); }
 
745
  /* 
402
746
    Returns true if this is constant (during query execution, i.e. its value
403
747
    will not change until next fix_fields) and its value is known.
404
748
  */
405
749
  virtual bool const_item() const { return used_tables() == 0; }
406
 
  /*
 
750
  /* 
407
751
    Returns true if this is constant but its value may be not known yet.
408
752
    (Can be used for parameters of prep. stmts or of stored procedures.)
409
753
  */
410
 
  virtual bool const_during_execution() const
 
754
  virtual bool const_during_execution() const 
411
755
  { return (used_tables() & ~PARAM_TABLE_BIT) == 0; }
412
756
 
413
757
  /**
421
765
    query and why they should be generated from the Item-tree, @see
422
766
    mysql_register_view().
423
767
  */
424
 
  virtual void print(String *str, enum_query_type query_type);
 
768
  virtual inline void print(String *str,
 
769
                            enum_query_type query_type __attribute__((unused)))
 
770
  {
 
771
    str->append(full_name());
 
772
  }
425
773
 
426
774
  void print_item_w_name(String *, enum_query_type query_type);
427
775
  virtual void update_used_tables() {}
428
 
  virtual void split_sum_func(Session *session, Item **ref_pointer_array,
429
 
                              List<Item> &fields);
430
 
 
 
776
  virtual void split_sum_func(THD *thd __attribute__((unused)),
 
777
                              Item **ref_pointer_array __attribute__((unused)),
 
778
                              List<Item> &fields __attribute__((unused))) {}
431
779
  /* Called for items that really have to be split */
432
 
  void split_sum_func(Session *session, Item **ref_pointer_array,
433
 
                      List<Item> &fields,
434
 
                      Item **ref, bool skip_registered);
435
 
 
436
 
  virtual bool get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate);
 
780
  void split_sum_func2(THD *thd, Item **ref_pointer_array, List<Item> &fields,
 
781
                       Item **ref, bool skip_registered);
 
782
  virtual bool get_date(DRIZZLE_TIME *ltime,uint fuzzydate);
437
783
  virtual bool get_time(DRIZZLE_TIME *ltime);
438
 
  virtual bool get_date_result(DRIZZLE_TIME *ltime,uint32_t fuzzydate);
439
 
 
 
784
  virtual bool get_date_result(DRIZZLE_TIME *ltime,uint fuzzydate)
 
785
  { return get_date(ltime,fuzzydate); }
440
786
  /*
441
 
    The method allows to determine nullness of a complex expression
442
 
    without fully evaluating it, instead of calling val/result*() then
 
787
    The method allows to determine nullness of a complex expression 
 
788
    without fully evaluating it, instead of calling val/result*() then 
443
789
    checking null_value. Used in Item_func_isnull/Item_func_isnotnull
444
790
    and Item_sum_count/Item_sum_count_distinct.
445
791
    Any new item which can be NULL must implement this method.
446
792
  */
447
 
  virtual bool is_null();
 
793
  virtual bool is_null() { return 0; }
448
794
 
449
795
  /*
450
796
   Make sure the null_value member has a correct value.
451
797
  */
452
 
  virtual void update_null_value ();
 
798
  virtual void update_null_value () { (void) val_int(); }
453
799
 
454
800
  /*
455
801
    Inform the item that there will be no distinction between its result
461
807
      Item_cond_and and subquery-related item) enable special optimizations
462
808
      when they are "top level".
463
809
  */
464
 
  virtual void top_level_item(void);
 
810
  virtual void top_level_item(void) {}
465
811
  /*
466
812
    set field of temporary table for Item which can be switched on temporary
467
813
    table during query processing (grouping and so on)
468
814
  */
469
 
  virtual void set_result_field(Field *field);
470
 
  virtual bool is_result_field(void);
471
 
  virtual bool is_bool_func(void);
472
 
  virtual void save_in_result_field(bool no_conversions);
473
 
 
 
815
  virtual void set_result_field(Field *field __attribute__((unused))) {}
 
816
  virtual bool is_result_field(void) { return 0; }
 
817
  virtual bool is_bool_func(void) { return 0; }
 
818
  virtual void save_in_result_field(bool no_conversions __attribute__((unused)))
 
819
  {}
474
820
  /*
475
821
    set value of aggregate function in case of no rows for grouping were found
476
822
  */
477
 
  virtual void no_rows_in_result(void);
478
 
  virtual Item *copy_or_same(Session *session);
479
 
 
480
 
  virtual Item *copy_andor_structure(Session *session);
481
 
 
482
 
  virtual Item *real_item(void);
483
 
  virtual Item *get_tmp_table_item(Session *session);
484
 
 
485
 
  static const CHARSET_INFO *default_charset();
486
 
  virtual const CHARSET_INFO *compare_collation();
487
 
 
488
 
  virtual bool walk(Item_processor processor,
489
 
                    bool walk_subquery,
490
 
                    unsigned char *arg);
491
 
 
492
 
  virtual Item* transform(Item_transformer transformer, unsigned char *arg);
 
823
  virtual void no_rows_in_result(void) {}
 
824
  virtual Item *copy_or_same(THD *thd __attribute__((unused)))
 
825
  { return this; }
 
826
  virtual Item *copy_andor_structure(THD *thd  __attribute__((unused)))
 
827
  { return this; }
 
828
  virtual Item *real_item(void) { return this; }
 
829
  virtual Item *get_tmp_table_item(THD *thd) { return copy_or_same(thd); }
 
830
 
 
831
  static CHARSET_INFO *default_charset();
 
832
  virtual CHARSET_INFO *compare_collation() { return NULL; }
 
833
 
 
834
  virtual bool walk(Item_processor processor __attribute__((unused)),
 
835
                    bool walk_subquery __attribute__((unused)),
 
836
                    uchar *arg)
 
837
  {
 
838
    return (this->*processor)(arg);
 
839
  }
 
840
 
 
841
  virtual Item* transform(Item_transformer transformer, uchar *arg);
493
842
 
494
843
  /*
495
844
    This function performs a generic "compilation" of the Item tree.
496
 
    The process of compilation is assumed to go as follows:
497
 
 
 
845
    The process of compilation is assumed to go as follows: 
 
846
    
498
847
    compile()
499
 
    {
 
848
    { 
500
849
      if (this->*some_analyzer(...))
501
850
      {
502
851
        compile children if any;
505
854
    }
506
855
 
507
856
    i.e. analysis is performed top-down while transformation is done
508
 
    bottom-up.
509
 
  */
510
 
  virtual Item* compile(Item_analyzer analyzer, unsigned char **arg_p,
511
 
                        Item_transformer transformer, unsigned char *arg_t);
512
 
 
513
 
  virtual void traverse_cond(Cond_traverser traverser,
514
 
                             void *arg,
515
 
                             traverse_order order);
516
 
 
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);
525
 
 
526
 
  /*
527
 
    The next function differs from the previous one that a bitmap to be updated
528
 
    is passed as unsigned char *arg.
529
 
  */
530
 
  virtual bool register_field_in_bitmap(unsigned char *arg);
531
 
  virtual bool subst_argument_checker(unsigned char **arg);
532
 
 
533
 
  /*
534
 
    Check if an expression/function is allowed for a virtual column
535
 
    SYNOPSIS
536
 
      check_vcol_func_processor()
537
 
      arg is just ignored
538
 
    RETURN VALUE
539
 
      TRUE                           Function not accepted
540
 
      FALSE                          Function accepted
541
 
  */
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);
546
 
 
 
857
    bottom-up.      
 
858
  */
 
859
  virtual Item* compile(Item_analyzer analyzer, uchar **arg_p,
 
860
                        Item_transformer transformer, uchar *arg_t)
 
861
  {
 
862
    if ((this->*analyzer) (arg_p))
 
863
      return ((this->*transformer) (arg_t));
 
864
    return 0;
 
865
  }
 
866
 
 
867
   virtual void traverse_cond(Cond_traverser traverser __attribute__((unused)),
 
868
                              void *arg,
 
869
                              traverse_order order __attribute__((unused)))
 
870
   {
 
871
     (*traverser)(this, arg);
 
872
   }
 
873
 
 
874
  virtual bool remove_dependence_processor(uchar * arg __attribute__((unused)))
 
875
  { return 0; }
 
876
  virtual bool remove_fixed(uchar * arg __attribute__((unused)))
 
877
  {
 
878
    fixed= 0;
 
879
    return 0;
 
880
  }
 
881
  virtual bool cleanup_processor(uchar *arg __attribute__((unused)));
 
882
  virtual bool collect_item_field_processor(uchar * arg __attribute__((unused)))
 
883
  { return 0; }
 
884
  virtual bool find_item_in_field_list_processor(uchar *arg __attribute__((unused)))
 
885
 { return 0; }
 
886
  virtual bool change_context_processor(uchar *context __attribute__((unused)))
 
887
  { return 0; }
 
888
  virtual bool reset_query_id_processor(uchar *query_id_arg __attribute__((unused)))
 
889
  { return 0; }
 
890
  virtual bool register_field_in_read_map(uchar *arg __attribute__((unused)))
 
891
  { return 0; }
 
892
  virtual bool subst_argument_checker(uchar **arg)
 
893
  {
 
894
    if (*arg)
 
895
      *arg= NULL;
 
896
    return true;
 
897
  }
 
898
 
 
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; }
547
902
 
548
903
  /*
549
904
    For SP local variable returns pointer to Item representing its
550
905
    current value and pointer to current Item otherwise.
551
906
  */
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; }
554
909
 
555
910
  /*
556
911
    For SP local variable returns address of pointer to Item representing its
557
912
    current value and pointer passed via parameter otherwise.
558
913
  */
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; }
560
915
 
561
916
  // Row emulation
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();
570
 
 
571
 
  Field *tmp_table_field_from_field_type(Table *table, bool fixed_length);
572
 
  virtual Item_field *filed_for_view_update();
573
 
 
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);
577
 
  void delete_self();
 
924
  virtual void bring_value() {}
 
925
 
 
926
  Field *tmp_table_field_from_field_type(TABLE *table, bool fixed_length);
 
927
  virtual Item_field *filed_for_view_update() { return 0; }
 
928
 
 
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);
 
932
  void delete_self()
 
933
  {
 
934
    cleanup();
 
935
    delete this;
 
936
  }
578
937
 
579
938
  /*
580
939
    result_as_int64_t() must return true for Items representing DATE/TIME
583
942
    their values should be compared as integers (because the integer
584
943
    representation is more precise than the string one).
585
944
  */
586
 
  virtual bool result_as_int64_t();
 
945
  virtual bool result_as_int64_t() { return false; }
587
946
  bool is_datetime();
588
947
 
589
948
  /*
597
956
    where 'cost' is either 'double' or some structure of various cost
598
957
    parameters.
599
958
  */
600
 
  virtual bool is_expensive();
601
 
 
 
959
  virtual bool is_expensive()
 
960
  {
 
961
    if (is_expensive_cache < 0)
 
962
      is_expensive_cache= walk(&Item::is_expensive_processor, 0, (uchar*)0);
 
963
    return test(is_expensive_cache);
 
964
  }
602
965
  String *check_well_formed_result(String *str, bool send_error= 0);
603
 
  bool eq_by_collation(Item *item, bool binary_cmp,
604
 
                       const CHARSET_INFO * const cs);
605
 
 
 
966
  bool eq_by_collation(Item *item, bool binary_cmp, CHARSET_INFO *cs); 
606
967
};
607
968
 
608
969
 
622
983
  }
623
984
};
624
985
 
 
986
bool agg_item_collations(DTCollation &c, const char *name,
 
987
                         Item **items, uint nitems, uint flags, int item_sep);
 
988
bool agg_item_collations_for_comparison(DTCollation &c, const char *name,
 
989
                                        Item **items, uint nitems, uint flags);
 
990
bool agg_item_charsets(DTCollation &c, const char *name,
 
991
                       Item **items, uint nitems, uint flags, int item_sep);
 
992
 
625
993
 
626
994
class Item_num: public Item_basic_constant
627
995
{
628
996
public:
629
997
  Item_num() {}                               /* Remove gcc warning */
630
998
  virtual Item_num *neg()= 0;
631
 
  Item *safe_charset_converter(const CHARSET_INFO * const tocs);
 
999
  Item *safe_charset_converter(CHARSET_INFO *tocs);
632
1000
};
633
1001
 
 
1002
#define NO_CACHED_FIELD_INDEX ((uint)(-1))
 
1003
 
 
1004
class st_select_lex;
634
1005
class Item_ident :public Item
635
1006
{
636
1007
protected:
652
1023
  bool alias_name_used; /* true if item was resolved against alias */
653
1024
  /* 
654
1025
    Cached value of index for this field in table->field array, used by prep. 
655
 
    stmts for speeding up their re-execution. Holds NO_CACHED_FIELD_INDEX
 
1026
    stmts for speeding up their re-execution. Holds NO_CACHED_FIELD_INDEX 
656
1027
    if index value is not known.
657
1028
  */
658
 
  uint32_t cached_field_index;
 
1029
  uint cached_field_index;
659
1030
  /*
660
1031
    Cached pointer to table which contains this field, used for the same reason
661
1032
    by prep. stmt. too in case then we have not-fully qualified field.
662
1033
    0 - means no cached value.
663
1034
  */
664
 
  TableList *cached_table;
 
1035
  TABLE_LIST *cached_table;
665
1036
  st_select_lex *depended_from;
666
1037
  Item_ident(Name_resolution_context *context_arg,
667
1038
             const char *db_name_arg, const char *table_name_arg,
668
1039
             const char *field_name_arg);
669
 
  Item_ident(Session *session, Item_ident *item);
 
1040
  Item_ident(THD *thd, Item_ident *item);
670
1041
  const char *full_name() const;
671
1042
  void cleanup();
672
 
  bool remove_dependence_processor(unsigned char * arg);
 
1043
  bool remove_dependence_processor(uchar * arg);
673
1044
  virtual void print(String *str, enum_query_type query_type);
674
 
  virtual bool change_context_processor(unsigned char *cntx)
 
1045
  virtual bool change_context_processor(uchar *cntx)
675
1046
    { context= (Name_resolution_context *)cntx; return false; }
676
 
  friend bool insert_fields(Session *session, Name_resolution_context *context,
 
1047
  friend bool insert_fields(THD *thd, Name_resolution_context *context,
677
1048
                            const char *db_name,
678
1049
                            const char *table_name, List_iterator<Item> *it,
679
1050
                            bool any_privileges);
693
1064
  {}
694
1065
 
695
1066
  enum Type type() const { return FIELD_ITEM; }
696
 
  double val_real();
697
 
  int64_t val_int();
698
 
  String *val_str(String *str);
699
 
  my_decimal *val_decimal(my_decimal *dec);
 
1067
  double val_real() { return field->val_real(); }
 
1068
  int64_t val_int() { return field->val_int(); }
 
1069
  String *val_str(String *str) { return field->val_str(str); }
 
1070
  my_decimal *val_decimal(my_decimal *dec) { return field->val_decimal(dec); }
700
1071
  void make_field(Send_field *tmp_field);
701
1072
};
702
1073
 
703
1074
 
 
1075
class Item_equal;
 
1076
class COND_EQUAL;
 
1077
 
704
1078
class Item_field :public Item_ident
705
1079
{
706
1080
protected:
713
1087
    if any_privileges set to true then here real effective privileges will
714
1088
    be stored
715
1089
  */
716
 
  uint32_t have_privileges;
 
1090
  uint have_privileges;
717
1091
  /* field need any privileges (for VIEW creation) */
718
1092
  bool any_privileges;
719
1093
  Item_field(Name_resolution_context *context_arg,
722
1096
  /*
723
1097
    Constructor needed to process subselect with temporary tables (see Item)
724
1098
  */
725
 
  Item_field(Session *session, Item_field *item);
 
1099
  Item_field(THD *thd, Item_field *item);
726
1100
  /*
727
1101
    Constructor used inside setup_wild(), ensures that field, table,
728
1102
    and database names will live as long as Item_field (this is important
729
1103
    in prepared statements).
730
1104
  */
731
 
  Item_field(Session *session, Name_resolution_context *context_arg, Field *field);
 
1105
  Item_field(THD *thd, Name_resolution_context *context_arg, Field *field);
732
1106
  /*
733
1107
    If this constructor is used, fix_fields() won't work, because
734
1108
    db_name, table_name and column_name are unknown. It's necessary to call
748
1122
  bool val_bool_result();
749
1123
  bool send(Protocol *protocol, String *str_arg);
750
1124
  void reset_field(Field *f);
751
 
  bool fix_fields(Session *, Item **);
 
1125
  bool fix_fields(THD *, Item **);
752
1126
  void fix_after_pullout(st_select_lex *new_parent, Item **ref);
753
1127
  void make_field(Send_field *tmp_field);
754
1128
  int save_in_field(Field *field,bool no_conversions);
755
1129
  void save_org_in_field(Field *field);
756
1130
  table_map used_tables() const;
757
 
  enum Item_result result_type () const;
758
 
  Item_result cast_to_int_type() const;
759
 
  enum_field_types field_type() const;
 
1131
  enum Item_result result_type () const
 
1132
  {
 
1133
    return field->result_type();
 
1134
  }
 
1135
  Item_result cast_to_int_type() const
 
1136
  {
 
1137
    return field->cast_to_int_type();
 
1138
  }
 
1139
  enum_field_types field_type() const
 
1140
  {
 
1141
    return field->type();
 
1142
  }
760
1143
  enum_monotonicity_info get_monotonicity_info() const
761
1144
  {
762
1145
    return MONOTONIC_STRICT_INCREASING;
763
1146
  }
764
1147
  int64_t val_int_endpoint(bool left_endp, bool *incl_endp);
765
1148
  Field *get_tmp_table_field() { return result_field; }
766
 
  Field *tmp_table_field(Table *t_arg __attribute__((unused))) { return result_field; }
767
 
  bool get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate);
768
 
  bool get_date_result(DRIZZLE_TIME *ltime,uint32_t fuzzydate);
 
1149
  Field *tmp_table_field(TABLE *t_arg __attribute__((unused))) { return result_field; }
 
1150
  bool get_date(DRIZZLE_TIME *ltime,uint fuzzydate);
 
1151
  bool get_date_result(DRIZZLE_TIME *ltime,uint fuzzydate);
769
1152
  bool get_time(DRIZZLE_TIME *ltime);
770
 
  bool is_null();
 
1153
  bool is_null() { return field->is_null(); }
771
1154
  void update_null_value();
772
 
  Item *get_tmp_table_item(Session *session);
773
 
  bool collect_item_field_processor(unsigned char * arg);
774
 
  bool find_item_in_field_list_processor(unsigned char *arg);
775
 
  bool register_field_in_read_map(unsigned char *arg);
776
 
  bool register_field_in_bitmap(unsigned char *arg);
777
 
  bool check_vcol_func_processor(unsigned char *arg __attribute__((unused)))
778
 
  { return false; }
 
1155
  Item *get_tmp_table_item(THD *thd);
 
1156
  bool collect_item_field_processor(uchar * arg);
 
1157
  bool find_item_in_field_list_processor(uchar *arg);
 
1158
  bool register_field_in_read_map(uchar *arg);
779
1159
  void cleanup();
780
 
  bool result_as_int64_t();
 
1160
  bool result_as_int64_t()
 
1161
  {
 
1162
    return field->can_be_compared_as_int64_t();
 
1163
  }
781
1164
  Item_equal *find_item_equal(COND_EQUAL *cond_equal);
782
 
  bool subst_argument_checker(unsigned char **arg);
783
 
  Item *equal_fields_propagator(unsigned char *arg);
784
 
  bool set_no_const_sub(unsigned char *arg);
785
 
  Item *replace_equal_field(unsigned char *arg);
786
 
  uint32_t max_disp_length();
 
1165
  bool subst_argument_checker(uchar **arg);
 
1166
  Item *equal_fields_propagator(uchar *arg);
 
1167
  bool set_no_const_sub(uchar *arg);
 
1168
  Item *replace_equal_field(uchar *arg);
 
1169
  inline uint32_t max_disp_length() { return field->max_display_length(); }
787
1170
  Item_field *filed_for_view_update() { return this; }
788
 
  Item *safe_charset_converter(const CHARSET_INFO * const tocs);
789
 
  int fix_outer_field(Session *session, Field **field, Item **reference);
790
 
  virtual Item *update_value_transformer(unsigned char *select_arg);
 
1171
  Item *safe_charset_converter(CHARSET_INFO *tocs);
 
1172
  int fix_outer_field(THD *thd, Field **field, Item **reference);
 
1173
  virtual Item *update_value_transformer(uchar *select_arg);
791
1174
  virtual void print(String *str, enum_query_type query_type);
792
1175
 
793
1176
  friend class Item_default_value;
827
1210
    str->append(STRING_WITH_LEN("NULL"));
828
1211
  }
829
1212
 
830
 
  Item *safe_charset_converter(const CHARSET_INFO * const tocs);
831
 
  bool check_vcol_func_processor(unsigned char *arg __attribute__((unused)))
832
 
  { return false; }
 
1213
  Item *safe_charset_converter(CHARSET_INFO *tocs);
833
1214
};
834
1215
 
835
1216
class Item_null_result :public Item_null
842
1223
  {
843
1224
    save_in_field(result_field, no_conversions);
844
1225
  }
845
 
  bool check_vcol_func_processor(unsigned char *arg __attribute__((unused)))
846
 
  { return true; }
847
1226
};  
848
1227
 
849
1228
/* Item represents one placeholder ('?') of prepared statement */
886
1265
    */
887
1266
    struct CONVERSION_INFO
888
1267
    {
889
 
      const CHARSET_INFO *character_set_client;
890
 
      const CHARSET_INFO *character_set_of_placeholder;
 
1268
      CHARSET_INFO *character_set_client;
 
1269
      CHARSET_INFO *character_set_of_placeholder;
891
1270
      /*
892
1271
        This points at character set of connection if conversion
893
1272
        to it is required (i. e. if placeholder typecode is not BLOB).
894
1273
        Otherwise it's equal to character_set_client (to simplify
895
1274
        check in convert_str_value()).
896
1275
      */
897
 
      const CHARSET_INFO *final_character_set_of_str_value;
 
1276
      CHARSET_INFO *final_character_set_of_str_value;
898
1277
    } cs_info;
899
1278
    DRIZZLE_TIME     time;
900
1279
  } value;
916
1295
    Offset of placeholder inside statement text. Used to create
917
1296
    no-placeholders version of this statement for the binary log.
918
1297
  */
919
 
  uint32_t pos_in_query;
 
1298
  uint pos_in_query;
920
1299
 
921
 
  Item_param(uint32_t pos_in_query_arg);
 
1300
  Item_param(uint pos_in_query_arg);
922
1301
 
923
1302
  enum Item_result result_type () const { return item_result_type; }
924
1303
  enum Type type() const { return item_type; }
929
1308
  my_decimal *val_decimal(my_decimal*);
930
1309
  String *val_str(String*);
931
1310
  bool get_time(DRIZZLE_TIME *tm);
932
 
  bool get_date(DRIZZLE_TIME *tm, uint32_t fuzzydate);
 
1311
  bool get_date(DRIZZLE_TIME *tm, uint fuzzydate);
933
1312
  int  save_in_field(Field *field, bool no_conversions);
934
1313
 
935
1314
  void set_null();
936
1315
  void set_int(int64_t i, uint32_t max_length_arg);
937
1316
  void set_double(double i);
938
 
  void set_decimal(char *str, ulong length);
 
1317
  void set_decimal(const char *str, ulong length);
939
1318
  bool set_str(const char *str, ulong length);
940
1319
  bool set_longdata(const char *str, ulong length);
941
 
  void set_time(DRIZZLE_TIME *tm, enum enum_drizzle_timestamp_type type,
942
 
                uint32_t max_length_arg);
943
 
  bool set_from_user_var(Session *session, const user_var_entry *entry);
 
1320
  void set_time(DRIZZLE_TIME *tm, timestamp_type type, uint32_t max_length_arg);
 
1321
  bool set_from_user_var(THD *thd, const user_var_entry *entry);
944
1322
  void reset();
945
1323
  /*
946
1324
    Assign placeholder value from bind data.
948
1326
    don't need to check that packet is not broken there). See
949
1327
    sql_prepare.cc for details.
950
1328
  */
951
 
  void (*set_param_func)(Item_param *param, unsigned char **pos, ulong len);
 
1329
  void (*set_param_func)(Item_param *param, uchar **pos, ulong len);
952
1330
 
953
1331
  const String *query_val_str(String *str) const;
954
1332
 
955
 
  bool convert_str_value(Session *session);
 
1333
  bool convert_str_value(THD *thd);
956
1334
 
957
1335
  /*
958
1336
    If value for parameter was not set we treat it as non-const
975
1353
    constant, assert otherwise. This method is called only if
976
1354
    basic_const_item returned true.
977
1355
  */
978
 
  Item *safe_charset_converter(const CHARSET_INFO * const tocs);
 
1356
  Item *safe_charset_converter(CHARSET_INFO *tocs);
979
1357
  Item *clone_item();
980
1358
  /*
981
1359
    Implement by-value equality evaluation if parameter value
992
1370
{
993
1371
public:
994
1372
  int64_t value;
995
 
  Item_int(int32_t i,uint32_t length= MY_INT32_NUM_DECIMAL_DIGITS)
 
1373
  Item_int(int32_t i,uint length= MY_INT32_NUM_DECIMAL_DIGITS)
996
1374
    :value((int64_t) i)
997
1375
    { max_length=length; fixed= 1; }
998
 
  Item_int(int64_t i,uint32_t length= MY_INT64_NUM_DECIMAL_DIGITS)
 
1376
  Item_int(int64_t i,uint length= MY_INT64_NUM_DECIMAL_DIGITS)
999
1377
    :value(i)
1000
1378
    { max_length=length; fixed= 1; }
1001
 
  Item_int(uint64_t i, uint32_t length= MY_INT64_NUM_DECIMAL_DIGITS)
 
1379
  Item_int(uint64_t i, uint length= MY_INT64_NUM_DECIMAL_DIGITS)
1002
1380
    :value((int64_t)i)
1003
1381
    { max_length=length; fixed= 1; unsigned_flag= 1; }
1004
 
  Item_int(const char *str_arg,int64_t i,uint32_t length) :value(i)
 
1382
  Item_int(const char *str_arg,int64_t i,uint length) :value(i)
1005
1383
    { max_length=length; name=(char*) str_arg; fixed= 1; }
1006
 
  Item_int(const char *str_arg, uint32_t length=64);
 
1384
  Item_int(const char *str_arg, uint length=64);
1007
1385
  enum Type type() const { return INT_ITEM; }
1008
1386
  enum Item_result result_type () const { return INT_RESULT; }
1009
1387
  enum_field_types field_type() const { return DRIZZLE_TYPE_LONGLONG; }
1016
1394
  Item *clone_item() { return new Item_int(name,value,max_length); }
1017
1395
  virtual void print(String *str, enum_query_type query_type);
1018
1396
  Item_num *neg() { value= -value; return this; }
1019
 
  uint32_t decimal_precision() const
 
1397
  uint decimal_precision() const
1020
1398
  { return (uint)(max_length - test(value < 0)); }
1021
1399
  bool eq(const Item *, bool binary_cmp) const;
1022
 
  bool check_vcol_func_processor(unsigned char *arg __attribute__((unused)))
1023
 
  { return false; }
1024
1400
};
1025
1401
 
1026
1402
 
1027
1403
class Item_uint :public Item_int
1028
1404
{
1029
1405
public:
1030
 
  Item_uint(const char *str_arg, uint32_t length);
 
1406
  Item_uint(const char *str_arg, uint length);
1031
1407
  Item_uint(uint64_t i) :Item_int((uint64_t) i, 10) {}
1032
 
  Item_uint(const char *str_arg, int64_t i, uint32_t length);
 
1408
  Item_uint(const char *str_arg, int64_t i, uint length);
1033
1409
  double val_real()
1034
1410
    { assert(fixed == 1); return uint64_t2double((uint64_t)value); }
1035
1411
  String *val_str(String*);
1037
1413
  int save_in_field(Field *field, bool no_conversions);
1038
1414
  virtual void print(String *str, enum_query_type query_type);
1039
1415
  Item_num *neg ();
1040
 
  uint32_t decimal_precision() const { return max_length; }
1041
 
  bool check_vcol_func_processor(unsigned char *arg __attribute__((unused)))
1042
 
  { return false; }
 
1416
  uint decimal_precision() const { return max_length; }
1043
1417
};
1044
1418
 
1045
1419
 
1049
1423
protected:
1050
1424
  my_decimal decimal_value;
1051
1425
public:
1052
 
  Item_decimal(const char *str_arg, uint32_t length, const CHARSET_INFO * const charset);
 
1426
  Item_decimal(const char *str_arg, uint length, CHARSET_INFO *charset);
1053
1427
  Item_decimal(const char *str, const my_decimal *val_arg,
1054
 
               uint32_t decimal_par, uint32_t length);
 
1428
               uint decimal_par, uint length);
1055
1429
  Item_decimal(my_decimal *value_par);
1056
1430
  Item_decimal(int64_t val, bool unsig);
1057
1431
  Item_decimal(double val, int precision, int scale);
1058
 
  Item_decimal(const unsigned char *bin, int precision, int scale);
 
1432
  Item_decimal(const uchar *bin, int precision, int scale);
1059
1433
 
1060
1434
  enum Type type() const { return DECIMAL_ITEM; }
1061
1435
  enum Item_result result_type () const { return DECIMAL_RESULT; }
1078
1452
    unsigned_flag= !decimal_value.sign();
1079
1453
    return this;
1080
1454
  }
1081
 
  uint32_t decimal_precision() const { return decimal_value.precision(); }
 
1455
  uint decimal_precision() const { return decimal_value.precision(); }
1082
1456
  bool eq(const Item *, bool binary_cmp) const;
1083
1457
  void set_decimal_value(my_decimal *value_par);
1084
 
  bool check_vcol_func_processor(unsigned char *arg __attribute__((unused)))
1085
 
  { return false; }
1086
1458
};
1087
1459
 
1088
1460
 
1092
1464
public:
1093
1465
  double value;
1094
1466
  // Item_real() :value(0) {}
1095
 
  Item_float(const char *str_arg, uint32_t length);
1096
 
  Item_float(const char *str,double val_arg,uint32_t decimal_par,uint32_t length)
 
1467
  Item_float(const char *str_arg, uint length);
 
1468
  Item_float(const char *str,double val_arg,uint decimal_par,uint length)
1097
1469
    :value(val_arg)
1098
1470
  {
1099
1471
    presentation= name=(char*) str;
1101
1473
    max_length=length;
1102
1474
    fixed= 1;
1103
1475
  }
1104
 
  Item_float(double value_par, uint32_t decimal_par) :presentation(0), value(value_par)
 
1476
  Item_float(double value_par, uint decimal_par) :presentation(0), value(value_par)
1105
1477
  {
1106
1478
    decimals= (uint8_t) decimal_par;
1107
1479
    fixed= 1;
1110
1482
  enum Type type() const { return REAL_ITEM; }
1111
1483
  enum_field_types field_type() const { return DRIZZLE_TYPE_DOUBLE; }
1112
1484
  double val_real() { assert(fixed == 1); return value; }
1113
 
  int64_t val_int();
 
1485
  int64_t val_int()
 
1486
  {
 
1487
    assert(fixed == 1);
 
1488
    if (value <= (double) INT64_MIN)
 
1489
    {
 
1490
       return INT64_MIN;
 
1491
    }
 
1492
    else if (value >= (double) (uint64_t) INT64_MAX)
 
1493
    {
 
1494
      return INT64_MAX;
 
1495
    }
 
1496
    return (int64_t) rint(value);
 
1497
  }
1114
1498
  String *val_str(String*);
1115
1499
  my_decimal *val_decimal(my_decimal *);
1116
1500
  bool basic_const_item() const { return 1; }
1126
1510
{
1127
1511
  const char *func_name;
1128
1512
public:
1129
 
  Item_static_float_func(const char *str, double val_arg, uint32_t decimal_par,
1130
 
                        uint32_t length)
1131
 
    :Item_float(NULL, val_arg, decimal_par, length), func_name(str)
 
1513
  Item_static_float_func(const char *str, double val_arg, uint decimal_par,
 
1514
                        uint length)
 
1515
    :Item_float(NullS, val_arg, decimal_par, length), func_name(str)
1132
1516
  {}
1133
1517
 
1134
1518
  virtual inline void print(String *str,
1137
1521
    str->append(func_name);
1138
1522
  }
1139
1523
 
1140
 
  Item *safe_charset_converter(const CHARSET_INFO * const tocs);
1141
 
  bool check_vcol_func_processor(unsigned char *arg __attribute__((unused)))
1142
 
  { return false; }
 
1524
  Item *safe_charset_converter(CHARSET_INFO *tocs);
1143
1525
};
1144
1526
 
1145
1527
 
1146
1528
class Item_string :public Item_basic_constant
1147
1529
{
1148
1530
public:
1149
 
  Item_string(const char *str,uint32_t length,
1150
 
              const CHARSET_INFO * const cs, Derivation dv= DERIVATION_COERCIBLE,
1151
 
              uint32_t repertoire= MY_REPERTOIRE_UNICODE30)
 
1531
  Item_string(const char *str,uint length,
 
1532
              CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE,
 
1533
              uint repertoire= MY_REPERTOIRE_UNICODE30)
1152
1534
    : m_cs_specified(false)
1153
1535
  {
1154
1536
    str_value.set_or_copy_aligned(str, length, cs);
1167
1549
    fixed= 1;
1168
1550
  }
1169
1551
  /* Just create an item and do not fill string representation */
1170
 
  Item_string(const CHARSET_INFO * const cs, Derivation dv= DERIVATION_COERCIBLE)
 
1552
  Item_string(CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE)
1171
1553
    : m_cs_specified(false)
1172
1554
  {
1173
1555
    collation.set(cs, dv);
1176
1558
    decimals= NOT_FIXED_DEC;
1177
1559
    fixed= 1;
1178
1560
  }
1179
 
  Item_string(const char *name_par, const char *str, uint32_t length,
1180
 
              const CHARSET_INFO * const cs, Derivation dv= DERIVATION_COERCIBLE,
1181
 
              uint32_t repertoire= MY_REPERTOIRE_UNICODE30)
 
1561
  Item_string(const char *name_par, const char *str, uint length,
 
1562
              CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE,
 
1563
              uint repertoire= MY_REPERTOIRE_UNICODE30)
1182
1564
    : m_cs_specified(false)
1183
1565
  {
1184
1566
    str_value.set_or_copy_aligned(str, length, cs);
1189
1571
    // it is constant => can be used without fix_fields (and frequently used)
1190
1572
    fixed= 1;
1191
1573
  }
 
1574
  /*
 
1575
    This is used in stored procedures to avoid memory leaks and
 
1576
    does a deep copy of its argument.
 
1577
  */
 
1578
  void set_str_with_copy(const char *str_arg, uint length_arg)
 
1579
  {
 
1580
    str_value.copy(str_arg, length_arg, collation.collation);
 
1581
    max_length= str_value.numchars() * collation.collation->mbmaxlen;
 
1582
  }
1192
1583
  void set_repertoire_from_value()
1193
1584
  {
1194
1585
    collation.repertoire= my_string_repertoire(str_value.charset(),
1214
1605
    return new Item_string(name, str_value.ptr(), 
1215
1606
                           str_value.length(), collation.collation);
1216
1607
  }
1217
 
  Item *safe_charset_converter(const CHARSET_INFO * const tocs);
1218
 
  inline void append(char *str, uint32_t length)
 
1608
  Item *safe_charset_converter(CHARSET_INFO *tocs);
 
1609
  inline void append(char *str, uint length)
1219
1610
  {
1220
1611
    str_value.append(str, length);
1221
1612
    max_length= str_value.numchars() * collation.collation->mbmaxlen;
1260
1651
  {
1261
1652
    m_cs_specified= cs_specified;
1262
1653
  }
1263
 
  bool check_vcol_func_processor(unsigned char *arg __attribute__((unused)))
1264
 
  { return false; }
1265
1654
 
1266
1655
private:
1267
1656
  bool m_cs_specified;
1272
1661
{
1273
1662
  const char *func_name;
1274
1663
public:
1275
 
  Item_static_string_func(const char *name_par, const char *str, uint32_t length,
1276
 
                          const CHARSET_INFO * const cs,
 
1664
  Item_static_string_func(const char *name_par, const char *str, uint length,
 
1665
                          CHARSET_INFO *cs,
1277
1666
                          Derivation dv= DERIVATION_COERCIBLE)
1278
 
    :Item_string(NULL, str, length, cs, dv), func_name(name_par)
 
1667
    :Item_string(NullS, str, length, cs, dv), func_name(name_par)
1279
1668
  {}
1280
 
  Item *safe_charset_converter(const CHARSET_INFO * const tocs);
 
1669
  Item *safe_charset_converter(CHARSET_INFO *tocs);
1281
1670
 
1282
1671
  virtual inline void print(String *str,
1283
1672
                            enum_query_type query_type __attribute__((unused)))
1284
1673
  {
1285
1674
    str->append(func_name);
1286
1675
  }
1287
 
  bool check_vcol_func_processor(unsigned char *arg __attribute__((unused)))
1288
 
  { return true; }
1289
1676
};
1290
1677
 
1291
1678
 
1305
1692
class Item_blob :public Item_string
1306
1693
{
1307
1694
public:
1308
 
  Item_blob(const char *name, uint32_t length) :
 
1695
  Item_blob(const char *name, uint length) :
1309
1696
    Item_string(name, length, &my_charset_bin)
1310
1697
  { max_length= length; }
1311
1698
  enum Type type() const { return TYPE_HOLDER; }
1322
1709
class Item_empty_string :public Item_string
1323
1710
{
1324
1711
public:
1325
 
  Item_empty_string(const char *header,uint32_t length, const CHARSET_INFO * cs= NULL) :
 
1712
  Item_empty_string(const char *header,uint length, CHARSET_INFO *cs= NULL) :
1326
1713
    Item_string("",0, cs ? cs : &my_charset_utf8_general_ci)
1327
1714
    { name=(char*) header; max_length= cs ? length * cs->mbmaxlen : length; }
1328
1715
  void make_field(Send_field *field);
1333
1720
{
1334
1721
  enum_field_types int_field_type;
1335
1722
public:
1336
 
  Item_return_int(const char *name_arg, uint32_t length,
 
1723
  Item_return_int(const char *name_arg, uint length,
1337
1724
                  enum_field_types field_type_arg, int64_t value= 0)
1338
1725
    :Item_int(name_arg, value, length), int_field_type(field_type_arg)
1339
1726
  {
1347
1734
{
1348
1735
public:
1349
1736
  Item_hex_string() {}
1350
 
  Item_hex_string(const char *str,uint32_t str_length);
 
1737
  Item_hex_string(const char *str,uint str_length);
1351
1738
  enum Type type() const { return VARBIN_ITEM; }
1352
1739
  double val_real()
1353
1740
  { 
1364
1751
  enum_field_types field_type() const { return DRIZZLE_TYPE_VARCHAR; }
1365
1752
  virtual void print(String *str, enum_query_type query_type);
1366
1753
  bool eq(const Item *item, bool binary_cmp) const;
1367
 
  virtual Item *safe_charset_converter(const CHARSET_INFO * const tocs);
1368
 
  bool check_vcol_func_processor(unsigned char *arg __attribute__((unused)))
1369
 
  { return false; }
 
1754
  virtual Item *safe_charset_converter(CHARSET_INFO *tocs);
1370
1755
};
1371
1756
 
1372
1757
 
1373
1758
class Item_bin_string: public Item_hex_string
1374
1759
{
1375
1760
public:
1376
 
  Item_bin_string(const char *str,uint32_t str_length);
 
1761
  Item_bin_string(const char *str,uint str_length);
1377
1762
};
1378
1763
 
1379
1764
class Item_result_field :public Item    /* Item with result field */
1382
1767
  Field *result_field;                          /* Save result here */
1383
1768
  Item_result_field() :result_field(0) {}
1384
1769
  // Constructor used for Item_sum/Item_cond_and/or (see Item comment)
1385
 
  Item_result_field(Session *session, Item_result_field *item):
1386
 
    Item(session, item), result_field(item->result_field)
 
1770
  Item_result_field(THD *thd, Item_result_field *item):
 
1771
    Item(thd, item), result_field(item->result_field)
1387
1772
  {}
1388
1773
  ~Item_result_field() {}                       /* Required with gcc 2.95 */
1389
1774
  Field *get_tmp_table_field() { return result_field; }
1390
 
  Field *tmp_table_field(Table *t_arg __attribute__((unused)))
 
1775
  Field *tmp_table_field(TABLE *t_arg __attribute__((unused)))
1391
1776
  { return result_field; }
1392
1777
  table_map used_tables() const { return 1; }
1393
1778
  virtual void fix_length_and_dec()=0;
1398
1783
    save_in_field(result_field, no_conversions);
1399
1784
  }
1400
1785
  void cleanup();
1401
 
  bool check_vcol_func_processor(unsigned char *arg __attribute__((unused)))
1402
 
  { return false; }
1403
1786
};
1404
1787
 
1405
1788
 
1435
1818
           bool alias_name_used_arg= false);
1436
1819
 
1437
1820
  /* Constructor need to process subselect with temporary tables (see Item) */
1438
 
  Item_ref(Session *session, Item_ref *item)
1439
 
    :Item_ident(session, item), result_field(item->result_field), ref(item->ref) {}
 
1821
  Item_ref(THD *thd, Item_ref *item)
 
1822
    :Item_ident(thd, item), result_field(item->result_field), ref(item->ref) {}
1440
1823
  enum Type type() const                { return REF_ITEM; }
1441
1824
  bool eq(const Item *item, bool binary_cmp) const
1442
1825
  { 
1449
1832
  bool val_bool();
1450
1833
  String *val_str(String* tmp);
1451
1834
  bool is_null();
1452
 
  bool get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate);
 
1835
  bool get_date(DRIZZLE_TIME *ltime,uint fuzzydate);
1453
1836
  double val_result();
1454
1837
  int64_t val_int_result();
1455
1838
  String *str_result(String* tmp);
1457
1840
  bool val_bool_result();
1458
1841
  bool send(Protocol *prot, String *tmp);
1459
1842
  void make_field(Send_field *field);
1460
 
  bool fix_fields(Session *, Item **);
 
1843
  bool fix_fields(THD *, Item **);
1461
1844
  void fix_after_pullout(st_select_lex *new_parent, Item **ref);
1462
1845
  int save_in_field(Field *field, bool no_conversions);
1463
1846
  void save_org_in_field(Field *field);
1465
1848
  enum_field_types field_type() const   { return (*ref)->field_type(); }
1466
1849
  Field *get_tmp_table_field()
1467
1850
  { return result_field ? result_field : (*ref)->get_tmp_table_field(); }
1468
 
  Item *get_tmp_table_item(Session *session);
 
1851
  Item *get_tmp_table_item(THD *thd);
1469
1852
  table_map used_tables() const         
1470
1853
  {
1471
1854
    return depended_from ? OUTER_REF_TABLE_BIT : (*ref)->used_tables(); 
1486
1869
  {
1487
1870
    return ref ? (*ref)->real_item() : this;
1488
1871
  }
1489
 
  bool walk(Item_processor processor, bool walk_subquery, unsigned char *arg)
 
1872
  bool walk(Item_processor processor, bool walk_subquery, uchar *arg)
1490
1873
  { return (*ref)->walk(processor, walk_subquery, arg); }
1491
1874
  virtual void print(String *str, enum_query_type query_type);
1492
1875
  bool result_as_int64_t()
1499
1882
  virtual Ref_Type ref_type() { return REF; }
1500
1883
 
1501
1884
  // Row emulation: forwarding of ROW-related calls to ref
1502
 
  uint32_t cols()
 
1885
  uint cols()
1503
1886
  {
1504
1887
    return ref && result_type() == ROW_RESULT ? (*ref)->cols() : 1;
1505
1888
  }
1506
 
  Item* element_index(uint32_t i)
 
1889
  Item* element_index(uint i)
1507
1890
  {
1508
1891
    return ref && result_type() == ROW_RESULT ? (*ref)->element_index(i) : this;
1509
1892
  }
1510
 
  Item** addr(uint32_t i)
 
1893
  Item** addr(uint i)
1511
1894
  {
1512
1895
    return ref && result_type() == ROW_RESULT ? (*ref)->addr(i) : 0;
1513
1896
  }
1514
 
  bool check_cols(uint32_t c)
 
1897
  bool check_cols(uint c)
1515
1898
  {
1516
1899
    return ref && result_type() == ROW_RESULT ? (*ref)->check_cols(c) 
1517
1900
                                              : Item::check_cols(c);
1544
1927
              field_name_arg, alias_name_used_arg)
1545
1928
  {}
1546
1929
  /* Constructor need to process subselect with temporary tables (see Item) */
1547
 
  Item_direct_ref(Session *session, Item_direct_ref *item) : Item_ref(session, item) {}
 
1930
  Item_direct_ref(THD *thd, Item_direct_ref *item) : Item_ref(thd, item) {}
1548
1931
 
1549
1932
  double val_real();
1550
1933
  int64_t val_int();
1552
1935
  my_decimal *val_decimal(my_decimal *);
1553
1936
  bool val_bool();
1554
1937
  bool is_null();
1555
 
  bool get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate);
 
1938
  bool get_date(DRIZZLE_TIME *ltime,uint fuzzydate);
1556
1939
  virtual Ref_Type ref_type() { return DIRECT_REF; }
1557
1940
};
1558
1941
 
1559
1942
/*
 
1943
  Class for view fields, the same as Item_direct_ref, but call fix_fields
 
1944
  of reference if it is not called yet
 
1945
*/
 
1946
class Item_direct_view_ref :public Item_direct_ref
 
1947
{
 
1948
public:
 
1949
  Item_direct_view_ref(Name_resolution_context *context_arg, Item **item,
 
1950
                  const char *table_name_arg,
 
1951
                  const char *field_name_arg)
 
1952
    :Item_direct_ref(context_arg, item, table_name_arg, field_name_arg) {}
 
1953
  /* Constructor need to process subselect with temporary tables (see Item) */
 
1954
  Item_direct_view_ref(THD *thd, Item_direct_ref *item)
 
1955
    :Item_direct_ref(thd, item) {}
 
1956
 
 
1957
  bool fix_fields(THD *, Item **);
 
1958
  bool eq(const Item *item, bool binary_cmp) const;
 
1959
  Item *get_tmp_table_item(THD *thd)
 
1960
  {
 
1961
    Item *item= Item_ref::get_tmp_table_item(thd);
 
1962
    item->name= name;
 
1963
    return item;
 
1964
  }
 
1965
  virtual Ref_Type ref_type() { return VIEW_REF; }
 
1966
};
 
1967
 
 
1968
 
 
1969
/*
1560
1970
  Class for outer fields.
1561
1971
  An object of this class is created when the select where the outer field was
1562
1972
  resolved is a grouping one. After it has been fixed the ref field will point
1566
1976
  Item_field::fix_outer_field() functions.
1567
1977
*/
1568
1978
 
 
1979
class Item_sum;
1569
1980
class Item_outer_ref :public Item_direct_ref
1570
1981
{
1571
1982
public:
1599
2010
  {
1600
2011
    outer_ref->save_org_in_field(result_field);
1601
2012
  }
1602
 
  bool fix_fields(Session *, Item **);
 
2013
  bool fix_fields(THD *, Item **);
1603
2014
  void fix_after_pullout(st_select_lex *new_parent, Item **ref);
1604
2015
  table_map used_tables() const
1605
2016
  {
1609
2020
};
1610
2021
 
1611
2022
 
 
2023
class Item_in_subselect;
 
2024
 
1612
2025
 
1613
2026
/*
1614
2027
  An object of this class:
1634
2047
  String* val_str(String* s);
1635
2048
  my_decimal *val_decimal(my_decimal *);
1636
2049
  bool val_bool();
1637
 
  bool get_date(DRIZZLE_TIME *ltime, uint32_t fuzzydate);
 
2050
  bool get_date(DRIZZLE_TIME *ltime, uint fuzzydate);
1638
2051
  virtual void print(String *str, enum_query_type query_type);
1639
2052
  /*
1640
2053
    we add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE
1660
2073
{
1661
2074
  Item *ref;
1662
2075
public:
1663
 
  Item_int_with_ref(int64_t i, Item *ref_arg, bool unsigned_arg) :
 
2076
  Item_int_with_ref(int64_t i, Item *ref_arg, my_bool unsigned_arg) :
1664
2077
    Item_int(i), ref(ref_arg)
1665
2078
  {
1666
2079
    unsigned_flag= unsigned_arg;
1673
2086
  virtual Item *real_item() { return ref; }
1674
2087
};
1675
2088
 
 
2089
#ifdef MYSQL_SERVER
 
2090
#include "item_sum.h"
 
2091
#include "item_func.h"
 
2092
#include "item_row.h"
 
2093
#include "item_cmpfunc.h"
 
2094
#include "item_strfunc.h"
 
2095
#include "item_timefunc.h"
 
2096
#include "item_subselect.h"
 
2097
#endif
1676
2098
 
1677
2099
class Item_copy_string :public Item
1678
2100
{
1681
2103
  Item *item;
1682
2104
  Item_copy_string(Item *i) :item(i)
1683
2105
  {
1684
 
    null_value= maybe_null= item->maybe_null;
 
2106
    null_value=maybe_null=item->maybe_null;
1685
2107
    decimals=item->decimals;
1686
2108
    max_length=item->max_length;
1687
2109
    name=item->name;
1695
2117
    int err_not_used;
1696
2118
    char *end_not_used;
1697
2119
    return (null_value ? 0.0 :
1698
 
            my_strntod(str_value.charset(), (char*) str_value.ptr(),
1699
 
                       str_value.length(), &end_not_used, &err_not_used));
 
2120
            my_strntod(str_value.charset(), (char*) str_value.ptr(),
 
2121
                       str_value.length(), &end_not_used, &err_not_used));
1700
2122
  }
1701
2123
  int64_t val_int()
1702
2124
  {
1703
2125
    int err;
1704
 
    return null_value ? 0 : my_strntoll(str_value.charset(),str_value.ptr(),
1705
 
                                        str_value.length(),10, (char**) 0,
1706
 
                                        &err);
 
2126
    return null_value ? 0LL : my_strntoll(str_value.charset(),str_value.ptr(),
 
2127
                                            str_value.length(),10, (char**) 0,
 
2128
                                            &err); 
1707
2129
  }
1708
2130
  String *val_str(String*);
1709
2131
  my_decimal *val_decimal(my_decimal *);
1718
2140
  bool const_item() const { return 0; }
1719
2141
  bool is_null() { return null_value; }
1720
2142
};
 
2143
 
 
2144
 
 
2145
class Cached_item :public Sql_alloc
 
2146
{
 
2147
public:
 
2148
  my_bool null_value;
 
2149
  Cached_item() :null_value(0) {}
 
2150
  virtual bool cmp(void)=0;
 
2151
  virtual ~Cached_item(); /*line -e1509 */
 
2152
};
 
2153
 
 
2154
class Cached_item_str :public Cached_item
 
2155
{
 
2156
  Item *item;
 
2157
  String value,tmp_value;
 
2158
public:
 
2159
  Cached_item_str(THD *thd, Item *arg);
 
2160
  bool cmp(void);
 
2161
  ~Cached_item_str();                           // Deallocate String:s
 
2162
};
 
2163
 
 
2164
 
 
2165
class Cached_item_real :public Cached_item
 
2166
{
 
2167
  Item *item;
 
2168
  double value;
 
2169
public:
 
2170
  Cached_item_real(Item *item_par) :item(item_par),value(0.0) {}
 
2171
  bool cmp(void);
 
2172
};
 
2173
 
 
2174
class Cached_item_int :public Cached_item
 
2175
{
 
2176
  Item *item;
 
2177
  int64_t value;
 
2178
public:
 
2179
  Cached_item_int(Item *item_par) :item(item_par),value(0) {}
 
2180
  bool cmp(void);
 
2181
};
 
2182
 
 
2183
 
 
2184
class Cached_item_decimal :public Cached_item
 
2185
{
 
2186
  Item *item;
 
2187
  my_decimal value;
 
2188
public:
 
2189
  Cached_item_decimal(Item *item_par);
 
2190
  bool cmp(void);
 
2191
};
 
2192
 
 
2193
class Cached_item_field :public Cached_item
 
2194
{
 
2195
  uchar *buff;
 
2196
  Field *field;
 
2197
  uint length;
 
2198
 
 
2199
public:
 
2200
  Cached_item_field(Field *arg_field) : field(arg_field)
 
2201
  {
 
2202
    field= arg_field;
 
2203
    /* TODO: take the memory allocation below out of the constructor. */
 
2204
    buff= (uchar*) sql_calloc(length=field->pack_length());
 
2205
  }
 
2206
  bool cmp(void);
 
2207
};
 
2208
 
1721
2209
class Item_default_value : public Item_field
1722
2210
{
1723
2211
public:
1732
2220
     arg(a) {}
1733
2221
  enum Type type() const { return DEFAULT_VALUE_ITEM; }
1734
2222
  bool eq(const Item *item, bool binary_cmp) const;
1735
 
  bool fix_fields(Session *, Item **);
 
2223
  bool fix_fields(THD *, Item **);
1736
2224
  virtual void print(String *str, enum_query_type query_type);
1737
2225
  int save_in_field(Field *field_arg, bool no_conversions);
1738
2226
  table_map used_tables() const { return (table_map)0L; }
1739
2227
 
1740
 
  bool walk(Item_processor processor, bool walk_subquery, unsigned char *args)
 
2228
  bool walk(Item_processor processor, bool walk_subquery, uchar *args)
1741
2229
  {
1742
2230
    return arg->walk(processor, walk_subquery, args) ||
1743
2231
      (this->*processor)(args);
1744
2232
  }
1745
2233
 
1746
 
  Item *transform(Item_transformer transformer, unsigned char *args);
 
2234
  Item *transform(Item_transformer transformer, uchar *args);
1747
2235
};
1748
2236
 
1749
2237
/*
1765
2253
               (const char *)NULL),
1766
2254
     arg(a) {}
1767
2255
  bool eq(const Item *item, bool binary_cmp) const;
1768
 
  bool fix_fields(Session *, Item **);
 
2256
  bool fix_fields(THD *, Item **);
1769
2257
  virtual void print(String *str, enum_query_type query_type);
1770
2258
  int save_in_field(Field *field_arg, bool no_conversions)
1771
2259
  {
1777
2265
  */
1778
2266
  table_map used_tables() const { return RAND_TABLE_BIT; }
1779
2267
 
1780
 
  bool walk(Item_processor processor, bool walk_subquery, unsigned char *args)
 
2268
  bool walk(Item_processor processor, bool walk_subquery, uchar *args)
1781
2269
  {
1782
2270
    return arg->walk(processor, walk_subquery, args) ||
1783
2271
            (this->*processor)(args);
1784
2272
  }
1785
 
  bool check_vcol_func_processor(unsigned char *arg __attribute__((unused)))
1786
 
  { return true; }
1787
2273
};
1788
2274
 
1789
2275
 
1816
2302
 
1817
2303
  void set_used_tables(table_map map) { used_table_map= map; }
1818
2304
 
1819
 
  virtual bool allocate(uint32_t i __attribute__((unused)))
 
2305
  virtual bool allocate(uint i __attribute__((unused)))
1820
2306
  { return 0; }
1821
2307
  virtual bool setup(Item *item)
1822
2308
  {
1836
2322
  table_map used_tables() const { return used_table_map; }
1837
2323
  virtual void keep_array() {}
1838
2324
  virtual void print(String *str, enum_query_type query_type);
1839
 
  bool eq_def(Field *field);
 
2325
  bool eq_def(Field *field) 
 
2326
  { 
 
2327
    return cached_field ? cached_field->eq_def (field) : false;
 
2328
  }
1840
2329
  bool eq(const Item *item,
1841
2330
          bool binary_cmp __attribute__((unused))) const
1842
2331
  {
1901
2390
  char buffer[STRING_BUFFER_USUAL_SIZE];
1902
2391
  String *value, value_buff;
1903
2392
  bool is_varbinary;
1904
 
 
 
2393
  
1905
2394
public:
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())
 
2401
  {}
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);
1915
2410
};
1916
2411
 
1917
 
 
1918
 
 
1919
 
void mark_select_range_as_dependent(Session *session,
 
2412
class Item_cache_row: public Item_cache
 
2413
{
 
2414
  Item_cache  **values;
 
2415
  uint item_count;
 
2416
  bool save_array;
 
2417
public:
 
2418
  Item_cache_row()
 
2419
    :Item_cache(), values(0), item_count(2), save_array(0) {}
 
2420
  
 
2421
  /*
 
2422
    'allocate' used only in row transformer, to preallocate space for row 
 
2423
    cache.
 
2424
  */
 
2425
  bool allocate(uint num);
 
2426
  /*
 
2427
    'setup' is needed only by row => it not called by simple row subselect
 
2428
    (only by IN subselect (in subselect optimizer))
 
2429
  */
 
2430
  bool setup(Item *item);
 
2431
  void store(Item *item);
 
2432
  void illegal_method_call(const char *);
 
2433
  void make_field(Send_field *)
 
2434
  {
 
2435
    illegal_method_call((const char*)"make_field");
 
2436
  };
 
2437
  double val_real()
 
2438
  {
 
2439
    illegal_method_call((const char*)"val");
 
2440
    return 0;
 
2441
  };
 
2442
  int64_t val_int()
 
2443
  {
 
2444
    illegal_method_call((const char*)"val_int");
 
2445
    return 0;
 
2446
  };
 
2447
  String *val_str(String *)
 
2448
  {
 
2449
    illegal_method_call((const char*)"val_str");
 
2450
    return 0;
 
2451
  };
 
2452
  my_decimal *val_decimal(my_decimal *val __attribute__((unused)))
 
2453
  {
 
2454
    illegal_method_call((const char*)"val_decimal");
 
2455
    return 0;
 
2456
  };
 
2457
 
 
2458
  enum Item_result result_type() const { return ROW_RESULT; }
 
2459
  
 
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);
 
2464
  bool null_inside();
 
2465
  void bring_value();
 
2466
  void keep_array() { save_array= 1; }
 
2467
  void cleanup()
 
2468
  {
 
2469
    Item_cache::cleanup();
 
2470
    if (save_array)
 
2471
      memset(values, 0, item_count*sizeof(Item**));
 
2472
    else
 
2473
      values= 0;
 
2474
    return;
 
2475
  }
 
2476
};
 
2477
 
 
2478
 
 
2479
/*
 
2480
  Item_type_holder used to store type. name, length of Item for UNIONS &
 
2481
  derived tables.
 
2482
 
 
2483
  Item_type_holder do not need cleanup() because its time of live limited by
 
2484
  single SP/PS execution.
 
2485
*/
 
2486
class Item_type_holder: public Item
 
2487
{
 
2488
protected:
 
2489
  TYPELIB *enum_set_typelib;
 
2490
  enum_field_types fld_type;
 
2491
 
 
2492
  void get_full_info(Item *item);
 
2493
 
 
2494
  /* It is used to count decimal precision in join_types */
 
2495
  int prev_decimal_int_part;
 
2496
public:
 
2497
  Item_type_holder(THD*, Item*);
 
2498
 
 
2499
  Item_result result_type() const;
 
2500
  enum_field_types field_type() const { return fld_type; };
 
2501
  enum Type type() const { return TYPE_HOLDER; }
 
2502
  double val_real();
 
2503
  int64_t val_int();
 
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 *);
 
2510
};
 
2511
 
 
2512
 
 
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);
1924
2519
 
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);
1927
 
 
1928
 
/**
1929
 
  Create field for temporary table.
1930
 
 
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
1936
 
                       in this array
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
1943
 
                       work:
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
1947
 
                       the temporary table
1948
 
  @param convert_blob_length If >0 create a varstring(convert_blob_length)
1949
 
                             field instead of blob.
1950
 
 
1951
 
  @retval
1952
 
    0                   on error
1953
 
  @retval
1954
 
    new_created field
1955
 
*/
1956
 
 
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,
1960
 
                        Item::Type type,
1961
 
                        Item ***copy_func, Field **from_field,
1962
 
                        Field **def_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);
1967
 
 
1968
 
#endif /* DRIZZLED_ITEM_H */