~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item.h

edit

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
 
21
 
 
22
20
#ifndef DRIZZLED_ITEM_H
23
21
#define DRIZZLED_ITEM_H
24
22
 
25
23
#include <drizzled/dtcollation.h>
26
 
#include <drizzled/global_charset_info.h>
27
 
#include <drizzled/item_result.h>
28
 
#include <drizzled/memory/sql_alloc.h>
 
24
#include <drizzled/type/time.h>
 
25
#include <drizzled/type/decimal.h>
29
26
#include <drizzled/sql_list.h>
30
 
#include <drizzled/sql_string.h>
31
 
 
32
 
#include <drizzled/visibility.h>
 
27
#include "drizzled/memory/sql_alloc.h"
 
28
#include <drizzled/table.h>
 
29
#include "drizzled/item_result.h"
33
30
 
34
31
namespace drizzled
35
32
{
36
33
 
37
 
class Field;
 
34
class TableList;
 
35
class Item_field;
 
36
class Name_resolution_context;
 
37
class Select_Lex;
38
38
class Item_equal;
39
 
class Item_field;
40
 
class Item_ident;
 
39
class user_var_entry;
 
40
class Item_sum;
41
41
class Item_in_subselect;
42
 
class Item_sum;
43
 
class Select_Lex;
44
42
class SendField;
45
 
class Table;
46
 
class user_var_entry;
 
43
class Field;
47
44
 
48
 
namespace plugin { class Client; }
49
 
namespace type { class Time; }
50
 
namespace type { class Decimal; }
 
45
namespace plugin
 
46
{
 
47
class Client;
 
48
}
51
49
 
52
50
/**
53
51
  Dummy error processor used by default by Name_resolution_context.
78
76
 * statement "tree" or Lex.  Each item represents something in the
79
77
 * execution plan.
80
78
 */
81
 
class DRIZZLED_API Item : public memory::SqlAlloc
 
79
class Item: public memory::SqlAlloc
82
80
{
83
81
  /* Prevent use of these */
84
82
  Item(const Item &);
165
163
 
166
164
  bool with_sum_func;
167
165
  bool is_autogenerated_name; /**< indicates whether name of this Item was autogenerated or set by user */
168
 
 
169
166
  /**
170
167
   * If this item is a subselect or some of its arguments is or contains a
171
168
   * subselect. Computed by fix_fields.
173
170
  bool with_subselect;
174
171
  DTCollation collation;
175
172
  Item_result cmp_context; /**< Comparison context */
176
 
 
177
173
  /**
178
174
   * Constructor
179
175
   *
194
190
   * optimisation changes in prepared statements
195
191
   */
196
192
  Item(Session *session, Item *item);
197
 
 
198
193
  virtual ~Item()
199
194
  {
200
195
#ifdef EXTRA_DEBUG
424
419
  int64_t val_int_from_decimal();
425
420
  double val_real_from_decimal();
426
421
 
427
 
  bool save_time_in_field(Field *field);
428
 
  bool save_date_in_field(Field *field);
429
 
 
 
422
  int save_time_in_field(Field *field);
 
423
  int save_date_in_field(Field *field);
430
424
  /**
431
425
   * Stores a string value in field directly
432
426
   *
586
580
    Get the value of the function as a type::Time structure.
587
581
    As a extra convenience the time structure is reset on error!
588
582
  */
589
 
  virtual bool get_date(type::Time &ltime, uint32_t fuzzydate);
 
583
  virtual bool get_date(type::Time *ltime,uint32_t fuzzydate);
590
584
  /**
591
585
    Get time of first argument.
592
586
 
593
587
    As a extra convenience the time structure is reset on error!
594
588
  */
595
 
  virtual bool get_time(type::Time &ltime);
596
 
  virtual bool get_date_result(type::Time &ltime,uint32_t fuzzydate);
 
589
  virtual bool get_time(type::Time *ltime);
 
590
  virtual bool get_date_result(type::Time *ltime,uint32_t fuzzydate);
597
591
 
598
592
  /**
599
593
    The method allows to determine nullness of a complex expression
791
785
    return (tmp > UINT32_MAX) ? (uint32_t) UINT32_MAX : (uint32_t) tmp;
792
786
  } 
793
787
 
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
 
 
801
 
protected:
802
 
  Session &getSession()
 
788
  uint32_t max_char_length() const
803
789
  {
804
 
    return _session;
805
 
  }
806
 
 
807
 
private:
808
 
  Session &_session;
 
790
    return max_length / collation.collation->mbmaxlen;
 
791
  }
 
792
 
 
793
  void fix_length_and_charset(uint32_t max_char_length_arg, CHARSET_INFO *cs)
 
794
  { 
 
795
    max_length= char_to_byte_length_safe(max_char_length_arg, cs->mbmaxlen);
 
796
    collation.collation= cs;
 
797
  }
 
798
 
 
799
  void fix_char_length(uint32_t max_char_length_arg)
 
800
  { 
 
801
    max_length= char_to_byte_length_safe(max_char_length_arg,
 
802
                                         collation.collation->mbmaxlen);
 
803
  }
 
804
 
 
805
  void fix_char_length_uint64_t(uint64_t max_char_length_arg)
 
806
  { 
 
807
    uint64_t max_result_length= max_char_length_arg *
 
808
      collation.collation->mbmaxlen;
 
809
 
 
810
    if (max_result_length >= MAX_BLOB_WIDTH)
 
811
    { 
 
812
      max_length= MAX_BLOB_WIDTH;
 
813
      maybe_null= false;
 
814
    }
 
815
    else
 
816
    {
 
817
      max_length= max_result_length;
 
818
    }
 
819
  }
 
820
 
 
821
  void fix_length_and_charset_datetime(uint32_t max_char_length_arg)
 
822
  { 
 
823
    collation.set(&my_charset_bin);
 
824
    fix_char_length(max_char_length_arg);
 
825
  }
809
826
};
810
827
 
811
828
namespace display {