~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/string.cc

  • Committer: Lee Bieber
  • Date: 2011-03-29 22:31:41 UTC
  • mfrom: (2257.1.3 build)
  • Revision ID: kalebral@gmail.com-20110329223141-yxc22h3l2he58sk0
Merge Andrew - 743842: Build failure using GCC 4.6
Merge Stewart - 738022: CachedDirectory silently fails to add entries if stat() fails
Merge Olaf - Common fwd: add copyright, add more declaration

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
 
20
#include <config.h>
21
21
 
22
22
#include <drizzled/session.h>
23
23
#include <drizzled/error.h>
26
26
namespace drizzled
27
27
{
28
28
 
29
 
Item *Item_string::safe_charset_converter(const CHARSET_INFO * const tocs)
 
29
Item *Item_string::safe_charset_converter(const charset_info_st * const tocs)
30
30
{
31
31
  Item_string *conv;
32
32
  size_t conv_errors;
45
45
    */
46
46
    return NULL;
47
47
  }
48
 
  if (!(ptr= current_session->strmake(cstr.ptr(), cstr.length())))
 
48
 
 
49
  if (!(ptr= getSession().strmake(cstr.ptr(), cstr.length())))
49
50
    return NULL;
 
51
 
50
52
  conv->str_value.set(ptr, cstr.length(), cstr.charset());
51
53
  /* Ensure that no one is going to change the result string */
52
54
  conv->str_value.mark_as_const();
54
56
}
55
57
 
56
58
 
57
 
Item *Item_static_string_func::safe_charset_converter(const CHARSET_INFO * const tocs)
 
59
Item *Item_static_string_func::safe_charset_converter(const charset_info_st * const tocs)
58
60
{
59
61
  Item_string *conv;
60
62
  size_t conv_errors;
93
95
  return 0;
94
96
}
95
97
 
96
 
void Item_string::print(String *str, enum_query_type query_type)
 
98
void Item_string::print(String *str)
97
99
{
98
 
  if (query_type == QT_ORDINARY && is_cs_specified())
 
100
  if (is_cs_specified())
99
101
  {
100
102
    str->append('_');
101
103
    str->append(collation.collation->csname);
114
116
  int error;
115
117
  char *end, *org_end;
116
118
  double tmp;
117
 
  const CHARSET_INFO * const cs= str_value.charset();
 
119
  const charset_info_st * const cs= str_value.charset();
118
120
 
119
121
  org_end= (char*) str_value.ptr() + str_value.length();
120
122
  tmp= my_strntod(cs, (char*) str_value.ptr(), str_value.length(), &end,
125
127
      We can use str_value.ptr() here as Item_string is gurantee to put an
126
128
      end \0 here.
127
129
    */
128
 
    push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
130
    push_warning_printf(&getSession(), DRIZZLE_ERROR::WARN_LEVEL_WARN,
129
131
                        ER_TRUNCATED_WRONG_VALUE,
130
132
                        ER(ER_TRUNCATED_WRONG_VALUE), "DOUBLE",
131
133
                        str_value.ptr());
144
146
  int64_t tmp;
145
147
  char *end= (char*) str_value.ptr()+ str_value.length();
146
148
  char *org_end= end;
147
 
  const CHARSET_INFO * const cs= str_value.charset();
 
149
  const charset_info_st * const cs= str_value.charset();
148
150
 
149
151
  tmp= (*(cs->cset->strtoll10))(cs, str_value.ptr(), &end, &err);
150
152
  /*
154
156
  if (err > 0 ||
155
157
      (end != org_end && !check_if_only_end_space(cs, end, org_end)))
156
158
  {
157
 
    push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
159
    push_warning_printf(&getSession(), DRIZZLE_ERROR::WARN_LEVEL_WARN,
158
160
                        ER_TRUNCATED_WRONG_VALUE,
159
161
                        ER(ER_TRUNCATED_WRONG_VALUE), "INTEGER",
160
162
                        str_value.ptr());
162
164
  return tmp;
163
165
}
164
166
 
165
 
my_decimal *Item_string::val_decimal(my_decimal *decimal_value)
 
167
type::Decimal *Item_string::val_decimal(type::Decimal *decimal_value)
166
168
{
167
169
  return val_decimal_from_string(decimal_value);
168
170
}