~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to sql/item.h

Merging trunk changes from over weekend.

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);
1145
1176
#ifndef DBUG_OFF
1146
1177
  void dbug_print()
1147
1178
  {
1148
 
    fprintf(DBUG_FILE, "<field ");
1149
 
    if (field)
1150
 
    {
1151
 
      fprintf(DBUG_FILE, "'%s.%s': ", field->table->alias, field->field_name);
1152
 
      field->dbug_print();
1153
 
    }
1154
 
    else
1155
 
      fprintf(DBUG_FILE, "NULL");
1156
 
 
1157
 
    fprintf(DBUG_FILE, ", result_field: ");
1158
 
    if (result_field)
1159
 
    {
1160
 
      fprintf(DBUG_FILE, "'%s.%s': ",
1161
 
              result_field->table->alias, result_field->field_name);
1162
 
      result_field->dbug_print();
1163
 
    }
1164
 
    else
1165
 
      fprintf(DBUG_FILE, "NULL");
1166
 
    fprintf(DBUG_FILE, ">\n");
1167
1179
  }
1168
1180
#endif
1169
1181
 
1198
1210
  Item *clone_item() { return new Item_null(name); }
1199
1211
  bool is_null() { return 1; }
1200
1212
 
1201
 
  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__)))
1202
1215
  {
1203
1216
    str->append(STRING_WITH_LEN("NULL"));
1204
1217
  }
1430
1443
  longlong val_int();
1431
1444
  double val_real();
1432
1445
  String *val_str(String*);
1433
 
  my_decimal *val_decimal(my_decimal *val) { return &decimal_value; }
 
1446
  my_decimal *val_decimal(my_decimal *val __attribute__((__unused__)))
 
1447
  { return &decimal_value; }
1434
1448
  int save_in_field(Field *field, bool no_conversions);
1435
1449
  bool basic_const_item() const { return 1; }
1436
1450
  Item *clone_item()
1507
1521
    :Item_float(NullS, val_arg, decimal_par, length), func_name(str)
1508
1522
  {}
1509
1523
 
1510
 
  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__)))
1511
1526
  {
1512
1527
    str->append(func_name);
1513
1528
  }
1659
1674
  {}
1660
1675
  Item *safe_charset_converter(CHARSET_INFO *tocs);
1661
1676
 
1662
 
  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__)))
1663
1679
  {
1664
1680
    str->append(func_name);
1665
1681
  }
1762
1778
  {}
1763
1779
  ~Item_result_field() {}                       /* Required with gcc 2.95 */
1764
1780
  Field *get_tmp_table_field() { return result_field; }
1765
 
  Field *tmp_table_field(TABLE *t_arg) { return result_field; }
 
1781
  Field *tmp_table_field(TABLE *t_arg __attribute__((__unused__)))
 
1782
  { return result_field; }
1766
1783
  table_map used_tables() const { return 1; }
1767
1784
  virtual void fix_length_and_dec()=0;
1768
1785
  void set_result_field(Field *field) { result_field= field; }
1995
2012
                     alias_name_used_arg),
1996
2013
    outer_ref(0), in_sum_func(0), found_in_select_list(1)
1997
2014
  {}
1998
 
  void save_in_result_field(bool no_conversions)
 
2015
  void save_in_result_field(bool no_conversions __attribute__((__unused__)))
1999
2016
  {
2000
2017
    outer_ref->save_org_in_field(result_field);
2001
2018
  }
2120
2137
  my_decimal *val_decimal(my_decimal *);
2121
2138
  void make_field(Send_field *field) { item->make_field(field); }
2122
2139
  void copy();
2123
 
  int save_in_field(Field *field, bool no_conversions)
 
2140
  int save_in_field(Field *field,
 
2141
                    bool no_conversions __attribute__((__unused__)))
2124
2142
  {
2125
2143
    return save_str_value_in_field(field, &str_value);
2126
2144
  }
2304
2322
 
2305
2323
  void set_used_tables(table_map map) { used_table_map= map; }
2306
2324
 
2307
 
  virtual bool allocate(uint i) { return 0; }
 
2325
  virtual bool allocate(uint i __attribute__((__unused__)))
 
2326
  { return 0; }
2308
2327
  virtual bool setup(Item *item)
2309
2328
  {
2310
2329
    example= item;
2327
2346
  { 
2328
2347
    return cached_field ? cached_field->eq_def (field) : FALSE;
2329
2348
  }
2330
 
  bool eq(const Item *item, bool binary_cmp) const
 
2349
  bool eq(const Item *item,
 
2350
          bool binary_cmp __attribute__((__unused__))) const
2331
2351
  {
2332
2352
    return this == item;
2333
2353
  }
2449
2469
    illegal_method_call((const char*)"val_str");
2450
2470
    return 0;
2451
2471
  };
2452
 
  my_decimal *val_decimal(my_decimal *val)
 
2472
  my_decimal *val_decimal(my_decimal *val __attribute__((__unused__)))
2453
2473
  {
2454
2474
    illegal_method_call((const char*)"val_decimal");
2455
2475
    return 0;