~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item.cc

  • 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:
680
680
}
681
681
 
682
682
 
683
 
void Item::set_name(const char *str, uint length, CHARSET_INFO *cs)
 
683
void Item::set_name(const char *str, uint length, const CHARSET_INFO * const cs)
684
684
{
685
685
  if (!length)
686
686
  {
744
744
}
745
745
 
746
746
 
747
 
Item *Item::safe_charset_converter(CHARSET_INFO *tocs)
 
747
Item *Item::safe_charset_converter(const CHARSET_INFO * const tocs)
748
748
{
749
749
  Item_func_conv_charset *conv= new Item_func_conv_charset(this, tocs, 1);
750
750
  return conv->safe ? conv : NULL;
762
762
  the latter returns a non-fixed Item, so val_str() crashes afterwards.
763
763
  Override Item_num method, to return a fixed item.
764
764
*/
765
 
Item *Item_num::safe_charset_converter(CHARSET_INFO *tocs __attribute__((unused)))
 
765
Item *Item_num::safe_charset_converter(const CHARSET_INFO * const tocs __attribute__((unused)))
766
766
{
767
767
  Item_string *conv;
768
768
  char buf[64];
777
777
}
778
778
 
779
779
 
780
 
Item *Item_static_float_func::safe_charset_converter(CHARSET_INFO *tocs __attribute__((unused)))
 
780
Item *Item_static_float_func::safe_charset_converter(const CHARSET_INFO * const tocs __attribute__((unused)))
781
781
{
782
782
  Item_string *conv;
783
783
  char buf[64];
793
793
}
794
794
 
795
795
 
796
 
Item *Item_string::safe_charset_converter(CHARSET_INFO *tocs)
 
796
Item *Item_string::safe_charset_converter(const CHARSET_INFO * const tocs)
797
797
{
798
798
  Item_string *conv;
799
799
  uint conv_errors;
821
821
}
822
822
 
823
823
 
824
 
Item *Item_param::safe_charset_converter(CHARSET_INFO *tocs)
 
824
Item *Item_param::safe_charset_converter(const CHARSET_INFO * const tocs)
825
825
{
826
826
  if (const_item())
827
827
  {
839
839
}
840
840
 
841
841
 
842
 
Item *Item_static_string_func::safe_charset_converter(CHARSET_INFO *tocs)
 
842
Item *Item_static_string_func::safe_charset_converter(const CHARSET_INFO * const tocs)
843
843
{
844
844
  Item_string *conv;
845
845
  uint conv_errors;
935
935
  return 0;
936
936
}
937
937
 
938
 
CHARSET_INFO *Item::default_charset()
 
938
const CHARSET_INFO *Item::default_charset()
939
939
{
940
940
  return current_thd->variables.collation_connection;
941
941
}
1197
1197
        set(dt);
1198
1198
        return 0;
1199
1199
      }
1200
 
      CHARSET_INFO *bin= get_charset_by_csname(collation->csname, 
1201
 
                                               MY_CS_BINSORT,MYF(0));
 
1200
      const CHARSET_INFO * const bin= get_charset_by_csname(collation->csname, 
 
1201
                                                            MY_CS_BINSORT,MYF(0));
1202
1202
      set(bin, DERIVATION_NONE);
1203
1203
    }
1204
1204
  }
1840
1840
 
1841
1841
 
1842
1842
Item_decimal::Item_decimal(const char *str_arg, uint length,
1843
 
                           CHARSET_INFO *charset)
 
1843
                           const CHARSET_INFO * const charset)
1844
1844
{
1845
1845
  str2my_decimal(E_DEC_FATAL_ERROR, str_arg, length, charset, &decimal_value);
1846
1846
  name= (char*) str_arg;
2023
2023
  int error;
2024
2024
  char *end, *org_end;
2025
2025
  double tmp;
2026
 
  CHARSET_INFO *cs= str_value.charset();
 
2026
  const CHARSET_INFO * const cs= str_value.charset();
2027
2027
 
2028
2028
  org_end= (char*) str_value.ptr() + str_value.length();
2029
2029
  tmp= my_strntod(cs, (char*) str_value.ptr(), str_value.length(), &end,
2054
2054
  int64_t tmp;
2055
2055
  char *end= (char*) str_value.ptr()+ str_value.length();
2056
2056
  char *org_end= end;
2057
 
  CHARSET_INFO *cs= str_value.charset();
 
2057
  const CHARSET_INFO * const cs= str_value.charset();
2058
2058
 
2059
2059
  tmp= (*(cs->cset->strtoll10))(cs, str_value.ptr(), &end, &err);
2060
2060
  /*
2113
2113
}
2114
2114
 
2115
2115
 
2116
 
Item *Item_null::safe_charset_converter(CHARSET_INFO *tocs)
 
2116
Item *Item_null::safe_charset_converter(const CHARSET_INFO * const tocs)
2117
2117
{
2118
2118
  collation.set(tocs);
2119
2119
  return this;
2335
2335
      break;
2336
2336
    case STRING_RESULT:
2337
2337
    {
2338
 
      CHARSET_INFO *fromcs= entry->collation.collation;
2339
 
      CHARSET_INFO *tocs= thd->variables.collation_connection;
 
2338
      const CHARSET_INFO * const fromcs= entry->collation.collation;
 
2339
      const CHARSET_INFO * const tocs= thd->variables.collation_connection;
2340
2340
      uint32_t dummy_offset;
2341
2341
 
2342
2342
      value.cs_info.character_set_of_placeholder= 
3689
3689
  return true;
3690
3690
}
3691
3691
 
3692
 
Item *Item_field::safe_charset_converter(CHARSET_INFO *tocs)
 
3692
Item *Item_field::safe_charset_converter(const CHARSET_INFO * const tocs)
3693
3693
{
3694
3694
  no_const_subst= 1;
3695
3695
  return Item::safe_charset_converter(tocs);
3968
3968
String *Item::check_well_formed_result(String *str, bool send_error)
3969
3969
{
3970
3970
  /* Check whether we got a well-formed string */
3971
 
  CHARSET_INFO *cs= str->charset();
 
3971
  const CHARSET_INFO * const cs= str->charset();
3972
3972
  int well_formed_error;
3973
3973
  uint wlen= cs->cset->well_formed_len(cs,
3974
3974
                                       str->ptr(), str->ptr() + str->length(),
4019
4019
    0    otherwise
4020
4020
*/
4021
4021
 
4022
 
bool Item::eq_by_collation(Item *item, bool binary_cmp, CHARSET_INFO *cs)
 
4022
bool Item::eq_by_collation(Item *item, bool binary_cmp, const CHARSET_INFO * const cs)
4023
4023
{
4024
 
  CHARSET_INFO *save_cs= 0;
4025
 
  CHARSET_INFO *save_item_cs= 0;
 
4024
  const CHARSET_INFO *save_cs= 0;
 
4025
  const CHARSET_INFO *save_item_cs= 0;
4026
4026
  if (collation.collation != cs)
4027
4027
  {
4028
4028
    save_cs= collation.collation;
4253
4253
  if (result_type() == STRING_RESULT)
4254
4254
  {
4255
4255
    String *result;
4256
 
    CHARSET_INFO *cs= collation.collation;
 
4256
    const CHARSET_INFO * const cs= collation.collation;
4257
4257
    char buff[MAX_FIELD_WIDTH];         // Alloc buffer for small columns
4258
4258
    str_value.set_quick(buff, sizeof(buff), cs);
4259
4259
    result=val_str(&str_value);
4587
4587
}
4588
4588
 
4589
4589
 
4590
 
Item *Item_hex_string::safe_charset_converter(CHARSET_INFO *tocs)
 
4590
Item *Item_hex_string::safe_charset_converter(const CHARSET_INFO * const tocs)
4591
4591
{
4592
4592
  Item_string *conv;
4593
4593
  String tmp, *str= val_str(&tmp);