~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item_cmpfunc.h

  • Committer: Andrey Hristov
  • Date: 2008-08-06 00:04:45 UTC
  • mto: (264.1.5 codestyle)
  • mto: This revision was merged to the branch mainline in revision 266.
  • Revision ID: ahristov@mysql.com-20080806000445-84urmltikgwk9v5d
Constify the usage of CHARSET_INFO almost to the last place in the code.
99% of the parameters are const CHARSET_INFO * const cs.
Wherever possible stack variables are also double consted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
347
347
 
348
348
  bool is_null() { return test(args[0]->is_null() || args[1]->is_null()); }
349
349
  bool is_bool_func() { return 1; }
350
 
  CHARSET_INFO *compare_collation() { return cmp.cmp_collation.collation; }
 
350
  const CHARSET_INFO *compare_collation() { return cmp.cmp_collation.collation; }
351
351
  uint decimal_precision() const { return 1; }
352
352
  void top_level_item() { abort_on_null= true; }
353
353
 
606
606
  void fix_length_and_dec();
607
607
  virtual void print(String *str, enum_query_type query_type);
608
608
  bool is_bool_func() { return 1; }
609
 
  CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
 
609
  const CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
610
610
  uint decimal_precision() const { return 1; }
611
611
};
612
612
 
747
747
  char *base;
748
748
  uint size;
749
749
  qsort2_cmp compare;
750
 
  CHARSET_INFO *collation;
 
750
  const CHARSET_INFO *collation;
751
751
  uint count;
752
752
  uint used_count;
753
753
  in_vector() {}
754
754
  in_vector(uint elements,uint element_length,qsort2_cmp cmp_func, 
755
 
            CHARSET_INFO *cmp_coll)
 
755
            const CHARSET_INFO * const cmp_coll)
756
756
    :base((char*) sql_calloc(elements*element_length)),
757
757
     size(element_length), compare(cmp_func), collation(cmp_coll),
758
758
     count(elements), used_count(elements) {}
761
761
  virtual uchar *get_value(Item *item)=0;
762
762
  void sort()
763
763
  {
764
 
    my_qsort2(base,used_count,size,compare,collation);
 
764
    my_qsort2(base,used_count,size,compare, (void *) collation);
765
765
  }
766
766
  int find(Item *item);
767
767
  
799
799
  char buff[STRING_BUFFER_USUAL_SIZE];
800
800
  String tmp;
801
801
public:
802
 
  in_string(uint elements,qsort2_cmp cmp_func, CHARSET_INFO *cs);
 
802
  in_string(uint elements,qsort2_cmp cmp_func, const CHARSET_INFO * const cs);
803
803
  ~in_string();
804
804
  void set(uint pos,Item *item);
805
805
  uchar *get_value(Item *item);
926
926
class cmp_item :public Sql_alloc
927
927
{
928
928
public:
929
 
  CHARSET_INFO *cmp_charset;
 
929
  const CHARSET_INFO *cmp_charset;
930
930
  cmp_item() { cmp_charset= &my_charset_bin; }
931
931
  virtual ~cmp_item() {}
932
932
  virtual void store_value(Item *item)= 0;
933
933
  virtual int cmp(Item *item)= 0;
934
934
  // for optimized IN with row
935
935
  virtual int compare(cmp_item *item)= 0;
936
 
  static cmp_item* get_comparator(Item_result type, CHARSET_INFO *cs);
 
936
  static cmp_item* get_comparator(Item_result type, const CHARSET_INFO * const cs);
937
937
  virtual cmp_item *make_same()= 0;
938
938
  virtual void store_value_by_template(cmp_item *tmpl  __attribute__((unused)),
939
939
                                       Item *item)
948
948
  String *value_res;
949
949
public:
950
950
  cmp_item_string () {}
951
 
  cmp_item_string (CHARSET_INFO *cs) { cmp_charset= cs; }
952
 
  void set_charset(CHARSET_INFO *cs) { cmp_charset= cs; }
 
951
  cmp_item_string (const CHARSET_INFO * const cs) { cmp_charset= cs; }
 
952
  void set_charset(const CHARSET_INFO * const cs) { cmp_charset= cs; }
953
953
  friend class cmp_item_sort_string;
954
954
  friend class cmp_item_sort_string_in_static;
955
955
};
962
962
public:
963
963
  cmp_item_sort_string():
964
964
    cmp_item_string() {}
965
 
  cmp_item_sort_string(CHARSET_INFO *cs):
 
965
  cmp_item_sort_string(const CHARSET_INFO * const cs):
966
966
    cmp_item_string(cs),
967
967
    value(value_buff, sizeof(value_buff), cs) {}
968
968
  void store_value(Item *item)
983
983
    return sortcmp(value_res, l_cmp->value_res, cmp_charset);
984
984
  } 
985
985
  cmp_item *make_same();
986
 
  void set_charset(CHARSET_INFO *cs)
 
986
  void set_charset(const CHARSET_INFO * const cs)
987
987
  {
988
988
    cmp_charset= cs;
989
989
    value.set_quick(value_buff, sizeof(value_buff), cs);
1079
1079
 protected:
1080
1080
  String value;
1081
1081
public:
1082
 
  cmp_item_sort_string_in_static(CHARSET_INFO *cs):
 
1082
  cmp_item_sort_string_in_static(const CHARSET_INFO * const cs):
1083
1083
    cmp_item_string(cs) {}
1084
1084
  void store_value(Item *item)
1085
1085
  {
1164
1164
  const char *func_name() const { return "case"; }
1165
1165
  virtual void print(String *str, enum_query_type query_type);
1166
1166
  Item *find_item(String *str);
1167
 
  CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
 
1167
  const CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
1168
1168
  void cleanup();
1169
1169
  void agg_str_lengths(Item *arg);
1170
1170
  void agg_num_lengths(Item *arg);
1233
1233
  const char *func_name() const { return " IN "; }
1234
1234
  bool nulls_in_row();
1235
1235
  bool is_bool_func() { return 1; }
1236
 
  CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
 
1236
  const CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
1237
1237
};
1238
1238
 
1239
1239
class cmp_item_row :public cmp_item
1304
1304
  table_map not_null_tables() const { return 0; }
1305
1305
  optimize_type select_optimize() const { return OPTIMIZE_NULL; }
1306
1306
  Item *neg_transformer(THD *thd);
1307
 
  CHARSET_INFO *compare_collation() { return args[0]->collation.collation; }
 
1307
  const CHARSET_INFO *compare_collation() { return args[0]->collation.collation; }
1308
1308
};
1309
1309
 
1310
1310
/* Functions used by HAVING for rewriting IN subquery */
1351
1351
  { return abort_on_null ? not_null_tables_cache : 0; }
1352
1352
  Item *neg_transformer(THD *thd);
1353
1353
  virtual void print(String *str, enum_query_type query_type);
1354
 
  CHARSET_INFO *compare_collation() { return args[0]->collation.collation; }
 
1354
  const CHARSET_INFO *compare_collation() { return args[0]->collation.collation; }
1355
1355
  void top_level_item() { abort_on_null=1; }
1356
1356
};
1357
1357
 
1552
1552
  bool walk(Item_processor processor, bool walk_subquery, uchar *arg);
1553
1553
  Item *transform(Item_transformer transformer, uchar *arg);
1554
1554
  virtual void print(String *str, enum_query_type query_type);
1555
 
  CHARSET_INFO *compare_collation() 
 
1555
  const CHARSET_INFO *compare_collation() 
1556
1556
  { return fields.head()->collation.collation; }
1557
1557
}; 
1558
1558