~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item.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:
47
47
 
48
48
class DTCollation {
49
49
public:
50
 
  CHARSET_INFO     *collation;
 
50
  const CHARSET_INFO *collation;
51
51
  enum Derivation derivation;
52
52
  uint repertoire;
53
53
  
54
 
  void set_repertoire_from_charset(CHARSET_INFO *cs)
 
54
  void set_repertoire_from_charset(const CHARSET_INFO * const cs)
55
55
  {
56
56
    repertoire= cs->state & MY_CS_PUREASCII ?
57
57
                MY_REPERTOIRE_ASCII : MY_REPERTOIRE_UNICODE30;
62
62
    derivation= DERIVATION_NONE;
63
63
    repertoire= MY_REPERTOIRE_UNICODE30;
64
64
  }
65
 
  DTCollation(CHARSET_INFO *collation_arg, Derivation derivation_arg)
 
65
  DTCollation(const CHARSET_INFO * const collation_arg, Derivation derivation_arg)
66
66
  {
67
67
    collation= collation_arg;
68
68
    derivation= derivation_arg;
74
74
    derivation= dt.derivation;
75
75
    repertoire= dt.repertoire;
76
76
  }
77
 
  void set(CHARSET_INFO *collation_arg, Derivation derivation_arg)
 
77
  void set(const CHARSET_INFO * const collation_arg, Derivation derivation_arg)
78
78
  {
79
79
    collation= collation_arg;
80
80
    derivation= derivation_arg;
81
81
    set_repertoire_from_charset(collation_arg);
82
82
  }
83
 
  void set(CHARSET_INFO *collation_arg,
 
83
  void set(const CHARSET_INFO * const collation_arg,
84
84
           Derivation derivation_arg,
85
85
           uint repertoire_arg)
86
86
  {
88
88
    derivation= derivation_arg;
89
89
    repertoire= repertoire_arg;
90
90
  }
91
 
  void set(CHARSET_INFO *collation_arg)
 
91
  void set(const CHARSET_INFO * const collation_arg)
92
92
  {
93
93
    collation= collation_arg;
94
94
    set_repertoire_from_charset(collation_arg);
509
509
    name=0;
510
510
#endif
511
511
  }             /*lint -e1509 */
512
 
  void set_name(const char *str, uint length, CHARSET_INFO *cs);
 
512
  void set_name(const char *str, uint length, const CHARSET_INFO * const cs);
513
513
  void rename(char *new_name);
514
514
  void init_make_field(Send_field *tmp_field,enum enum_field_types type);
515
515
  virtual void cleanup();
828
828
  virtual Item *real_item(void) { return this; }
829
829
  virtual Item *get_tmp_table_item(THD *thd) { return copy_or_same(thd); }
830
830
 
831
 
  static CHARSET_INFO *default_charset();
832
 
  virtual CHARSET_INFO *compare_collation() { return NULL; }
 
831
  static const CHARSET_INFO *default_charset();
 
832
  virtual const CHARSET_INFO *compare_collation() { return NULL; }
833
833
 
834
834
  virtual bool walk(Item_processor processor __attribute__((unused)),
835
835
                    bool walk_subquery __attribute__((unused)),
928
928
 
929
929
  virtual Item *neg_transformer(THD *thd __attribute__((unused))) { return NULL; }
930
930
  virtual Item *update_value_transformer(uchar *select_arg __attribute__((unused))) { return this; }
931
 
  virtual Item *safe_charset_converter(CHARSET_INFO *tocs);
 
931
  virtual Item *safe_charset_converter(const CHARSET_INFO * const tocs);
932
932
  void delete_self()
933
933
  {
934
934
    cleanup();
963
963
    return test(is_expensive_cache);
964
964
  }
965
965
  String *check_well_formed_result(String *str, bool send_error= 0);
966
 
  bool eq_by_collation(Item *item, bool binary_cmp, CHARSET_INFO *cs); 
 
966
  bool eq_by_collation(Item *item, bool binary_cmp, const CHARSET_INFO * const cs); 
967
967
};
968
968
 
969
969
 
996
996
public:
997
997
  Item_num() {}                               /* Remove gcc warning */
998
998
  virtual Item_num *neg()= 0;
999
 
  Item *safe_charset_converter(CHARSET_INFO *tocs);
 
999
  Item *safe_charset_converter(const CHARSET_INFO * const tocs);
1000
1000
};
1001
1001
 
1002
1002
#define NO_CACHED_FIELD_INDEX ((uint)(-1))
1168
1168
  Item *replace_equal_field(uchar *arg);
1169
1169
  inline uint32_t max_disp_length() { return field->max_display_length(); }
1170
1170
  Item_field *filed_for_view_update() { return this; }
1171
 
  Item *safe_charset_converter(CHARSET_INFO *tocs);
 
1171
  Item *safe_charset_converter(const CHARSET_INFO * const tocs);
1172
1172
  int fix_outer_field(THD *thd, Field **field, Item **reference);
1173
1173
  virtual Item *update_value_transformer(uchar *select_arg);
1174
1174
  virtual void print(String *str, enum_query_type query_type);
1210
1210
    str->append(STRING_WITH_LEN("NULL"));
1211
1211
  }
1212
1212
 
1213
 
  Item *safe_charset_converter(CHARSET_INFO *tocs);
 
1213
  Item *safe_charset_converter(const CHARSET_INFO * const tocs);
1214
1214
};
1215
1215
 
1216
1216
class Item_null_result :public Item_null
1265
1265
    */
1266
1266
    struct CONVERSION_INFO
1267
1267
    {
1268
 
      CHARSET_INFO *character_set_client;
1269
 
      CHARSET_INFO *character_set_of_placeholder;
 
1268
      const CHARSET_INFO *character_set_client;
 
1269
      const CHARSET_INFO *character_set_of_placeholder;
1270
1270
      /*
1271
1271
        This points at character set of connection if conversion
1272
1272
        to it is required (i. e. if placeholder typecode is not BLOB).
1273
1273
        Otherwise it's equal to character_set_client (to simplify
1274
1274
        check in convert_str_value()).
1275
1275
      */
1276
 
      CHARSET_INFO *final_character_set_of_str_value;
 
1276
      const CHARSET_INFO *final_character_set_of_str_value;
1277
1277
    } cs_info;
1278
1278
    DRIZZLE_TIME     time;
1279
1279
  } value;
1353
1353
    constant, assert otherwise. This method is called only if
1354
1354
    basic_const_item returned true.
1355
1355
  */
1356
 
  Item *safe_charset_converter(CHARSET_INFO *tocs);
 
1356
  Item *safe_charset_converter(const CHARSET_INFO * const tocs);
1357
1357
  Item *clone_item();
1358
1358
  /*
1359
1359
    Implement by-value equality evaluation if parameter value
1423
1423
protected:
1424
1424
  my_decimal decimal_value;
1425
1425
public:
1426
 
  Item_decimal(const char *str_arg, uint length, CHARSET_INFO *charset);
 
1426
  Item_decimal(const char *str_arg, uint length, const CHARSET_INFO * const charset);
1427
1427
  Item_decimal(const char *str, const my_decimal *val_arg,
1428
1428
               uint decimal_par, uint length);
1429
1429
  Item_decimal(my_decimal *value_par);
1521
1521
    str->append(func_name);
1522
1522
  }
1523
1523
 
1524
 
  Item *safe_charset_converter(CHARSET_INFO *tocs);
 
1524
  Item *safe_charset_converter(const CHARSET_INFO * const tocs);
1525
1525
};
1526
1526
 
1527
1527
 
1529
1529
{
1530
1530
public:
1531
1531
  Item_string(const char *str,uint length,
1532
 
              CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE,
 
1532
              const CHARSET_INFO * const cs, Derivation dv= DERIVATION_COERCIBLE,
1533
1533
              uint repertoire= MY_REPERTOIRE_UNICODE30)
1534
1534
    : m_cs_specified(false)
1535
1535
  {
1549
1549
    fixed= 1;
1550
1550
  }
1551
1551
  /* Just create an item and do not fill string representation */
1552
 
  Item_string(CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE)
 
1552
  Item_string(const CHARSET_INFO * const cs, Derivation dv= DERIVATION_COERCIBLE)
1553
1553
    : m_cs_specified(false)
1554
1554
  {
1555
1555
    collation.set(cs, dv);
1559
1559
    fixed= 1;
1560
1560
  }
1561
1561
  Item_string(const char *name_par, const char *str, uint length,
1562
 
              CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE,
 
1562
              const CHARSET_INFO * const cs, Derivation dv= DERIVATION_COERCIBLE,
1563
1563
              uint repertoire= MY_REPERTOIRE_UNICODE30)
1564
1564
    : m_cs_specified(false)
1565
1565
  {
1605
1605
    return new Item_string(name, str_value.ptr(), 
1606
1606
                           str_value.length(), collation.collation);
1607
1607
  }
1608
 
  Item *safe_charset_converter(CHARSET_INFO *tocs);
 
1608
  Item *safe_charset_converter(const CHARSET_INFO * const tocs);
1609
1609
  inline void append(char *str, uint length)
1610
1610
  {
1611
1611
    str_value.append(str, length);
1662
1662
  const char *func_name;
1663
1663
public:
1664
1664
  Item_static_string_func(const char *name_par, const char *str, uint length,
1665
 
                          CHARSET_INFO *cs,
 
1665
                          const CHARSET_INFO * const cs,
1666
1666
                          Derivation dv= DERIVATION_COERCIBLE)
1667
1667
    :Item_string(NullS, str, length, cs, dv), func_name(name_par)
1668
1668
  {}
1669
 
  Item *safe_charset_converter(CHARSET_INFO *tocs);
 
1669
  Item *safe_charset_converter(const CHARSET_INFO * const tocs);
1670
1670
 
1671
1671
  virtual inline void print(String *str,
1672
1672
                            enum_query_type query_type __attribute__((unused)))
1709
1709
class Item_empty_string :public Item_string
1710
1710
{
1711
1711
public:
1712
 
  Item_empty_string(const char *header,uint length, CHARSET_INFO *cs= NULL) :
 
1712
  Item_empty_string(const char *header,uint length, const CHARSET_INFO * cs= NULL) :
1713
1713
    Item_string("",0, cs ? cs : &my_charset_utf8_general_ci)
1714
1714
    { name=(char*) header; max_length= cs ? length * cs->mbmaxlen : length; }
1715
1715
  void make_field(Send_field *field);
1751
1751
  enum_field_types field_type() const { return DRIZZLE_TYPE_VARCHAR; }
1752
1752
  virtual void print(String *str, enum_query_type query_type);
1753
1753
  bool eq(const Item *item, bool binary_cmp) const;
1754
 
  virtual Item *safe_charset_converter(CHARSET_INFO *tocs);
 
1754
  virtual Item *safe_charset_converter(const CHARSET_INFO * const tocs);
1755
1755
};
1756
1756
 
1757
1757
 
2405
2405
  String* val_str(String *) { assert(fixed == 1); return value; }
2406
2406
  my_decimal *val_decimal(my_decimal *);
2407
2407
  enum Item_result result_type() const { return STRING_RESULT; }
2408
 
  CHARSET_INFO *charset() const { return value->charset(); };
 
2408
  const CHARSET_INFO *charset() const { return value->charset(); };
2409
2409
  int save_in_field(Field *field, bool no_conversions);
2410
2410
};
2411
2411