~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item.cc

  • Committer: Brian Aker
  • Date: 2008-08-07 16:29:49 UTC
  • mfrom: (264.1.20 codestyle)
  • Revision ID: brian@tangent.org-20080807162949-7o8eyjgdn8ms3n1a
Merge from Monty.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
 
17
 
#ifdef USE_PRAGMA_IMPLEMENTATION
18
 
#pragma implementation                          // gcc: Class implementation
19
 
#endif
20
 
#include "mysql_priv.h"
21
 
#include "sql_select.h"
 
17
#include <drizzled/server_includes.h>
 
18
#include <drizzled/sql_select.h>
22
19
#include <drizzled/drizzled_error_messages.h>
23
20
 
24
21
const String my_null_string("NULL", 4, default_charset_info);
680
677
}
681
678
 
682
679
 
683
 
void Item::set_name(const char *str, uint length, CHARSET_INFO *cs)
 
680
void Item::set_name(const char *str, uint length, const CHARSET_INFO * const cs)
684
681
{
685
682
  if (!length)
686
683
  {
744
741
}
745
742
 
746
743
 
747
 
Item *Item::safe_charset_converter(CHARSET_INFO *tocs)
 
744
Item *Item::safe_charset_converter(const CHARSET_INFO * const tocs)
748
745
{
749
746
  Item_func_conv_charset *conv= new Item_func_conv_charset(this, tocs, 1);
750
747
  return conv->safe ? conv : NULL;
762
759
  the latter returns a non-fixed Item, so val_str() crashes afterwards.
763
760
  Override Item_num method, to return a fixed item.
764
761
*/
765
 
Item *Item_num::safe_charset_converter(CHARSET_INFO *tocs __attribute__((unused)))
 
762
Item *Item_num::safe_charset_converter(const CHARSET_INFO * const tocs __attribute__((unused)))
766
763
{
767
764
  Item_string *conv;
768
765
  char buf[64];
777
774
}
778
775
 
779
776
 
780
 
Item *Item_static_float_func::safe_charset_converter(CHARSET_INFO *tocs __attribute__((unused)))
 
777
Item *Item_static_float_func::safe_charset_converter(const CHARSET_INFO * const tocs __attribute__((unused)))
781
778
{
782
779
  Item_string *conv;
783
780
  char buf[64];
793
790
}
794
791
 
795
792
 
796
 
Item *Item_string::safe_charset_converter(CHARSET_INFO *tocs)
 
793
Item *Item_string::safe_charset_converter(const CHARSET_INFO * const tocs)
797
794
{
798
795
  Item_string *conv;
799
796
  uint conv_errors;
821
818
}
822
819
 
823
820
 
824
 
Item *Item_param::safe_charset_converter(CHARSET_INFO *tocs)
 
821
Item *Item_param::safe_charset_converter(const CHARSET_INFO * const tocs)
825
822
{
826
823
  if (const_item())
827
824
  {
839
836
}
840
837
 
841
838
 
842
 
Item *Item_static_string_func::safe_charset_converter(CHARSET_INFO *tocs)
 
839
Item *Item_static_string_func::safe_charset_converter(const CHARSET_INFO * const tocs)
843
840
{
844
841
  Item_string *conv;
845
842
  uint conv_errors;
935
932
  return 0;
936
933
}
937
934
 
938
 
CHARSET_INFO *Item::default_charset()
 
935
const CHARSET_INFO *Item::default_charset()
939
936
{
940
937
  return current_thd->variables.collation_connection;
941
938
}
1197
1194
        set(dt);
1198
1195
        return 0;
1199
1196
      }
1200
 
      CHARSET_INFO *bin= get_charset_by_csname(collation->csname, 
1201
 
                                               MY_CS_BINSORT,MYF(0));
 
1197
      const CHARSET_INFO * const bin= get_charset_by_csname(collation->csname, 
 
1198
                                                            MY_CS_BINSORT,MYF(0));
1202
1199
      set(bin, DERIVATION_NONE);
1203
1200
    }
1204
1201
  }
1840
1837
 
1841
1838
 
1842
1839
Item_decimal::Item_decimal(const char *str_arg, uint length,
1843
 
                           CHARSET_INFO *charset)
 
1840
                           const CHARSET_INFO * const charset)
1844
1841
{
1845
1842
  str2my_decimal(E_DEC_FATAL_ERROR, str_arg, length, charset, &decimal_value);
1846
1843
  name= (char*) str_arg;
2023
2020
  int error;
2024
2021
  char *end, *org_end;
2025
2022
  double tmp;
2026
 
  CHARSET_INFO *cs= str_value.charset();
 
2023
  const CHARSET_INFO * const cs= str_value.charset();
2027
2024
 
2028
2025
  org_end= (char*) str_value.ptr() + str_value.length();
2029
2026
  tmp= my_strntod(cs, (char*) str_value.ptr(), str_value.length(), &end,
2054
2051
  int64_t tmp;
2055
2052
  char *end= (char*) str_value.ptr()+ str_value.length();
2056
2053
  char *org_end= end;
2057
 
  CHARSET_INFO *cs= str_value.charset();
 
2054
  const CHARSET_INFO * const cs= str_value.charset();
2058
2055
 
2059
2056
  tmp= (*(cs->cset->strtoll10))(cs, str_value.ptr(), &end, &err);
2060
2057
  /*
2113
2110
}
2114
2111
 
2115
2112
 
2116
 
Item *Item_null::safe_charset_converter(CHARSET_INFO *tocs)
 
2113
Item *Item_null::safe_charset_converter(const CHARSET_INFO * const tocs)
2117
2114
{
2118
2115
  collation.set(tocs);
2119
2116
  return this;
2335
2332
      break;
2336
2333
    case STRING_RESULT:
2337
2334
    {
2338
 
      CHARSET_INFO *fromcs= entry->collation.collation;
2339
 
      CHARSET_INFO *tocs= thd->variables.collation_connection;
 
2335
      const CHARSET_INFO * const fromcs= entry->collation.collation;
 
2336
      const CHARSET_INFO * const tocs= thd->variables.collation_connection;
2340
2337
      uint32_t dummy_offset;
2341
2338
 
2342
2339
      value.cs_info.character_set_of_placeholder= 
3689
3686
  return true;
3690
3687
}
3691
3688
 
3692
 
Item *Item_field::safe_charset_converter(CHARSET_INFO *tocs)
 
3689
Item *Item_field::safe_charset_converter(const CHARSET_INFO * const tocs)
3693
3690
{
3694
3691
  no_const_subst= 1;
3695
3692
  return Item::safe_charset_converter(tocs);
3968
3965
String *Item::check_well_formed_result(String *str, bool send_error)
3969
3966
{
3970
3967
  /* Check whether we got a well-formed string */
3971
 
  CHARSET_INFO *cs= str->charset();
 
3968
  const CHARSET_INFO * const cs= str->charset();
3972
3969
  int well_formed_error;
3973
3970
  uint wlen= cs->cset->well_formed_len(cs,
3974
3971
                                       str->ptr(), str->ptr() + str->length(),
4019
4016
    0    otherwise
4020
4017
*/
4021
4018
 
4022
 
bool Item::eq_by_collation(Item *item, bool binary_cmp, CHARSET_INFO *cs)
 
4019
bool Item::eq_by_collation(Item *item, bool binary_cmp, const CHARSET_INFO * const cs)
4023
4020
{
4024
 
  CHARSET_INFO *save_cs= 0;
4025
 
  CHARSET_INFO *save_item_cs= 0;
 
4021
  const CHARSET_INFO *save_cs= 0;
 
4022
  const CHARSET_INFO *save_item_cs= 0;
4026
4023
  if (collation.collation != cs)
4027
4024
  {
4028
4025
    save_cs= collation.collation;
4253
4250
  if (result_type() == STRING_RESULT)
4254
4251
  {
4255
4252
    String *result;
4256
 
    CHARSET_INFO *cs= collation.collation;
 
4253
    const CHARSET_INFO * const cs= collation.collation;
4257
4254
    char buff[MAX_FIELD_WIDTH];         // Alloc buffer for small columns
4258
4255
    str_value.set_quick(buff, sizeof(buff), cs);
4259
4256
    result=val_str(&str_value);
4587
4584
}
4588
4585
 
4589
4586
 
4590
 
Item *Item_hex_string::safe_charset_converter(CHARSET_INFO *tocs)
 
4587
Item *Item_hex_string::safe_charset_converter(const CHARSET_INFO * const tocs)
4591
4588
{
4592
4589
  Item_string *conv;
4593
4590
  String tmp, *str= val_str(&tmp);