~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item.h

  • Committer: Brian Aker
  • Date: 2008-10-20 03:40:03 UTC
  • mto: (492.3.21 drizzle-clean-code)
  • mto: This revision was merged to the branch mainline in revision 530.
  • Revision ID: brian@tangent.org-20081020034003-t2dcnl0ayr2ymm8k
THD -> Session rename

Show diffs side-by-side

added added

removed removed

Lines of Context:
236
236
};
237
237
 
238
238
 
239
 
void dummy_error_processor(THD *thd, void *data);
 
239
void dummy_error_processor(Session *thd, void *data);
240
240
 
241
 
void view_error_processor(THD *thd, void *data);
 
241
void view_error_processor(Session *thd, void *data);
242
242
 
243
243
/*
244
244
  Instances of Name_resolution_context store the information necesary for
298
298
    hide underlying tables in errors about views (i.e. it substitute some
299
299
    errors for views)
300
300
  */
301
 
  void (*error_processor)(THD *, void *);
 
301
  void (*error_processor)(Session *, void *);
302
302
  void *error_processor_data;
303
303
 
304
304
  /*
334
334
    resolve_in_select_list= false;
335
335
  }
336
336
 
337
 
  void process_error(THD *thd)
 
337
  void process_error(Session *thd)
338
338
  {
339
339
    (*error_processor)(thd, error_processor_data);
340
340
  }
503
503
     top AND/OR structure of WHERE clause to protect it of
504
504
     optimisation changes in prepared statements
505
505
  */
506
 
  Item(THD *thd, Item *item);
 
506
  Item(Session *thd, Item *item);
507
507
  virtual ~Item()
508
508
  {
509
509
#ifdef EXTRA_DEBUG
516
516
  virtual void cleanup();
517
517
  virtual void make_field(Send_field *field);
518
518
  Field *make_string_field(Table *table);
519
 
  virtual bool fix_fields(THD *, Item **);
 
519
  virtual bool fix_fields(Session *, Item **);
520
520
  /*
521
521
    Fix after some tables has been pulled out. Basically re-calculate all
522
522
    attributes that are dependent on the tables.
774
774
 
775
775
  void print_item_w_name(String *, enum_query_type query_type);
776
776
  virtual void update_used_tables() {}
777
 
  virtual void split_sum_func(THD *thd __attribute__((unused)),
 
777
  virtual void split_sum_func(Session *thd __attribute__((unused)),
778
778
                              Item **ref_pointer_array __attribute__((unused)),
779
779
                              List<Item> &fields __attribute__((unused))) {}
780
780
  /* Called for items that really have to be split */
781
 
  void split_sum_func2(THD *thd, Item **ref_pointer_array, List<Item> &fields,
 
781
  void split_sum_func2(Session *thd, Item **ref_pointer_array, List<Item> &fields,
782
782
                       Item **ref, bool skip_registered);
783
783
  virtual bool get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate);
784
784
  virtual bool get_time(DRIZZLE_TIME *ltime);
822
822
    set value of aggregate function in case of no rows for grouping were found
823
823
  */
824
824
  virtual void no_rows_in_result(void) {}
825
 
  virtual Item *copy_or_same(THD *thd __attribute__((unused)))
 
825
  virtual Item *copy_or_same(Session *thd __attribute__((unused)))
826
826
  { return this; }
827
 
  virtual Item *copy_andor_structure(THD *thd  __attribute__((unused)))
 
827
  virtual Item *copy_andor_structure(Session *thd  __attribute__((unused)))
828
828
  { return this; }
829
829
  virtual Item *real_item(void) { return this; }
830
 
  virtual Item *get_tmp_table_item(THD *thd) { return copy_or_same(thd); }
 
830
  virtual Item *get_tmp_table_item(Session *thd) { return copy_or_same(thd); }
831
831
 
832
832
  static const CHARSET_INFO *default_charset();
833
833
  virtual const CHARSET_INFO *compare_collation() { return NULL; }
931
931
    For SP local variable returns address of pointer to Item representing its
932
932
    current value and pointer passed via parameter otherwise.
933
933
  */
934
 
  virtual Item **this_item_addr(THD *thd __attribute__((unused)), Item **addr_arg) { return addr_arg; }
 
934
  virtual Item **this_item_addr(Session *thd __attribute__((unused)), Item **addr_arg) { return addr_arg; }
935
935
 
936
936
  // Row emulation
937
937
  virtual uint32_t cols() { return 1; }
946
946
  Field *tmp_table_field_from_field_type(Table *table, bool fixed_length);
947
947
  virtual Item_field *filed_for_view_update() { return 0; }
948
948
 
949
 
  virtual Item *neg_transformer(THD *thd __attribute__((unused))) { return NULL; }
 
949
  virtual Item *neg_transformer(Session *thd __attribute__((unused))) { return NULL; }
950
950
  virtual Item *update_value_transformer(unsigned char *select_arg __attribute__((unused))) { return this; }
951
951
  virtual Item *safe_charset_converter(const CHARSET_INFO * const tocs);
952
952
  void delete_self()
1057
1057
  Item_ident(Name_resolution_context *context_arg,
1058
1058
             const char *db_name_arg, const char *table_name_arg,
1059
1059
             const char *field_name_arg);
1060
 
  Item_ident(THD *thd, Item_ident *item);
 
1060
  Item_ident(Session *thd, Item_ident *item);
1061
1061
  const char *full_name() const;
1062
1062
  void cleanup();
1063
1063
  bool remove_dependence_processor(unsigned char * arg);
1064
1064
  virtual void print(String *str, enum_query_type query_type);
1065
1065
  virtual bool change_context_processor(unsigned char *cntx)
1066
1066
    { context= (Name_resolution_context *)cntx; return false; }
1067
 
  friend bool insert_fields(THD *thd, Name_resolution_context *context,
 
1067
  friend bool insert_fields(Session *thd, Name_resolution_context *context,
1068
1068
                            const char *db_name,
1069
1069
                            const char *table_name, List_iterator<Item> *it,
1070
1070
                            bool any_privileges);
1116
1116
  /*
1117
1117
    Constructor needed to process subselect with temporary tables (see Item)
1118
1118
  */
1119
 
  Item_field(THD *thd, Item_field *item);
 
1119
  Item_field(Session *thd, Item_field *item);
1120
1120
  /*
1121
1121
    Constructor used inside setup_wild(), ensures that field, table,
1122
1122
    and database names will live as long as Item_field (this is important
1123
1123
    in prepared statements).
1124
1124
  */
1125
 
  Item_field(THD *thd, Name_resolution_context *context_arg, Field *field);
 
1125
  Item_field(Session *thd, Name_resolution_context *context_arg, Field *field);
1126
1126
  /*
1127
1127
    If this constructor is used, fix_fields() won't work, because
1128
1128
    db_name, table_name and column_name are unknown. It's necessary to call
1142
1142
  bool val_bool_result();
1143
1143
  bool send(Protocol *protocol, String *str_arg);
1144
1144
  void reset_field(Field *f);
1145
 
  bool fix_fields(THD *, Item **);
 
1145
  bool fix_fields(Session *, Item **);
1146
1146
  void fix_after_pullout(st_select_lex *new_parent, Item **ref);
1147
1147
  void make_field(Send_field *tmp_field);
1148
1148
  int save_in_field(Field *field,bool no_conversions);
1172
1172
  bool get_time(DRIZZLE_TIME *ltime);
1173
1173
  bool is_null() { return field->is_null(); }
1174
1174
  void update_null_value();
1175
 
  Item *get_tmp_table_item(THD *thd);
 
1175
  Item *get_tmp_table_item(Session *thd);
1176
1176
  bool collect_item_field_processor(unsigned char * arg);
1177
1177
  bool find_item_in_field_list_processor(unsigned char *arg);
1178
1178
  bool register_field_in_read_map(unsigned char *arg);
1192
1192
  inline uint32_t max_disp_length() { return field->max_display_length(); }
1193
1193
  Item_field *filed_for_view_update() { return this; }
1194
1194
  Item *safe_charset_converter(const CHARSET_INFO * const tocs);
1195
 
  int fix_outer_field(THD *thd, Field **field, Item **reference);
 
1195
  int fix_outer_field(Session *thd, Field **field, Item **reference);
1196
1196
  virtual Item *update_value_transformer(unsigned char *select_arg);
1197
1197
  virtual void print(String *str, enum_query_type query_type);
1198
1198
 
1346
1346
  bool set_longdata(const char *str, ulong length);
1347
1347
  void set_time(DRIZZLE_TIME *tm, enum enum_drizzle_timestamp_type type,
1348
1348
                uint32_t max_length_arg);
1349
 
  bool set_from_user_var(THD *thd, const user_var_entry *entry);
 
1349
  bool set_from_user_var(Session *thd, const user_var_entry *entry);
1350
1350
  void reset();
1351
1351
  /*
1352
1352
    Assign placeholder value from bind data.
1358
1358
 
1359
1359
  const String *query_val_str(String *str) const;
1360
1360
 
1361
 
  bool convert_str_value(THD *thd);
 
1361
  bool convert_str_value(Session *thd);
1362
1362
 
1363
1363
  /*
1364
1364
    If value for parameter was not set we treat it as non-const
1809
1809
  Field *result_field;                          /* Save result here */
1810
1810
  Item_result_field() :result_field(0) {}
1811
1811
  // Constructor used for Item_sum/Item_cond_and/or (see Item comment)
1812
 
  Item_result_field(THD *thd, Item_result_field *item):
 
1812
  Item_result_field(Session *thd, Item_result_field *item):
1813
1813
    Item(thd, item), result_field(item->result_field)
1814
1814
  {}
1815
1815
  ~Item_result_field() {}                       /* Required with gcc 2.95 */
1862
1862
           bool alias_name_used_arg= false);
1863
1863
 
1864
1864
  /* Constructor need to process subselect with temporary tables (see Item) */
1865
 
  Item_ref(THD *thd, Item_ref *item)
 
1865
  Item_ref(Session *thd, Item_ref *item)
1866
1866
    :Item_ident(thd, item), result_field(item->result_field), ref(item->ref) {}
1867
1867
  enum Type type() const                { return REF_ITEM; }
1868
1868
  bool eq(const Item *item, bool binary_cmp) const
1884
1884
  bool val_bool_result();
1885
1885
  bool send(Protocol *prot, String *tmp);
1886
1886
  void make_field(Send_field *field);
1887
 
  bool fix_fields(THD *, Item **);
 
1887
  bool fix_fields(Session *, Item **);
1888
1888
  void fix_after_pullout(st_select_lex *new_parent, Item **ref);
1889
1889
  int save_in_field(Field *field, bool no_conversions);
1890
1890
  void save_org_in_field(Field *field);
1892
1892
  enum_field_types field_type() const   { return (*ref)->field_type(); }
1893
1893
  Field *get_tmp_table_field()
1894
1894
  { return result_field ? result_field : (*ref)->get_tmp_table_field(); }
1895
 
  Item *get_tmp_table_item(THD *thd);
 
1895
  Item *get_tmp_table_item(Session *thd);
1896
1896
  table_map used_tables() const         
1897
1897
  {
1898
1898
    return depended_from ? OUTER_REF_TABLE_BIT : (*ref)->used_tables(); 
1971
1971
              field_name_arg, alias_name_used_arg)
1972
1972
  {}
1973
1973
  /* Constructor need to process subselect with temporary tables (see Item) */
1974
 
  Item_direct_ref(THD *thd, Item_direct_ref *item) : Item_ref(thd, item) {}
 
1974
  Item_direct_ref(Session *thd, Item_direct_ref *item) : Item_ref(thd, item) {}
1975
1975
 
1976
1976
  double val_real();
1977
1977
  int64_t val_int();
1995
1995
                  const char *field_name_arg)
1996
1996
    :Item_direct_ref(context_arg, item, table_name_arg, field_name_arg) {}
1997
1997
  /* Constructor need to process subselect with temporary tables (see Item) */
1998
 
  Item_direct_view_ref(THD *thd, Item_direct_ref *item)
 
1998
  Item_direct_view_ref(Session *thd, Item_direct_ref *item)
1999
1999
    :Item_direct_ref(thd, item) {}
2000
2000
 
2001
 
  bool fix_fields(THD *, Item **);
 
2001
  bool fix_fields(Session *, Item **);
2002
2002
  bool eq(const Item *item, bool binary_cmp) const;
2003
 
  Item *get_tmp_table_item(THD *thd)
 
2003
  Item *get_tmp_table_item(Session *thd)
2004
2004
  {
2005
2005
    Item *item= Item_ref::get_tmp_table_item(thd);
2006
2006
    item->name= name;
2054
2054
  {
2055
2055
    outer_ref->save_org_in_field(result_field);
2056
2056
  }
2057
 
  bool fix_fields(THD *, Item **);
 
2057
  bool fix_fields(Session *, Item **);
2058
2058
  void fix_after_pullout(st_select_lex *new_parent, Item **ref);
2059
2059
  table_map used_tables() const
2060
2060
  {
2200
2200
  Item *item;
2201
2201
  String value,tmp_value;
2202
2202
public:
2203
 
  Cached_item_str(THD *thd, Item *arg);
 
2203
  Cached_item_str(Session *thd, Item *arg);
2204
2204
  bool cmp(void);
2205
2205
  ~Cached_item_str();                           // Deallocate String:s
2206
2206
};
2264
2264
     arg(a) {}
2265
2265
  enum Type type() const { return DEFAULT_VALUE_ITEM; }
2266
2266
  bool eq(const Item *item, bool binary_cmp) const;
2267
 
  bool fix_fields(THD *, Item **);
 
2267
  bool fix_fields(Session *, Item **);
2268
2268
  virtual void print(String *str, enum_query_type query_type);
2269
2269
  int save_in_field(Field *field_arg, bool no_conversions);
2270
2270
  table_map used_tables() const { return (table_map)0L; }
2297
2297
               (const char *)NULL),
2298
2298
     arg(a) {}
2299
2299
  bool eq(const Item *item, bool binary_cmp) const;
2300
 
  bool fix_fields(THD *, Item **);
 
2300
  bool fix_fields(Session *, Item **);
2301
2301
  virtual void print(String *str, enum_query_type query_type);
2302
2302
  int save_in_field(Field *field_arg, bool no_conversions)
2303
2303
  {
2540
2540
  /* It is used to count decimal precision in join_types */
2541
2541
  int prev_decimal_int_part;
2542
2542
public:
2543
 
  Item_type_holder(THD*, Item*);
 
2543
  Item_type_holder(Session*, Item*);
2544
2544
 
2545
2545
  Item_result result_type() const;
2546
2546
  enum_field_types field_type() const { return fld_type; };
2549
2549
  int64_t val_int();
2550
2550
  my_decimal *val_decimal(my_decimal *);
2551
2551
  String *val_str(String*);
2552
 
  bool join_types(THD *thd, Item *);
 
2552
  bool join_types(Session *thd, Item *);
2553
2553
  Field *make_field_by_type(Table *table);
2554
2554
  static uint32_t display_length(Item *item);
2555
2555
  static enum_field_types get_real_type(Item *);
2557
2557
 
2558
2558
 
2559
2559
class st_select_lex;
2560
 
void mark_select_range_as_dependent(THD *thd,
 
2560
void mark_select_range_as_dependent(Session *thd,
2561
2561
                                    st_select_lex *last_select,
2562
2562
                                    st_select_lex *current_sel,
2563
2563
                                    Field *found_field, Item *found_item,
2564
2564
                                    Item_ident *resolved_item);
2565
2565
 
2566
 
extern Cached_item *new_Cached_item(THD *thd, Item *item,
 
2566
extern Cached_item *new_Cached_item(Session *thd, Item *item,
2567
2567
                                    bool use_result_field);
2568
 
extern void resolve_const_item(THD *thd, Item **ref, Item *cmp_item);
 
2568
extern void resolve_const_item(Session *thd, Item **ref, Item *cmp_item);
2569
2569
extern bool field_is_equal_to_item(Field *field,Item *item);
2570
2570
 
2571
2571
#endif