~drizzle-trunk/drizzle/development

390.1.2 by Monty Taylor
Fixed copyright headers in drizzled/
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2008 Sun Microsystems
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; version 2 of the License.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, write to the Free Software
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
1 by brian
clean slate
19
584.4.4 by Monty Taylor
Split out Name_resolution_context.
20
#ifndef DRIZZLED_ITEM_H
21
#define DRIZZLED_ITEM_H
489.1.8 by Monty Taylor
Split out Item_int_func and Item_func from Item_func. (don't think too hard about the second one)
22
584.4.1 by Monty Taylor
Split out DTCollation.
23
#include <drizzled/dtcollation.h>
584.1.14 by Monty Taylor
Removed field.h from common_includes.
24
#include <mysys/drizzle_time.h>
993.1.9 by Padraig O'Sullivan
Cleaning some header file includes after removing my_bitmap.h.
25
#include <drizzled/key_map.h>
584.1.14 by Monty Taylor
Removed field.h from common_includes.
26
#include <drizzled/my_decimal.h>
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
27
#include <drizzled/sql_bitmap.h>
28
#include <drizzled/sql_list.h>
29
#include <drizzled/sql_alloc.h>
798.2.29 by Brian Aker
Detangle more of the session object
30
#include <drizzled/table.h>
584.4.1 by Monty Taylor
Split out DTCollation.
31
1 by brian
clean slate
32
class Protocol;
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
33
class TableList;
1 by brian
clean slate
34
class Item_field;
584.4.4 by Monty Taylor
Split out Name_resolution_context.
35
class Name_resolution_context;
846 by Brian Aker
Removing on typedeffed class.
36
class Select_Lex;
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
37
class Item_equal;
38
class user_var_entry;
39
class Item_sum;
40
class Item_in_subselect;
584.1.14 by Monty Taylor
Removed field.h from common_includes.
41
class Send_field;
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
42
class Field;
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
43
520.1.22 by Brian Aker
Second pass of thd cleanup
44
void dummy_error_processor(Session *session, void *data);
45
void view_error_processor(Session *session, void *data);
1 by brian
clean slate
46
47
48
/*************************************************************************/
49
/*
50
  Analyzer function
51
    SYNOPSIS
52
      argp   in/out IN:  Analysis parameter
53
                    OUT: Parameter to be passed to the transformer
54
584.4.2 by Monty Taylor
Split out hybrid_type_traits.
55
     RETURN
163 by Brian Aker
Merge Monty's code.
56
      true   Invoke the transformer
57
      false  Don't do it
1 by brian
clean slate
58
59
*/
481 by Brian Aker
Remove all of uchar.
60
typedef bool (Item::*Item_analyzer) (unsigned char **argp);
61
typedef Item* (Item::*Item_transformer) (unsigned char *arg);
1 by brian
clean slate
62
typedef void (*Cond_traverser) (const Item *item, void *arg);
584.4.2 by Monty Taylor
Split out hybrid_type_traits.
63
typedef bool (Item::*Item_processor) (unsigned char *arg);
1 by brian
clean slate
64
65
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
66
class Item: public Sql_alloc
1 by brian
clean slate
67
{
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
68
  /* Prevent use of these */
69
  Item(const Item &);
1 by brian
clean slate
70
  void operator=(Item &);
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
71
1 by brian
clean slate
72
  /* Cache of the result of is_expensive(). */
206 by Brian Aker
Removed final uint dead types.
73
  int8_t is_expensive_cache;
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
74
  virtual bool is_expensive_processor(unsigned char *arg);
1 by brian
clean slate
75
76
public:
77
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
78
  enum Type {FIELD_ITEM= 0,
608 by Brian Aker
Adding snowman test (plus a dead variable removal).
79
    FUNC_ITEM,
80
    SUM_FUNC_ITEM,
81
    STRING_ITEM,
82
    INT_ITEM,
83
    REAL_ITEM,
84
    NULL_ITEM,
85
    VARBIN_ITEM,
86
    COPY_STR_ITEM,
87
    FIELD_AVG_ITEM,
88
    DEFAULT_VALUE_ITEM,
89
    PROC_ITEM,
90
    COND_ITEM,
91
    REF_ITEM,
92
    FIELD_STD_ITEM,
93
    FIELD_VARIANCE_ITEM,
94
    INSERT_VALUE_ITEM,
95
    SUBSELECT_ITEM,
96
    ROW_ITEM, CACHE_ITEM,
97
    TYPE_HOLDER,
98
    PARAM_ITEM,
99
    DECIMAL_ITEM
100
  };
1 by brian
clean slate
101
798.2.28 by Brian Aker
More pulling of code... master_pos function code removed.
102
  enum traverse_order { T_POSTFIX, T_PREFIX };
1 by brian
clean slate
103
  enum cond_result { COND_UNDEF,COND_OK,COND_TRUE,COND_FALSE };
104
105
  /*
106
    str_values's main purpose is to be used to cache the value in
107
    save_in_field
108
  */
109
  String str_value;
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
110
111
  /* Name from select */
112
  char * name;
113
1 by brian
clean slate
114
  /* Original item name (if it was renamed)*/
115
  char * orig_name;
116
  Item *next;
203 by Brian Aker
Small cleanup around uint32 types (need to merge).
117
  uint32_t max_length;
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
118
119
  /* Length of name */
120
  uint32_t name_length;
121
206 by Brian Aker
Removed final uint dead types.
122
  int8_t marker;
123
  uint8_t decimals;
275 by Brian Aker
Full removal of my_bool from central server.
124
  bool maybe_null;			/* If item may be null */
125
  bool null_value;			/* if item is null */
126
  bool unsigned_flag;
127
  bool with_sum_func;
128
  bool fixed;                        /* If item fixed with fix_fields */
129
  bool is_autogenerated_name;        /* indicate was name of this Item
1 by brian
clean slate
130
                                           autogenerated or set by user */
131
  DTCollation collation;
275 by Brian Aker
Full removal of my_bool from central server.
132
  bool with_subselect;               /* If this item is a subselect or some
1 by brian
clean slate
133
                                           of its arguments is or contains a
134
                                           subselect. Computed by fix_fields. */
135
  Item_result cmp_context;              /* Comparison context */
136
  // alloc & destruct is done as start of select using sql_alloc
137
  Item();
138
  /*
139
     Constructor used by Item_field, Item_ref & aggregate (sum) functions.
140
     Used for duplicating lists in processing queries with temporary
141
     tables
142
     Also it used for Item_cond_and/Item_cond_or for creating
143
     top AND/OR structure of WHERE clause to protect it of
144
     optimisation changes in prepared statements
145
  */
520.1.22 by Brian Aker
Second pass of thd cleanup
146
  Item(Session *session, Item *item);
1 by brian
clean slate
147
  virtual ~Item()
148
  {
149
#ifdef EXTRA_DEBUG
150
    name=0;
151
#endif
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
152
  }
153
  void set_name(const char *str, uint32_t length,
154
                const CHARSET_INFO * const cs);
1 by brian
clean slate
155
  void rename(char *new_name);
156
  void init_make_field(Send_field *tmp_field,enum enum_field_types type);
157
  virtual void cleanup();
158
  virtual void make_field(Send_field *field);
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
159
  Field *make_string_field(Table *table);
520.1.21 by Brian Aker
THD -> Session rename
160
  virtual bool fix_fields(Session *, Item **);
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
161
1 by brian
clean slate
162
  /*
163
    Fix after some tables has been pulled out. Basically re-calculate all
164
    attributes that are dependent on the tables.
165
  */
846 by Brian Aker
Removing on typedeffed class.
166
  virtual void fix_after_pullout(Select_Lex *new_parent, Item **ref);
1 by brian
clean slate
167
168
  /*
169
    should be used in case where we are sure that we do not need
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
170
    complete fix_fields() procedure.  */
1 by brian
clean slate
171
  inline void quick_fix_field() { fixed= 1; }
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
172
173
  /*
174
  Save value in field, but don't give any warnings
175
176
  NOTES
177
   This is used to temporary store and retrieve a value in a column,
178
   for example in opt_range to adjust the key value to fit the column.
179
  Return: Function returns 1 on overflow and -1 on fatal errors
180
  */
1 by brian
clean slate
181
  int save_in_field_no_warnings(Field *field, bool no_conversions);
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
182
1 by brian
clean slate
183
  virtual int save_in_field(Field *field, bool no_conversions);
184
  virtual void save_org_in_field(Field *field)
185
  { (void) save_in_field(field, 1); }
186
  virtual int save_safe_in_field(Field *field)
187
  { return save_in_field(field, 1); }
188
  virtual bool send(Protocol *protocol, String *str);
189
  virtual bool eq(const Item *, bool binary_cmp) const;
190
  virtual Item_result result_type() const { return REAL_RESULT; }
191
  virtual Item_result cast_to_int_type() const { return result_type(); }
192
  virtual enum_field_types string_field_type() const;
193
  virtual enum_field_types field_type() const;
194
  virtual enum Type type() const =0;
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
195
1 by brian
clean slate
196
  /*
197
    Return information about function monotonicity. See comment for
198
    enum_monotonicity_info for details. This function can only be called
199
    after fix_fields() call.
200
  */
201
  virtual enum_monotonicity_info get_monotonicity_info() const
202
  { return NON_MONOTONIC; }
203
204
  /*
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
205
    Convert:
206
      "func_arg $CMP$ const" half-interval
207
    into:
208
      "FUNC(func_arg) $CMP2$ const2"
1 by brian
clean slate
209
210
    SYNOPSIS
211
      val_int_endpoint()
163 by Brian Aker
Merge Monty's code.
212
        left_endp  false  <=> The interval is "x < const" or "x <= const"
213
                   true   <=> The interval is "x > const" or "x >= const"
1 by brian
clean slate
214
163 by Brian Aker
Merge Monty's code.
215
        incl_endp  IN   true <=> the comparison is '<' or '>'
216
                        false <=> the comparison is '<=' or '>='
1 by brian
clean slate
217
                   OUT  The same but for the "F(x) $CMP$ F(const)" comparison
218
219
    DESCRIPTION
220
      This function is defined only for unary monotonic functions. The caller
221
      supplies the source half-interval
222
223
         x $CMP$ const
224
225
      The value of const is supplied implicitly as the value this item's
226
      argument, the form of $CMP$ comparison is specified through the
227
      function's arguments. The calle returns the result interval
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
228
1 by brian
clean slate
229
         F(x) $CMP2$ F(const)
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
230
231
      passing back F(const) as the return value, and the form of $CMP2$
1 by brian
clean slate
232
      through the out parameter. NULL values are assumed to be comparable and
233
      be less than any non-NULL values.
234
235
    RETURN
236
      The output range bound, which equal to the value of val_int()
53.2.32 by Monty Taylor
First large swath at getting handler stuff clean.
237
        - If the value of the function is NULL then the bound is the
163 by Brian Aker
Merge Monty's code.
238
          smallest possible value of INT64_MIN
1 by brian
clean slate
239
  */
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
240
  virtual int64_t val_int_endpoint(bool left_endp, bool *incl_endp);
1 by brian
clean slate
241
242
243
  /* valXXX methods must return NULL or 0 or 0.0 if null_value is set. */
244
  /*
245
    Return double precision floating point representation of item.
246
247
    SYNOPSIS
248
      val_real()
249
250
    RETURN
163 by Brian Aker
Merge Monty's code.
251
      In case of NULL value return 0.0 and set null_value flag to true.
252
      If value is not null null_value flag will be reset to false.
1 by brian
clean slate
253
  */
254
  virtual double val_real()=0;
255
  /*
256
    Return integer representation of item.
257
258
    SYNOPSIS
259
      val_int()
260
261
    RETURN
163 by Brian Aker
Merge Monty's code.
262
      In case of NULL value return 0 and set null_value flag to true.
263
      If value is not null null_value flag will be reset to false.
1 by brian
clean slate
264
  */
152 by Brian Aker
longlong replacement
265
  virtual int64_t val_int()=0;
1 by brian
clean slate
266
  /*
267
    This is just a shortcut to avoid the cast. You should still use
268
    unsigned_flag to check the sign of the item.
269
  */
151 by Brian Aker
Ulonglong to uint64_t
270
  inline uint64_t val_uint() { return (uint64_t) val_int(); }
1 by brian
clean slate
271
  /*
272
    Return string representation of this item object.
273
274
    SYNOPSIS
275
      val_str()
276
      str   an allocated buffer this or any nested Item object can use to
277
            store return value of this method.
278
279
    NOTE
280
      Buffer passed via argument  should only be used if the item itself
281
      doesn't have an own String buffer. In case when the item maintains
282
      it's own string buffer, it's preferable to return it instead to
283
      minimize number of mallocs/memcpys.
284
      The caller of this method can modify returned string, but only in case
285
      when it was allocated on heap, (is_alloced() is true).  This allows
286
      the caller to efficiently use a buffer allocated by a child without
287
      having to allocate a buffer of it's own. The buffer, given to
288
      val_str() as argument, belongs to the caller and is later used by the
289
      caller at it's own choosing.
290
      A few implications from the above:
291
      - unless you return a string object which only points to your buffer
292
        but doesn't manages it you should be ready that it will be
293
        modified.
294
      - even for not allocated strings (is_alloced() == false) the caller
295
        can change charset (see Item_func_{typecast/binary}. XXX: is this
296
        a bug?
297
      - still you should try to minimize data copying and return internal
298
        object whenever possible.
299
300
    RETURN
301
      In case of NULL value return 0 (NULL pointer) and set null_value flag
163 by Brian Aker
Merge Monty's code.
302
      to true.
303
      If value is not null null_value flag will be reset to false.
1 by brian
clean slate
304
  */
305
  virtual String *val_str(String *str)=0;
306
  /*
307
    Return decimal representation of item with fixed point.
308
309
    SYNOPSIS
310
      val_decimal()
311
      decimal_buffer  buffer which can be used by Item for returning value
312
                      (but can be not)
313
314
    NOTE
315
      Returned value should not be changed if it is not the same which was
316
      passed via argument.
317
318
    RETURN
319
      Return pointer on my_decimal (it can be other then passed via argument)
163 by Brian Aker
Merge Monty's code.
320
        if value is not NULL (null_value flag will be reset to false).
1 by brian
clean slate
321
      In case of NULL value it return 0 pointer and set null_value flag
163 by Brian Aker
Merge Monty's code.
322
        to true.
1 by brian
clean slate
323
  */
324
  virtual my_decimal *val_decimal(my_decimal *decimal_buffer)= 0;
325
  /*
326
    Return boolean value of item.
327
328
    RETURN
163 by Brian Aker
Merge Monty's code.
329
      false value is false or NULL
330
      true value is true (not equal to 0)
1 by brian
clean slate
331
  */
332
  virtual bool val_bool();
333
  virtual String *val_nodeset(String*) { return 0; }
334
  /* Helper functions, see item_sum.cc */
335
  String *val_string_from_real(String *str);
336
  String *val_string_from_int(String *str);
337
  String *val_string_from_decimal(String *str);
338
  my_decimal *val_decimal_from_real(my_decimal *decimal_value);
339
  my_decimal *val_decimal_from_int(my_decimal *decimal_value);
340
  my_decimal *val_decimal_from_string(my_decimal *decimal_value);
341
  my_decimal *val_decimal_from_date(my_decimal *decimal_value);
342
  my_decimal *val_decimal_from_time(my_decimal *decimal_value);
152 by Brian Aker
longlong replacement
343
  int64_t val_int_from_decimal();
1 by brian
clean slate
344
  double val_real_from_decimal();
345
346
  int save_time_in_field(Field *field);
347
  int save_date_in_field(Field *field);
348
  int save_str_value_in_field(Field *field, String *result);
349
53.2.32 by Monty Taylor
First large swath at getting handler stuff clean.
350
  virtual Field *get_tmp_table_field(void) { return 0; }
1 by brian
clean slate
351
  /* This is also used to create fields in CREATE ... SELECT: */
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
352
  virtual Field *tmp_table_field(Table *t_arg);
353
  virtual const char *full_name(void) const;
1 by brian
clean slate
354
355
  /*
356
    *result* family of methods is analog of *val* family (see above) but
357
    return value of result_field of item if it is present. If Item have not
358
    result field, it return val(). This methods set null_value flag in same
359
    way as *val* methods do it.
360
  */
361
  virtual double  val_result() { return val_real(); }
152 by Brian Aker
longlong replacement
362
  virtual int64_t val_int_result() { return val_int(); }
1 by brian
clean slate
363
  virtual String *str_result(String* tmp) { return val_str(tmp); }
364
  virtual my_decimal *val_decimal_result(my_decimal *val)
365
  { return val_decimal(val); }
366
  virtual bool val_bool_result() { return val_bool(); }
367
368
  /* bit map of tables used by item */
369
  virtual table_map used_tables() const { return (table_map) 0L; }
370
  /*
371
    Return table map of tables that can't be NULL tables (tables that are
372
    used in a context where if they would contain a NULL row generated
373
    by a LEFT or RIGHT join, the item would not be true).
374
    This expression is used on WHERE item to determinate if a LEFT JOIN can be
375
    converted to a normal join.
376
    Generally this function should return used_tables() if the function
377
    would return null if any of the arguments are null
378
    As this is only used in the beginning of optimization, the value don't
379
    have to be updated in update_used_tables()
380
  */
381
  virtual table_map not_null_tables() const { return used_tables(); }
382
  /*
383
    Returns true if this is a simple constant item like an integer, not
384
    a constant expression. Used in the optimizer to propagate basic constants.
385
  */
386
  virtual bool basic_const_item() const { return 0; }
387
  /* cloning of constant items (0 if it is not const) */
388
  virtual Item *clone_item() { return 0; }
389
  virtual cond_result eq_cmp_result() const { return COND_OK; }
482 by Brian Aker
Remove uint.
390
  inline uint32_t float_length(uint32_t decimals_par) const
1 by brian
clean slate
391
  { return decimals != NOT_FIXED_DEC ? (DBL_DIG+2+decimals_par) : DBL_DIG+8;}
482 by Brian Aker
Remove uint.
392
  virtual uint32_t decimal_precision() const;
584.1.14 by Monty Taylor
Removed field.h from common_includes.
393
  int decimal_int_part() const;
394
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
395
  /*
1 by brian
clean slate
396
    Returns true if this is constant (during query execution, i.e. its value
397
    will not change until next fix_fields) and its value is known.
398
  */
399
  virtual bool const_item() const { return used_tables() == 0; }
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
400
  /*
1 by brian
clean slate
401
    Returns true if this is constant but its value may be not known yet.
402
    (Can be used for parameters of prep. stmts or of stored procedures.)
403
  */
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
404
  virtual bool const_during_execution() const
1 by brian
clean slate
405
  { return (used_tables() & ~PARAM_TABLE_BIT) == 0; }
406
407
  /**
408
    This method is used for to:
409
      - to generate a view definition query (SELECT-statement);
410
      - to generate a SQL-query for EXPLAIN EXTENDED;
411
      - to generate a SQL-query to be shown in INFORMATION_SCHEMA;
412
      - debug.
413
414
    For more information about view definition query, INFORMATION_SCHEMA
415
    query and why they should be generated from the Item-tree, @see
416
    mysql_register_view().
417
  */
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
418
  virtual void print(String *str, enum_query_type query_type);
1 by brian
clean slate
419
420
  void print_item_w_name(String *, enum_query_type query_type);
421
  virtual void update_used_tables() {}
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
422
  virtual void split_sum_func(Session *session, Item **ref_pointer_array,
423
                              List<Item> &fields);
424
1 by brian
clean slate
425
  /* Called for items that really have to be split */
779.3.18 by Monty Taylor
Cleaned up warnings up through innodb.
426
  void split_sum_func(Session *session, Item **ref_pointer_array,
427
                      List<Item> &fields,
428
                      Item **ref, bool skip_registered);
584.4.9 by Monty Taylor
Renamed split_sum_func2 to split_sum_func. It's C++.
429
482 by Brian Aker
Remove uint.
430
  virtual bool get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate);
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
431
  virtual bool get_time(DRIZZLE_TIME *ltime);
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
432
  virtual bool get_date_result(DRIZZLE_TIME *ltime,uint32_t fuzzydate);
433
1 by brian
clean slate
434
  /*
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
435
    The method allows to determine nullness of a complex expression
436
    without fully evaluating it, instead of calling val/result*() then
1 by brian
clean slate
437
    checking null_value. Used in Item_func_isnull/Item_func_isnotnull
438
    and Item_sum_count/Item_sum_count_distinct.
439
    Any new item which can be NULL must implement this method.
440
  */
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
441
  virtual bool is_null();
1 by brian
clean slate
442
443
  /*
444
   Make sure the null_value member has a correct value.
445
  */
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
446
  virtual void update_null_value ();
1 by brian
clean slate
447
448
  /*
449
    Inform the item that there will be no distinction between its result
163 by Brian Aker
Merge Monty's code.
450
    being false or NULL.
1 by brian
clean slate
451
452
    NOTE
453
      This function will be called for eg. Items that are top-level AND-parts
454
      of the WHERE clause. Items implementing this function (currently
455
      Item_cond_and and subquery-related item) enable special optimizations
456
      when they are "top level".
457
  */
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
458
  virtual void top_level_item(void);
1 by brian
clean slate
459
  /*
460
    set field of temporary table for Item which can be switched on temporary
461
    table during query processing (grouping and so on)
462
  */
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
463
  virtual void set_result_field(Field *field);
464
  virtual bool is_result_field(void);
465
  virtual bool is_bool_func(void);
466
  virtual void save_in_result_field(bool no_conversions);
467
1 by brian
clean slate
468
  /*
469
    set value of aggregate function in case of no rows for grouping were found
470
  */
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
471
  virtual void no_rows_in_result(void);
472
  virtual Item *copy_or_same(Session *session);
473
474
  virtual Item *copy_andor_structure(Session *session);
475
476
  virtual Item *real_item(void);
779.3.10 by Monty Taylor
Turned on -Wshadow.
477
  virtual const Item *real_item(void) const;
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
478
  virtual Item *get_tmp_table_item(Session *session);
1 by brian
clean slate
479
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
480
  static const CHARSET_INFO *default_charset();
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
481
  virtual const CHARSET_INFO *compare_collation();
1 by brian
clean slate
482
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
483
  virtual bool walk(Item_processor processor,
484
                    bool walk_subquery,
485
                    unsigned char *arg);
1 by brian
clean slate
486
481 by Brian Aker
Remove all of uchar.
487
  virtual Item* transform(Item_transformer transformer, unsigned char *arg);
1 by brian
clean slate
488
489
  /*
490
    This function performs a generic "compilation" of the Item tree.
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
491
    The process of compilation is assumed to go as follows:
492
1 by brian
clean slate
493
    compile()
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
494
    {
1 by brian
clean slate
495
      if (this->*some_analyzer(...))
496
      {
497
        compile children if any;
498
        this->*some_transformer(...);
499
      }
500
    }
501
502
    i.e. analysis is performed top-down while transformation is done
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
503
    bottom-up.
1 by brian
clean slate
504
  */
481 by Brian Aker
Remove all of uchar.
505
  virtual Item* compile(Item_analyzer analyzer, unsigned char **arg_p,
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
506
                        Item_transformer transformer, unsigned char *arg_t);
507
508
  virtual void traverse_cond(Cond_traverser traverser,
509
                             void *arg,
510
                             traverse_order order);
511
512
  virtual bool remove_dependence_processor(unsigned char * arg);
513
  virtual bool remove_fixed(unsigned char * arg);
514
  virtual bool cleanup_processor(unsigned char *arg);
515
  virtual bool collect_item_field_processor(unsigned char * arg);
516
  virtual bool find_item_in_field_list_processor(unsigned char *arg);
517
  virtual bool change_context_processor(unsigned char *context);
518
  virtual bool reset_query_id_processor(unsigned char *query_id_arg);
519
  virtual bool register_field_in_read_map(unsigned char *arg);
520
383.7.1 by Andrey Zhakov
Initial submit of code and tests
521
  /*
522
    The next function differs from the previous one that a bitmap to be updated
481.3.1 by Monty Taylor
Merged vcol stuff.
523
    is passed as unsigned char *arg.
383.7.1 by Andrey Zhakov
Initial submit of code and tests
524
  */
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
525
  virtual bool register_field_in_bitmap(unsigned char *arg);
526
  virtual bool subst_argument_checker(unsigned char **arg);
1 by brian
clean slate
527
383.7.1 by Andrey Zhakov
Initial submit of code and tests
528
  /*
529
    Check if an expression/function is allowed for a virtual column
530
    SYNOPSIS
531
      check_vcol_func_processor()
532
      arg is just ignored
533
    RETURN VALUE
534
      TRUE                           Function not accepted
535
      FALSE                          Function accepted
536
  */
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
537
  virtual bool check_vcol_func_processor(unsigned char *arg);
538
  virtual Item *equal_fields_propagator(unsigned char * arg);
539
  virtual bool set_no_const_sub(unsigned char *arg);
540
  virtual Item *replace_equal_field(unsigned char * arg);
1 by brian
clean slate
541
542
  // Row emulation
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
543
  virtual uint32_t cols();
544
  virtual Item* element_index(uint32_t i);
545
  virtual Item** addr(uint32_t i);
482 by Brian Aker
Remove uint.
546
  virtual bool check_cols(uint32_t c);
1 by brian
clean slate
547
  // It is not row => null inside is impossible
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
548
  virtual bool null_inside();
1 by brian
clean slate
549
  // used in row subselects to get value of elements
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
550
  virtual void bring_value();
1 by brian
clean slate
551
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
552
  Field *tmp_table_field_from_field_type(Table *table, bool fixed_length);
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
553
  virtual Item_field *filed_for_view_update();
1 by brian
clean slate
554
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
555
  virtual Item *neg_transformer(Session *session);
556
  virtual Item *update_value_transformer(unsigned char *select_arg);
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
557
  virtual Item *safe_charset_converter(const CHARSET_INFO * const tocs);
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
558
  void delete_self();
1 by brian
clean slate
559
560
  /*
163 by Brian Aker
Merge Monty's code.
561
    result_as_int64_t() must return true for Items representing DATE/TIME
1 by brian
clean slate
562
    functions and DATE/TIME table fields.
563
    Those Items have result_type()==STRING_RESULT (and not INT_RESULT), but
564
    their values should be compared as integers (because the integer
565
    representation is more precise than the string one).
566
  */
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
567
  virtual bool result_as_int64_t();
1 by brian
clean slate
568
  bool is_datetime();
569
570
  /*
571
    Test whether an expression is expensive to compute. Used during
572
    optimization to avoid computing expensive expressions during this
573
    phase. Also used to force temp tables when sorting on expensive
574
    functions.
575
    TODO:
576
    Normally we should have a method:
577
      cost Item::execution_cost(),
578
    where 'cost' is either 'double' or some structure of various cost
579
    parameters.
580
  */
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
581
  virtual bool is_expensive();
582
1 by brian
clean slate
583
  String *check_well_formed_result(String *str, bool send_error= 0);
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
584
  bool eq_by_collation(Item *item, bool binary_cmp,
585
                       const CHARSET_INFO * const cs);
586
1 by brian
clean slate
587
};
588
642.1.1 by Lee
move functions from item.cc/item.h to item directory
589
#include <drizzled/item/ident.h>
590
656.1.6 by Monty Taylor
Merged in Eric's whitespace cleanup.
591
void mark_as_dependent(Session *session,
846 by Brian Aker
Removing on typedeffed class.
592
		       Select_Lex *last,
593
                       Select_Lex *current,
642.1.1 by Lee
move functions from item.cc/item.h to item directory
594
                       Item_ident *resolved_item,
595
                       Item_ident *mark_item);
596
656.1.6 by Monty Taylor
Merged in Eric's whitespace cleanup.
597
Item** resolve_ref_in_select_and_group(Session *session,
598
			               Item_ident *ref,
846 by Brian Aker
Removing on typedeffed class.
599
				       Select_Lex *select);
1 by brian
clean slate
600
601
520.1.22 by Brian Aker
Second pass of thd cleanup
602
void mark_select_range_as_dependent(Session *session,
846 by Brian Aker
Removing on typedeffed class.
603
                                    Select_Lex *last_select,
604
                                    Select_Lex *current_sel,
1 by brian
clean slate
605
                                    Field *found_field, Item *found_item,
606
                                    Item_ident *resolved_item);
607
520.1.22 by Brian Aker
Second pass of thd cleanup
608
extern void resolve_const_item(Session *session, Item **ref, Item *cmp_item);
1 by brian
clean slate
609
extern bool field_is_equal_to_item(Field *field,Item *item);
489.1.8 by Monty Taylor
Split out Item_int_func and Item_func from Item_func. (don't think too hard about the second one)
610
575.4.7 by Monty Taylor
More header cleanup.
611
/**
612
  Create field for temporary table.
613
614
  @param session		Thread handler
615
  @param table		Temporary table
616
  @param item		Item to create a field for
617
  @param type		Type of item (normally item->type)
618
  @param copy_func	If set and item is a function, store copy of item
619
                       in this array
620
  @param from_field    if field will be created using other field as example,
621
                       pointer example field will be written here
622
  @param default_field	If field has a default value field, store it here
623
  @param group		1 if we are going to do a relative group by on result
624
  @param modify_item	1 if item->result_field should point to new item.
625
                       This is relevent for how fill_record() is going to
626
                       work:
627
                       If modify_item is 1 then fill_record() will update
628
                       the record in the original table.
629
                       If modify_item is 0 then fill_record() will update
630
                       the temporary table
631
  @param convert_blob_length If >0 create a varstring(convert_blob_length)
632
                             field instead of blob.
633
634
  @retval
635
    0			on error
636
  @retval
637
    new_created field
638
*/
639
640
/* TODO: This is here for now because it needs the Item::Type. It should live
641
   in Field or Table once item.h is clean enough to actually include */
642
Field *create_tmp_field(Session *session, Table *table, Item *item,
643
                        Item::Type type,
644
                        Item ***copy_func, Field **from_field,
645
                        Field **def_field,
646
                        bool group, bool modify_item,
647
                        bool table_cant_handle_bit_fields,
648
                        bool make_copy_field,
649
                        uint32_t convert_blob_length);
650
584.4.4 by Monty Taylor
Split out Name_resolution_context.
651
#endif /* DRIZZLED_ITEM_H */