~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/fstring.cc

  • Committer: Mats Kindahl
  • Date: 2008-08-07 06:24:22 UTC
  • mfrom: (265 drizzle)
  • mto: (264.1.19 codestyle)
  • mto: This revision was merged to the branch mainline in revision 266.
  • Revision ID: mats@mysql.com-20080807062422-20kyv6ssp4grfm0s
Manual merge of lp:drizzle into ~mkindahl/remove-mem-casts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#endif
24
24
 
25
25
#include <drizzled/field/fstring.h>
 
26
#include <drizzled/drizzled_error_messages.h>
26
27
 
27
28
#define LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE 128
28
29
#define DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE 128
92
93
    char buf[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE];
93
94
    String tmp(buf, sizeof(buf), cs);
94
95
    tmp.copy((char*) ptr, field_length, cs);
95
 
    push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
 
96
    push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
96
97
                        ER_TRUNCATED_WRONG_VALUE, 
97
98
                        ER(ER_TRUNCATED_WRONG_VALUE),
98
99
                        "DOUBLE", tmp.c_ptr());
117
118
    char buf[LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE];
118
119
    String tmp(buf, sizeof(buf), cs);
119
120
    tmp.copy((char*) ptr, field_length, cs);
120
 
    push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
 
121
    push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
121
122
                        ER_TRUNCATED_WRONG_VALUE, 
122
123
                        ER(ER_TRUNCATED_WRONG_VALUE),
123
124
                        "INTEGER", tmp.c_ptr());
153
154
    CHARSET_INFO *cs= charset();
154
155
    String tmp(buf, sizeof(buf), cs);
155
156
    tmp.copy((char*) ptr, field_length, cs);
156
 
    push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
 
157
    push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
157
158
                        ER_TRUNCATED_WRONG_VALUE, 
158
159
                        ER(ER_TRUNCATED_WRONG_VALUE),
159
160
                        "DECIMAL", tmp.c_ptr());
203
204
 
204
205
  length= cs->cset->snprintf(cs,(char*) res.ptr(),
205
206
                             res.alloced_length(), "%s(%d)",
206
 
                             ((type() == DRIZZLE_TYPE_VAR_STRING &&
 
207
                             ((type() == DRIZZLE_TYPE_VARCHAR &&
207
208
                               !thd->variables.new_mode) ?
208
209
                              (has_charset() ? "varchar" : "varbinary") :
209
210
                              (has_charset() ? "char" : "binary")),
210
211
                             (int) field_length / charset()->mbmaxlen);
211
212
  res.length(length);
212
 
  if ((thd->variables.sql_mode & (MODE_MYSQL323 | MODE_MYSQL40)) &&
213
 
      has_charset() && (charset()->state & MY_CS_BINSORT))
214
 
    res.append(STRING_WITH_LEN(" binary"));
215
213
}
216
214
 
217
215
 
412
410
                               bool keep_type)
413
411
{
414
412
  Field *field;
415
 
  if (type() != DRIZZLE_TYPE_VAR_STRING || keep_type)
416
 
    field= Field::new_field(root, new_table, keep_type);
417
 
  else if ((field= new Field_varstring(field_length, maybe_null(), field_name,
418
 
                                       new_table->s, charset())))
419
 
  {
420
 
    /*
421
 
      Old VARCHAR field which should be modified to a VARCHAR on copy
422
 
      This is done to ensure that ALTER TABLE will convert old VARCHAR fields
423
 
      to now VARCHAR fields.
424
 
    */
425
 
    field->init(new_table);
426
 
    /*
427
 
      Normally orig_table is different from table only if field was created
428
 
      via ::new_field.  Here we alter the type of field, so ::new_field is
429
 
      not applicable. But we still need to preserve the original field
430
 
      metadata for the client-server protocol.
431
 
    */
432
 
    field->orig_table= orig_table;
433
 
  }
 
413
  field= Field::new_field(root, new_table, keep_type);
434
414
  return field;
435
415
}
436
416