~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field.cc

  • Committer: Brian Aker
  • Date: 2008-07-31 19:40:12 UTC
  • Revision ID: brian@tangent.org-20080731194012-oat11oy5vombrb1b
First pass of CHAR removal.

Show diffs side-by-side

added added

removed removed

Lines of Context:
663
663
bool Field::type_can_have_key_part(enum enum_field_types type)
664
664
{
665
665
  switch (type) {
 
666
  case DRIZZLE_TYPE_STRING:
 
667
    assert(0);
666
668
  case DRIZZLE_TYPE_VARCHAR:
667
669
  case DRIZZLE_TYPE_BLOB:
668
 
  case DRIZZLE_TYPE_STRING:
669
670
    return true;
670
671
  default:
671
672
    return false;
1312
1313
    copy->length-= table->s->blob_ptr_size;
1313
1314
    return copy->length;
1314
1315
  }
1315
 
  else if (!zero_pack() &&
1316
 
           (type() == DRIZZLE_TYPE_STRING && copy->length >= 4 &&
1317
 
            copy->length < 256))
1318
 
  {
1319
 
    copy->strip=1;                              /* Remove end space */
1320
 
    store_length= 2;
1321
 
  }
1322
1316
  else
1323
1317
  {
1324
1318
    copy->strip=0;
1716
1710
 
1717
1711
 
1718
1712
/**
1719
 
  Store double value in Field_string or Field_varstring.
 
1713
  Store double value in Field_varstring.
1720
1714
 
1721
1715
  Pretty prints double number into field_length characters buffer.
1722
1716
 
2127
2121
void Create_field::create_length_to_internal_length(void)
2128
2122
{
2129
2123
  switch (sql_type) {
 
2124
  case DRIZZLE_TYPE_STRING:
 
2125
    assert(0);
2130
2126
  case DRIZZLE_TYPE_BLOB:
2131
 
  case DRIZZLE_TYPE_STRING:
2132
2127
  case DRIZZLE_TYPE_VARCHAR:
2133
2128
    length*= charset->mbmaxlen;
2134
2129
    key_length= length;
2295
2290
    max_field_charlength= MAX_FIELD_VARCHARLENGTH;
2296
2291
    break;
2297
2292
  case DRIZZLE_TYPE_STRING:
 
2293
    assert(0);
2298
2294
    break;
2299
2295
  case DRIZZLE_TYPE_BLOB:
2300
2296
    if (fld_default_value)
2445
2441
      ((length > max_field_charlength && fld_type != DRIZZLE_TYPE_SET &&
2446
2442
        fld_type != DRIZZLE_TYPE_ENUM &&
2447
2443
        (fld_type != DRIZZLE_TYPE_VARCHAR || fld_default_value)) ||
2448
 
       (!length &&
2449
 
        fld_type != DRIZZLE_TYPE_STRING &&
2450
 
        fld_type != DRIZZLE_TYPE_VARCHAR)))
 
2444
       (!length && fld_type != DRIZZLE_TYPE_VARCHAR)))
2451
2445
  {
2452
 
    my_error((fld_type == DRIZZLE_TYPE_VARCHAR ||
2453
 
              fld_type == DRIZZLE_TYPE_STRING) ?  ER_TOO_BIG_FIELDLENGTH :
2454
 
                                                ER_TOO_BIG_DISPLAYWIDTH,
 
2446
    my_error((fld_type == DRIZZLE_TYPE_VARCHAR) ?  ER_TOO_BIG_FIELDLENGTH : ER_TOO_BIG_DISPLAYWIDTH,
2455
2447
              MYF(0),
2456
2448
              fld_name, max_field_charlength); /* purecov: inspected */
2457
2449
    return(true);
2485
2477
{
2486
2478
  switch (type) {
2487
2479
  case DRIZZLE_TYPE_STRING:
 
2480
    assert(0);
2488
2481
  case DRIZZLE_TYPE_VARCHAR:     return (length + (length < 256 ? 1: 2));
2489
2482
  case DRIZZLE_TYPE_TINY        : return 1;
2490
2483
  case DRIZZLE_TYPE_SHORT : return 2;
2554
2547
  {
2555
2548
    if (!f_is_packed(pack_flag))
2556
2549
    {
2557
 
      if (field_type == DRIZZLE_TYPE_STRING)
2558
 
        return new Field_string(ptr,field_length,null_pos,null_bit,
2559
 
                                unireg_check, field_name,
2560
 
                                field_charset);
2561
2550
      if (field_type == DRIZZLE_TYPE_VARCHAR)
2562
2551
        return new Field_varstring(ptr,field_length,
2563
2552
                                   HA_VARCHAR_PACKLENGTH(field_length),
2674
2663
    key_length/= charset->mbmaxlen;
2675
2664
    break;
2676
2665
  case DRIZZLE_TYPE_STRING:
 
2666
    assert(0);
2677
2667
    /* Change CHAR -> VARCHAR if dynamic record length */
2678
2668
  case DRIZZLE_TYPE_ENUM:
2679
2669
  case DRIZZLE_TYPE_SET: