~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/create_field.cc

  • Committer: Brian Aker
  • Date: 2010-12-31 21:25:11 UTC
  • mto: (2045.1.1 clean)
  • mto: This revision was merged to the branch mainline in revision 2046.
  • Revision ID: brian@tangent.org-20101231212511-bhlyaw71ij4v15au
Make more time usage private.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 * @file Implementation of CreateField class
22
22
 */
23
23
 
24
 
#include <config.h>
 
24
#include "config.h"
25
25
#include <errno.h>
26
26
#include <float.h>
27
 
#include <drizzled/sql_select.h>
28
 
#include <drizzled/error.h>
29
 
#include <drizzled/field.h>
30
 
#include <drizzled/create_field.h>
31
 
#include <drizzled/field/str.h>
32
 
#include <drizzled/field/num.h>
33
 
#include <drizzled/field/blob.h>
34
 
#include <drizzled/field/boolean.h>
35
 
#include <drizzled/field/enum.h>
36
 
#include <drizzled/field/null.h>
37
 
#include <drizzled/field/date.h>
38
 
#include <drizzled/field/decimal.h>
39
 
#include <drizzled/field/real.h>
40
 
#include <drizzled/field/double.h>
41
 
#include <drizzled/field/int32.h>
42
 
#include <drizzled/field/int64.h>
43
 
#include <drizzled/field/num.h>
44
 
#include <drizzled/field/epoch.h>
45
 
#include <drizzled/field/datetime.h>
46
 
#include <drizzled/field/varstring.h>
47
 
#include <drizzled/field/uuid.h>
48
 
#include <drizzled/temporal.h>
49
 
#include <drizzled/item/string.h>
50
 
#include <drizzled/table.h>
 
27
#include "drizzled/sql_select.h"
 
28
#include "drizzled/error.h"
 
29
#include "drizzled/field.h"
 
30
#include "drizzled/create_field.h"
 
31
#include "drizzled/field/str.h"
 
32
#include "drizzled/field/num.h"
 
33
#include "drizzled/field/blob.h"
 
34
#include "drizzled/field/boolean.h"
 
35
#include "drizzled/field/enum.h"
 
36
#include "drizzled/field/null.h"
 
37
#include "drizzled/field/date.h"
 
38
#include "drizzled/field/decimal.h"
 
39
#include "drizzled/field/real.h"
 
40
#include "drizzled/field/double.h"
 
41
#include "drizzled/field/int32.h"
 
42
#include "drizzled/field/int64.h"
 
43
#include "drizzled/field/num.h"
 
44
#include "drizzled/field/epoch.h"
 
45
#include "drizzled/field/datetime.h"
 
46
#include "drizzled/field/varstring.h"
 
47
#include "drizzled/field/uuid.h"
 
48
#include "drizzled/temporal.h"
 
49
#include "drizzled/item/string.h"
51
50
 
52
 
#include <drizzled/display.h>
 
51
#include "drizzled/display.h"
53
52
 
54
53
#include <algorithm>
55
54
 
75
74
 
76
75
  /* Fix if the original table had 4 byte pointer blobs */
77
76
  if (flags & BLOB_FLAG)
78
 
  {
79
 
    pack_length= (pack_length - old_field->getTable()->getShare()->sizeBlobPtr() + portable_sizeof_char_ptr);
80
 
  }
 
77
    pack_length= (pack_length - old_field->getTable()->getShare()->blob_ptr_size + portable_sizeof_char_ptr);
81
78
 
82
79
  switch (sql_type) 
83
80
  {
105
102
  if (!(flags & (NO_DEFAULT_VALUE_FLAG)) &&
106
103
      !(flags & AUTO_INCREMENT_FLAG) &&
107
104
      old_field->ptr && orig_field &&
108
 
      (not old_field->is_timestamp() ||                /* set def only if */
 
105
      (sql_type != DRIZZLE_TYPE_TIMESTAMP ||                /* set def only if */
109
106
       old_field->getTable()->timestamp_field != old_field ||  /* timestamp field */
110
107
       unireg_check == Field::TIMESTAMP_UN_FIELD))        /* has default val */
111
108
  {
221
218
  interval= 0;
222
219
  pack_length= key_length= 0;
223
220
  charset= fld_charset;
224
 
  interval_list.clear();
 
221
  interval_list.empty();
225
222
 
226
223
  comment= *fld_comment;
227
224
 
230
227
    it is NOT NULL, not an AUTO_INCREMENT field and not a TIMESTAMP.
231
228
  */
232
229
  if (!fld_default_value && !(fld_type_modifier & AUTO_INCREMENT_FLAG) &&
233
 
      (fld_type_modifier & NOT_NULL_FLAG) && (fld_type != DRIZZLE_TYPE_TIMESTAMP and fld_type != DRIZZLE_TYPE_MICROTIME))
234
 
  {
 
230
      (fld_type_modifier & NOT_NULL_FLAG) && fld_type != DRIZZLE_TYPE_TIMESTAMP)
235
231
    flags|= NO_DEFAULT_VALUE_FLAG;
236
 
  }
237
232
 
238
233
  if (fld_length && !(length= (uint32_t) atoi(fld_length)))
239
234
    fld_length= 0;
305
300
        return(true);
306
301
      }
307
302
      break;
308
 
    case DRIZZLE_TYPE_MICROTIME:
309
 
      /* 
310
 
        This assert() should be correct due to absence of length
311
 
        specifiers for timestamp. Previous manipulation also wasn't
312
 
        ever called (from examining lcov)
313
 
      */
314
 
      assert(fld_type);
315
303
    case DRIZZLE_TYPE_TIMESTAMP:
316
 
      length= MicroTimestamp::MAX_STRING_LENGTH;
317
 
 
 
304
      if (!fld_length)
 
305
      {
 
306
        length= DateTime::MAX_STRING_LENGTH;
 
307
      }
 
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(length == (uint32_t)DateTime::MAX_STRING_LENGTH);
 
314
 
 
315
      flags|= UNSIGNED_FLAG;
318
316
      if (fld_default_value)
319
317
      {
320
318
        /* Grammar allows only NOW() value for ON UPDATE clause */
330
328
          def= 0;
331
329
        }
332
330
        else
333
 
        {
334
331
          unireg_check= (fld_on_update_value ? Field::TIMESTAMP_UN_FIELD:
335
 
                         Field::NONE);
336
 
        }
 
332
                                              Field::NONE);
337
333
      }
338
334
      else
339
335
      {
375
371
        /* Should be safe. */
376
372
        pack_length= 4;
377
373
 
378
 
        List<String>::iterator it(fld_interval_list->begin());
 
374
        List_iterator<String> it(*fld_interval_list);
379
375
        String *tmp;
380
376
        while ((tmp= it++))
381
377
          interval_list.push_back(tmp);