~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to sql/item.h

  • Committer: Monty Taylor
  • Date: 2008-07-05 23:05:08 UTC
  • mto: This revision was merged to the branch mainline in revision 77.
  • Revision ID: monty@inaugust.com-20080705230508-9txkg702oln6hxjl
First large swath at getting handler stuff clean.

Show diffs side-by-side

added added

removed removed

Lines of Context:
165
165
  virtual void div(Hybrid_type *val, ulonglong u) const
166
166
  { val->real/= ulonglong2double(u); }
167
167
 
168
 
  virtual longlong val_int(Hybrid_type *val, bool unsigned_flag) const
 
168
  virtual longlong val_int(Hybrid_type *val,
 
169
                           bool unsigned_flag __attribute__((__unused__))) const
169
170
  { return (longlong) rint(val->real); }
170
171
  virtual double val_real(Hybrid_type *val) const { return val->real; }
171
172
  virtual my_decimal *val_decimal(Hybrid_type *val, my_decimal *buf) const;
190
191
 
191
192
  virtual longlong val_int(Hybrid_type *val, bool unsigned_flag) const;
192
193
  virtual double val_real(Hybrid_type *val) const;
193
 
  virtual my_decimal *val_decimal(Hybrid_type *val, my_decimal *buf) const
 
194
  virtual my_decimal *val_decimal(Hybrid_type *val,
 
195
                                  my_decimal *buf __attribute__((__unused__))) const
194
196
  { return &val->dec_buf[val->used_dec_buf_no]; }
195
197
  virtual String *val_str(Hybrid_type *val, String *buf, uint8 decimals) const;
196
198
  static const Hybrid_type_traits_decimal *instance();
213
215
  virtual void div(Hybrid_type *val, ulonglong u) const
214
216
  { val->integer/= (longlong) u; }
215
217
 
216
 
  virtual longlong val_int(Hybrid_type *val, bool unsigned_flag) const
 
218
  virtual longlong val_int(Hybrid_type *val,
 
219
                           bool unsigned_flag __attribute__((__unused__))) const
217
220
  { return val->integer; }
218
221
  virtual double val_real(Hybrid_type *val) const
219
222
  { return (double) val->integer; }
220
 
  virtual my_decimal *val_decimal(Hybrid_type *val, my_decimal *buf) const
 
223
  virtual my_decimal *val_decimal(Hybrid_type *val,
 
224
                                  my_decimal *buf __attribute__((__unused__))) const
221
225
  {
222
226
    int2my_decimal(E_DEC_FATAL_ERROR, val->integer, 0, &val->dec_buf[2]);
223
227
    return &val->dec_buf[2];
224
228
  }
225
 
  virtual String *val_str(Hybrid_type *val, String *buf, uint8 decimals) const
 
229
  virtual String *val_str(Hybrid_type *val, String *buf,
 
230
                          uint8 decimals __attribute__((__unused__))) const
226
231
  { buf->set(val->integer, &my_charset_bin); return buf;}
227
232
  static const Hybrid_type_traits_integer *instance();
228
233
  Hybrid_type_traits_integer() {};
430
435
  void operator=(Item &);
431
436
  /* Cache of the result of is_expensive(). */
432
437
  int8 is_expensive_cache;
433
 
  virtual bool is_expensive_processor(uchar *arg) { return 0; }
 
438
  virtual bool is_expensive_processor(uchar *arg __attribute__((__unused__)))
 
439
  { return 0; }
434
440
 
435
441
public:
436
442
  static void *operator new(size_t size)
437
443
  { return sql_alloc(size); }
438
444
  static void *operator new(size_t size, MEM_ROOT *mem_root)
439
445
  { return alloc_root(mem_root, size); }
440
 
  static void operator delete(void *ptr,size_t size) { TRASH(ptr, size); }
441
 
  static void operator delete(void *ptr, MEM_ROOT *mem_root) {}
 
446
  static void operator delete(void *ptr __attribute__((__unused__)),
 
447
                              size_t size __attribute__((__unused__)))
 
448
  { TRASH(ptr, size); }
 
449
  static void operator delete(void *ptr __attribute__((__unused__)),
 
450
                              MEM_ROOT *mem_root __attribute__((__unused__)))
 
451
  {}
442
452
 
443
453
  enum Type {FIELD_ITEM= 0, FUNC_ITEM, SUM_FUNC_ITEM, STRING_ITEM,
444
454
             INT_ITEM, REAL_ITEM, NULL_ITEM, VARBIN_ITEM,
510
520
    Fix after some tables has been pulled out. Basically re-calculate all
511
521
    attributes that are dependent on the tables.
512
522
  */
513
 
  virtual void fix_after_pullout(st_select_lex *new_parent, Item **ref) {};
 
523
  virtual void fix_after_pullout(st_select_lex *new_parent __attribute__((__unused__)),
 
524
                                 Item **ref __attribute__((__unused__))) {};
514
525
 
515
526
  /*
516
527
    should be used in case where we are sure that we do not need
570
581
 
571
582
    RETURN
572
583
      The output range bound, which equal to the value of val_int()
573
 
        - If the value of the function is NULL then the bound is the 
574
 
          smallest possible value of LONGLONG_MIN 
 
584
        - If the value of the function is NULL then the bound is the
 
585
          smallest possible value of LONGLONG_MIN
575
586
  */
576
 
  virtual longlong val_int_endpoint(bool left_endp, bool *incl_endp)
 
587
  virtual longlong val_int_endpoint(bool left_endp __attribute__((__unused__)),
 
588
                                    bool *incl_endp __attribute__((__unused__)))
577
589
  { DBUG_ASSERT(0); return 0; }
578
590
 
579
591
 
684
696
  int save_date_in_field(Field *field);
685
697
  int save_str_value_in_field(Field *field, String *result);
686
698
 
687
 
  virtual Field *get_tmp_table_field() { return 0; }
 
699
  virtual Field *get_tmp_table_field(void) { return 0; }
688
700
  /* This is also used to create fields in CREATE ... SELECT: */
689
 
  virtual Field *tmp_table_field(TABLE *t_arg) { return 0; }
690
 
  virtual const char *full_name() const { return name ? name : "???"; }
 
701
  virtual Field *tmp_table_field(TABLE *t_arg __attribute__((__unused__)))
 
702
  { return 0; }
 
703
  virtual const char *full_name(void) const { return name ? name : "???"; }
691
704
 
692
705
  /*
693
706
    *result* family of methods is analog of *val* family (see above) but
752
765
    query and why they should be generated from the Item-tree, @see
753
766
    mysql_register_view().
754
767
  */
755
 
  virtual inline void print(String *str, enum_query_type query_type)
 
768
  virtual inline void print(String *str,
 
769
                            enum_query_type query_type __attribute__((__unused__)))
756
770
  {
757
771
    str->append(full_name());
758
772
  }
759
773
 
760
774
  void print_item_w_name(String *, enum_query_type query_type);
761
775
  virtual void update_used_tables() {}
762
 
  virtual void split_sum_func(THD *thd, Item **ref_pointer_array,
763
 
                              List<Item> &fields) {}
 
776
  virtual void split_sum_func(THD *thd __attribute__((__unused__)),
 
777
                              Item **ref_pointer_array __attribute__((__unused__)),
 
778
                              List<Item> &fields __attribute__((__unused__))) {}
764
779
  /* Called for items that really have to be split */
765
780
  void split_sum_func2(THD *thd, Item **ref_pointer_array, List<Item> &fields,
766
781
                       Item **ref, bool skip_registered);
792
807
      Item_cond_and and subquery-related item) enable special optimizations
793
808
      when they are "top level".
794
809
  */
795
 
  virtual void top_level_item() {}
 
810
  virtual void top_level_item(void) {}
796
811
  /*
797
812
    set field of temporary table for Item which can be switched on temporary
798
813
    table during query processing (grouping and so on)
799
814
  */
800
 
  virtual void set_result_field(Field *field) {}
801
 
  virtual bool is_result_field() { return 0; }
802
 
  virtual bool is_bool_func() { return 0; }
803
 
  virtual void save_in_result_field(bool no_conversions) {}
 
815
  virtual void set_result_field(Field *field __attribute__((__unused__))) {}
 
816
  virtual bool is_result_field(void) { return 0; }
 
817
  virtual bool is_bool_func(void) { return 0; }
 
818
  virtual void save_in_result_field(bool no_conversions __attribute__((__unused__)))
 
819
  {}
804
820
  /*
805
821
    set value of aggregate function in case of no rows for grouping were found
806
822
  */
807
 
  virtual void no_rows_in_result() {}
808
 
  virtual Item *copy_or_same(THD *thd) { return this; }
809
 
  virtual Item *copy_andor_structure(THD *thd) { return this; }
810
 
  virtual Item *real_item() { return this; }
 
823
  virtual void no_rows_in_result(void) {}
 
824
  virtual Item *copy_or_same(THD *thd __attribute__((__unused__)))
 
825
  { return this; }
 
826
  virtual Item *copy_andor_structure(THD *thd  __attribute__((__unused__)))
 
827
  { return this; }
 
828
  virtual Item *real_item(void) { return this; }
811
829
  virtual Item *get_tmp_table_item(THD *thd) { return copy_or_same(thd); }
812
830
 
813
831
  static CHARSET_INFO *default_charset();
814
832
  virtual CHARSET_INFO *compare_collation() { return NULL; }
815
833
 
816
 
  virtual bool walk(Item_processor processor, bool walk_subquery, uchar *arg)
 
834
  virtual bool walk(Item_processor processor __attribute__((__unused__)),
 
835
                    bool walk_subquery __attribute__((__unused__)),
 
836
                    uchar *arg)
817
837
  {
818
838
    return (this->*processor)(arg);
819
839
  }
844
864
    return 0;
845
865
  }
846
866
 
847
 
   virtual void traverse_cond(Cond_traverser traverser,
848
 
                              void *arg, traverse_order order)
 
867
   virtual void traverse_cond(Cond_traverser traverser __attribute__((__unused__)),
 
868
                              void *arg,
 
869
                              traverse_order order __attribute__((__unused__)))
849
870
   {
850
871
     (*traverser)(this, arg);
851
872
   }
852
873
 
853
 
  virtual bool remove_dependence_processor(uchar * arg) { return 0; }
854
 
  virtual bool remove_fixed(uchar * arg) { fixed= 0; return 0; }
855
 
  virtual bool cleanup_processor(uchar *arg);
856
 
  virtual bool collect_item_field_processor(uchar * arg) { return 0; }
857
 
  virtual bool find_item_in_field_list_processor(uchar *arg) { return 0; }
858
 
  virtual bool change_context_processor(uchar *context) { return 0; }
859
 
  virtual bool reset_query_id_processor(uchar *query_id_arg) { return 0; }
860
 
  virtual bool register_field_in_read_map(uchar *arg) { return 0; }
 
874
  virtual bool remove_dependence_processor(uchar * arg __attribute__((__unused__)))
 
875
  { return 0; }
 
876
  virtual bool remove_fixed(uchar * arg __attribute__((__unused__)))
 
877
  {
 
878
    fixed= 0;
 
879
    return 0;
 
880
  }
 
881
  virtual bool cleanup_processor(uchar *arg __attribute__((__unused__)));
 
882
  virtual bool collect_item_field_processor(uchar * arg __attribute__((__unused__)))
 
883
  { return 0; }
 
884
  virtual bool find_item_in_field_list_processor(uchar *arg __attribute__((__unused__)))
 
885
 { return 0; }
 
886
  virtual bool change_context_processor(uchar *context __attribute__((__unused__)))
 
887
  { return 0; }
 
888
  virtual bool reset_query_id_processor(uchar *query_id_arg __attribute__((__unused__)))
 
889
  { return 0; }
 
890
  virtual bool register_field_in_read_map(uchar *arg __attribute__((__unused__)))
 
891
  { return 0; }
861
892
  virtual bool subst_argument_checker(uchar **arg)
862
 
  { 
 
893
  {
863
894
    if (*arg)
864
 
      *arg= NULL; 
865
 
    return TRUE;     
 
895
      *arg= NULL;
 
896
    return true;
866
897
  }
867
898
 
868
 
  virtual Item *equal_fields_propagator(uchar * arg) { return this; }
869
 
  virtual bool set_no_const_sub(uchar *arg) { return FALSE; }
870
 
  virtual Item *replace_equal_field(uchar * arg) { return this; }
 
899
  virtual Item *equal_fields_propagator(uchar * arg __attribute__((__unused__))) { return this; }
 
900
  virtual bool set_no_const_sub(uchar *arg __attribute__((__unused__))) { return false; }
 
901
  virtual Item *replace_equal_field(uchar * arg __attribute__((__unused__))) { return this; }
871
902
 
872
903
  /*
873
904
    For SP local variable returns pointer to Item representing its
874
905
    current value and pointer to current Item otherwise.
875
906
  */
876
 
  virtual Item *this_item() { return this; }
877
 
  virtual const Item *this_item() const { return this; }
 
907
  virtual Item *this_item(void) { return this; }
 
908
  virtual const Item *this_item(void) const { return this; }
878
909
 
879
910
  /*
880
911
    For SP local variable returns address of pointer to Item representing its
881
912
    current value and pointer passed via parameter otherwise.
882
913
  */
883
 
  virtual Item **this_item_addr(THD *thd, Item **addr_arg) { return addr_arg; }
 
914
  virtual Item **this_item_addr(THD *thd __attribute__((__unused__)), Item **addr_arg) { return addr_arg; }
884
915
 
885
916
  // Row emulation
886
917
  virtual uint cols() { return 1; }
887
 
  virtual Item* element_index(uint i) { return this; }
888
 
  virtual Item** addr(uint i) { return 0; }
 
918
  virtual Item* element_index(uint i __attribute__((__unused__))) { return this; }
 
919
  virtual Item** addr(uint i __attribute__((__unused__))) { return 0; }
889
920
  virtual bool check_cols(uint c);
890
921
  // It is not row => null inside is impossible
891
922
  virtual bool null_inside() { return 0; }
895
926
  Field *tmp_table_field_from_field_type(TABLE *table, bool fixed_length);
896
927
  virtual Item_field *filed_for_view_update() { return 0; }
897
928
 
898
 
  virtual Item *neg_transformer(THD *thd) { return NULL; }
899
 
  virtual Item *update_value_transformer(uchar *select_arg) { return this; }
 
929
  virtual Item *neg_transformer(THD *thd __attribute__((__unused__))) { return NULL; }
 
930
  virtual Item *update_value_transformer(uchar *select_arg __attribute__((__unused__))) { return this; }
900
931
  virtual Item *safe_charset_converter(CHARSET_INFO *tocs);
901
932
  void delete_self()
902
933
  {
1115
1146
  }
1116
1147
  longlong val_int_endpoint(bool left_endp, bool *incl_endp);
1117
1148
  Field *get_tmp_table_field() { return result_field; }
1118
 
  Field *tmp_table_field(TABLE *t_arg) { return result_field; }
 
1149
  Field *tmp_table_field(TABLE *t_arg __attribute__((__unused__))) { return result_field; }
1119
1150
  bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
1120
1151
  bool get_date_result(MYSQL_TIME *ltime,uint fuzzydate);
1121
1152
  bool get_time(MYSQL_TIME *ltime);
1179
1210
  Item *clone_item() { return new Item_null(name); }
1180
1211
  bool is_null() { return 1; }
1181
1212
 
1182
 
  virtual inline void print(String *str, enum_query_type query_type)
 
1213
  virtual inline void print(String *str,
 
1214
                            enum_query_type query_type __attribute__((__unused__)))
1183
1215
  {
1184
1216
    str->append(STRING_WITH_LEN("NULL"));
1185
1217
  }
1411
1443
  longlong val_int();
1412
1444
  double val_real();
1413
1445
  String *val_str(String*);
1414
 
  my_decimal *val_decimal(my_decimal *val) { return &decimal_value; }
 
1446
  my_decimal *val_decimal(my_decimal *val __attribute__((__unused__)))
 
1447
  { return &decimal_value; }
1415
1448
  int save_in_field(Field *field, bool no_conversions);
1416
1449
  bool basic_const_item() const { return 1; }
1417
1450
  Item *clone_item()
1488
1521
    :Item_float(NullS, val_arg, decimal_par, length), func_name(str)
1489
1522
  {}
1490
1523
 
1491
 
  virtual inline void print(String *str, enum_query_type query_type)
 
1524
  virtual inline void print(String *str,
 
1525
                            enum_query_type query_type __attribute__((__unused__)))
1492
1526
  {
1493
1527
    str->append(func_name);
1494
1528
  }
1640
1674
  {}
1641
1675
  Item *safe_charset_converter(CHARSET_INFO *tocs);
1642
1676
 
1643
 
  virtual inline void print(String *str, enum_query_type query_type)
 
1677
  virtual inline void print(String *str,
 
1678
                            enum_query_type query_type __attribute__((__unused__)))
1644
1679
  {
1645
1680
    str->append(func_name);
1646
1681
  }
1743
1778
  {}
1744
1779
  ~Item_result_field() {}                       /* Required with gcc 2.95 */
1745
1780
  Field *get_tmp_table_field() { return result_field; }
1746
 
  Field *tmp_table_field(TABLE *t_arg) { return result_field; }
 
1781
  Field *tmp_table_field(TABLE *t_arg __attribute__((__unused__)))
 
1782
  { return result_field; }
1747
1783
  table_map used_tables() const { return 1; }
1748
1784
  virtual void fix_length_and_dec()=0;
1749
1785
  void set_result_field(Field *field) { result_field= field; }
1976
2012
                     alias_name_used_arg),
1977
2013
    outer_ref(0), in_sum_func(0), found_in_select_list(1)
1978
2014
  {}
1979
 
  void save_in_result_field(bool no_conversions)
 
2015
  void save_in_result_field(bool no_conversions __attribute__((__unused__)))
1980
2016
  {
1981
2017
    outer_ref->save_org_in_field(result_field);
1982
2018
  }
2101
2137
  my_decimal *val_decimal(my_decimal *);
2102
2138
  void make_field(Send_field *field) { item->make_field(field); }
2103
2139
  void copy();
2104
 
  int save_in_field(Field *field, bool no_conversions)
 
2140
  int save_in_field(Field *field,
 
2141
                    bool no_conversions __attribute__((__unused__)))
2105
2142
  {
2106
2143
    return save_str_value_in_field(field, &str_value);
2107
2144
  }
2285
2322
 
2286
2323
  void set_used_tables(table_map map) { used_table_map= map; }
2287
2324
 
2288
 
  virtual bool allocate(uint i) { return 0; }
 
2325
  virtual bool allocate(uint i __attribute__((__unused__)))
 
2326
  { return 0; }
2289
2327
  virtual bool setup(Item *item)
2290
2328
  {
2291
2329
    example= item;
2308
2346
  { 
2309
2347
    return cached_field ? cached_field->eq_def (field) : FALSE;
2310
2348
  }
2311
 
  bool eq(const Item *item, bool binary_cmp) const
 
2349
  bool eq(const Item *item,
 
2350
          bool binary_cmp __attribute__((__unused__))) const
2312
2351
  {
2313
2352
    return this == item;
2314
2353
  }
2430
2469
    illegal_method_call((const char*)"val_str");
2431
2470
    return 0;
2432
2471
  };
2433
 
  my_decimal *val_decimal(my_decimal *val)
 
2472
  my_decimal *val_decimal(my_decimal *val __attribute__((__unused__)))
2434
2473
  {
2435
2474
    illegal_method_call((const char*)"val_decimal");
2436
2475
    return 0;