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