~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field.cc

  • Committer: Brian Aker
  • Date: 2011-01-04 04:05:27 UTC
  • mto: (2057.2.1 clean)
  • mto: This revision was merged to the branch mainline in revision 2064.
  • Revision ID: brian@tangent.org-20110104040527-w2xglgjmlet2hy1p
First pass on micro timestamp.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
#include "drizzled/field/time.h"
46
46
#include "drizzled/field/epoch.h"
47
47
#include "drizzled/field/datetime.h"
 
48
#include "drizzled/field/microtime.h"
48
49
#include "drizzled/field/varstring.h"
49
50
#include "drizzled/field/uuid.h"
50
51
#include "drizzled/time_functions.h"
92
93
    DRIZZLE_TYPE_VARCHAR,
93
94
    //DRIZZLE_TYPE_UUID
94
95
    DRIZZLE_TYPE_VARCHAR,
 
96
    //DRIZZLE_TYPE_MICROTIME
 
97
    DRIZZLE_TYPE_VARCHAR,
95
98
  },
96
99
  /* DRIZZLE_TYPE_DOUBLE -> */
97
100
  {
123
126
    DRIZZLE_TYPE_VARCHAR,
124
127
    //DRIZZLE_TYPE_UUID
125
128
    DRIZZLE_TYPE_VARCHAR,
 
129
    //DRIZZLE_TYPE_MICROTIME
 
130
    DRIZZLE_TYPE_VARCHAR,
126
131
  },
127
132
  /* DRIZZLE_TYPE_NULL -> */
128
133
  {
154
159
    DRIZZLE_TYPE_BOOLEAN,
155
160
    //DRIZZLE_TYPE_UUID
156
161
    DRIZZLE_TYPE_UUID,
 
162
    //DRIZZLE_TYPE_MICROTIME
 
163
    DRIZZLE_TYPE_MICROTIME,
157
164
  },
158
165
  /* DRIZZLE_TYPE_TIMESTAMP -> */
159
166
  {
185
192
    DRIZZLE_TYPE_VARCHAR,
186
193
    //DRIZZLE_TYPE_UUID
187
194
    DRIZZLE_TYPE_VARCHAR,
 
195
    //DRIZZLE_TYPE_MICROTIME
 
196
    DRIZZLE_TYPE_VARCHAR,
188
197
  },
189
198
  /* DRIZZLE_TYPE_LONGLONG -> */
190
199
  {
215
224
    DRIZZLE_TYPE_VARCHAR,
216
225
    //DRIZZLE_TYPE_UUID
217
226
    DRIZZLE_TYPE_VARCHAR,
 
227
    //DRIZZLE_TYPE_MICROTIME
 
228
    DRIZZLE_TYPE_VARCHAR,
218
229
  },
219
230
  /* DRIZZLE_TYPE_DATETIME -> */
220
231
  {
246
257
    DRIZZLE_TYPE_VARCHAR,
247
258
    //DRIZZLE_TYPE_UUID
248
259
    DRIZZLE_TYPE_VARCHAR,
 
260
    //DRIZZLE_TYPE_MICROTIME
 
261
    DRIZZLE_TYPE_VARCHAR,
249
262
  },
250
263
  /* DRIZZLE_TYPE_DATE -> */
251
264
  {
277
290
    DRIZZLE_TYPE_VARCHAR,
278
291
    //DRIZZLE_TYPE_UUID
279
292
    DRIZZLE_TYPE_VARCHAR,
 
293
    //DRIZZLE_TYPE_MICROTIME
 
294
    DRIZZLE_TYPE_VARCHAR,
280
295
  },
281
296
  /* DRIZZLE_TYPE_VARCHAR -> */
282
297
  {
308
323
    DRIZZLE_TYPE_VARCHAR,
309
324
    //DRIZZLE_TYPE_UUID
310
325
    DRIZZLE_TYPE_VARCHAR,
 
326
    //DRIZZLE_TYPE_MICROTIME
 
327
    DRIZZLE_TYPE_VARCHAR,
311
328
  },
312
329
  /* DRIZZLE_TYPE_DECIMAL -> */
313
330
  {
339
356
    DRIZZLE_TYPE_VARCHAR,
340
357
    //DRIZZLE_TYPE_UUID
341
358
    DRIZZLE_TYPE_VARCHAR,
 
359
    //DRIZZLE_TYPE_MICROTIME
 
360
    DRIZZLE_TYPE_VARCHAR,
342
361
  },
343
362
  /* DRIZZLE_TYPE_ENUM -> */
344
363
  {
370
389
    DRIZZLE_TYPE_VARCHAR,
371
390
    //DRIZZLE_TYPE_UUID
372
391
    DRIZZLE_TYPE_VARCHAR,
 
392
    //DRIZZLE_TYPE_MICROTIME
 
393
    DRIZZLE_TYPE_VARCHAR,
373
394
   },
374
395
  /* DRIZZLE_TYPE_BLOB -> */
375
396
  {
401
422
    DRIZZLE_TYPE_VARCHAR,
402
423
    //DRIZZLE_TYPE_UUID
403
424
    DRIZZLE_TYPE_VARCHAR,
 
425
    //DRIZZLE_TYPE_MICROTIME
 
426
    DRIZZLE_TYPE_VARCHAR,
404
427
  },
405
428
  /* DRIZZLE_TYPE_TIME -> */
406
429
  {
432
455
    DRIZZLE_TYPE_VARCHAR,
433
456
    //DRIZZLE_TYPE_UUID
434
457
    DRIZZLE_TYPE_UUID,
 
458
    //DRIZZLE_TYPE_MICROTIME
 
459
    DRIZZLE_TYPE_VARCHAR,
435
460
  },
436
461
  /* DRIZZLE_TYPE_BOOLEAN -> */
437
462
  {
463
488
    DRIZZLE_TYPE_BOOLEAN,
464
489
    //DRIZZLE_TYPE_UUID
465
490
    DRIZZLE_TYPE_VARCHAR,
 
491
    //DRIZZLE_TYPE_MICROTIME
 
492
    DRIZZLE_TYPE_VARCHAR,
466
493
  },
467
494
  /* DRIZZLE_TYPE_UUID -> */
468
495
  {
494
521
    DRIZZLE_TYPE_VARCHAR,
495
522
    //DRIZZLE_TYPE_UUID
496
523
    DRIZZLE_TYPE_UUID,
 
524
    //DRIZZLE_TYPE_MICROTIME
 
525
    DRIZZLE_TYPE_VARCHAR,
 
526
  },
 
527
  /* DRIZZLE_TYPE_MICROTIME -> */
 
528
  {
 
529
    //DRIZZLE_TYPE_LONG
 
530
    DRIZZLE_TYPE_VARCHAR,
 
531
    //DRIZZLE_TYPE_DOUBLE
 
532
    DRIZZLE_TYPE_VARCHAR,
 
533
    //DRIZZLE_TYPE_NULL
 
534
    DRIZZLE_TYPE_MICROTIME,
 
535
    //DRIZZLE_TYPE_TIMESTAMP
 
536
    DRIZZLE_TYPE_VARCHAR,
 
537
    //DRIZZLE_TYPE_LONGLONG
 
538
    DRIZZLE_TYPE_VARCHAR,
 
539
    //DRIZZLE_TYPE_DATETIME
 
540
    DRIZZLE_TYPE_VARCHAR,
 
541
    //DRIZZLE_TYPE_DATE
 
542
    DRIZZLE_TYPE_VARCHAR,
 
543
    //DRIZZLE_TYPE_VARCHAR
 
544
    DRIZZLE_TYPE_VARCHAR,
 
545
    //DRIZZLE_TYPE_DECIMAL
 
546
    DRIZZLE_TYPE_VARCHAR,
 
547
    //DRIZZLE_TYPE_VARCHAR,
 
548
    DRIZZLE_TYPE_VARCHAR,
 
549
    //DRIZZLE_TYPE_BLOB
 
550
    DRIZZLE_TYPE_BLOB,
 
551
    //DRIZZLE_TYPE_TIME
 
552
    DRIZZLE_TYPE_TIME,
 
553
    //DRIZZLE_TYPE_BOOLEAN
 
554
    DRIZZLE_TYPE_VARCHAR,
 
555
    //DRIZZLE_TYPE_UUID
 
556
    DRIZZLE_TYPE_UUID,
 
557
    //DRIZZLE_TYPE_MICROTIME
 
558
    DRIZZLE_TYPE_MICROTIME,
497
559
  },
498
560
};
499
561
 
527
589
  STRING_RESULT,
528
590
  //DRIZZLE_TYPE_UUID
529
591
  STRING_RESULT,
 
592
  //DRIZZLE_TYPE_MICROTIME
 
593
  STRING_RESULT,
530
594
};
531
595
 
532
596
bool test_if_important_data(const CHARSET_INFO * const cs, 
1047
1111
{
1048
1112
  if (!Field::eq_def(field))
1049
1113
    return 0;
 
1114
 
1050
1115
  TYPELIB *from_lib=((Field_enum*) field)->typelib;
1051
1116
 
1052
1117
  if (typelib->count < from_lib->count)
1053
1118
    return 0;
 
1119
 
1054
1120
  for (uint32_t i=0 ; i < from_lib->count ; i++)
 
1121
  {
1055
1122
    if (my_strnncoll(field_charset,
1056
1123
                     (const unsigned char*)typelib->type_names[i],
1057
1124
                     strlen(typelib->type_names[i]),
1058
1125
                     (const unsigned char*)from_lib->type_names[i],
1059
1126
                     strlen(from_lib->type_names[i])))
1060
1127
      return 0;
 
1128
  }
 
1129
 
1061
1130
  return 1;
1062
1131
}
1063
1132
 
1066
1135
  switch (type) {
1067
1136
  case DRIZZLE_TYPE_VARCHAR: return (length + (length < 256 ? 1: 2));
1068
1137
  case DRIZZLE_TYPE_UUID: return field::Uuid::max_string_length();
 
1138
  case DRIZZLE_TYPE_MICROTIME: return field::Microtime::max_string_length();
 
1139
  case DRIZZLE_TYPE_TIMESTAMP: return field::Epoch::max_string_length();
1069
1140
  case DRIZZLE_TYPE_BOOLEAN: return field::Boolean::max_string_length();
1070
1141
  case DRIZZLE_TYPE_DATE:
1071
1142
  case DRIZZLE_TYPE_ENUM:
1073
1144
  case DRIZZLE_TYPE_DOUBLE: return sizeof(double);
1074
1145
  case DRIZZLE_TYPE_TIME:
1075
1146
  case DRIZZLE_TYPE_DATETIME:
1076
 
  case DRIZZLE_TYPE_TIMESTAMP:
1077
1147
  case DRIZZLE_TYPE_LONGLONG: return 8; /* Don't crash if no int64_t */
1078
1148
  case DRIZZLE_TYPE_NULL: return 0;
1079
1149
  case DRIZZLE_TYPE_BLOB: return 4 + portable_sizeof_char_ptr;