~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item.h

  • Committer: Brian Aker
  • Date: 2008-11-04 15:39:09 UTC
  • mfrom: (575.1.2 devel)
  • Revision ID: brian@tangent.org-20081104153909-c72hn65udxs1ccal
Merge of Monty's work

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000-2006 MySQL AB
2
 
 
3
 
   This program is free software; you can redistribute it and/or modify
4
 
   it under the terms of the GNU General Public License as published by
5
 
   the Free Software Foundation; version 2 of the License.
6
 
 
7
 
   This program is distributed in the hope that it will be useful,
8
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 
   GNU General Public License for more details.
11
 
 
12
 
   You should have received a copy of the GNU General Public License
13
 
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
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
 */
 
19
 
 
20
#ifndef drizzled_item_h
 
21
#define drizzled_item_h
15
22
 
16
23
class Protocol;
17
24
struct TableList;
44
51
public:
45
52
  const CHARSET_INFO *collation;
46
53
  enum Derivation derivation;
47
 
  uint repertoire;
 
54
  uint32_t repertoire;
48
55
  
49
56
  void set_repertoire_from_charset(const CHARSET_INFO * const cs)
50
57
  {
77
84
  }
78
85
  void set(const CHARSET_INFO * const collation_arg,
79
86
           Derivation derivation_arg,
80
 
           uint repertoire_arg)
 
87
           uint32_t repertoire_arg)
81
88
  {
82
89
    collation= collation_arg;
83
90
    derivation= derivation_arg;
90
97
  }
91
98
  void set(Derivation derivation_arg)
92
99
  { derivation= derivation_arg; }
93
 
  bool aggregate(DTCollation &dt, uint flags= 0);
94
 
  bool set(DTCollation &dt1, DTCollation &dt2, uint flags= 0)
 
100
  bool aggregate(DTCollation &dt, uint32_t flags= 0);
 
101
  bool set(DTCollation &dt1, DTCollation &dt2, uint32_t flags= 0)
95
102
  { set(dt1); return aggregate(dt2, flags); }
96
103
  const char *derivation_name() const
97
104
  {
161
168
  { val->real/= uint64_t2double(u); }
162
169
 
163
170
  virtual int64_t val_int(Hybrid_type *val,
164
 
                           bool unsigned_flag __attribute__((unused))) const
165
 
  { return (int64_t) rint(val->real); }
 
171
                          bool unsigned_flag) const;
166
172
  virtual double val_real(Hybrid_type *val) const { return val->real; }
167
173
  virtual my_decimal *val_decimal(Hybrid_type *val, my_decimal *buf) const;
168
174
  virtual String *val_str(Hybrid_type *val, String *buf, uint8_t decimals) const;
229
235
};
230
236
 
231
237
 
232
 
void dummy_error_processor(THD *thd, void *data);
 
238
void dummy_error_processor(Session *session, void *data);
233
239
 
234
 
void view_error_processor(THD *thd, void *data);
 
240
void view_error_processor(Session *session, void *data);
235
241
 
236
242
/*
237
243
  Instances of Name_resolution_context store the information necesary for
291
297
    hide underlying tables in errors about views (i.e. it substitute some
292
298
    errors for views)
293
299
  */
294
 
  void (*error_processor)(THD *, void *);
 
300
  void (*error_processor)(Session *, void *);
295
301
  void *error_processor_data;
296
302
 
297
303
  /*
327
333
    resolve_in_select_list= false;
328
334
  }
329
335
 
330
 
  void process_error(THD *thd)
 
336
  void process_error(Session *session)
331
337
  {
332
 
    (*error_processor)(thd, error_processor_data);
 
338
    (*error_processor)(session, error_processor_data);
333
339
  }
334
340
};
335
341
 
407
413
} enum_monotonicity_info;
408
414
 
409
415
/*************************************************************************/
410
 
typedef bool (Item::*Item_processor) (uchar *arg);
 
416
typedef bool (Item::*Item_processor) (unsigned char *arg);
411
417
/*
412
418
  Analyzer function
413
419
    SYNOPSIS
419
425
      false  Don't do it
420
426
 
421
427
*/
422
 
typedef bool (Item::*Item_analyzer) (uchar **argp);
423
 
typedef Item* (Item::*Item_transformer) (uchar *arg);
 
428
typedef bool (Item::*Item_analyzer) (unsigned char **argp);
 
429
typedef Item* (Item::*Item_transformer) (unsigned char *arg);
424
430
typedef void (*Cond_traverser) (const Item *item, void *arg);
425
431
 
426
432
 
430
436
  void operator=(Item &);
431
437
  /* Cache of the result of is_expensive(). */
432
438
  int8_t is_expensive_cache;
433
 
  virtual bool is_expensive_processor(uchar *arg __attribute__((unused)))
 
439
  virtual bool is_expensive_processor(unsigned char *arg __attribute__((unused)))
434
440
  { return 0; }
435
441
 
436
442
public:
459
465
  enum traverse_order { POSTFIX, PREFIX };
460
466
  
461
467
  /* Reuse size, only used by SP local variable assignment, otherwize 0 */
462
 
  uint rsize;
 
468
  uint32_t rsize;
463
469
 
464
470
  /*
465
471
    str_values's main purpose is to be used to cache the value in
471
477
  char * orig_name;
472
478
  Item *next;
473
479
  uint32_t max_length;
474
 
  uint name_length;                     /* Length of name */
 
480
  uint32_t name_length;                     /* Length of name */
475
481
  int8_t marker;
476
482
  uint8_t decimals;
477
483
  bool maybe_null;                      /* If item may be null */
496
502
     top AND/OR structure of WHERE clause to protect it of
497
503
     optimisation changes in prepared statements
498
504
  */
499
 
  Item(THD *thd, Item *item);
 
505
  Item(Session *session, Item *item);
500
506
  virtual ~Item()
501
507
  {
502
508
#ifdef EXTRA_DEBUG
503
509
    name=0;
504
510
#endif
505
511
  }             /*lint -e1509 */
506
 
  void set_name(const char *str, uint length, const CHARSET_INFO * const cs);
 
512
  void set_name(const char *str, uint32_t length, const CHARSET_INFO * const cs);
507
513
  void rename(char *new_name);
508
514
  void init_make_field(Send_field *tmp_field,enum enum_field_types type);
509
515
  virtual void cleanup();
510
516
  virtual void make_field(Send_field *field);
511
517
  Field *make_string_field(Table *table);
512
 
  virtual bool fix_fields(THD *, Item **);
 
518
  virtual bool fix_fields(Session *, Item **);
513
519
  /*
514
520
    Fix after some tables has been pulled out. Basically re-calculate all
515
521
    attributes that are dependent on the tables.
731
737
  /* cloning of constant items (0 if it is not const) */
732
738
  virtual Item *clone_item() { return 0; }
733
739
  virtual cond_result eq_cmp_result() const { return COND_OK; }
734
 
  inline uint float_length(uint decimals_par) const
 
740
  inline uint32_t float_length(uint32_t decimals_par) const
735
741
  { return decimals != NOT_FIXED_DEC ? (DBL_DIG+2+decimals_par) : DBL_DIG+8;}
736
 
  virtual uint decimal_precision() const;
 
742
  virtual uint32_t decimal_precision() const;
737
743
  inline int decimal_int_part() const
738
744
  { return my_decimal_int_part(decimal_precision(), decimals); }
739
745
  /* 
767
773
 
768
774
  void print_item_w_name(String *, enum_query_type query_type);
769
775
  virtual void update_used_tables() {}
770
 
  virtual void split_sum_func(THD *thd __attribute__((unused)),
 
776
  virtual void split_sum_func(Session *session __attribute__((unused)),
771
777
                              Item **ref_pointer_array __attribute__((unused)),
772
778
                              List<Item> &fields __attribute__((unused))) {}
773
779
  /* Called for items that really have to be split */
774
 
  void split_sum_func2(THD *thd, Item **ref_pointer_array, List<Item> &fields,
 
780
  void split_sum_func2(Session *session, Item **ref_pointer_array, List<Item> &fields,
775
781
                       Item **ref, bool skip_registered);
776
 
  virtual bool get_date(DRIZZLE_TIME *ltime,uint fuzzydate);
 
782
  virtual bool get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate);
777
783
  virtual bool get_time(DRIZZLE_TIME *ltime);
778
 
  virtual bool get_date_result(DRIZZLE_TIME *ltime,uint fuzzydate)
 
784
  virtual bool get_date_result(DRIZZLE_TIME *ltime,uint32_t fuzzydate)
779
785
  { return get_date(ltime,fuzzydate); }
780
786
  /*
781
787
    The method allows to determine nullness of a complex expression 
815
821
    set value of aggregate function in case of no rows for grouping were found
816
822
  */
817
823
  virtual void no_rows_in_result(void) {}
818
 
  virtual Item *copy_or_same(THD *thd __attribute__((unused)))
 
824
  virtual Item *copy_or_same(Session *session __attribute__((unused)))
819
825
  { return this; }
820
 
  virtual Item *copy_andor_structure(THD *thd  __attribute__((unused)))
 
826
  virtual Item *copy_andor_structure(Session *session  __attribute__((unused)))
821
827
  { return this; }
822
828
  virtual Item *real_item(void) { return this; }
823
 
  virtual Item *get_tmp_table_item(THD *thd) { return copy_or_same(thd); }
 
829
  virtual Item *get_tmp_table_item(Session *session) { return copy_or_same(session); }
824
830
 
825
831
  static const CHARSET_INFO *default_charset();
826
832
  virtual const CHARSET_INFO *compare_collation() { return NULL; }
827
833
 
828
834
  virtual bool walk(Item_processor processor __attribute__((unused)),
829
835
                    bool walk_subquery __attribute__((unused)),
830
 
                    uchar *arg)
 
836
                    unsigned char *arg)
831
837
  {
832
838
    return (this->*processor)(arg);
833
839
  }
834
840
 
835
 
  virtual Item* transform(Item_transformer transformer, uchar *arg);
 
841
  virtual Item* transform(Item_transformer transformer, unsigned char *arg);
836
842
 
837
843
  /*
838
844
    This function performs a generic "compilation" of the Item tree.
850
856
    i.e. analysis is performed top-down while transformation is done
851
857
    bottom-up.      
852
858
  */
853
 
  virtual Item* compile(Item_analyzer analyzer, uchar **arg_p,
854
 
                        Item_transformer transformer, uchar *arg_t)
 
859
  virtual Item* compile(Item_analyzer analyzer, unsigned char **arg_p,
 
860
                        Item_transformer transformer, unsigned char *arg_t)
855
861
  {
856
862
    if ((this->*analyzer) (arg_p))
857
863
      return ((this->*transformer) (arg_t));
865
871
     (*traverser)(this, arg);
866
872
   }
867
873
 
868
 
  virtual bool remove_dependence_processor(uchar * arg __attribute__((unused)))
 
874
  virtual bool remove_dependence_processor(unsigned char * arg __attribute__((unused)))
869
875
  { return 0; }
870
 
  virtual bool remove_fixed(uchar * arg __attribute__((unused)))
 
876
  virtual bool remove_fixed(unsigned char * arg __attribute__((unused)))
871
877
  {
872
878
    fixed= 0;
873
879
    return 0;
874
880
  }
875
 
  virtual bool cleanup_processor(uchar *arg __attribute__((unused)));
876
 
  virtual bool collect_item_field_processor(uchar * arg __attribute__((unused)))
 
881
  virtual bool cleanup_processor(unsigned char *arg __attribute__((unused)));
 
882
  virtual bool collect_item_field_processor(unsigned char * arg __attribute__((unused)))
877
883
  { return 0; }
878
 
  virtual bool find_item_in_field_list_processor(uchar *arg __attribute__((unused)))
 
884
  virtual bool find_item_in_field_list_processor(unsigned char *arg __attribute__((unused)))
879
885
 { return 0; }
880
 
  virtual bool change_context_processor(uchar *context __attribute__((unused)))
881
 
  { return 0; }
882
 
  virtual bool reset_query_id_processor(uchar *query_id_arg __attribute__((unused)))
883
 
  { return 0; }
884
 
  virtual bool register_field_in_read_map(uchar *arg __attribute__((unused)))
885
 
  { return 0; }
886
 
  virtual bool subst_argument_checker(uchar **arg)
 
886
  virtual bool change_context_processor(unsigned char *context __attribute__((unused)))
 
887
  { return 0; }
 
888
  virtual bool reset_query_id_processor(unsigned char *query_id_arg __attribute__((unused)))
 
889
  { return 0; }
 
890
  virtual bool register_field_in_read_map(unsigned char *arg __attribute__((unused)))
 
891
  { return 0; }
 
892
  /*
 
893
    The next function differs from the previous one that a bitmap to be updated
 
894
    is passed as unsigned char *arg.
 
895
  */
 
896
  virtual bool register_field_in_bitmap(unsigned char *arg __attribute__((unused)))
 
897
  { return 0; }
 
898
  virtual bool subst_argument_checker(unsigned char **arg)
887
899
  {
888
900
    if (*arg)
889
901
      *arg= NULL;
890
902
    return true;
891
903
  }
892
904
 
893
 
  virtual Item *equal_fields_propagator(uchar * arg __attribute__((unused))) { return this; }
894
 
  virtual bool set_no_const_sub(uchar *arg __attribute__((unused))) { return false; }
895
 
  virtual Item *replace_equal_field(uchar * arg __attribute__((unused))) { return this; }
 
905
  /*
 
906
    Check if an expression/function is allowed for a virtual column
 
907
    SYNOPSIS
 
908
      check_vcol_func_processor()
 
909
      arg is just ignored
 
910
    RETURN VALUE
 
911
      TRUE                           Function not accepted
 
912
      FALSE                          Function accepted
 
913
  */
 
914
  virtual bool check_vcol_func_processor(unsigned char *arg __attribute__((unused))) 
 
915
  { return true; }
 
916
 
 
917
  virtual Item *equal_fields_propagator(unsigned char * arg __attribute__((unused))) { return this; }
 
918
  virtual bool set_no_const_sub(unsigned char *arg __attribute__((unused))) { return false; }
 
919
  virtual Item *replace_equal_field(unsigned char * arg __attribute__((unused))) { return this; }
 
920
 
896
921
 
897
922
  /*
898
923
    For SP local variable returns pointer to Item representing its
905
930
    For SP local variable returns address of pointer to Item representing its
906
931
    current value and pointer passed via parameter otherwise.
907
932
  */
908
 
  virtual Item **this_item_addr(THD *thd __attribute__((unused)), Item **addr_arg) { return addr_arg; }
 
933
  virtual Item **this_item_addr(Session *session __attribute__((unused)), Item **addr_arg) { return addr_arg; }
909
934
 
910
935
  // Row emulation
911
 
  virtual uint cols() { return 1; }
912
 
  virtual Item* element_index(uint i __attribute__((unused))) { return this; }
913
 
  virtual Item** addr(uint i __attribute__((unused))) { return 0; }
914
 
  virtual bool check_cols(uint c);
 
936
  virtual uint32_t cols() { return 1; }
 
937
  virtual Item* element_index(uint32_t i __attribute__((unused))) { return this; }
 
938
  virtual Item** addr(uint32_t i __attribute__((unused))) { return 0; }
 
939
  virtual bool check_cols(uint32_t c);
915
940
  // It is not row => null inside is impossible
916
941
  virtual bool null_inside() { return 0; }
917
942
  // used in row subselects to get value of elements
920
945
  Field *tmp_table_field_from_field_type(Table *table, bool fixed_length);
921
946
  virtual Item_field *filed_for_view_update() { return 0; }
922
947
 
923
 
  virtual Item *neg_transformer(THD *thd __attribute__((unused))) { return NULL; }
924
 
  virtual Item *update_value_transformer(uchar *select_arg __attribute__((unused))) { return this; }
 
948
  virtual Item *neg_transformer(Session *session __attribute__((unused))) { return NULL; }
 
949
  virtual Item *update_value_transformer(unsigned char *select_arg __attribute__((unused))) { return this; }
925
950
  virtual Item *safe_charset_converter(const CHARSET_INFO * const tocs);
926
951
  void delete_self()
927
952
  {
953
978
  virtual bool is_expensive()
954
979
  {
955
980
    if (is_expensive_cache < 0)
956
 
      is_expensive_cache= walk(&Item::is_expensive_processor, 0, (uchar*)0);
 
981
      is_expensive_cache= walk(&Item::is_expensive_processor, 0, (unsigned char*)0);
957
982
    return test(is_expensive_cache);
958
983
  }
959
984
  String *check_well_formed_result(String *str, bool send_error= 0);
978
1003
};
979
1004
 
980
1005
bool agg_item_collations(DTCollation &c, const char *name,
981
 
                         Item **items, uint nitems, uint flags, int item_sep);
 
1006
                         Item **items, uint32_t nitems, uint32_t flags, int item_sep);
982
1007
bool agg_item_collations_for_comparison(DTCollation &c, const char *name,
983
 
                                        Item **items, uint nitems, uint flags);
 
1008
                                        Item **items, uint32_t nitems, uint32_t flags);
984
1009
bool agg_item_charsets(DTCollation &c, const char *name,
985
 
                       Item **items, uint nitems, uint flags, int item_sep);
 
1010
                       Item **items, uint32_t nitems, uint32_t flags, int item_sep);
986
1011
 
987
1012
 
988
1013
class Item_num: public Item_basic_constant
1020
1045
    stmts for speeding up their re-execution. Holds NO_CACHED_FIELD_INDEX 
1021
1046
    if index value is not known.
1022
1047
  */
1023
 
  uint cached_field_index;
 
1048
  uint32_t cached_field_index;
1024
1049
  /*
1025
1050
    Cached pointer to table which contains this field, used for the same reason
1026
1051
    by prep. stmt. too in case then we have not-fully qualified field.
1031
1056
  Item_ident(Name_resolution_context *context_arg,
1032
1057
             const char *db_name_arg, const char *table_name_arg,
1033
1058
             const char *field_name_arg);
1034
 
  Item_ident(THD *thd, Item_ident *item);
 
1059
  Item_ident(Session *session, Item_ident *item);
1035
1060
  const char *full_name() const;
1036
1061
  void cleanup();
1037
 
  bool remove_dependence_processor(uchar * arg);
 
1062
  bool remove_dependence_processor(unsigned char * arg);
1038
1063
  virtual void print(String *str, enum_query_type query_type);
1039
 
  virtual bool change_context_processor(uchar *cntx)
 
1064
  virtual bool change_context_processor(unsigned char *cntx)
1040
1065
    { context= (Name_resolution_context *)cntx; return false; }
1041
 
  friend bool insert_fields(THD *thd, Name_resolution_context *context,
 
1066
  friend bool insert_fields(Session *session, Name_resolution_context *context,
1042
1067
                            const char *db_name,
1043
1068
                            const char *table_name, List_iterator<Item> *it,
1044
1069
                            bool any_privileges);
1068
1093
 
1069
1094
class Item_equal;
1070
1095
class COND_EQUAL;
 
1096
class user_var_entry;
1071
1097
 
1072
1098
class Item_field :public Item_ident
1073
1099
{
1081
1107
    if any_privileges set to true then here real effective privileges will
1082
1108
    be stored
1083
1109
  */
1084
 
  uint have_privileges;
 
1110
  uint32_t have_privileges;
1085
1111
  /* field need any privileges (for VIEW creation) */
1086
1112
  bool any_privileges;
1087
1113
  Item_field(Name_resolution_context *context_arg,
1090
1116
  /*
1091
1117
    Constructor needed to process subselect with temporary tables (see Item)
1092
1118
  */
1093
 
  Item_field(THD *thd, Item_field *item);
 
1119
  Item_field(Session *session, Item_field *item);
1094
1120
  /*
1095
1121
    Constructor used inside setup_wild(), ensures that field, table,
1096
1122
    and database names will live as long as Item_field (this is important
1097
1123
    in prepared statements).
1098
1124
  */
1099
 
  Item_field(THD *thd, Name_resolution_context *context_arg, Field *field);
 
1125
  Item_field(Session *session, Name_resolution_context *context_arg, Field *field);
1100
1126
  /*
1101
1127
    If this constructor is used, fix_fields() won't work, because
1102
1128
    db_name, table_name and column_name are unknown. It's necessary to call
1116
1142
  bool val_bool_result();
1117
1143
  bool send(Protocol *protocol, String *str_arg);
1118
1144
  void reset_field(Field *f);
1119
 
  bool fix_fields(THD *, Item **);
 
1145
  bool fix_fields(Session *, Item **);
1120
1146
  void fix_after_pullout(st_select_lex *new_parent, Item **ref);
1121
1147
  void make_field(Send_field *tmp_field);
1122
1148
  int save_in_field(Field *field,bool no_conversions);
1141
1167
  int64_t val_int_endpoint(bool left_endp, bool *incl_endp);
1142
1168
  Field *get_tmp_table_field() { return result_field; }
1143
1169
  Field *tmp_table_field(Table *t_arg __attribute__((unused))) { return result_field; }
1144
 
  bool get_date(DRIZZLE_TIME *ltime,uint fuzzydate);
1145
 
  bool get_date_result(DRIZZLE_TIME *ltime,uint fuzzydate);
 
1170
  bool get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate);
 
1171
  bool get_date_result(DRIZZLE_TIME *ltime,uint32_t fuzzydate);
1146
1172
  bool get_time(DRIZZLE_TIME *ltime);
1147
1173
  bool is_null() { return field->is_null(); }
1148
1174
  void update_null_value();
1149
 
  Item *get_tmp_table_item(THD *thd);
1150
 
  bool collect_item_field_processor(uchar * arg);
1151
 
  bool find_item_in_field_list_processor(uchar *arg);
1152
 
  bool register_field_in_read_map(uchar *arg);
 
1175
  Item *get_tmp_table_item(Session *session);
 
1176
  bool collect_item_field_processor(unsigned char * arg);
 
1177
  bool find_item_in_field_list_processor(unsigned char *arg);
 
1178
  bool register_field_in_read_map(unsigned char *arg);
 
1179
  bool register_field_in_bitmap(unsigned char *arg);
 
1180
  bool check_vcol_func_processor(unsigned char *arg __attribute__((unused)))
 
1181
  { return false; }
1153
1182
  void cleanup();
1154
1183
  bool result_as_int64_t()
1155
1184
  {
1156
1185
    return field->can_be_compared_as_int64_t();
1157
1186
  }
1158
1187
  Item_equal *find_item_equal(COND_EQUAL *cond_equal);
1159
 
  bool subst_argument_checker(uchar **arg);
1160
 
  Item *equal_fields_propagator(uchar *arg);
1161
 
  bool set_no_const_sub(uchar *arg);
1162
 
  Item *replace_equal_field(uchar *arg);
 
1188
  bool subst_argument_checker(unsigned char **arg);
 
1189
  Item *equal_fields_propagator(unsigned char *arg);
 
1190
  bool set_no_const_sub(unsigned char *arg);
 
1191
  Item *replace_equal_field(unsigned char *arg);
1163
1192
  inline uint32_t max_disp_length() { return field->max_display_length(); }
1164
1193
  Item_field *filed_for_view_update() { return this; }
1165
1194
  Item *safe_charset_converter(const CHARSET_INFO * const tocs);
1166
 
  int fix_outer_field(THD *thd, Field **field, Item **reference);
1167
 
  virtual Item *update_value_transformer(uchar *select_arg);
 
1195
  int fix_outer_field(Session *session, Field **field, Item **reference);
 
1196
  virtual Item *update_value_transformer(unsigned char *select_arg);
1168
1197
  virtual void print(String *str, enum_query_type query_type);
1169
1198
 
1170
1199
  friend class Item_default_value;
1205
1234
  }
1206
1235
 
1207
1236
  Item *safe_charset_converter(const CHARSET_INFO * const tocs);
 
1237
  bool check_vcol_func_processor(unsigned char *arg __attribute__((unused)))
 
1238
  { return false; }
1208
1239
};
1209
1240
 
1210
1241
class Item_null_result :public Item_null
1217
1248
  {
1218
1249
    save_in_field(result_field, no_conversions);
1219
1250
  }
 
1251
  bool check_vcol_func_processor(unsigned char *arg __attribute__((unused)))
 
1252
  { return true; }
1220
1253
};  
1221
1254
 
1222
1255
/* Item represents one placeholder ('?') of prepared statement */
1289
1322
    Offset of placeholder inside statement text. Used to create
1290
1323
    no-placeholders version of this statement for the binary log.
1291
1324
  */
1292
 
  uint pos_in_query;
 
1325
  uint32_t pos_in_query;
1293
1326
 
1294
 
  Item_param(uint pos_in_query_arg);
 
1327
  Item_param(uint32_t pos_in_query_arg);
1295
1328
 
1296
1329
  enum Item_result result_type () const { return item_result_type; }
1297
1330
  enum Type type() const { return item_type; }
1302
1335
  my_decimal *val_decimal(my_decimal*);
1303
1336
  String *val_str(String*);
1304
1337
  bool get_time(DRIZZLE_TIME *tm);
1305
 
  bool get_date(DRIZZLE_TIME *tm, uint fuzzydate);
 
1338
  bool get_date(DRIZZLE_TIME *tm, uint32_t fuzzydate);
1306
1339
  int  save_in_field(Field *field, bool no_conversions);
1307
1340
 
1308
1341
  void set_null();
1311
1344
  void set_decimal(char *str, ulong length);
1312
1345
  bool set_str(const char *str, ulong length);
1313
1346
  bool set_longdata(const char *str, ulong length);
1314
 
  void set_time(DRIZZLE_TIME *tm, timestamp_type type, uint32_t max_length_arg);
1315
 
  bool set_from_user_var(THD *thd, const user_var_entry *entry);
 
1347
  void set_time(DRIZZLE_TIME *tm, enum enum_drizzle_timestamp_type type,
 
1348
                uint32_t max_length_arg);
 
1349
  bool set_from_user_var(Session *session, const user_var_entry *entry);
1316
1350
  void reset();
1317
1351
  /*
1318
1352
    Assign placeholder value from bind data.
1320
1354
    don't need to check that packet is not broken there). See
1321
1355
    sql_prepare.cc for details.
1322
1356
  */
1323
 
  void (*set_param_func)(Item_param *param, uchar **pos, ulong len);
 
1357
  void (*set_param_func)(Item_param *param, unsigned char **pos, ulong len);
1324
1358
 
1325
1359
  const String *query_val_str(String *str) const;
1326
1360
 
1327
 
  bool convert_str_value(THD *thd);
 
1361
  bool convert_str_value(Session *session);
1328
1362
 
1329
1363
  /*
1330
1364
    If value for parameter was not set we treat it as non-const
1364
1398
{
1365
1399
public:
1366
1400
  int64_t value;
1367
 
  Item_int(int32_t i,uint length= MY_INT32_NUM_DECIMAL_DIGITS)
 
1401
  Item_int(int32_t i,uint32_t length= MY_INT32_NUM_DECIMAL_DIGITS)
1368
1402
    :value((int64_t) i)
1369
1403
    { max_length=length; fixed= 1; }
1370
 
  Item_int(int64_t i,uint length= MY_INT64_NUM_DECIMAL_DIGITS)
 
1404
  Item_int(int64_t i,uint32_t length= MY_INT64_NUM_DECIMAL_DIGITS)
1371
1405
    :value(i)
1372
1406
    { max_length=length; fixed= 1; }
1373
 
  Item_int(uint64_t i, uint length= MY_INT64_NUM_DECIMAL_DIGITS)
 
1407
  Item_int(uint64_t i, uint32_t length= MY_INT64_NUM_DECIMAL_DIGITS)
1374
1408
    :value((int64_t)i)
1375
1409
    { max_length=length; fixed= 1; unsigned_flag= 1; }
1376
 
  Item_int(const char *str_arg,int64_t i,uint length) :value(i)
 
1410
  Item_int(const char *str_arg,int64_t i,uint32_t length) :value(i)
1377
1411
    { max_length=length; name=(char*) str_arg; fixed= 1; }
1378
 
  Item_int(const char *str_arg, uint length=64);
 
1412
  Item_int(const char *str_arg, uint32_t length=64);
1379
1413
  enum Type type() const { return INT_ITEM; }
1380
1414
  enum Item_result result_type () const { return INT_RESULT; }
1381
1415
  enum_field_types field_type() const { return DRIZZLE_TYPE_LONGLONG; }
1388
1422
  Item *clone_item() { return new Item_int(name,value,max_length); }
1389
1423
  virtual void print(String *str, enum_query_type query_type);
1390
1424
  Item_num *neg() { value= -value; return this; }
1391
 
  uint decimal_precision() const
 
1425
  uint32_t decimal_precision() const
1392
1426
  { return (uint)(max_length - test(value < 0)); }
1393
1427
  bool eq(const Item *, bool binary_cmp) const;
 
1428
  bool check_vcol_func_processor(unsigned char *arg __attribute__((unused)))
 
1429
  { return false; }
1394
1430
};
1395
1431
 
1396
1432
 
1397
1433
class Item_uint :public Item_int
1398
1434
{
1399
1435
public:
1400
 
  Item_uint(const char *str_arg, uint length);
 
1436
  Item_uint(const char *str_arg, uint32_t length);
1401
1437
  Item_uint(uint64_t i) :Item_int((uint64_t) i, 10) {}
1402
 
  Item_uint(const char *str_arg, int64_t i, uint length);
 
1438
  Item_uint(const char *str_arg, int64_t i, uint32_t length);
1403
1439
  double val_real()
1404
1440
    { assert(fixed == 1); return uint64_t2double((uint64_t)value); }
1405
1441
  String *val_str(String*);
1407
1443
  int save_in_field(Field *field, bool no_conversions);
1408
1444
  virtual void print(String *str, enum_query_type query_type);
1409
1445
  Item_num *neg ();
1410
 
  uint decimal_precision() const { return max_length; }
 
1446
  uint32_t decimal_precision() const { return max_length; }
 
1447
  bool check_vcol_func_processor(unsigned char *arg __attribute__((unused)))
 
1448
  { return false; }
1411
1449
};
1412
1450
 
1413
1451
 
1417
1455
protected:
1418
1456
  my_decimal decimal_value;
1419
1457
public:
1420
 
  Item_decimal(const char *str_arg, uint length, const CHARSET_INFO * const charset);
 
1458
  Item_decimal(const char *str_arg, uint32_t length, const CHARSET_INFO * const charset);
1421
1459
  Item_decimal(const char *str, const my_decimal *val_arg,
1422
 
               uint decimal_par, uint length);
 
1460
               uint32_t decimal_par, uint32_t length);
1423
1461
  Item_decimal(my_decimal *value_par);
1424
1462
  Item_decimal(int64_t val, bool unsig);
1425
1463
  Item_decimal(double val, int precision, int scale);
1426
 
  Item_decimal(const uchar *bin, int precision, int scale);
 
1464
  Item_decimal(const unsigned char *bin, int precision, int scale);
1427
1465
 
1428
1466
  enum Type type() const { return DECIMAL_ITEM; }
1429
1467
  enum Item_result result_type () const { return DECIMAL_RESULT; }
1446
1484
    unsigned_flag= !decimal_value.sign();
1447
1485
    return this;
1448
1486
  }
1449
 
  uint decimal_precision() const { return decimal_value.precision(); }
 
1487
  uint32_t decimal_precision() const { return decimal_value.precision(); }
1450
1488
  bool eq(const Item *, bool binary_cmp) const;
1451
1489
  void set_decimal_value(my_decimal *value_par);
 
1490
  bool check_vcol_func_processor(unsigned char *arg __attribute__((unused)))
 
1491
  { return false; }
1452
1492
};
1453
1493
 
1454
1494
 
1458
1498
public:
1459
1499
  double value;
1460
1500
  // Item_real() :value(0) {}
1461
 
  Item_float(const char *str_arg, uint length);
1462
 
  Item_float(const char *str,double val_arg,uint decimal_par,uint length)
 
1501
  Item_float(const char *str_arg, uint32_t length);
 
1502
  Item_float(const char *str,double val_arg,uint32_t decimal_par,uint32_t length)
1463
1503
    :value(val_arg)
1464
1504
  {
1465
1505
    presentation= name=(char*) str;
1467
1507
    max_length=length;
1468
1508
    fixed= 1;
1469
1509
  }
1470
 
  Item_float(double value_par, uint decimal_par) :presentation(0), value(value_par)
 
1510
  Item_float(double value_par, uint32_t decimal_par) :presentation(0), value(value_par)
1471
1511
  {
1472
1512
    decimals= (uint8_t) decimal_par;
1473
1513
    fixed= 1;
1476
1516
  enum Type type() const { return REAL_ITEM; }
1477
1517
  enum_field_types field_type() const { return DRIZZLE_TYPE_DOUBLE; }
1478
1518
  double val_real() { assert(fixed == 1); return value; }
1479
 
  int64_t val_int()
1480
 
  {
1481
 
    assert(fixed == 1);
1482
 
    if (value <= (double) INT64_MIN)
1483
 
    {
1484
 
       return INT64_MIN;
1485
 
    }
1486
 
    else if (value >= (double) (uint64_t) INT64_MAX)
1487
 
    {
1488
 
      return INT64_MAX;
1489
 
    }
1490
 
    return (int64_t) rint(value);
1491
 
  }
 
1519
  int64_t val_int();
1492
1520
  String *val_str(String*);
1493
1521
  my_decimal *val_decimal(my_decimal *);
1494
1522
  bool basic_const_item() const { return 1; }
1504
1532
{
1505
1533
  const char *func_name;
1506
1534
public:
1507
 
  Item_static_float_func(const char *str, double val_arg, uint decimal_par,
1508
 
                        uint length)
1509
 
    :Item_float(NullS, val_arg, decimal_par, length), func_name(str)
 
1535
  Item_static_float_func(const char *str, double val_arg, uint32_t decimal_par,
 
1536
                        uint32_t length)
 
1537
    :Item_float(NULL, val_arg, decimal_par, length), func_name(str)
1510
1538
  {}
1511
1539
 
1512
1540
  virtual inline void print(String *str,
1516
1544
  }
1517
1545
 
1518
1546
  Item *safe_charset_converter(const CHARSET_INFO * const tocs);
 
1547
  bool check_vcol_func_processor(unsigned char *arg __attribute__((unused)))
 
1548
  { return false; }
1519
1549
};
1520
1550
 
1521
1551
 
1522
1552
class Item_string :public Item_basic_constant
1523
1553
{
1524
1554
public:
1525
 
  Item_string(const char *str,uint length,
 
1555
  Item_string(const char *str,uint32_t length,
1526
1556
              const CHARSET_INFO * const cs, Derivation dv= DERIVATION_COERCIBLE,
1527
 
              uint repertoire= MY_REPERTOIRE_UNICODE30)
 
1557
              uint32_t repertoire= MY_REPERTOIRE_UNICODE30)
1528
1558
    : m_cs_specified(false)
1529
1559
  {
1530
1560
    str_value.set_or_copy_aligned(str, length, cs);
1552
1582
    decimals= NOT_FIXED_DEC;
1553
1583
    fixed= 1;
1554
1584
  }
1555
 
  Item_string(const char *name_par, const char *str, uint length,
 
1585
  Item_string(const char *name_par, const char *str, uint32_t length,
1556
1586
              const CHARSET_INFO * const cs, Derivation dv= DERIVATION_COERCIBLE,
1557
 
              uint repertoire= MY_REPERTOIRE_UNICODE30)
 
1587
              uint32_t repertoire= MY_REPERTOIRE_UNICODE30)
1558
1588
    : m_cs_specified(false)
1559
1589
  {
1560
1590
    str_value.set_or_copy_aligned(str, length, cs);
1569
1599
    This is used in stored procedures to avoid memory leaks and
1570
1600
    does a deep copy of its argument.
1571
1601
  */
1572
 
  void set_str_with_copy(const char *str_arg, uint length_arg)
 
1602
  void set_str_with_copy(const char *str_arg, uint32_t length_arg)
1573
1603
  {
1574
1604
    str_value.copy(str_arg, length_arg, collation.collation);
1575
1605
    max_length= str_value.numchars() * collation.collation->mbmaxlen;
1600
1630
                           str_value.length(), collation.collation);
1601
1631
  }
1602
1632
  Item *safe_charset_converter(const CHARSET_INFO * const tocs);
1603
 
  inline void append(char *str, uint length)
 
1633
  inline void append(char *str, uint32_t length)
1604
1634
  {
1605
1635
    str_value.append(str, length);
1606
1636
    max_length= str_value.numchars() * collation.collation->mbmaxlen;
1645
1675
  {
1646
1676
    m_cs_specified= cs_specified;
1647
1677
  }
 
1678
  bool check_vcol_func_processor(unsigned char *arg __attribute__((unused)))
 
1679
  { return false; }
1648
1680
 
1649
1681
private:
1650
1682
  bool m_cs_specified;
1655
1687
{
1656
1688
  const char *func_name;
1657
1689
public:
1658
 
  Item_static_string_func(const char *name_par, const char *str, uint length,
 
1690
  Item_static_string_func(const char *name_par, const char *str, uint32_t length,
1659
1691
                          const CHARSET_INFO * const cs,
1660
1692
                          Derivation dv= DERIVATION_COERCIBLE)
1661
 
    :Item_string(NullS, str, length, cs, dv), func_name(name_par)
 
1693
    :Item_string(NULL, str, length, cs, dv), func_name(name_par)
1662
1694
  {}
1663
1695
  Item *safe_charset_converter(const CHARSET_INFO * const tocs);
1664
1696
 
1667
1699
  {
1668
1700
    str->append(func_name);
1669
1701
  }
 
1702
  bool check_vcol_func_processor(unsigned char *arg __attribute__((unused)))
 
1703
  { return true; }
1670
1704
};
1671
1705
 
1672
1706
 
1686
1720
class Item_blob :public Item_string
1687
1721
{
1688
1722
public:
1689
 
  Item_blob(const char *name, uint length) :
 
1723
  Item_blob(const char *name, uint32_t length) :
1690
1724
    Item_string(name, length, &my_charset_bin)
1691
1725
  { max_length= length; }
1692
1726
  enum Type type() const { return TYPE_HOLDER; }
1703
1737
class Item_empty_string :public Item_string
1704
1738
{
1705
1739
public:
1706
 
  Item_empty_string(const char *header,uint length, const CHARSET_INFO * cs= NULL) :
 
1740
  Item_empty_string(const char *header,uint32_t length, const CHARSET_INFO * cs= NULL) :
1707
1741
    Item_string("",0, cs ? cs : &my_charset_utf8_general_ci)
1708
1742
    { name=(char*) header; max_length= cs ? length * cs->mbmaxlen : length; }
1709
1743
  void make_field(Send_field *field);
1714
1748
{
1715
1749
  enum_field_types int_field_type;
1716
1750
public:
1717
 
  Item_return_int(const char *name_arg, uint length,
 
1751
  Item_return_int(const char *name_arg, uint32_t length,
1718
1752
                  enum_field_types field_type_arg, int64_t value= 0)
1719
1753
    :Item_int(name_arg, value, length), int_field_type(field_type_arg)
1720
1754
  {
1728
1762
{
1729
1763
public:
1730
1764
  Item_hex_string() {}
1731
 
  Item_hex_string(const char *str,uint str_length);
 
1765
  Item_hex_string(const char *str,uint32_t str_length);
1732
1766
  enum Type type() const { return VARBIN_ITEM; }
1733
1767
  double val_real()
1734
1768
  { 
1746
1780
  virtual void print(String *str, enum_query_type query_type);
1747
1781
  bool eq(const Item *item, bool binary_cmp) const;
1748
1782
  virtual Item *safe_charset_converter(const CHARSET_INFO * const tocs);
 
1783
  bool check_vcol_func_processor(unsigned char *arg __attribute__((unused)))
 
1784
  { return false; }
1749
1785
};
1750
1786
 
1751
1787
 
1752
1788
class Item_bin_string: public Item_hex_string
1753
1789
{
1754
1790
public:
1755
 
  Item_bin_string(const char *str,uint str_length);
 
1791
  Item_bin_string(const char *str,uint32_t str_length);
1756
1792
};
1757
1793
 
1758
1794
class Item_result_field :public Item    /* Item with result field */
1761
1797
  Field *result_field;                          /* Save result here */
1762
1798
  Item_result_field() :result_field(0) {}
1763
1799
  // Constructor used for Item_sum/Item_cond_and/or (see Item comment)
1764
 
  Item_result_field(THD *thd, Item_result_field *item):
1765
 
    Item(thd, item), result_field(item->result_field)
 
1800
  Item_result_field(Session *session, Item_result_field *item):
 
1801
    Item(session, item), result_field(item->result_field)
1766
1802
  {}
1767
1803
  ~Item_result_field() {}                       /* Required with gcc 2.95 */
1768
1804
  Field *get_tmp_table_field() { return result_field; }
1777
1813
    save_in_field(result_field, no_conversions);
1778
1814
  }
1779
1815
  void cleanup();
 
1816
  bool check_vcol_func_processor(unsigned char *arg __attribute__((unused)))
 
1817
  { return false; }
1780
1818
};
1781
1819
 
1782
1820
 
1812
1850
           bool alias_name_used_arg= false);
1813
1851
 
1814
1852
  /* Constructor need to process subselect with temporary tables (see Item) */
1815
 
  Item_ref(THD *thd, Item_ref *item)
1816
 
    :Item_ident(thd, item), result_field(item->result_field), ref(item->ref) {}
 
1853
  Item_ref(Session *session, Item_ref *item)
 
1854
    :Item_ident(session, item), result_field(item->result_field), ref(item->ref) {}
1817
1855
  enum Type type() const                { return REF_ITEM; }
1818
1856
  bool eq(const Item *item, bool binary_cmp) const
1819
1857
  { 
1826
1864
  bool val_bool();
1827
1865
  String *val_str(String* tmp);
1828
1866
  bool is_null();
1829
 
  bool get_date(DRIZZLE_TIME *ltime,uint fuzzydate);
 
1867
  bool get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate);
1830
1868
  double val_result();
1831
1869
  int64_t val_int_result();
1832
1870
  String *str_result(String* tmp);
1834
1872
  bool val_bool_result();
1835
1873
  bool send(Protocol *prot, String *tmp);
1836
1874
  void make_field(Send_field *field);
1837
 
  bool fix_fields(THD *, Item **);
 
1875
  bool fix_fields(Session *, Item **);
1838
1876
  void fix_after_pullout(st_select_lex *new_parent, Item **ref);
1839
1877
  int save_in_field(Field *field, bool no_conversions);
1840
1878
  void save_org_in_field(Field *field);
1842
1880
  enum_field_types field_type() const   { return (*ref)->field_type(); }
1843
1881
  Field *get_tmp_table_field()
1844
1882
  { return result_field ? result_field : (*ref)->get_tmp_table_field(); }
1845
 
  Item *get_tmp_table_item(THD *thd);
 
1883
  Item *get_tmp_table_item(Session *session);
1846
1884
  table_map used_tables() const         
1847
1885
  {
1848
1886
    return depended_from ? OUTER_REF_TABLE_BIT : (*ref)->used_tables(); 
1863
1901
  {
1864
1902
    return ref ? (*ref)->real_item() : this;
1865
1903
  }
1866
 
  bool walk(Item_processor processor, bool walk_subquery, uchar *arg)
 
1904
  bool walk(Item_processor processor, bool walk_subquery, unsigned char *arg)
1867
1905
  { return (*ref)->walk(processor, walk_subquery, arg); }
1868
1906
  virtual void print(String *str, enum_query_type query_type);
1869
1907
  bool result_as_int64_t()
1876
1914
  virtual Ref_Type ref_type() { return REF; }
1877
1915
 
1878
1916
  // Row emulation: forwarding of ROW-related calls to ref
1879
 
  uint cols()
 
1917
  uint32_t cols()
1880
1918
  {
1881
1919
    return ref && result_type() == ROW_RESULT ? (*ref)->cols() : 1;
1882
1920
  }
1883
 
  Item* element_index(uint i)
 
1921
  Item* element_index(uint32_t i)
1884
1922
  {
1885
1923
    return ref && result_type() == ROW_RESULT ? (*ref)->element_index(i) : this;
1886
1924
  }
1887
 
  Item** addr(uint i)
 
1925
  Item** addr(uint32_t i)
1888
1926
  {
1889
1927
    return ref && result_type() == ROW_RESULT ? (*ref)->addr(i) : 0;
1890
1928
  }
1891
 
  bool check_cols(uint c)
 
1929
  bool check_cols(uint32_t c)
1892
1930
  {
1893
1931
    return ref && result_type() == ROW_RESULT ? (*ref)->check_cols(c) 
1894
1932
                                              : Item::check_cols(c);
1921
1959
              field_name_arg, alias_name_used_arg)
1922
1960
  {}
1923
1961
  /* Constructor need to process subselect with temporary tables (see Item) */
1924
 
  Item_direct_ref(THD *thd, Item_direct_ref *item) : Item_ref(thd, item) {}
 
1962
  Item_direct_ref(Session *session, Item_direct_ref *item) : Item_ref(session, item) {}
1925
1963
 
1926
1964
  double val_real();
1927
1965
  int64_t val_int();
1929
1967
  my_decimal *val_decimal(my_decimal *);
1930
1968
  bool val_bool();
1931
1969
  bool is_null();
1932
 
  bool get_date(DRIZZLE_TIME *ltime,uint fuzzydate);
 
1970
  bool get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate);
1933
1971
  virtual Ref_Type ref_type() { return DIRECT_REF; }
1934
1972
};
1935
1973
 
1945
1983
                  const char *field_name_arg)
1946
1984
    :Item_direct_ref(context_arg, item, table_name_arg, field_name_arg) {}
1947
1985
  /* Constructor need to process subselect with temporary tables (see Item) */
1948
 
  Item_direct_view_ref(THD *thd, Item_direct_ref *item)
1949
 
    :Item_direct_ref(thd, item) {}
 
1986
  Item_direct_view_ref(Session *session, Item_direct_ref *item)
 
1987
    :Item_direct_ref(session, item) {}
1950
1988
 
1951
 
  bool fix_fields(THD *, Item **);
 
1989
  bool fix_fields(Session *, Item **);
1952
1990
  bool eq(const Item *item, bool binary_cmp) const;
1953
 
  Item *get_tmp_table_item(THD *thd)
 
1991
  Item *get_tmp_table_item(Session *session)
1954
1992
  {
1955
 
    Item *item= Item_ref::get_tmp_table_item(thd);
 
1993
    Item *item= Item_ref::get_tmp_table_item(session);
1956
1994
    item->name= name;
1957
1995
    return item;
1958
1996
  }
2004
2042
  {
2005
2043
    outer_ref->save_org_in_field(result_field);
2006
2044
  }
2007
 
  bool fix_fields(THD *, Item **);
 
2045
  bool fix_fields(Session *, Item **);
2008
2046
  void fix_after_pullout(st_select_lex *new_parent, Item **ref);
2009
2047
  table_map used_tables() const
2010
2048
  {
2041
2079
  String* val_str(String* s);
2042
2080
  my_decimal *val_decimal(my_decimal *);
2043
2081
  bool val_bool();
2044
 
  bool get_date(DRIZZLE_TIME *ltime, uint fuzzydate);
 
2082
  bool get_date(DRIZZLE_TIME *ltime, uint32_t fuzzydate);
2045
2083
  virtual void print(String *str, enum_query_type query_type);
2046
2084
  /*
2047
2085
    we add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE
2111
2149
    int err_not_used;
2112
2150
    char *end_not_used;
2113
2151
    return (null_value ? 0.0 :
2114
 
            my_strntod(str_value.charset(), (char*) str_value.ptr(),
2115
 
                       str_value.length(), &end_not_used, &err_not_used));
 
2152
            my_strntod(str_value.charset(), (char*) str_value.ptr(),
 
2153
                       str_value.length(), &end_not_used, &err_not_used));
2116
2154
  }
2117
2155
  int64_t val_int()
2118
2156
  {
2119
2157
    int err;
2120
 
    return null_value ? 0LL : my_strntoll(str_value.charset(),str_value.ptr(),
2121
 
                                            str_value.length(),10, (char**) 0,
2122
 
                                            &err); 
 
2158
    return null_value ? 0 : my_strntoll(str_value.charset(),str_value.ptr(),
 
2159
                                        str_value.length(),10, (char**) 0,
 
2160
                                        &err);
2123
2161
  }
2124
2162
  String *val_str(String*);
2125
2163
  my_decimal *val_decimal(my_decimal *);
2150
2188
  Item *item;
2151
2189
  String value,tmp_value;
2152
2190
public:
2153
 
  Cached_item_str(THD *thd, Item *arg);
 
2191
  Cached_item_str(Session *session, Item *arg);
2154
2192
  bool cmp(void);
2155
2193
  ~Cached_item_str();                           // Deallocate String:s
2156
2194
};
2186
2224
 
2187
2225
class Cached_item_field :public Cached_item
2188
2226
{
2189
 
  uchar *buff;
 
2227
  unsigned char *buff;
2190
2228
  Field *field;
2191
 
  uint length;
 
2229
  uint32_t length;
2192
2230
 
2193
2231
public:
2194
2232
  Cached_item_field(Field *arg_field) : field(arg_field)
2195
2233
  {
2196
2234
    field= arg_field;
2197
2235
    /* TODO: take the memory allocation below out of the constructor. */
2198
 
    buff= (uchar*) sql_calloc(length=field->pack_length());
 
2236
    buff= (unsigned char*) sql_calloc(length=field->pack_length());
2199
2237
  }
2200
2238
  bool cmp(void);
2201
2239
};
2214
2252
     arg(a) {}
2215
2253
  enum Type type() const { return DEFAULT_VALUE_ITEM; }
2216
2254
  bool eq(const Item *item, bool binary_cmp) const;
2217
 
  bool fix_fields(THD *, Item **);
 
2255
  bool fix_fields(Session *, Item **);
2218
2256
  virtual void print(String *str, enum_query_type query_type);
2219
2257
  int save_in_field(Field *field_arg, bool no_conversions);
2220
2258
  table_map used_tables() const { return (table_map)0L; }
2221
2259
 
2222
 
  bool walk(Item_processor processor, bool walk_subquery, uchar *args)
 
2260
  bool walk(Item_processor processor, bool walk_subquery, unsigned char *args)
2223
2261
  {
2224
2262
    return arg->walk(processor, walk_subquery, args) ||
2225
2263
      (this->*processor)(args);
2226
2264
  }
2227
2265
 
2228
 
  Item *transform(Item_transformer transformer, uchar *args);
 
2266
  Item *transform(Item_transformer transformer, unsigned char *args);
2229
2267
};
2230
2268
 
2231
2269
/*
2247
2285
               (const char *)NULL),
2248
2286
     arg(a) {}
2249
2287
  bool eq(const Item *item, bool binary_cmp) const;
2250
 
  bool fix_fields(THD *, Item **);
 
2288
  bool fix_fields(Session *, Item **);
2251
2289
  virtual void print(String *str, enum_query_type query_type);
2252
2290
  int save_in_field(Field *field_arg, bool no_conversions)
2253
2291
  {
2259
2297
  */
2260
2298
  table_map used_tables() const { return RAND_TABLE_BIT; }
2261
2299
 
2262
 
  bool walk(Item_processor processor, bool walk_subquery, uchar *args)
 
2300
  bool walk(Item_processor processor, bool walk_subquery, unsigned char *args)
2263
2301
  {
2264
2302
    return arg->walk(processor, walk_subquery, args) ||
2265
2303
            (this->*processor)(args);
2266
2304
  }
 
2305
  bool check_vcol_func_processor(unsigned char *arg __attribute__((unused)))
 
2306
  { return true; }
2267
2307
};
2268
2308
 
2269
2309
 
2296
2336
 
2297
2337
  void set_used_tables(table_map map) { used_table_map= map; }
2298
2338
 
2299
 
  virtual bool allocate(uint i __attribute__((unused)))
 
2339
  virtual bool allocate(uint32_t i __attribute__((unused)))
2300
2340
  { return 0; }
2301
2341
  virtual bool setup(Item *item)
2302
2342
  {
2406
2446
class Item_cache_row: public Item_cache
2407
2447
{
2408
2448
  Item_cache  **values;
2409
 
  uint item_count;
 
2449
  uint32_t item_count;
2410
2450
  bool save_array;
2411
2451
public:
2412
2452
  Item_cache_row()
2416
2456
    'allocate' used only in row transformer, to preallocate space for row 
2417
2457
    cache.
2418
2458
  */
2419
 
  bool allocate(uint num);
 
2459
  bool allocate(uint32_t num);
2420
2460
  /*
2421
2461
    'setup' is needed only by row => it not called by simple row subselect
2422
2462
    (only by IN subselect (in subselect optimizer))
2451
2491
 
2452
2492
  enum Item_result result_type() const { return ROW_RESULT; }
2453
2493
  
2454
 
  uint cols() { return item_count; }
2455
 
  Item *element_index(uint i) { return values[i]; }
2456
 
  Item **addr(uint i) { return (Item **) (values + i); }
2457
 
  bool check_cols(uint c);
 
2494
  uint32_t cols() { return item_count; }
 
2495
  Item *element_index(uint32_t i) { return values[i]; }
 
2496
  Item **addr(uint32_t i) { return (Item **) (values + i); }
 
2497
  bool check_cols(uint32_t c);
2458
2498
  bool null_inside();
2459
2499
  void bring_value();
2460
2500
  void keep_array() { save_array= 1; }
2488
2528
  /* It is used to count decimal precision in join_types */
2489
2529
  int prev_decimal_int_part;
2490
2530
public:
2491
 
  Item_type_holder(THD*, Item*);
 
2531
  Item_type_holder(Session*, Item*);
2492
2532
 
2493
2533
  Item_result result_type() const;
2494
2534
  enum_field_types field_type() const { return fld_type; };
2497
2537
  int64_t val_int();
2498
2538
  my_decimal *val_decimal(my_decimal *);
2499
2539
  String *val_str(String*);
2500
 
  bool join_types(THD *thd, Item *);
 
2540
  bool join_types(Session *session, Item *);
2501
2541
  Field *make_field_by_type(Table *table);
2502
2542
  static uint32_t display_length(Item *item);
2503
2543
  static enum_field_types get_real_type(Item *);
2505
2545
 
2506
2546
 
2507
2547
class st_select_lex;
2508
 
void mark_select_range_as_dependent(THD *thd,
 
2548
void mark_select_range_as_dependent(Session *session,
2509
2549
                                    st_select_lex *last_select,
2510
2550
                                    st_select_lex *current_sel,
2511
2551
                                    Field *found_field, Item *found_item,
2512
2552
                                    Item_ident *resolved_item);
2513
2553
 
2514
 
extern Cached_item *new_Cached_item(THD *thd, Item *item,
 
2554
extern Cached_item *new_Cached_item(Session *session, Item *item,
2515
2555
                                    bool use_result_field);
2516
 
extern void resolve_const_item(THD *thd, Item **ref, Item *cmp_item);
 
2556
extern void resolve_const_item(Session *session, Item **ref, Item *cmp_item);
2517
2557
extern bool field_is_equal_to_item(Field *field,Item *item);
 
2558
 
 
2559
#endif