~drizzle-trunk/drizzle/development

1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
4
 *  Copyright (C) 2008-2009 Sun Microsystems, Inc.
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; version 2 of the License.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, write to the Free Software
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
19
20
/**
1052.2.7 by Nathan Williams
Merged trunk and resolved conflicts.
21
 * @file Implementation of CreateField class
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
22
 */
23
1241.9.36 by Monty Taylor
ZOMG. I deleted drizzled/server_includes.h.
24
#include "config.h"
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
25
#include <errno.h>
1241.9.1 by Monty Taylor
Removed global.h. Fixed all the headers.
26
#include <float.h>
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
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"
2023.2.2 by Brian Aker
Merge in BOOL change to BOOLEAN.
34
#include "drizzled/field/boolean.h"
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
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"
2007 by Brian Aker
Refactor naming for integers.
41
#include "drizzled/field/int32.h"
42
#include "drizzled/field/int64.h"
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
43
#include "drizzled/field/num.h"
1999.4.9 by Brian Aker
Created EPOCH
44
#include "drizzled/field/epoch.h"
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
45
#include "drizzled/field/datetime.h"
46
#include "drizzled/field/varstring.h"
1996.2.1 by Brian Aker
uuid type code.
47
#include "drizzled/field/uuid.h"
1079.3.2 by Stewart Smith
Replace MAX_(DATE|TIME).*_WIDTH defines in definitions.h with real (and correct) static const members to Temporal types.
48
#include "drizzled/temporal.h"
1878.3.2 by Monty Taylor
Split out show_type into its own header and made sys_var work through
49
#include "drizzled/item/string.h"
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
50
2008.2.4 by Brian Aker
Merge in additional fixes for sign, plus alter table, plus TIME on
51
#include "drizzled/display.h"
52
1067.4.1 by Nathan Williams
First few changes at converting cmin to std::min.
53
#include <algorithm>
54
55
using namespace std;
56
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
57
namespace drizzled
58
{
1067.4.1 by Nathan Williams
First few changes at converting cmin to std::min.
59
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
60
/** Create a field suitable for create of table. */
1052.2.7 by Nathan Williams
Merged trunk and resolved conflicts.
61
CreateField::CreateField(Field *old_field, Field *orig_field)
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
62
{
63
  field= old_field;
64
  field_name= change= old_field->field_name;
65
  length= old_field->field_length;
66
  flags= old_field->flags;
67
  unireg_check= old_field->unireg_check;
68
  pack_length= old_field->pack_length();
69
  key_length= old_field->key_length();
70
  sql_type= old_field->real_type();
71
  charset= old_field->charset(); // May be NULL ptr
72
  comment= old_field->comment;
73
  decimals= old_field->decimals();
74
75
  /* Fix if the original table had 4 byte pointer blobs */
76
  if (flags & BLOB_FLAG)
1660.1.3 by Brian Aker
Encapsulate Table in field
77
    pack_length= (pack_length - old_field->getTable()->getShare()->blob_ptr_size + portable_sizeof_char_ptr);
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
78
79
  switch (sql_type) 
80
  {
81
    case DRIZZLE_TYPE_BLOB:
82
      sql_type= DRIZZLE_TYPE_BLOB;
83
      length/= charset->mbmaxlen;
84
      key_length/= charset->mbmaxlen;
85
      break;
86
    case DRIZZLE_TYPE_ENUM:
87
    case DRIZZLE_TYPE_VARCHAR:
88
      /* This is corrected in create_length_to_internal_length */
89
      length= (length+charset->mbmaxlen-1) / charset->mbmaxlen;
90
      break;
91
    default:
92
      break;
93
  }
94
1315.2.15 by Stewart Smith
remove the now unused SET_FLAG define. We don't have the SET field type, and this flag was never set.
95
  if (flags & ENUM_FLAG)
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
96
    interval= ((Field_enum*) old_field)->typelib;
97
  else
98
    interval= 0;
99
  def= 0;
100
  char_length= length;
101
1638.10.114 by Stewart Smith
when creating a CreateField from a Field, a auto_incremen column should not have a default value of 0 as that's not magic.
102
  if (!(flags & (NO_DEFAULT_VALUE_FLAG)) &&
103
      !(flags & AUTO_INCREMENT_FLAG) &&
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
104
      old_field->ptr && orig_field &&
2046.2.1 by Brian Aker
First pass on micro timestamp.
105
      (not old_field->is_timestamp() ||                /* set def only if */
1660.1.3 by Brian Aker
Encapsulate Table in field
106
       old_field->getTable()->timestamp_field != old_field ||  /* timestamp field */
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
107
       unireg_check == Field::TIMESTAMP_UN_FIELD))        /* has default val */
108
  {
109
    ptrdiff_t diff;
110
111
    /* Get the value from default_values */
1672.3.6 by Brian Aker
First pass in encapsulating row
112
    diff= (ptrdiff_t) (orig_field->getTable()->getDefaultValues() - orig_field->getTable()->getInsertRecord());
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
113
    orig_field->move_field_offset(diff);	// Points now at default_values
114
    if (! orig_field->is_real_null())
115
    {
116
      char buff[MAX_FIELD_WIDTH], *pos;
117
      String tmp(buff, sizeof(buff), charset), *res;
1996.2.1 by Brian Aker
uuid type code.
118
      res= orig_field->val_str_internal(&tmp);
1253.1.6 by Monty Taylor
Moved mem_root functions into drizzled::memory:: namespace.
119
      pos= (char*) memory::sql_strmake(res->ptr(), res->length());
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
120
      def= new Item_string(pos, res->length(), charset);
121
    }
1672.3.6 by Brian Aker
First pass in encapsulating row
122
    orig_field->move_field_offset(-diff);	// Back to getInsertRecord()
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
123
  }
124
}
125
126
/**
1052.2.7 by Nathan Williams
Merged trunk and resolved conflicts.
127
  Convert CreateField::length from number of characters to number of bytes.
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
128
*/
1052.2.7 by Nathan Williams
Merged trunk and resolved conflicts.
129
void CreateField::create_length_to_internal_length(void)
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
130
{
131
  switch (sql_type) 
132
  {
133
    case DRIZZLE_TYPE_BLOB:
134
    case DRIZZLE_TYPE_VARCHAR:
135
      length*= charset->mbmaxlen;
136
      key_length= length;
137
      pack_length= calc_pack_length(sql_type, length);
138
      break;
139
    case DRIZZLE_TYPE_ENUM:
140
      /* Pack_length already calculated in ::init() */
141
      length*= charset->mbmaxlen;
142
      key_length= pack_length;
143
      break;
1211.1.1 by Brian Aker
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update
144
    case DRIZZLE_TYPE_DECIMAL:
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
145
      key_length= pack_length=
2030.1.2 by Brian Aker
First pass in refactoring of the name of my_decimal.
146
        class_decimal_get_binary_size(class_decimal_length_to_precision(length,
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
147
                  decimals,
148
                  flags &
149
                  UNSIGNED_FLAG),
150
          decimals);
151
      break;
152
    default:
153
      key_length= pack_length= calc_pack_length(sql_type, length);
154
      break;
155
  }
156
}
157
158
/**
159
  Init for a tmp table field. To be extended if need be.
160
*/
1052.2.7 by Nathan Williams
Merged trunk and resolved conflicts.
161
void CreateField::init_for_tmp_table(enum_field_types sql_type_arg,
1119.9.10 by Jay Pipes
Removes FIELDFLAG_MAYBE_NULL and f_maybe_null() macro.
162
                                     uint32_t length_arg,
163
                                     uint32_t decimals_arg,
1119.9.18 by Stewart Smith
Fix maybe_null for CreateField created for temp table in item/sum.cc (Item_sum_distinct)
164
                                     bool maybe_null)
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
165
{
166
  field_name= "";
167
  sql_type= sql_type_arg;
168
  char_length= length= length_arg;;
169
  unireg_check= Field::NONE;
170
  interval= 0;
171
  charset= &my_charset_bin;
1119.9.16 by Stewart Smith
don't store decimal/double scale in pack_flag, instead use the numeric option scale field in the table proto. This removes f_decimals() macro and the bits in the pack_flag for scale.
172
  decimals= decimals_arg & FIELDFLAG_MAX_DEC;
1119.9.18 by Stewart Smith
Fix maybe_null for CreateField created for temp table in item/sum.cc (Item_sum_distinct)
173
174
  if (! maybe_null)
175
    flags= NOT_NULL_FLAG;
176
  else
177
    flags= 0;
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
178
}
179
1052.2.7 by Nathan Williams
Merged trunk and resolved conflicts.
180
bool CreateField::init(Session *,
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
181
                        char *fld_name,
182
                        enum_field_types fld_type,
183
                        char *fld_length,
184
                        char *fld_decimals,
185
                        uint32_t fld_type_modifier,
186
                        Item *fld_default_value,
187
                        Item *fld_on_update_value,
188
                        LEX_STRING *fld_comment,
189
                        char *fld_change,
190
                        List<String> *fld_interval_list,
191
                        const CHARSET_INFO * const fld_charset,
192
                        uint32_t,
193
                        enum column_format_type column_format_in)
194
                        
195
{
196
  uint32_t sign_len= 0;
197
  uint32_t allowed_type_modifier= 0;
198
  uint32_t max_field_charlength= MAX_FIELD_CHARLENGTH;
199
200
  field= 0;
201
  field_name= fld_name;
202
  def= fld_default_value;
203
  flags= fld_type_modifier;
204
  flags|= (((uint32_t)column_format_in & COLUMN_FORMAT_MASK) << COLUMN_FORMAT_FLAGS);
205
  unireg_check= (fld_type_modifier & AUTO_INCREMENT_FLAG ?
206
                 Field::NEXT_NUMBER : Field::NONE);
207
  decimals= fld_decimals ? (uint32_t)atoi(fld_decimals) : 0;
208
  if (decimals >= NOT_FIXED_DEC)
209
  {
210
    my_error(ER_TOO_BIG_SCALE, MYF(0), decimals, fld_name,
211
             NOT_FIXED_DEC-1);
212
    return(true);
213
  }
214
215
  sql_type= fld_type;
216
  length= 0;
217
  change= fld_change;
218
  interval= 0;
219
  pack_length= key_length= 0;
220
  charset= fld_charset;
1101.1.24 by Monty Taylor
Reverted my change to interval_list
221
  interval_list.empty();
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
222
223
  comment= *fld_comment;
224
225
  /*
226
    Set NO_DEFAULT_VALUE_FLAG if this field doesn't have a default value and
227
    it is NOT NULL, not an AUTO_INCREMENT field and not a TIMESTAMP.
228
  */
229
  if (!fld_default_value && !(fld_type_modifier & AUTO_INCREMENT_FLAG) &&
2046.2.1 by Brian Aker
First pass on micro timestamp.
230
      (fld_type_modifier & NOT_NULL_FLAG) && (fld_type != DRIZZLE_TYPE_TIMESTAMP and fld_type != DRIZZLE_TYPE_MICROTIME))
231
  {
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
232
    flags|= NO_DEFAULT_VALUE_FLAG;
2046.2.1 by Brian Aker
First pass on micro timestamp.
233
  }
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
234
235
  if (fld_length && !(length= (uint32_t) atoi(fld_length)))
971.6.11 by Eric Day
Removed purecov messages.
236
    fld_length= 0;
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
237
  sign_len= fld_type_modifier & UNSIGNED_FLAG ? 0 : 1;
238
239
  switch (fld_type) 
240
  {
241
    case DRIZZLE_TYPE_LONG:
242
      if (!fld_length)
243
        length= MAX_INT_WIDTH+sign_len;
244
      allowed_type_modifier= AUTO_INCREMENT_FLAG;
245
      break;
246
    case DRIZZLE_TYPE_LONGLONG:
247
      if (!fld_length)
248
        length= MAX_BIGINT_WIDTH;
249
      allowed_type_modifier= AUTO_INCREMENT_FLAG;
250
      break;
251
    case DRIZZLE_TYPE_NULL:
252
      break;
1211.1.1 by Brian Aker
Updating with my change to to DECIMAL from NEWDECIMAL and Stewart's update
253
    case DRIZZLE_TYPE_DECIMAL:
2030.1.2 by Brian Aker
First pass in refactoring of the name of my_decimal.
254
      class_decimal_trim(&length, &decimals);
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
255
      if (length > DECIMAL_MAX_PRECISION)
256
      {
257
        my_error(ER_TOO_BIG_PRECISION, MYF(0), length, fld_name,
258
                DECIMAL_MAX_PRECISION);
259
        return(true);
260
      }
261
      if (length < decimals)
262
      {
263
        my_error(ER_M_BIGGER_THAN_D, MYF(0), fld_name);
264
        return(true);
265
      }
2030.1.2 by Brian Aker
First pass in refactoring of the name of my_decimal.
266
      length= class_decimal_precision_to_length(length, decimals, fld_type_modifier & UNSIGNED_FLAG);
267
      pack_length= class_decimal_get_binary_size(length, decimals);
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
268
      break;
269
    case DRIZZLE_TYPE_VARCHAR:
270
      /*
271
        Long VARCHAR's are automaticly converted to blobs in mysql_prepare_table
272
        if they don't have a default value
273
      */
274
      max_field_charlength= MAX_FIELD_VARCHARLENGTH;
275
      break;
276
    case DRIZZLE_TYPE_BLOB:
277
      if (fld_default_value)
278
      {
279
        /* Allow empty as default value. */
280
        String str,*res;
281
        res= fld_default_value->val_str(&str);
282
        if (res->length())
283
        {
284
          my_error(ER_BLOB_CANT_HAVE_DEFAULT, MYF(0), fld_name);
285
          return(true);
286
        }
287
288
      }
289
      flags|= BLOB_FLAG;
290
      break;
291
    case DRIZZLE_TYPE_DOUBLE:
292
      allowed_type_modifier= AUTO_INCREMENT_FLAG;
293
      if (!fld_length && !fld_decimals)
294
      {
295
        length= DBL_DIG+7;
296
        decimals= NOT_FIXED_DEC;
297
      }
298
      if (length < decimals &&
299
          decimals != NOT_FIXED_DEC)
300
      {
301
        my_error(ER_M_BIGGER_THAN_D, MYF(0), fld_name);
302
        return(true);
303
      }
304
      break;
2046.2.1 by Brian Aker
First pass on micro timestamp.
305
    case DRIZZLE_TYPE_MICROTIME:
2057.2.3 by Brian Aker
Move the syntax for creation to what the standard has.
306
      /* 
307
        This assert() should be correct due to absence of length
308
        specifiers for timestamp. Previous manipulation also wasn't
309
        ever called (from examining lcov)
310
      */
311
      assert(fld_type);
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
312
    case DRIZZLE_TYPE_TIMESTAMP:
2057.2.3 by Brian Aker
Move the syntax for creation to what the standard has.
313
      length= MicroTimestamp::MAX_STRING_LENGTH;
1079.3.2 by Stewart Smith
Replace MAX_(DATE|TIME).*_WIDTH defines in definitions.h with real (and correct) static const members to Temporal types.
314
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
315
      if (fld_default_value)
316
      {
317
        /* Grammar allows only NOW() value for ON UPDATE clause */
318
        if (fld_default_value->type() == Item::FUNC_ITEM &&
319
            ((Item_func*)fld_default_value)->functype() == Item_func::NOW_FUNC)
320
        {
321
          unireg_check= (fld_on_update_value ? Field::TIMESTAMP_DNUN_FIELD:
322
                                              Field::TIMESTAMP_DN_FIELD);
323
          /*
324
            We don't need default value any longer moreover it is dangerous.
325
            Everything handled by unireg_check further.
326
          */
327
          def= 0;
328
        }
329
        else
2046.2.1 by Brian Aker
First pass on micro timestamp.
330
        {
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
331
          unireg_check= (fld_on_update_value ? Field::TIMESTAMP_UN_FIELD:
2046.2.1 by Brian Aker
First pass on micro timestamp.
332
                         Field::NONE);
333
        }
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
334
      }
335
      else
336
      {
337
        /*
338
          If we have default TIMESTAMP NOT NULL column without explicit DEFAULT
339
          or ON UPDATE values then for the sake of compatiblity we should treat
340
          this column as having DEFAULT NOW() ON UPDATE NOW() (when we don't
341
          have another TIMESTAMP column with auto-set option before this one)
342
          or DEFAULT 0 (in other cases).
343
          So here we are setting TIMESTAMP_OLD_FIELD only temporary, and will
344
          replace this value by TIMESTAMP_DNUN_FIELD or NONE later when
345
          information about all TIMESTAMP fields in table will be availiable.
346
347
          If we have TIMESTAMP NULL column without explicit DEFAULT value
348
          we treat it as having DEFAULT NULL attribute.
349
        */
350
        unireg_check= (fld_on_update_value ? Field::TIMESTAMP_UN_FIELD :
351
                      (flags & NOT_NULL_FLAG ? Field::TIMESTAMP_OLD_FIELD :
352
                                                Field::NONE));
353
      }
354
      break;
355
    case DRIZZLE_TYPE_DATE:
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
356
      length= Date::MAX_STRING_LENGTH;
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
357
      break;
1996.2.1 by Brian Aker
uuid type code.
358
    case DRIZZLE_TYPE_UUID:
359
      length= field::Uuid::max_string_length();
360
      break;
2023.2.2 by Brian Aker
Merge in BOOL change to BOOLEAN.
361
    case DRIZZLE_TYPE_BOOLEAN:
362
      length= field::Boolean::max_string_length();
2023.2.1 by Brian Aker
Merge in BOOL type.
363
      break;
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
364
    case DRIZZLE_TYPE_DATETIME:
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
365
      length= DateTime::MAX_STRING_LENGTH;
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
366
      break;
1999.4.7 by Brian Aker
Merge in first pass of TIME type (closer to EPOCH time).
367
    case DRIZZLE_TYPE_TIME:
368
      length= DateTime::MAX_STRING_LENGTH;
369
      break;
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
370
    case DRIZZLE_TYPE_ENUM:
371
      {
372
        /* Should be safe. */
1782.4.4 by Brian Aker
Fix enum at being an intefer (which is what PG did, and it saves on
373
        pack_length= 4;
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
374
375
        List_iterator<String> it(*fld_interval_list);
376
        String *tmp;
377
        while ((tmp= it++))
1101.1.24 by Monty Taylor
Reverted my change to interval_list
378
          interval_list.push_back(tmp);
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
379
        length= 1;
380
        break;
381
    }
382
  }
383
  /* Remember the value of length */
384
  char_length= length;
385
386
  if (!(flags & BLOB_FLAG) &&
387
      ((length > max_field_charlength &&
388
        fld_type != DRIZZLE_TYPE_ENUM &&
389
        (fld_type != DRIZZLE_TYPE_VARCHAR || fld_default_value)) ||
390
       (!length && fld_type != DRIZZLE_TYPE_VARCHAR)))
391
  {
392
    my_error((fld_type == DRIZZLE_TYPE_VARCHAR) ?  ER_TOO_BIG_FIELDLENGTH : ER_TOO_BIG_DISPLAYWIDTH,
393
              MYF(0),
971.6.11 by Eric Day
Removed purecov messages.
394
              fld_name, max_field_charlength);
1055.2.10 by Jay Pipes
Moves Create_field implementation out into its own implementation file.
395
    return true;
396
  }
397
  fld_type_modifier&= AUTO_INCREMENT_FLAG;
398
  if ((~allowed_type_modifier) & fld_type_modifier)
399
  {
400
    my_error(ER_WRONG_FIELD_SPEC, MYF(0), fld_name);
401
    return true;
402
  }
403
404
  return false; /* success */
405
}
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
406
2008.2.4 by Brian Aker
Merge in additional fixes for sign, plus alter table, plus TIME on
407
std::ostream& operator<<(std::ostream& output, const CreateField &field)
408
{
409
  output << "CreateField:(";
410
  output <<  field.field_name;
411
  output << ", ";
412
  output << drizzled::display::type(field.type());
413
  output << ", { ";
414
415
  if (field.flags & NOT_NULL_FLAG)
416
    output << " NOT_NULL";
417
418
  if (field.flags & PRI_KEY_FLAG)
419
    output << ", PRIMARY KEY";
420
421
  if (field.flags & UNIQUE_KEY_FLAG)
422
    output << ", UNIQUE KEY";
423
424
  if (field.flags & MULTIPLE_KEY_FLAG)
425
    output << ", MULTIPLE KEY";
426
427
  if (field.flags & BLOB_FLAG)
428
    output << ", BLOB";
429
430
  if (field.flags & UNSIGNED_FLAG)
431
    output << ", UNSIGNED";
432
433
  if (field.flags & BINARY_FLAG)
434
    output << ", BINARY";
435
  output << "}, ";
436
  if (field.field)
437
    output << *field.field;
438
  output << ")";
439
440
  return output;  // for multiple << operators.
441
}
442
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
443
} /* namespace drizzled */