~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
 *
1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
390.1.2 by Monty Taylor
Fixed copyright headers in drizzled/
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
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
20
21
584.4.4 by Monty Taylor
Split out Name_resolution_context.
22
#ifndef DRIZZLED_ITEM_H
23
#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)
24
2154.2.3 by Brian Aker
Update headers (more removal of session).
25
#include <drizzled/global_charset_info.h>
584.4.1 by Monty Taylor
Split out DTCollation.
26
#include <drizzled/dtcollation.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_list.h>
2154.2.4 by Brian Aker
This fixes 716459
28
#include <drizzled/sql_string.h>
2154.2.3 by Brian Aker
Update headers (more removal of session).
29
#include <drizzled/memory/sql_alloc.h>
30
#include <drizzled/item_result.h>
584.4.1 by Monty Taylor
Split out DTCollation.
31
2119.4.1 by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by
32
#include "drizzled/visibility.h"
33
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
34
namespace drizzled
35
{
36
2154.2.4 by Brian Aker
This fixes 716459
37
class Field;
38
class Item_equal;
1 by brian
clean slate
39
class Item_field;
2154.2.4 by Brian Aker
This fixes 716459
40
class Item_ident;
41
class Item_in_subselect;
42
class Item_sum;
846 by Brian Aker
Removing on typedeffed class.
43
class Select_Lex;
2154.2.4 by Brian Aker
This fixes 716459
44
class SendField;
45
class Table;
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
46
class user_var_entry;
47
2154.2.4 by Brian Aker
This fixes 716459
48
namespace plugin { class Client; }
49
namespace type { class Time; }
50
namespace type { class Decimal; }
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
51
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
52
/**
53
  Dummy error processor used by default by Name_resolution_context.
54
55
  @note
56
    do nothing
57
*/
520.1.22 by Brian Aker
Second pass of thd cleanup
58
void dummy_error_processor(Session *session, void *data);
1 by brian
clean slate
59
60
/*
61
  Analyzer function
62
    SYNOPSIS
63
      argp   in/out IN:  Analysis parameter
64
                    OUT: Parameter to be passed to the transformer
65
584.4.2 by Monty Taylor
Split out hybrid_type_traits.
66
     RETURN
163 by Brian Aker
Merge Monty's code.
67
      true   Invoke the transformer
68
      false  Don't do it
1 by brian
clean slate
69
70
*/
481 by Brian Aker
Remove all of uchar.
71
typedef bool (Item::*Item_analyzer) (unsigned char **argp);
72
typedef Item* (Item::*Item_transformer) (unsigned char *arg);
1 by brian
clean slate
73
typedef void (*Cond_traverser) (const Item *item, void *arg);
584.4.2 by Monty Taylor
Split out hybrid_type_traits.
74
typedef bool (Item::*Item_processor) (unsigned char *arg);
1 by brian
clean slate
75
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
76
/**
1237.6.7 by Brian Aker
More removal of field
77
 * The Item class is the base class for all items in the parsed
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
78
 * statement "tree" or Lex.  Each item represents something in the
79
 * execution plan.
80
 */
2137.1.10 by Brian Aker
Fix item so that we have session (ie, it always exists within the context so
81
class DRIZZLED_API Item : public memory::SqlAlloc
1 by brian
clean slate
82
{
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
83
  /* Prevent use of these */
84
  Item(const Item &);
1 by brian
clean slate
85
  void operator=(Item &);
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
86
1 by brian
clean slate
87
  /* Cache of the result of is_expensive(). */
206 by Brian Aker
Removed final uint dead types.
88
  int8_t is_expensive_cache;
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
89
  virtual bool is_expensive_processor(unsigned char *arg);
1 by brian
clean slate
90
91
public:
92
1237.6.7 by Brian Aker
More removal of field
93
  enum Type
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
94
  {
95
    FIELD_ITEM= 0,
608 by Brian Aker
Adding snowman test (plus a dead variable removal).
96
    FUNC_ITEM,
97
    SUM_FUNC_ITEM,
98
    STRING_ITEM,
99
    INT_ITEM,
100
    REAL_ITEM,
101
    NULL_ITEM,
102
    VARBIN_ITEM,
103
    COPY_STR_ITEM,
104
    FIELD_AVG_ITEM,
105
    DEFAULT_VALUE_ITEM,
106
    PROC_ITEM,
107
    COND_ITEM,
108
    REF_ITEM,
109
    FIELD_STD_ITEM,
110
    FIELD_VARIANCE_ITEM,
111
    INSERT_VALUE_ITEM,
112
    SUBSELECT_ITEM,
113
    ROW_ITEM, CACHE_ITEM,
114
    TYPE_HOLDER,
115
    PARAM_ITEM,
2023.2.7 by Brian Aker
Create an Bool primtive type for item.
116
    BOOLEAN_ITEM,
608 by Brian Aker
Adding snowman test (plus a dead variable removal).
117
    DECIMAL_ITEM
118
  };
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
119
  enum traverse_order
1237.6.7 by Brian Aker
More removal of field
120
  {
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
121
    T_POSTFIX,
122
    T_PREFIX
123
  };
124
  enum cond_result
125
  {
126
    COND_UNDEF,
127
    COND_OK,
128
    COND_TRUE,
129
    COND_FALSE
130
  };
131
132
  /**
133
   *  str_values's main purpose is to be used to cache the value in
134
   *  save_in_field
135
   */
1 by brian
clean slate
136
  String str_value;
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
137
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
138
  /** Name from select */
139
  char *name;
2015.1.3 by Brian Aker
Merge in CAST operators for SIGNED/UNSIGNED
140
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
141
  /** Length of name */
142
  uint32_t name_length;
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
143
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
144
  /** Original item name (if it was renamed) */
145
  char *orig_name;
1 by brian
clean slate
146
  Item *next;
203 by Brian Aker
Small cleanup around uint32 types (need to merge).
147
  uint32_t max_length;
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
148
206 by Brian Aker
Removed final uint dead types.
149
  int8_t marker;
150
  uint8_t decimals;
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
151
  bool fixed; /**< If item fixed with fix_fields */
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
152
  bool maybe_null; /**< True if item may be null */
153
  bool null_value; /**< True if item is null */
275 by Brian Aker
Full removal of my_bool from central server.
154
  bool unsigned_flag;
2015.1.3 by Brian Aker
Merge in CAST operators for SIGNED/UNSIGNED
155
156
  bool is_unsigned() const
157
  {
158
    return unsigned_flag;
159
  }
160
161
  virtual bool negative() const
162
  {
163
    return false;
164
  }
165
275 by Brian Aker
Full removal of my_bool from central server.
166
  bool with_sum_func;
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
167
  bool is_autogenerated_name; /**< indicates whether name of this Item was autogenerated or set by user */
2137.1.10 by Brian Aker
Fix item so that we have session (ie, it always exists within the context so
168
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
169
  /**
170
   * If this item is a subselect or some of its arguments is or contains a
1237.6.7 by Brian Aker
More removal of field
171
   * subselect. Computed by fix_fields.
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
172
   */
173
  bool with_subselect;
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
174
  DTCollation collation;
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
175
  Item_result cmp_context; /**< Comparison context */
2137.1.10 by Brian Aker
Fix item so that we have session (ie, it always exists within the context so
176
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
177
  /**
178
   * Constructor
179
   *
180
   * @note
181
   *
1253.1.6 by Monty Taylor
Moved mem_root functions into drizzled::memory:: namespace.
182
   * Alloc & destruct is done as start of select using memory::sql_alloc
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
183
   */
1 by brian
clean slate
184
  Item();
2023.2.7 by Brian Aker
Create an Bool primtive type for item.
185
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
186
  /**
187
   * Constructor used by Item_field, Item_ref & aggregate (sum) functions.
1237.6.7 by Brian Aker
More removal of field
188
   *
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
189
   * Used for duplicating lists in processing queries with temporary
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
190
   * tables.
1237.6.7 by Brian Aker
More removal of field
191
   *
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
192
   * Also it used for Item_cond_and/Item_cond_or for creating
193
   * top AND/OR structure of WHERE clause to protect it of
194
   * optimisation changes in prepared statements
195
   */
520.1.22 by Brian Aker
Second pass of thd cleanup
196
  Item(Session *session, Item *item);
2137.1.10 by Brian Aker
Fix item so that we have session (ie, it always exists within the context so
197
1 by brian
clean slate
198
  virtual ~Item()
199
  {
200
#ifdef EXTRA_DEBUG
2023.2.7 by Brian Aker
Create an Bool primtive type for item.
201
    name= NULL;
1 by brian
clean slate
202
#endif
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
203
  }
1273.16.4 by Brian Aker
Added columsn for COLUMNS
204
205
  void set_name(const std::string &arg)
206
  {
207
    set_name(arg.c_str(), arg.length(), system_charset_info);
208
  }
209
210
  void set_name(const char *str, uint32_t length, const CHARSET_INFO * const cs= system_charset_info);
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
211
  /**
212
   * Renames item (used for views, cleanup() return original name).
213
   *
214
   * @param new_name	new name of item;
215
   */
1 by brian
clean slate
216
  void rename(char *new_name);
1052.2.4 by Nathan Williams
No actual code changes. Changed Send_field to SendField to be consistent with coding standards.
217
  void init_make_field(SendField *tmp_field,enum enum_field_types type);
1 by brian
clean slate
218
  virtual void cleanup();
1052.2.4 by Nathan Williams
No actual code changes. Changed Send_field to SendField to be consistent with coding standards.
219
  virtual void make_field(SendField *field);
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
220
  /**
221
    Create a field to hold a string value from an item.
222
223
    If max_length > CONVERT_IF_BIGGER_TO_BLOB create a blob @n
224
    If max_length > 0 create a varchar @n
225
    If max_length == 0 create a CHAR(0)
226
227
    @param table		Table for which the field is created
228
  */
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
229
  Field *make_string_field(Table *table);
520.1.21 by Brian Aker
THD -> Session rename
230
  virtual bool fix_fields(Session *, Item **);
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
231
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
232
  /**
233
   * Fix after some tables has been pulled out. Basically re-calculate all
234
   * attributes that are dependent on the tables.
235
   */
846 by Brian Aker
Removing on typedeffed class.
236
  virtual void fix_after_pullout(Select_Lex *new_parent, Item **ref);
1 by brian
clean slate
237
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
238
  /**
239
   * Should be used in case where we are sure that we do not need
1237.6.7 by Brian Aker
More removal of field
240
   * complete fix_fields() procedure.
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
241
   */
242
  inline void quick_fix_field()
243
  {
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
244
    fixed= true;
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
245
  }
246
1 by brian
clean slate
247
  virtual int save_in_field(Field *field, bool no_conversions);
248
  virtual void save_org_in_field(Field *field)
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
249
  {
250
    (void) save_in_field(field, true);
251
  }
1 by brian
clean slate
252
  virtual int save_safe_in_field(Field *field)
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
253
  {
254
    return save_in_field(field, true);
255
  }
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
256
  /**
257
   * This is only called from items that is not of type item_field.
258
   */
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
259
  virtual bool send(plugin::Client *client, String *str);
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
260
  /**
1237.6.7 by Brian Aker
More removal of field
261
    Compares this Item to another Item, returning true if Item's
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
262
    are functionally equal.
263
264
    @details
265
266
    This function is called when:
267
    - Comparing items in the WHERE clause (when doing where optimization)
268
    - When trying to find an order_st BY/GROUP BY item in the SELECT part
269
  */
1 by brian
clean slate
270
  virtual bool eq(const Item *, bool binary_cmp) const;
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
271
  virtual Item_result result_type() const
272
  {
273
    return REAL_RESULT;
274
  }
275
  virtual Item_result cast_to_int_type() const
276
  {
277
    return result_type();
278
  }
1 by brian
clean slate
279
  virtual enum_field_types string_field_type() const;
280
  virtual enum_field_types field_type() const;
281
  virtual enum Type type() const =0;
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
282
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
283
  /**
284
   * Converts
285
   *  "func_arg $CMP$ const" half-interval
286
   * into
287
   *  "FUNC(func_arg) $CMP2$ const2"
288
   *
289
   * @details
290
   *
291
   * left_endp  false  <=> The interval is "x < const" or "x <= const"
292
   *            true   <=> The interval is "x > const" or "x >= const"
293
   *
294
   * incl_endp  IN   true <=> the comparison is '<' or '>'
295
   *                false <=> the comparison is '<=' or '>='
296
   *            OUT  The same but for the "F(x) $CMP$ F(const)" comparison
297
   *
298
   * This function is defined only for unary monotonic functions. The caller
299
   * supplies the source half-interval
1237.6.7 by Brian Aker
More removal of field
300
   *
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
301
   * x $CMP$ const
302
   *
303
   * The value of const is supplied implicitly as the value this item's
304
   * argument, the form of $CMP$ comparison is specified through the
305
   * function's arguments. The calle returns the result interval
1237.6.7 by Brian Aker
More removal of field
306
   *
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
307
   * F(x) $CMP2$ F(const)
308
   *
309
   * passing back F(const) as the return value, and the form of $CMP2$
310
   * through the out parameter. NULL values are assumed to be comparable and
311
   * be less than any non-NULL values.
312
   *
313
   * @retval
314
   *
315
   * The output range bound, which equal to the value of val_int()
316
   * - If the value of the function is NULL then the bound is the
317
   * smallest possible value of INT64_MIN
318
   */
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
319
  virtual int64_t val_int_endpoint(bool left_endp, bool *incl_endp);
1 by brian
clean slate
320
321
  /* valXXX methods must return NULL or 0 or 0.0 if null_value is set. */
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
322
  /**
323
   * Returns double precision floating point representation of item.
324
   *
325
   * @retval
326
   *
327
   * In case of NULL value return 0.0 and set null_value flag to true.
328
   * If value is not null null_value flag will be reset to false.
329
   */
1 by brian
clean slate
330
  virtual double val_real()=0;
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
331
  /**
332
   * Returns integer representation of item.
333
   *
334
   * @retval
1237.6.7 by Brian Aker
More removal of field
335
   *
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
336
   * In case of NULL value return 0 and set null_value flag to true.
337
   * If value is not null null_value flag will be reset to false.
338
   */
152 by Brian Aker
longlong replacement
339
  virtual int64_t val_int()=0;
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
340
  /**
341
   * This is just a shortcut to avoid the cast. You should still use
342
   * unsigned_flag to check the sign of the item.
343
   */
344
  inline uint64_t val_uint()
345
  {
346
    return (uint64_t) val_int();
347
  }
348
  /**
349
   * Return string representation of this item object.
350
   *
351
   * @param an allocated buffer this or any nested Item object can use to
352
   *        store return value of this method.
353
   *
354
   * @note
355
   *
356
   * Buffer passed via argument  should only be used if the item itself
357
   * doesn't have an own String buffer. In case when the item maintains
358
   * it's own string buffer, it's preferable to return it instead to
359
   * minimize number of mallocs/memcpys.
360
   *
361
   * The caller of this method can modify returned string, but only in case
362
   * when it was allocated on heap, (is_alloced() is true).  This allows
363
   * the caller to efficiently use a buffer allocated by a child without
364
   * having to allocate a buffer of it's own. The buffer, given to
365
   * val_str() as argument, belongs to the caller and is later used by the
366
   * caller at it's own choosing.
367
   *
368
   * A few implications from the above:
369
   *  - unless you return a string object which only points to your buffer
370
   *    but doesn't manages it you should be ready that it will be
371
   *    modified.
372
   *  - even for not allocated strings (is_alloced() == false) the caller
373
   *    can change charset (see Item_func_{typecast/binary}. XXX: is this
374
   *    a bug?
375
   *  - still you should try to minimize data copying and return internal
376
   *    object whenever possible.
377
   *
378
   * @retval
379
   *   In case of NULL value return 0 (NULL pointer) and set null_value flag
380
   *   to true.
381
   *   If value is not null null_value flag will be reset to false.
382
   */
1 by brian
clean slate
383
  virtual String *val_str(String *str)=0;
2023.2.4 by Brian Aker
Merge in cast() for BOOLEAN.
384
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
385
  /**
386
   * Return decimal representation of item with fixed point.
387
   *
388
   * @param buffer which can be used by Item for returning value
389
   *        (but can be not)
390
   *
391
   * @note
392
   *
393
   * Returned value should not be changed if it is not the same which was
394
   * passed via argument.
395
   *
396
   * @retval
397
   *
2030.1.4 by Brian Aker
Change my_decimal to Decimal
398
   * Return pointer on type::Decimal (it can be other then passed via argument)
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
399
   * if value is not NULL (null_value flag will be reset to false).
400
   * In case of NULL value it return 0 pointer and set null_value flag
401
   * to true.
402
   */
2030.1.4 by Brian Aker
Change my_decimal to Decimal
403
  virtual type::Decimal *val_decimal(type::Decimal *decimal_buffer)= 0;
2015.1.3 by Brian Aker
Merge in CAST operators for SIGNED/UNSIGNED
404
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
405
  /**
406
   * Return boolean value of item.
407
   *
408
   * @retval
409
   *
410
   * false value is false or NULL
411
   * true value is true (not equal to 0)
412
   */
1 by brian
clean slate
413
  virtual bool val_bool();
2015.1.3 by Brian Aker
Merge in CAST operators for SIGNED/UNSIGNED
414
1 by brian
clean slate
415
  /* Helper functions, see item_sum.cc */
416
  String *val_string_from_real(String *str);
417
  String *val_string_from_int(String *str);
418
  String *val_string_from_decimal(String *str);
2030.1.4 by Brian Aker
Change my_decimal to Decimal
419
  type::Decimal *val_decimal_from_real(type::Decimal *decimal_value);
420
  type::Decimal *val_decimal_from_int(type::Decimal *decimal_value);
421
  type::Decimal *val_decimal_from_string(type::Decimal *decimal_value);
422
  type::Decimal *val_decimal_from_date(type::Decimal *decimal_value);
423
  type::Decimal *val_decimal_from_time(type::Decimal *decimal_value);
152 by Brian Aker
longlong replacement
424
  int64_t val_int_from_decimal();
1 by brian
clean slate
425
  double val_real_from_decimal();
426
2126.3.1 by Brian Aker
Add bool int patch
427
  bool save_time_in_field(Field *field);
428
  bool save_date_in_field(Field *field);
429
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
430
  /**
431
   * Stores a string value in field directly
432
   *
433
   * @details
434
   *
435
   * The method is used by Item_*::save_in_field implementations
436
   * when we don't need to calculate the value to store
1237.6.7 by Brian Aker
More removal of field
437
   *
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
438
   * @see Item_string::save_in_field() implementation for example
439
   *
440
   * @param Pointer to field where to store
441
   * @param Pointer to the string value to be stored
442
   *
443
   * @retval
444
   *  Nonzero value if error
445
   *
446
   */
1 by brian
clean slate
447
  int save_str_value_in_field(Field *field, String *result);
448
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
449
  virtual Field *get_tmp_table_field(void)
450
  {
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
451
    return NULL;
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
452
  }
1 by brian
clean slate
453
  /* This is also used to create fields in CREATE ... SELECT: */
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
454
  virtual Field *tmp_table_field(Table *t_arg);
455
  virtual const char *full_name(void) const;
1 by brian
clean slate
456
457
  /*
458
    *result* family of methods is analog of *val* family (see above) but
459
    return value of result_field of item if it is present. If Item have not
460
    result field, it return val(). This methods set null_value flag in same
461
    way as *val* methods do it.
462
  */
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
463
  virtual double  val_result() 
464
  {
465
    return val_real();
466
  }
467
  virtual int64_t val_int_result()
468
  {
469
    return val_int();
470
  }
471
  virtual String *str_result(String* tmp)
472
  {
473
    return val_str(tmp);
474
  }
2030.1.4 by Brian Aker
Change my_decimal to Decimal
475
  virtual type::Decimal *val_decimal_result(type::Decimal *val)
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
476
  {
477
    return val_decimal(val);
478
  }
479
  virtual bool val_bool_result()
480
  {
481
    return val_bool();
482
  }
483
  /**
484
   * Returns bit map of tables used by item
485
   */
486
  virtual table_map used_tables() const
487
  {
488
    return (table_map) 0L;
489
  }
490
  /**
1 by brian
clean slate
491
    Return table map of tables that can't be NULL tables (tables that are
492
    used in a context where if they would contain a NULL row generated
493
    by a LEFT or RIGHT join, the item would not be true).
494
    This expression is used on WHERE item to determinate if a LEFT JOIN can be
495
    converted to a normal join.
496
    Generally this function should return used_tables() if the function
497
    would return null if any of the arguments are null
498
    As this is only used in the beginning of optimization, the value don't
499
    have to be updated in update_used_tables()
500
  */
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
501
  virtual table_map not_null_tables() const
502
  {
503
    return used_tables();
504
  }
505
  /**
1 by brian
clean slate
506
    Returns true if this is a simple constant item like an integer, not
507
    a constant expression. Used in the optimizer to propagate basic constants.
508
  */
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
509
  virtual bool basic_const_item() const
510
  {
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
511
    return false;
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
512
  }
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
513
  /* cloning of constant items (NULL if it is not const) */
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
514
  virtual Item *clone_item()
515
  {
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
516
    return NULL;
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
517
  }
518
  virtual cond_result eq_cmp_result() const
519
  {
520
    return COND_OK;
521
  }
1241.9.1 by Monty Taylor
Removed global.h. Fixed all the headers.
522
  uint32_t float_length(uint32_t decimals_par) const;
482 by Brian Aker
Remove uint.
523
  virtual uint32_t decimal_precision() const;
584.1.14 by Monty Taylor
Removed field.h from common_includes.
524
  int decimal_int_part() const;
525
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
526
  /**
1 by brian
clean slate
527
    Returns true if this is constant (during query execution, i.e. its value
528
    will not change until next fix_fields) and its value is known.
529
  */
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
530
  virtual bool const_item() const
531
  {
532
    return used_tables() == 0;
533
  }
534
  /**
1 by brian
clean slate
535
    Returns true if this is constant but its value may be not known yet.
536
    (Can be used for parameters of prep. stmts or of stored procedures.)
537
  */
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
538
  virtual bool const_during_execution() const
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
539
  {
540
    return (used_tables() & ~PARAM_TABLE_BIT) == 0;
541
  }
1 by brian
clean slate
542
543
  /**
544
    This method is used for to:
545
      - to generate a view definition query (SELECT-statement);
546
      - to generate a SQL-query for EXPLAIN EXTENDED;
547
      - to generate a SQL-query to be shown in INFORMATION_SCHEMA;
548
      - debug.
549
550
    For more information about view definition query, INFORMATION_SCHEMA
551
    query and why they should be generated from the Item-tree, @see
2026.2.1 by Monty Taylor
Renamed things prefixed mysql_ or mysqld_
552
    register_view().
1 by brian
clean slate
553
  */
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
554
  virtual void print(String *str, enum_query_type query_type);
1 by brian
clean slate
555
556
  void print_item_w_name(String *, enum_query_type query_type);
557
  virtual void update_used_tables() {}
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
558
  virtual void split_sum_func(Session *session, 
559
                              Item **ref_pointer_array,
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
560
                              List<Item> &fields);
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
561
  /**
562
    Move SUM items out from item tree and replace with reference.
563
564
    @param session			Thread handler
565
    @param ref_pointer_array	Pointer to array of reference fields
566
    @param fields		All fields in select
567
    @param ref			Pointer to item
568
    @param skip_registered       <=> function be must skipped for registered
569
                                SUM items
570
571
    @note
572
      This is from split_sum_func() for items that should be split
573
574
      All found SUM items are added FIRST in the fields list and
575
      we replace the item with a reference.
576
577
      session->fatal_error() may be called if we are out of memory
578
  */
579
  void split_sum_func(Session *session, 
580
                      Item **ref_pointer_array,
779.3.18 by Monty Taylor
Cleaned up warnings up through innodb.
581
                      List<Item> &fields,
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
582
                      Item **ref, 
583
                      bool skip_registered);
584.4.9 by Monty Taylor
Renamed split_sum_func2 to split_sum_func. It's C++.
584
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
585
  /**
2030.1.5 by Brian Aker
Update for moving DRIZZLE_TIME to type::Time
586
    Get the value of the function as a type::Time structure.
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
587
    As a extra convenience the time structure is reset on error!
588
  */
2104.2.8 by Brian Aker
Merge in reference from pointer.
589
  virtual bool get_date(type::Time &ltime, uint32_t fuzzydate);
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
590
  /**
591
    Get time of first argument.
592
593
    As a extra convenience the time structure is reset on error!
594
  */
2104.2.8 by Brian Aker
Merge in reference from pointer.
595
  virtual bool get_time(type::Time &ltime);
596
  virtual bool get_date_result(type::Time &ltime,uint32_t fuzzydate);
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
597
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
598
  /**
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
599
    The method allows to determine nullness of a complex expression
600
    without fully evaluating it, instead of calling val/result*() then
1 by brian
clean slate
601
    checking null_value. Used in Item_func_isnull/Item_func_isnotnull
602
    and Item_sum_count/Item_sum_count_distinct.
603
    Any new item which can be NULL must implement this method.
604
  */
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
605
  virtual bool is_null();
1 by brian
clean slate
606
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
607
  /** Make sure the null_value member has a correct value. */
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
608
  virtual void update_null_value ();
1 by brian
clean slate
609
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
610
  /**
1 by brian
clean slate
611
    Inform the item that there will be no distinction between its result
163 by Brian Aker
Merge Monty's code.
612
    being false or NULL.
1 by brian
clean slate
613
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
614
    @note
615
1 by brian
clean slate
616
      This function will be called for eg. Items that are top-level AND-parts
617
      of the WHERE clause. Items implementing this function (currently
618
      Item_cond_and and subquery-related item) enable special optimizations
619
      when they are "top level".
620
  */
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
621
  virtual void top_level_item(void);
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
622
  /**
623
   * Sets field of temporary table for Item which can be switched on temporary
624
   * table during query processing (grouping and so on)
625
   */
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
626
  virtual void set_result_field(Field *field);
627
  virtual bool is_result_field(void);
628
  virtual bool is_bool_func(void);
629
  virtual void save_in_result_field(bool no_conversions);
630
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
631
  /**
632
   * Sets value of aggregate function in case of no rows for grouping were found
633
   */
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
634
  virtual void no_rows_in_result(void);
635
  virtual Item *copy_or_same(Session *session);
636
637
  virtual Item *copy_andor_structure(Session *session);
638
639
  virtual Item *real_item(void);
779.3.10 by Monty Taylor
Turned on -Wshadow.
640
  virtual const Item *real_item(void) const;
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
641
  virtual Item *get_tmp_table_item(Session *session);
1 by brian
clean slate
642
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
643
  static const CHARSET_INFO *default_charset();
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
644
  virtual const CHARSET_INFO *compare_collation();
1 by brian
clean slate
645
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
646
  virtual bool walk(Item_processor processor,
647
                    bool walk_subquery,
648
                    unsigned char *arg);
1 by brian
clean slate
649
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
650
  /**
651
    Traverse item tree possibly transforming it (replacing items).
652
653
    If you don't need to transform an item tree, but only traverse
654
    it, please use Item::walk() instead.
655
656
    @param transformer    functor that performs transformation of a subtree
657
    @param arg            opaque argument passed to the functor
658
659
    @return
660
      Returns pointer to the new subtree root.  Session::change_item_tree()
661
      should be called for it if transformation took place, i.e. if a
662
      pointer to newly allocated item is returned.
663
  */
481 by Brian Aker
Remove all of uchar.
664
  virtual Item* transform(Item_transformer transformer, unsigned char *arg);
1 by brian
clean slate
665
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
666
  /**
1 by brian
clean slate
667
    This function performs a generic "compilation" of the Item tree.
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
668
    The process of compilation is assumed to go as follows:
669
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
670
    @code
1 by brian
clean slate
671
    compile()
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
672
    {
1 by brian
clean slate
673
      if (this->*some_analyzer(...))
674
      {
675
        compile children if any;
676
        this->*some_transformer(...);
677
      }
678
    }
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
679
    @endcode
1 by brian
clean slate
680
681
    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
682
    bottom-up.
1 by brian
clean slate
683
  */
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
684
  virtual Item* compile(Item_analyzer analyzer, 
685
                        unsigned char **arg_p,
686
                        Item_transformer transformer, 
687
                        unsigned char *arg_t);
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
688
689
  virtual void traverse_cond(Cond_traverser traverser,
690
                             void *arg,
691
                             traverse_order order);
692
693
  virtual bool remove_dependence_processor(unsigned char * arg);
694
  virtual bool remove_fixed(unsigned char * arg);
695
  virtual bool collect_item_field_processor(unsigned char * arg);
696
  virtual bool find_item_in_field_list_processor(unsigned char *arg);
697
  virtual bool change_context_processor(unsigned char *context);
698
  virtual bool register_field_in_read_map(unsigned char *arg);
699
  virtual bool subst_argument_checker(unsigned char **arg);
1 by brian
clean slate
700
1240.8.4 by Dennis Schoen
add Item functions
701
  virtual bool cache_const_expr_analyzer(unsigned char **arg);
702
  virtual Item* cache_const_expr_transformer(unsigned char *arg);
703
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
704
  virtual Item *equal_fields_propagator(unsigned char * arg);
705
  virtual bool set_no_const_sub(unsigned char *arg);
706
  virtual Item *replace_equal_field(unsigned char * arg);
1 by brian
clean slate
707
708
  // Row emulation
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
709
  virtual uint32_t cols();
710
  virtual Item* element_index(uint32_t i);
711
  virtual Item** addr(uint32_t i);
482 by Brian Aker
Remove uint.
712
  virtual bool check_cols(uint32_t c);
1 by brian
clean slate
713
  // It is not row => null inside is impossible
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
714
  virtual bool null_inside();
1 by brian
clean slate
715
  // used in row subselects to get value of elements
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
716
  virtual void bring_value();
1 by brian
clean slate
717
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
718
  /**
719
    Create a field based on field_type of argument.
720
721
    For now, this is only used to create a field for
722
    IFNULL(x,something) and time functions
723
724
    @retval
725
      NULL  error
726
    @retval
727
      \#    Created field
728
  */
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
729
  Field *tmp_table_field_from_field_type(Table *table, bool fixed_length);
1 by brian
clean slate
730
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
731
  virtual Item *neg_transformer(Session *session);
732
  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.
733
  virtual Item *safe_charset_converter(const CHARSET_INFO * const tocs);
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
734
  void delete_self();
1 by brian
clean slate
735
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
736
  /**
737
   * Returns true for Items representing DATE/TIME functions and DATE/TIME table fields.
738
   * Those Items have result_type()==STRING_RESULT (and not INT_RESULT), but
739
   * their values should be compared as integers (because the integer
740
   * representation is more precise than the string one).
741
   */
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
742
  virtual bool result_as_int64_t();
1 by brian
clean slate
743
  bool is_datetime();
744
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
745
  /**
746
   * Tests whether an expression is expensive to compute. Used during
747
   * optimization to avoid computing expensive expressions during this
748
   * phase. Also used to force temp tables when sorting on expensive
749
   * functions.
750
   *
751
   * @todo
752
   * 
753
   * Normally we should have a method:
754
   * cost Item::execution_cost(),
755
   * where 'cost' is either 'double' or some structure of various cost
756
   * parameters.
1637.5.6 by Prafulla Tekawade
This bug is simillar to mysql bug 36133
757
   *
758
   *NOTE
759
   *   This function is now used to prevent evaluation of materialized IN
760
   *   subquery predicates before it is allowed. grep for
761
   *   DontEvaluateMaterializedSubqueryTooEarly to see the uses.
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
762
   */
584.4.8 by Monty Taylor
Moved stuff from item.h to item.cc
763
  virtual bool is_expensive();
764
1 by brian
clean slate
765
  String *check_well_formed_result(String *str, bool send_error= 0);
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
766
  /**
767
   * Compares two items using a given collation
768
   *
769
   * @details
770
   *
771
   *  This method works exactly as Item::eq if the collation cs coincides with
772
   *  the collation of the compared objects. Otherwise, first the collations that
773
   *  differ from cs are replaced for cs and then the items are compared by
774
   *  Item::eq. After the comparison the original collations of items are
775
   *  restored.
776
   *
777
   * @param Pointer to the item to compare with
778
   * @param Compare as binary?
779
   * @param Pointer to the collation to use when comparing strings
780
   *
781
   * @retval
782
   *  true if compared items has been detected as equal
783
   * @retval
784
   *  false otherwise
785
   */
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
786
  bool eq_by_collation(Item *item, bool binary_cmp, const CHARSET_INFO * const cs);
2015.1.3 by Brian Aker
Merge in CAST operators for SIGNED/UNSIGNED
787
788
  inline uint32_t char_to_byte_length_safe(uint32_t char_length_arg, uint32_t mbmaxlen_arg)
789
  { 
790
    uint64_t tmp= ((uint64_t) char_length_arg) * mbmaxlen_arg;
791
    return (tmp > UINT32_MAX) ? (uint32_t) UINT32_MAX : (uint32_t) tmp;
792
  } 
793
2154.2.4 by Brian Aker
This fixes 716459
794
  uint32_t max_char_length() const;
795
796
  void fix_length_and_charset(uint32_t max_char_length_arg, CHARSET_INFO *cs);
797
  void fix_char_length(uint32_t max_char_length_arg);
798
  void fix_char_length_uint64_t(uint64_t max_char_length_arg);
799
  void fix_length_and_charset_datetime(uint32_t max_char_length_arg);
800
2137.1.10 by Brian Aker
Fix item so that we have session (ie, it always exists within the context so
801
protected:
802
  Session &getSession()
803
  {
804
    return _session;
805
  }
806
807
private:
808
  Session &_session;
1 by brian
clean slate
809
};
810
1992.5.1 by Brian Aker
Additional cerr output bits for a few classes (Item, Field,...)
811
namespace display {
812
const std::string &type(Item::Type type);
813
} /* namespace display */
814
815
std::ostream& operator<<(std::ostream& output, const Item &item);
816
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
817
} /* namespace drizzled */
818
819
/** @TODO Why is this in the middle? */
642.1.1 by Lee
move functions from item.cc/item.h to item directory
820
#include <drizzled/item/ident.h>
821
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
822
namespace drizzled
823
{
824
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
825
/**
826
  Mark item and Select_Lexs as dependent if item was resolved in
827
  outer SELECT.
828
829
  @param session             thread handler
830
  @param last            select from which current item depend
831
  @param current         current select
832
  @param resolved_item   item which was resolved in outer SELECT(for warning)
833
  @param mark_item       item which should be marked (can be differ in case of
834
                         substitution)
835
*/
656.1.6 by Monty Taylor
Merged in Eric's whitespace cleanup.
836
void mark_as_dependent(Session *session,
846 by Brian Aker
Removing on typedeffed class.
837
		       Select_Lex *last,
838
                       Select_Lex *current,
642.1.1 by Lee
move functions from item.cc/item.h to item directory
839
                       Item_ident *resolved_item,
840
                       Item_ident *mark_item);
841
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
842
/**
843
  Resolve a column reference in a sub-select.
844
845
  Resolve a column reference (usually inside a HAVING clause) against the
846
  SELECT and GROUP BY clauses of the query described by 'select'. The name
847
  resolution algorithm searches both the SELECT and GROUP BY clauses, and in
848
  case of a name conflict prefers GROUP BY column names over SELECT names. If
849
  both clauses contain different fields with the same names, a warning is
850
  issued that name of 'ref' is ambiguous. We extend ANSI SQL in that when no
851
  GROUP BY column is found, then a HAVING name is resolved as a possibly
852
  derived SELECT column. This extension is allowed only if the
853
  MODE_ONLY_FULL_GROUP_BY sql mode isn't enabled.
854
855
  @param session     current thread
856
  @param ref     column reference being resolved
857
  @param select  the select that ref is resolved against
858
859
  @note
860
    The resolution procedure is:
861
    - Search for a column or derived column named col_ref_i [in table T_j]
862
    in the SELECT clause of Q.
863
    - Search for a column named col_ref_i [in table T_j]
864
    in the GROUP BY clause of Q.
865
    - If found different columns with the same name in GROUP BY and SELECT
866
    - issue a warning and return the GROUP BY column,
867
    - otherwise
868
    - if the MODE_ONLY_FULL_GROUP_BY mode is enabled return error
869
    - else return the found SELECT column.
870
871
872
  @return
873
    - NULL - there was an error, and the error was already reported
874
    - not_found_item - the item was not resolved, no error was reported
875
    - resolved item - if the item was resolved
876
*/
877
Item** resolve_ref_in_select_and_group(Session *session, Item_ident *ref, Select_Lex *select);
878
879
/**
880
  Mark range of selects and resolved identifier (field/reference)
881
  item as dependent.
882
883
  @param session             thread handler
884
  @param last_select     select where resolved_item was resolved
885
  @param current_sel     current select (select where resolved_item was placed)
886
  @param found_field     field which was found during resolving
887
  @param found_item      Item which was found during resolving (if resolved
888
                         identifier belongs to VIEW)
889
  @param resolved_item   Identifier which was resolved
890
891
  @note
892
    We have to mark all items between current_sel (including) and
893
    last_select (excluding) as dependend (select before last_select should
894
    be marked with actual table mask used by resolved item, all other with
895
    OUTER_REF_TABLE_BIT) and also write dependence information to Item of
896
    resolved identifier.
897
*/
520.1.22 by Brian Aker
Second pass of thd cleanup
898
void mark_select_range_as_dependent(Session *session,
846 by Brian Aker
Removing on typedeffed class.
899
                                    Select_Lex *last_select,
900
                                    Select_Lex *current_sel,
1 by brian
clean slate
901
                                    Field *found_field, Item *found_item,
902
                                    Item_ident *resolved_item);
903
520.1.22 by Brian Aker
Second pass of thd cleanup
904
extern void resolve_const_item(Session *session, Item **ref, Item *cmp_item);
1055.2.12 by Jay Pipes
Documentation and style cleanup on Item class
905
/**
906
  Return true if the value stored in the field is equal to the const
907
  item.
908
909
  We need to use this on the range optimizer because in some cases
910
  we can't store the value in the field without some precision/character loss.
911
*/
1 by brian
clean slate
912
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)
913
575.4.7 by Monty Taylor
More header cleanup.
914
/**
915
  Create field for temporary table.
916
1235.1.11 by Brian Aker
Small cleanups, did in MERGE table only engine flag.
917
  @todo:
918
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
919
   This is here for now because it needs the Item::Type. It should live
920
   in Field or Table once item.h is clean enough to actually include
921
575.4.7 by Monty Taylor
More header cleanup.
922
  @param session		Thread handler
923
  @param table		Temporary table
924
  @param item		Item to create a field for
925
  @param type		Type of item (normally item->type)
926
  @param copy_func	If set and item is a function, store copy of item
927
                       in this array
928
  @param from_field    if field will be created using other field as example,
929
                       pointer example field will be written here
930
  @param default_field	If field has a default value field, store it here
931
  @param group		1 if we are going to do a relative group by on result
932
  @param modify_item	1 if item->result_field should point to new item.
933
                       This is relevent for how fill_record() is going to
934
                       work:
935
                       If modify_item is 1 then fill_record() will update
936
                       the record in the original table.
937
                       If modify_item is 0 then fill_record() will update
938
                       the temporary table
939
  @param convert_blob_length If >0 create a varstring(convert_blob_length)
940
                             field instead of blob.
941
942
  @retval
943
    0			on error
944
  @retval
945
    new_created field
946
*/
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
947
Field *create_tmp_field(Session *session,
1235.1.11 by Brian Aker
Small cleanups, did in MERGE table only engine flag.
948
                        Table *table,
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
949
                        Item *item,
575.4.7 by Monty Taylor
More header cleanup.
950
                        Item::Type type,
1235.1.11 by Brian Aker
Small cleanups, did in MERGE table only engine flag.
951
                        Item ***copy_func,
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
952
                        Field **from_field,
575.4.7 by Monty Taylor
More header cleanup.
953
                        Field **def_field,
1235.1.11 by Brian Aker
Small cleanups, did in MERGE table only engine flag.
954
                        bool group,
1055.2.11 by Jay Pipes
Adds documentation to Item class members and methods. Style and indentation cleanup in item.h
955
                        bool modify_item,
575.4.7 by Monty Taylor
More header cleanup.
956
                        bool make_copy_field,
957
                        uint32_t convert_blob_length);
958
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
959
} /* namespace drizzled */
960
584.4.4 by Monty Taylor
Split out Name_resolution_context.
961
#endif /* DRIZZLED_ITEM_H */