~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item.h

  • Committer: Padraig O'Sullivan
  • Date: 2009-09-13 01:03:01 UTC
  • mto: (1126.9.2 captain-20090915-01)
  • mto: This revision was merged to the branch mainline in revision 1133.
  • Revision ID: osullivan.padraig@gmail.com-20090913010301-tcvvezipx1124acy
Added calls to the dtrace delete begin/end probes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#define DRIZZLED_ITEM_H
22
22
 
23
23
#include <drizzled/dtcollation.h>
24
 
#include <drizzled/drizzle_time.h>
25
 
#include <drizzled/decimal.h>
 
24
#include <mysys/drizzle_time.h>
 
25
#include <drizzled/my_decimal.h>
26
26
#include <drizzled/sql_bitmap.h>
27
27
#include <drizzled/sql_list.h>
28
 
#include "drizzled/memory/sql_alloc.h"
 
28
#include <drizzled/sql_alloc.h>
29
29
#include <drizzled/table.h>
30
 
#include "drizzled/item_result.h"
31
 
 
32
 
namespace drizzled
33
 
{
34
30
 
35
31
class TableList;
36
32
class Item_field;
43
39
class SendField;
44
40
class Field;
45
41
 
 
42
namespace drizzled
 
43
{
46
44
namespace plugin
47
45
{
48
 
class Client;
 
46
class Protocol;
 
47
}
49
48
}
50
49
 
51
50
/**
73
72
typedef bool (Item::*Item_processor) (unsigned char *arg);
74
73
 
75
74
/**
76
 
 * The Item class is the base class for all items in the parsed
 
75
 * The Item class is the base class for all items in the parsed 
77
76
 * statement "tree" or Lex.  Each item represents something in the
78
77
 * execution plan.
79
78
 */
80
 
class Item: public memory::SqlAlloc
 
79
class Item: public Sql_alloc
81
80
{
82
81
  /* Prevent use of these */
83
82
  Item(const Item &);
89
88
 
90
89
public:
91
90
 
92
 
  enum Type
 
91
  enum Type 
93
92
  {
94
93
    FIELD_ITEM= 0,
95
94
    FUNC_ITEM,
115
114
    DECIMAL_ITEM
116
115
  };
117
116
  enum traverse_order
118
 
  {
 
117
  { 
119
118
    T_POSTFIX,
120
119
    T_PREFIX
121
120
  };
153
152
  bool is_autogenerated_name; /**< indicates whether name of this Item was autogenerated or set by user */
154
153
  /**
155
154
   * If this item is a subselect or some of its arguments is or contains a
156
 
   * subselect. Computed by fix_fields.
 
155
   * subselect. Computed by fix_fields. 
157
156
   */
158
157
  bool with_subselect;
159
158
  DTCollation collation;
163
162
   *
164
163
   * @note
165
164
   *
166
 
   * Alloc & destruct is done as start of select using memory::sql_alloc
 
165
   * Alloc & destruct is done as start of select using sql_alloc
167
166
   */
168
167
  Item();
169
168
  /**
170
169
   * Constructor used by Item_field, Item_ref & aggregate (sum) functions.
171
 
   *
 
170
   * 
172
171
   * Used for duplicating lists in processing queries with temporary
173
172
   * tables.
174
 
   *
 
173
   * 
175
174
   * Also it used for Item_cond_and/Item_cond_or for creating
176
175
   * top AND/OR structure of WHERE clause to protect it of
177
176
   * optimisation changes in prepared statements
183
182
    name=0;
184
183
#endif
185
184
  }
186
 
 
187
 
  void set_name(const std::string &arg)
188
 
  {
189
 
    set_name(arg.c_str(), arg.length(), system_charset_info);
190
 
  }
191
 
 
192
 
  void set_name(const char *str, uint32_t length, const CHARSET_INFO * const cs= system_charset_info);
 
185
  void set_name(const char *str, uint32_t length, const CHARSET_INFO * const cs);
193
186
  /**
194
187
   * Renames item (used for views, cleanup() return original name).
195
188
   *
219
212
 
220
213
  /**
221
214
   * Should be used in case where we are sure that we do not need
222
 
   * complete fix_fields() procedure.
 
215
   * complete fix_fields() procedure.  
223
216
   */
224
217
  inline void quick_fix_field()
225
218
  {
226
219
    fixed= true;
227
220
  }
228
221
 
 
222
  /**
 
223
   * Save value in field, but don't give any warnings.
 
224
   *
 
225
   * @note
 
226
   *
 
227
   * This is used to temporary store and retrieve a value in a column,
 
228
   * for example in opt_range to adjust the key value to fit the column.
 
229
   * Return: Function returns 1 on overflow and -1 on fatal errors
 
230
   */
 
231
  int save_in_field_no_warnings(Field *field, bool no_conversions);
 
232
 
229
233
  virtual int save_in_field(Field *field, bool no_conversions);
230
234
  virtual void save_org_in_field(Field *field)
231
235
  {
238
242
  /**
239
243
   * This is only called from items that is not of type item_field.
240
244
   */
241
 
  virtual bool send(plugin::Client *client, String *str);
 
245
  virtual bool send(drizzled::plugin::Protocol *protocol, String *str);
242
246
  /**
243
 
    Compares this Item to another Item, returning true if Item's
 
247
    Compares this Item to another Item, returning true if Item's 
244
248
    are functionally equal.
245
249
 
246
250
    @details
279
283
   *
280
284
   * This function is defined only for unary monotonic functions. The caller
281
285
   * supplies the source half-interval
282
 
   *
 
286
   * 
283
287
   * x $CMP$ const
284
288
   *
285
289
   * The value of const is supplied implicitly as the value this item's
286
290
   * argument, the form of $CMP$ comparison is specified through the
287
291
   * function's arguments. The calle returns the result interval
288
 
   *
 
292
   * 
289
293
   * F(x) $CMP2$ F(const)
290
294
   *
291
295
   * passing back F(const) as the return value, and the form of $CMP2$
314
318
   * Returns integer representation of item.
315
319
   *
316
320
   * @retval
317
 
   *
 
321
   * 
318
322
   * In case of NULL value return 0 and set null_value flag to true.
319
323
   * If value is not null null_value flag will be reset to false.
320
324
   */
412
416
   *
413
417
   * The method is used by Item_*::save_in_field implementations
414
418
   * when we don't need to calculate the value to store
415
 
   *
 
419
   * 
416
420
   * @see Item_string::save_in_field() implementation for example
417
421
   *
418
422
   * @param Pointer to field where to store
497
501
  {
498
502
    return COND_OK;
499
503
  }
500
 
  uint32_t float_length(uint32_t decimals_par) const;
 
504
  inline uint32_t float_length(uint32_t decimals_par) const
 
505
  {
 
506
    return decimals != NOT_FIXED_DEC ? (DBL_DIG+2+decimals_par) : DBL_DIG+8;
 
507
  }
501
508
  virtual uint32_t decimal_precision() const;
502
509
  int decimal_int_part() const;
503
510
 
673
680
  virtual bool collect_item_field_processor(unsigned char * arg);
674
681
  virtual bool find_item_in_field_list_processor(unsigned char *arg);
675
682
  virtual bool change_context_processor(unsigned char *context);
 
683
  virtual bool reset_query_id_processor(unsigned char *query_id_arg);
676
684
  virtual bool register_field_in_read_map(unsigned char *arg);
677
685
  virtual bool subst_argument_checker(unsigned char **arg);
678
686
 
679
 
  virtual bool cache_const_expr_analyzer(unsigned char **arg);
680
 
  virtual Item* cache_const_expr_transformer(unsigned char *arg);
681
 
 
682
687
  virtual Item *equal_fields_propagator(unsigned char * arg);
683
688
  virtual bool set_no_const_sub(unsigned char *arg);
684
689
  virtual Item *replace_equal_field(unsigned char * arg);
705
710
      \#    Created field
706
711
  */
707
712
  Field *tmp_table_field_from_field_type(Table *table, bool fixed_length);
 
713
  virtual Item_field *filed_for_view_update();
708
714
 
709
715
  virtual Item *neg_transformer(Session *session);
710
716
  virtual Item *update_value_transformer(unsigned char *select_arg);
759
765
  bool eq_by_collation(Item *item, bool binary_cmp, const CHARSET_INFO * const cs);
760
766
};
761
767
 
762
 
} /* namespace drizzled */
763
 
 
764
 
/** @TODO Why is this in the middle? */
765
768
#include <drizzled/item/ident.h>
766
769
 
767
 
namespace drizzled
768
 
{
769
 
 
770
770
/**
771
771
  Mark item and Select_Lexs as dependent if item was resolved in
772
772
  outer SELECT.
859
859
/**
860
860
  Create field for temporary table.
861
861
 
862
 
  @todo:
863
 
 
 
862
  @todo: 
 
863
  
864
864
   This is here for now because it needs the Item::Type. It should live
865
865
   in Field or Table once item.h is clean enough to actually include
866
866
 
890
890
    new_created field
891
891
*/
892
892
Field *create_tmp_field(Session *session,
893
 
                        Table *table,
 
893
                        Table *table, 
894
894
                        Item *item,
895
895
                        Item::Type type,
896
 
                        Item ***copy_func,
 
896
                        Item ***copy_func, 
897
897
                        Field **from_field,
898
898
                        Field **def_field,
899
 
                        bool group,
 
899
                        bool group, 
900
900
                        bool modify_item,
 
901
                        bool table_cant_handle_bit_fields,
901
902
                        bool make_copy_field,
902
903
                        uint32_t convert_blob_length);
903
904
 
904
 
} /* namespace drizzled */
905
 
 
906
905
#endif /* DRIZZLED_ITEM_H */