~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field.cc

  • Committer: Monty Taylor
  • Date: 2008-11-19 08:07:10 UTC
  • mto: (589.1.3 devel)
  • mto: This revision was merged to the branch mainline in revision 590.
  • Revision ID: monty@inaugust.com-20081119080710-wjyg9i0hcfddzss4
Removed field includes from field.h.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#include <errno.h>
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>
32
50
 
33
51
 
34
52
/*****************************************************************************
1329
1347
}
1330
1348
 
1331
1349
 
1332
 
/*
1333
 
  Report "not well formed" or "cannot convert" error
1334
 
  after storing a character string info a field.
1335
 
 
1336
 
  SYNOPSIS
1337
 
    check_string_copy_error()
1338
 
    field                    - Field
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
1343
 
 
1344
 
  NOTES
1345
 
    As of version 5.0 both cases return the same error:
1346
 
 
1347
 
      "Invalid string value: 'xxx' for column 't' at row 1"
1348
 
 
1349
 
  Future versions will possibly introduce a new error message:
1350
 
 
1351
 
      "Cannot convert character string: 'xxx' for column 't' at row 1"
1352
 
 
1353
 
  RETURN
1354
 
    false - If errors didn't happen
1355
 
    true  - If an error happened
1356
 
*/
1357
 
 
1358
 
bool
1359
 
check_string_copy_error(Field_str *field,
1360
 
                        const char *well_formed_error_pos,
1361
 
                        const char *cannot_convert_error_pos,
1362
 
                        const char *end,
1363
 
                        const CHARSET_INFO * const cs)
1364
 
{
1365
 
  const char *pos, *end_orig;
1366
 
  char tmp[64], *t;
1367
 
  
1368
 
  if (!(pos= well_formed_error_pos) &&
1369
 
      !(pos= cannot_convert_error_pos))
1370
 
    return false;
1371
 
 
1372
 
  end_orig= end;
1373
 
  set_if_smaller(end, pos + 6);
1374
 
 
1375
 
  for (t= tmp; pos < end; pos++)
1376
 
  {
1377
 
    /*
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.
1381
 
      
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.
1385
 
    */
1386
 
    if (((unsigned char) *pos) >= 0x20 &&
1387
 
        ((unsigned char) *pos) <= 0x7F &&
1388
 
        cs->mbminlen == 1)
1389
 
    {
1390
 
      *t++= *pos;
1391
 
    }
1392
 
    else
1393
 
    {
1394
 
      *t++= '\\';
1395
 
      *t++= 'x';
1396
 
      *t++= _dig_vec_upper[((unsigned char) *pos) >> 4];
1397
 
      *t++= _dig_vec_upper[((unsigned char) *pos) & 15];
1398
 
    }
1399
 
  }
1400
 
  if (end_orig > end)
1401
 
  {
1402
 
    *t++= '.';
1403
 
    *t++= '.';
1404
 
    *t++= '.';
1405
 
  }
1406
 
  *t= '\0';
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);
1415
 
  return true;
1416
 
}
1417
 
 
1418
1350
uint32_t Field::is_equal(Create_field *new_field)
1419
1351
{
1420
1352
  return (new_field->sql_type == real_type());