30
30
#include <drizzled/error.h>
31
31
#include <drizzled/virtual_column_info.h>
32
#include <drizzled/field/str.h>
33
#include <drizzled/field/longstr.h>
34
#include <drizzled/field/num.h>
35
#include <drizzled/field/blob.h>
36
#include <drizzled/field/enum.h>
37
#include <drizzled/field/null.h>
38
#include <drizzled/field/date.h>
39
#include <drizzled/field/fdecimal.h>
40
#include <drizzled/field/real.h>
41
#include <drizzled/field/double.h>
42
#include <drizzled/field/long.h>
43
#include <drizzled/field/int64_t.h>
44
#include <drizzled/field/num.h>
45
#include <drizzled/field/timetype.h>
46
#include <drizzled/field/timestamp.h>
47
#include <drizzled/field/datetime.h>
48
#include <drizzled/field/fstring.h>
49
#include <drizzled/field/varstring.h>
34
52
/*****************************************************************************
1333
Report "not well formed" or "cannot convert" error
1334
after storing a character string info a field.
1337
check_string_copy_error()
1339
well_formed_error_pos - where not well formed data was first met
1340
cannot_convert_error_pos - where a not-convertable character was first met
1341
end - end of the string
1342
cs - character set of the string
1345
As of version 5.0 both cases return the same error:
1347
"Invalid string value: 'xxx' for column 't' at row 1"
1349
Future versions will possibly introduce a new error message:
1351
"Cannot convert character string: 'xxx' for column 't' at row 1"
1354
false - If errors didn't happen
1355
true - If an error happened
1359
check_string_copy_error(Field_str *field,
1360
const char *well_formed_error_pos,
1361
const char *cannot_convert_error_pos,
1363
const CHARSET_INFO * const cs)
1365
const char *pos, *end_orig;
1368
if (!(pos= well_formed_error_pos) &&
1369
!(pos= cannot_convert_error_pos))
1373
set_if_smaller(end, pos + 6);
1375
for (t= tmp; pos < end; pos++)
1378
If the source string is ASCII compatible (mbminlen==1)
1379
and the source character is in ASCII printable range (0x20..0x7F),
1380
then display the character as is.
1382
Otherwise, if the source string is not ASCII compatible (e.g. UCS2),
1383
or the source character is not in the printable range,
1384
then print the character using HEX notation.
1386
if (((unsigned char) *pos) >= 0x20 &&
1387
((unsigned char) *pos) <= 0x7F &&
1396
*t++= _dig_vec_upper[((unsigned char) *pos) >> 4];
1397
*t++= _dig_vec_upper[((unsigned char) *pos) & 15];
1407
push_warning_printf(field->table->in_use,
1408
field->table->in_use->abort_on_warning ?
1409
DRIZZLE_ERROR::WARN_LEVEL_ERROR :
1410
DRIZZLE_ERROR::WARN_LEVEL_WARN,
1411
ER_TRUNCATED_WRONG_VALUE_FOR_FIELD,
1412
ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),
1413
"string", tmp, field->field_name,
1414
(uint32_t) field->table->in_use->row_count);
1418
1350
uint32_t Field::is_equal(Create_field *new_field)
1420
1352
return (new_field->sql_type == real_type());