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