~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/create_field.cc

  • Committer: Monty Taylor
  • Date: 2010-12-22 03:15:22 UTC
  • mto: (2023.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 2024.
  • Revision ID: mordred@inaugust.com-20101222031522-bmi73y3y00f480qs
Fixed some valgrind warning suppressions which were getting fooled by a
different stack.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include "drizzled/field/str.h"
32
32
#include "drizzled/field/num.h"
33
33
#include "drizzled/field/blob.h"
34
 
#include "drizzled/field/boolean.h"
35
34
#include "drizzled/field/enum.h"
36
35
#include "drizzled/field/null.h"
37
36
#include "drizzled/field/date.h"
41
40
#include "drizzled/field/int32.h"
42
41
#include "drizzled/field/int64.h"
43
42
#include "drizzled/field/num.h"
44
 
#include "drizzled/field/epoch.h"
 
43
#include "drizzled/field/timestamp.h"
45
44
#include "drizzled/field/datetime.h"
46
45
#include "drizzled/field/varstring.h"
47
46
#include "drizzled/field/uuid.h"
74
73
 
75
74
  /* Fix if the original table had 4 byte pointer blobs */
76
75
  if (flags & BLOB_FLAG)
77
 
  {
78
 
    pack_length= (pack_length - old_field->getTable()->getShare()->sizeBlobPtr() + portable_sizeof_char_ptr);
79
 
  }
 
76
    pack_length= (pack_length - old_field->getTable()->getShare()->blob_ptr_size + portable_sizeof_char_ptr);
80
77
 
81
78
  switch (sql_type) 
82
79
  {
104
101
  if (!(flags & (NO_DEFAULT_VALUE_FLAG)) &&
105
102
      !(flags & AUTO_INCREMENT_FLAG) &&
106
103
      old_field->ptr && orig_field &&
107
 
      (not old_field->is_timestamp() ||                /* set def only if */
 
104
      (sql_type != DRIZZLE_TYPE_TIMESTAMP ||                /* set def only if */
108
105
       old_field->getTable()->timestamp_field != old_field ||  /* timestamp field */
109
106
       unireg_check == Field::TIMESTAMP_UN_FIELD))        /* has default val */
110
107
  {
145
142
      break;
146
143
    case DRIZZLE_TYPE_DECIMAL:
147
144
      key_length= pack_length=
148
 
        class_decimal_get_binary_size(class_decimal_length_to_precision(length,
 
145
        my_decimal_get_binary_size(my_decimal_length_to_precision(length,
149
146
                  decimals,
150
147
                  flags &
151
148
                  UNSIGNED_FLAG),
229
226
    it is NOT NULL, not an AUTO_INCREMENT field and not a TIMESTAMP.
230
227
  */
231
228
  if (!fld_default_value && !(fld_type_modifier & AUTO_INCREMENT_FLAG) &&
232
 
      (fld_type_modifier & NOT_NULL_FLAG) && (fld_type != DRIZZLE_TYPE_TIMESTAMP and fld_type != DRIZZLE_TYPE_MICROTIME))
233
 
  {
 
229
      (fld_type_modifier & NOT_NULL_FLAG) && fld_type != DRIZZLE_TYPE_TIMESTAMP)
234
230
    flags|= NO_DEFAULT_VALUE_FLAG;
235
 
  }
236
231
 
237
232
  if (fld_length && !(length= (uint32_t) atoi(fld_length)))
238
233
    fld_length= 0;
253
248
    case DRIZZLE_TYPE_NULL:
254
249
      break;
255
250
    case DRIZZLE_TYPE_DECIMAL:
256
 
      class_decimal_trim(&length, &decimals);
 
251
      my_decimal_trim(&length, &decimals);
257
252
      if (length > DECIMAL_MAX_PRECISION)
258
253
      {
259
254
        my_error(ER_TOO_BIG_PRECISION, MYF(0), length, fld_name,
265
260
        my_error(ER_M_BIGGER_THAN_D, MYF(0), fld_name);
266
261
        return(true);
267
262
      }
268
 
      length= class_decimal_precision_to_length(length, decimals, fld_type_modifier & UNSIGNED_FLAG);
269
 
      pack_length= class_decimal_get_binary_size(length, decimals);
 
263
      length= my_decimal_precision_to_length(length, decimals, fld_type_modifier & UNSIGNED_FLAG);
 
264
      pack_length= my_decimal_get_binary_size(length, decimals);
270
265
      break;
271
266
    case DRIZZLE_TYPE_VARCHAR:
272
267
      /*
304
299
        return(true);
305
300
      }
306
301
      break;
307
 
    case DRIZZLE_TYPE_MICROTIME:
308
 
      /* 
309
 
        This assert() should be correct due to absence of length
310
 
        specifiers for timestamp. Previous manipulation also wasn't
311
 
        ever called (from examining lcov)
312
 
      */
313
 
      assert(fld_type);
314
302
    case DRIZZLE_TYPE_TIMESTAMP:
315
 
      length= MicroTimestamp::MAX_STRING_LENGTH;
316
 
 
 
303
      if (!fld_length)
 
304
      {
 
305
        length= DateTime::MAX_STRING_LENGTH;
 
306
      }
 
307
 
 
308
      /* This assert() should be correct due to absence of length
 
309
         specifiers for timestamp. Previous manipulation also wasn't
 
310
         ever called (from examining lcov)
 
311
      */
 
312
      assert(length == (uint32_t)DateTime::MAX_STRING_LENGTH);
 
313
 
 
314
      flags|= UNSIGNED_FLAG;
317
315
      if (fld_default_value)
318
316
      {
319
317
        /* Grammar allows only NOW() value for ON UPDATE clause */
329
327
          def= 0;
330
328
        }
331
329
        else
332
 
        {
333
330
          unireg_check= (fld_on_update_value ? Field::TIMESTAMP_UN_FIELD:
334
 
                         Field::NONE);
335
 
        }
 
331
                                              Field::NONE);
336
332
      }
337
333
      else
338
334
      {
360
356
    case DRIZZLE_TYPE_UUID:
361
357
      length= field::Uuid::max_string_length();
362
358
      break;
363
 
    case DRIZZLE_TYPE_BOOLEAN:
364
 
      length= field::Boolean::max_string_length();
365
 
      break;
366
359
    case DRIZZLE_TYPE_DATETIME:
367
360
      length= DateTime::MAX_STRING_LENGTH;
368
361
      break;
369
 
    case DRIZZLE_TYPE_TIME:
370
 
      length= DateTime::MAX_STRING_LENGTH;
371
 
      break;
372
362
    case DRIZZLE_TYPE_ENUM:
373
363
      {
374
364
        /* Should be safe. */