~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field.cc

  • Committer: Monty Taylor
  • Date: 2008-07-31 05:13:04 UTC
  • mfrom: (240 drizzle)
  • mto: (202.3.5 gettextize)
  • mto: This revision was merged to the branch mainline in revision 243.
  • Revision ID: monty@inaugust.com-20080731051304-a9kawbozru3fic1g
MergedĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
    DRIZZLE_TYPE_NEWDECIMAL,  DRIZZLE_TYPE_VARCHAR,
85
85
  //DRIZZLE_TYPE_SET
86
86
    DRIZZLE_TYPE_VARCHAR,
87
 
  //DRIZZLE_TYPE_BLOB         DRIZZLE_TYPE_VAR_STRING
88
 
    DRIZZLE_TYPE_BLOB,        DRIZZLE_TYPE_VARCHAR,
 
87
  //DRIZZLE_TYPE_BLOB
 
88
    DRIZZLE_TYPE_BLOB,
89
89
  //DRIZZLE_TYPE_STRING       
90
90
    DRIZZLE_TYPE_STRING
91
91
  },
111
111
    DRIZZLE_TYPE_NEWDECIMAL,  DRIZZLE_TYPE_VARCHAR,
112
112
  //DRIZZLE_TYPE_SET
113
113
    DRIZZLE_TYPE_VARCHAR,
114
 
  //DRIZZLE_TYPE_BLOB         DRIZZLE_TYPE_VAR_STRING
115
 
    DRIZZLE_TYPE_BLOB,        DRIZZLE_TYPE_VARCHAR,
 
114
  //DRIZZLE_TYPE_BLOB
 
115
    DRIZZLE_TYPE_BLOB,
116
116
  //DRIZZLE_TYPE_STRING       
117
117
    DRIZZLE_TYPE_STRING     
118
118
  },
138
138
    DRIZZLE_TYPE_NEWDECIMAL,  DRIZZLE_TYPE_VARCHAR,
139
139
  //DRIZZLE_TYPE_SET
140
140
    DRIZZLE_TYPE_VARCHAR,
141
 
  //DRIZZLE_TYPE_BLOB         DRIZZLE_TYPE_VAR_STRING
142
 
    DRIZZLE_TYPE_BLOB,        DRIZZLE_TYPE_VARCHAR,
 
141
  //DRIZZLE_TYPE_BLOB
 
142
    DRIZZLE_TYPE_BLOB,
143
143
  //DRIZZLE_TYPE_STRING
144
144
    DRIZZLE_TYPE_STRING
145
145
  },
165
165
    DRIZZLE_TYPE_NEWDECIMAL,  DRIZZLE_TYPE_VARCHAR,
166
166
  //DRIZZLE_TYPE_SET
167
167
    DRIZZLE_TYPE_VARCHAR,
168
 
  //DRIZZLE_TYPE_BLOB         DRIZZLE_TYPE_VAR_STRING
169
 
    DRIZZLE_TYPE_BLOB,        DRIZZLE_TYPE_VARCHAR,
 
168
  //DRIZZLE_TYPE_BLOB
 
169
    DRIZZLE_TYPE_BLOB,
170
170
  //DRIZZLE_TYPE_STRING
171
171
    DRIZZLE_TYPE_STRING
172
172
  },
192
192
    DRIZZLE_TYPE_DOUBLE,      DRIZZLE_TYPE_VARCHAR,
193
193
  //DRIZZLE_TYPE_SET
194
194
    DRIZZLE_TYPE_VARCHAR,
195
 
  //DRIZZLE_TYPE_BLOB         DRIZZLE_TYPE_VAR_STRING
196
 
    DRIZZLE_TYPE_BLOB,        DRIZZLE_TYPE_VARCHAR,
 
195
  //DRIZZLE_TYPE_BLOB
 
196
    DRIZZLE_TYPE_BLOB,
197
197
  //DRIZZLE_TYPE_STRING
198
198
    DRIZZLE_TYPE_STRING
199
199
  },
219
219
    DRIZZLE_TYPE_NEWDECIMAL,  DRIZZLE_TYPE_ENUM,
220
220
  //DRIZZLE_TYPE_SET
221
221
    DRIZZLE_TYPE_SET,
222
 
  //DRIZZLE_TYPE_BLOB         DRIZZLE_TYPE_VAR_STRING
223
 
    DRIZZLE_TYPE_BLOB,        DRIZZLE_TYPE_VARCHAR,
 
222
  //DRIZZLE_TYPE_BLOB
 
223
    DRIZZLE_TYPE_BLOB,
224
224
  //DRIZZLE_TYPE_STRING
225
225
    DRIZZLE_TYPE_STRING
226
226
  },
246
246
    DRIZZLE_TYPE_VARCHAR,     DRIZZLE_TYPE_VARCHAR,
247
247
  //DRIZZLE_TYPE_SET
248
248
    DRIZZLE_TYPE_VARCHAR,
249
 
  //DRIZZLE_TYPE_BLOB         DRIZZLE_TYPE_VAR_STRING
250
 
    DRIZZLE_TYPE_BLOB,        DRIZZLE_TYPE_VARCHAR,
 
249
  //DRIZZLE_TYPE_BLOB
 
250
    DRIZZLE_TYPE_BLOB,
251
251
  //DRIZZLE_TYPE_STRING
252
252
    DRIZZLE_TYPE_STRING
253
253
  },
273
273
    DRIZZLE_TYPE_NEWDECIMAL,  DRIZZLE_TYPE_VARCHAR,
274
274
  //DRIZZLE_TYPE_SET
275
275
    DRIZZLE_TYPE_VARCHAR,
276
 
  //DRIZZLE_TYPE_BLOB         DRIZZLE_TYPE_VAR_STRING
277
 
    DRIZZLE_TYPE_BLOB,        DRIZZLE_TYPE_VARCHAR,
 
276
  //DRIZZLE_TYPE_BLOB
 
277
    DRIZZLE_TYPE_BLOB,
278
278
  //DRIZZLE_TYPE_STRING
279
279
    DRIZZLE_TYPE_STRING
280
280
  },
300
300
    DRIZZLE_TYPE_VARCHAR,     DRIZZLE_TYPE_VARCHAR,
301
301
  //DRIZZLE_TYPE_SET
302
302
    DRIZZLE_TYPE_VARCHAR,
303
 
  //DRIZZLE_TYPE_BLOB         DRIZZLE_TYPE_VAR_STRING
304
 
    DRIZZLE_TYPE_BLOB,        DRIZZLE_TYPE_VARCHAR,
 
303
  //DRIZZLE_TYPE_BLOB
 
304
    DRIZZLE_TYPE_BLOB,
305
305
  //DRIZZLE_TYPE_STRING
306
306
    DRIZZLE_TYPE_STRING
307
307
  },
327
327
    DRIZZLE_TYPE_VARCHAR,     DRIZZLE_TYPE_VARCHAR,
328
328
  //DRIZZLE_TYPE_SET
329
329
    DRIZZLE_TYPE_VARCHAR,
330
 
  //DRIZZLE_TYPE_BLOB         DRIZZLE_TYPE_VAR_STRING
331
 
    DRIZZLE_TYPE_BLOB,        DRIZZLE_TYPE_VARCHAR,
 
330
  //DRIZZLE_TYPE_BLOB
 
331
    DRIZZLE_TYPE_BLOB,
332
332
  //DRIZZLE_TYPE_STRING
333
333
    DRIZZLE_TYPE_STRING
334
334
  },
354
354
    DRIZZLE_TYPE_VARCHAR,     DRIZZLE_TYPE_VARCHAR,
355
355
  //DRIZZLE_TYPE_SET
356
356
    DRIZZLE_TYPE_VARCHAR,
357
 
  //DRIZZLE_TYPE_BLOB         DRIZZLE_TYPE_VAR_STRING
358
 
    DRIZZLE_TYPE_BLOB,        DRIZZLE_TYPE_VARCHAR,
 
357
  //DRIZZLE_TYPE_BLOB
 
358
    DRIZZLE_TYPE_BLOB,
359
359
  //DRIZZLE_TYPE_STRING
360
360
    DRIZZLE_TYPE_STRING
361
361
  },
381
381
    DRIZZLE_TYPE_VARCHAR,     DRIZZLE_TYPE_VARCHAR,
382
382
  //DRIZZLE_TYPE_SET
383
383
    DRIZZLE_TYPE_VARCHAR,
384
 
  //DRIZZLE_TYPE_BLOB         DRIZZLE_TYPE_VAR_STRING
385
 
    DRIZZLE_TYPE_BLOB,        DRIZZLE_TYPE_VARCHAR,
 
384
  //DRIZZLE_TYPE_BLOB
 
385
    DRIZZLE_TYPE_BLOB,
386
386
  //DRIZZLE_TYPE_STRING
387
387
    DRIZZLE_TYPE_STRING
388
388
  },
408
408
    DRIZZLE_TYPE_VARCHAR,     DRIZZLE_TYPE_VARCHAR,
409
409
  //DRIZZLE_TYPE_SET
410
410
    DRIZZLE_TYPE_VARCHAR,
411
 
  //DRIZZLE_TYPE_BLOB         DRIZZLE_TYPE_VAR_STRING
412
 
    DRIZZLE_TYPE_BLOB,        DRIZZLE_TYPE_VARCHAR,
 
411
  //DRIZZLE_TYPE_BLOB
 
412
    DRIZZLE_TYPE_BLOB,
413
413
  //DRIZZLE_TYPE_STRING
414
414
    DRIZZLE_TYPE_VARCHAR
415
415
  },
435
435
    DRIZZLE_TYPE_NEWDECIMAL,  DRIZZLE_TYPE_VARCHAR,
436
436
  //DRIZZLE_TYPE_SET
437
437
    DRIZZLE_TYPE_VARCHAR,
438
 
  //DRIZZLE_TYPE_BLOB         DRIZZLE_TYPE_VAR_STRING
439
 
    DRIZZLE_TYPE_BLOB,        DRIZZLE_TYPE_VARCHAR,
 
438
  //DRIZZLE_TYPE_BLOB
 
439
    DRIZZLE_TYPE_BLOB,
440
440
  //DRIZZLE_TYPE_STRING
441
441
    DRIZZLE_TYPE_STRING
442
442
  },
462
462
    DRIZZLE_TYPE_VARCHAR,     DRIZZLE_TYPE_VARCHAR,
463
463
  //DRIZZLE_TYPE_SET
464
464
    DRIZZLE_TYPE_VARCHAR,
465
 
  //DRIZZLE_TYPE_BLOB         DRIZZLE_TYPE_VAR_STRING
466
 
    DRIZZLE_TYPE_BLOB,        DRIZZLE_TYPE_VARCHAR,
 
465
  //DRIZZLE_TYPE_BLOB
 
466
    DRIZZLE_TYPE_BLOB,
467
467
  //DRIZZLE_TYPE_STRING
468
468
    DRIZZLE_TYPE_STRING
469
469
  },
489
489
    DRIZZLE_TYPE_VARCHAR,     DRIZZLE_TYPE_VARCHAR,
490
490
  //DRIZZLE_TYPE_SET
491
491
    DRIZZLE_TYPE_VARCHAR,
492
 
  //DRIZZLE_TYPE_BLOB         DRIZZLE_TYPE_VAR_STRING
493
 
    DRIZZLE_TYPE_BLOB,        DRIZZLE_TYPE_VARCHAR,
 
492
  //DRIZZLE_TYPE_BLOB
 
493
    DRIZZLE_TYPE_BLOB,
494
494
  //DRIZZLE_TYPE_STRING
495
495
    DRIZZLE_TYPE_STRING
496
496
  },
516
516
    DRIZZLE_TYPE_BLOB,        DRIZZLE_TYPE_BLOB,
517
517
  //DRIZZLE_TYPE_SET
518
518
    DRIZZLE_TYPE_BLOB,
519
 
  //DRIZZLE_TYPE_BLOB         DRIZZLE_TYPE_VAR_STRING
520
 
    DRIZZLE_TYPE_BLOB,        DRIZZLE_TYPE_BLOB,
 
519
  //DRIZZLE_TYPE_BLOB
 
520
    DRIZZLE_TYPE_BLOB,
521
521
  //DRIZZLE_TYPE_STRING
522
522
    DRIZZLE_TYPE_BLOB
523
523
  },
524
 
  /* DRIZZLE_TYPE_VAR_STRING -> */
525
 
  {
526
 
  //DRIZZLE_TYPE_DECIMAL      DRIZZLE_TYPE_TINY
527
 
    DRIZZLE_TYPE_VARCHAR,     DRIZZLE_TYPE_VARCHAR,
528
 
  //DRIZZLE_TYPE_SHORT        DRIZZLE_TYPE_LONG
529
 
    DRIZZLE_TYPE_VARCHAR,     DRIZZLE_TYPE_VARCHAR,
530
 
  //DRIZZLE_TYPE_DOUBLE
531
 
    DRIZZLE_TYPE_VARCHAR,
532
 
  //DRIZZLE_TYPE_NULL         DRIZZLE_TYPE_TIMESTAMP
533
 
    DRIZZLE_TYPE_VARCHAR,     DRIZZLE_TYPE_VARCHAR,
534
 
  //DRIZZLE_TYPE_LONGLONG
535
 
    DRIZZLE_TYPE_VARCHAR,
536
 
  //DRIZZLE_TYPE_DATE         DRIZZLE_TYPE_TIME
537
 
    DRIZZLE_TYPE_VARCHAR,     DRIZZLE_TYPE_VARCHAR,
538
 
  //DRIZZLE_TYPE_DATETIME
539
 
    DRIZZLE_TYPE_VARCHAR,
540
 
  //DRIZZLE_TYPE_NEWDATE      DRIZZLE_TYPE_VARCHAR
541
 
    DRIZZLE_TYPE_VARCHAR,     DRIZZLE_TYPE_VARCHAR,
542
 
  //DRIZZLE_TYPE_NEWDECIMAL   DRIZZLE_TYPE_ENUM
543
 
    DRIZZLE_TYPE_VARCHAR,     DRIZZLE_TYPE_VARCHAR,
544
 
  //DRIZZLE_TYPE_SET
545
 
    DRIZZLE_TYPE_VARCHAR,
546
 
  //DRIZZLE_TYPE_BLOB         DRIZZLE_TYPE_VAR_STRING
547
 
    DRIZZLE_TYPE_BLOB,        DRIZZLE_TYPE_VARCHAR,
548
 
  //DRIZZLE_TYPE_STRING
549
 
    DRIZZLE_TYPE_VARCHAR
550
 
  },
551
524
  /* DRIZZLE_TYPE_STRING -> */
552
525
  {
553
526
  //DRIZZLE_TYPE_DECIMAL      DRIZZLE_TYPE_TINY
570
543
    DRIZZLE_TYPE_STRING,      DRIZZLE_TYPE_STRING,
571
544
  //DRIZZLE_TYPE_SET
572
545
    DRIZZLE_TYPE_STRING,
573
 
  //DRIZZLE_TYPE_BLOB         DRIZZLE_TYPE_VAR_STRING
574
 
    DRIZZLE_TYPE_BLOB,        DRIZZLE_TYPE_VARCHAR,
 
546
  //DRIZZLE_TYPE_BLOB
 
547
    DRIZZLE_TYPE_BLOB,
575
548
  //DRIZZLE_TYPE_STRING
576
549
    DRIZZLE_TYPE_STRING
577
550
  }
619
592
  DECIMAL_RESULT,           STRING_RESULT,
620
593
  //DRIZZLE_TYPE_SET
621
594
  STRING_RESULT,
622
 
  //DRIZZLE_TYPE_BLOB         DRIZZLE_TYPE_VAR_STRING
623
 
  STRING_RESULT,            STRING_RESULT,
 
595
  //DRIZZLE_TYPE_BLOB
 
596
  STRING_RESULT,
624
597
  //DRIZZLE_TYPE_STRING
625
598
  STRING_RESULT
626
599
};
691
664
  switch (type) {
692
665
  case DRIZZLE_TYPE_VARCHAR:
693
666
  case DRIZZLE_TYPE_BLOB:
694
 
  case DRIZZLE_TYPE_VAR_STRING:
695
667
  case DRIZZLE_TYPE_STRING:
696
668
    return true;
697
669
  default:
2155
2127
{
2156
2128
  switch (sql_type) {
2157
2129
  case DRIZZLE_TYPE_BLOB:
2158
 
  case DRIZZLE_TYPE_VAR_STRING:
2159
2130
  case DRIZZLE_TYPE_STRING:
2160
2131
  case DRIZZLE_TYPE_VARCHAR:
2161
2132
    length*= charset->mbmaxlen;
2465
2436
      length= 1; /* See comment for DRIZZLE_TYPE_SET above. */
2466
2437
      break;
2467
2438
   }
2468
 
  case DRIZZLE_TYPE_VAR_STRING:
2469
 
    assert(0);  /* Impossible, we killed it */
2470
 
    break;
2471
2439
  }
2472
2440
  /* Remember the value of length */
2473
2441
  char_length= length;
2480
2448
        fld_type != DRIZZLE_TYPE_STRING &&
2481
2449
        fld_type != DRIZZLE_TYPE_VARCHAR)))
2482
2450
  {
2483
 
    my_error((fld_type == DRIZZLE_TYPE_VAR_STRING ||
2484
 
              fld_type == DRIZZLE_TYPE_VARCHAR ||
 
2451
    my_error((fld_type == DRIZZLE_TYPE_VARCHAR ||
2485
2452
              fld_type == DRIZZLE_TYPE_STRING) ?  ER_TOO_BIG_FIELDLENGTH :
2486
2453
                                                ER_TOO_BIG_DISPLAYWIDTH,
2487
2454
              MYF(0),
2516
2483
uint32_t calc_pack_length(enum_field_types type,uint32_t length)
2517
2484
{
2518
2485
  switch (type) {
2519
 
  case DRIZZLE_TYPE_VAR_STRING:
2520
2486
  case DRIZZLE_TYPE_STRING:
2521
2487
  case DRIZZLE_TYPE_VARCHAR:     return (length + (length < 256 ? 1: 2));
2522
2488
  case DRIZZLE_TYPE_TINY        : return 1;
2587
2553
  {
2588
2554
    if (!f_is_packed(pack_flag))
2589
2555
    {
2590
 
      if (field_type == DRIZZLE_TYPE_STRING ||
2591
 
          field_type == DRIZZLE_TYPE_VAR_STRING)
 
2556
      if (field_type == DRIZZLE_TYPE_STRING)
2592
2557
        return new Field_string(ptr,field_length,null_pos,null_bit,
2593
2558
                                unireg_check, field_name,
2594
2559
                                field_charset);
2709
2674
    break;
2710
2675
  case DRIZZLE_TYPE_STRING:
2711
2676
    /* Change CHAR -> VARCHAR if dynamic record length */
2712
 
    if (old_field->type() == DRIZZLE_TYPE_VAR_STRING)
2713
 
      sql_type= DRIZZLE_TYPE_VARCHAR;
2714
 
    /* fall through */
2715
 
 
2716
2677
  case DRIZZLE_TYPE_ENUM:
2717
2678
  case DRIZZLE_TYPE_SET:
2718
2679
  case DRIZZLE_TYPE_VARCHAR:
2719
 
  case DRIZZLE_TYPE_VAR_STRING:
2720
2680
    /* This is corrected in create_length_to_internal_length */
2721
2681
    length= (length+charset->mbmaxlen-1) / charset->mbmaxlen;
2722
2682
    break;