~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/fstring.cc

  • Committer: Brian Aker
  • Date: 2008-10-06 06:47:29 UTC
  • Revision ID: brian@tangent.org-20081006064729-2i9mhjkzyvow9xsm
RemoveĀ uint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
 
21
#ifdef USE_PRAGMA_IMPLEMENTATION
 
22
#pragma implementation                          // gcc: Class implementation
 
23
#endif
21
24
 
22
25
#include <drizzled/server_includes.h>
23
26
#include <drizzled/field/fstring.h>
24
 
#include <drizzled/error.h>
 
27
#include <drizzled/drizzled_error_messages.h>
25
28
 
26
29
#define LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE 128
27
30
#define DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE 128
39
42
  const char *cannot_convert_error_pos;
40
43
  const char *from_end_pos;
41
44
 
42
 
  /* See the comment for Field_long::store(int64_t) */
43
 
  assert(table->in_use == current_session);
 
45
  /* See the comment for Field_long::store(long long) */
 
46
  assert(table->in_use == current_thd);
44
47
 
45
48
  copy_length= well_formed_copy_nchars(field_charset,
46
49
                                       (char*) ptr, field_length,
91
94
    char buf[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE];
92
95
    String tmp(buf, sizeof(buf), cs);
93
96
    tmp.copy((char*) ptr, field_length, cs);
94
 
    push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
97
    push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
95
98
                        ER_TRUNCATED_WRONG_VALUE, 
96
99
                        ER(ER_TRUNCATED_WRONG_VALUE),
97
100
                        "DOUBLE", tmp.c_ptr());
116
119
    char buf[LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE];
117
120
    String tmp(buf, sizeof(buf), cs);
118
121
    tmp.copy((char*) ptr, field_length, cs);
119
 
    push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
122
    push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
120
123
                        ER_TRUNCATED_WRONG_VALUE, 
121
124
                        ER(ER_TRUNCATED_WRONG_VALUE),
122
125
                        "INTEGER", tmp.c_ptr());
128
131
String *Field_string::val_str(String *val_buffer __attribute__((unused)),
129
132
                              String *val_ptr)
130
133
{
131
 
  /* See the comment for Field_long::store(int64_t) */
132
 
  assert(table->in_use == current_session);
 
134
  /* See the comment for Field_long::store(long long) */
 
135
  assert(table->in_use == current_thd);
133
136
  uint32_t length;
134
137
 
135
138
  length= field_charset->cset->lengthsp(field_charset, (const char*) ptr, field_length);
149
152
    const CHARSET_INFO * const cs= charset();
150
153
    String tmp(buf, sizeof(buf), cs);
151
154
    tmp.copy((char*) ptr, field_length, cs);
152
 
    push_warning_printf(current_session, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
155
    push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
153
156
                        ER_TRUNCATED_WRONG_VALUE, 
154
157
                        ER(ER_TRUNCATED_WRONG_VALUE),
155
158
                        "DECIMAL", tmp.c_ptr());
193
196
 
194
197
void Field_string::sql_type(String &res) const
195
198
{
196
 
  Session *session= table->in_use;
 
199
  THD *thd= table->in_use;
197
200
  const CHARSET_INFO * const cs= res.charset();
198
201
  uint32_t length;
199
202
 
200
203
  length= cs->cset->snprintf(cs,(char*) res.ptr(),
201
204
                             res.alloced_length(), "%s(%d)",
202
205
                             ((type() == DRIZZLE_TYPE_VARCHAR &&
203
 
                               !session->variables.new_mode) ?
 
206
                               !thd->variables.new_mode) ?
204
207
                              (has_charset() ? "varchar" : "varbinary") :
205
208
                              (has_charset() ? "char" : "binary")),
206
209
                             (int) field_length / charset()->mbmaxlen);