1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008-2009 Sun Microsystems
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.
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.
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
20
#ifndef DRIZZLED_CREATE_FIELD_H
21
#define DRIZZLED_CREATE_FIELD_H
23
#include "drizzled/field.h"
29
typedef struct st_typelib TYPELIB;
32
* Class representing a field in a CREATE TABLE statement.
34
* Basically, all information for a new or altered field
35
* definition is contained in the Create_field class.
37
class CreateField :public memory::SqlAlloc
40
const char *field_name; /**< Name of the field to be created */
41
const char *change; /**< If done with alter table */
42
const char *after; /**< Put this new Field after this Field */
43
LEX_STRING comment; /**< A comment for this field */
44
Item *def; /**< Default value for the new field */
45
enum enum_field_types sql_type; /**< The data type of the new field */
47
* At various stages in execution this can be length of field in bytes or
48
* max number of characters.
52
* The value of `length' as set by parser: is the number of characters
53
* for most of the types, or of bytes for BLOBs or numeric types.
60
Field::utype unireg_check; /**< See Field::unireg_check */
61
TYPELIB *interval; /**< Which interval to use (ENUM types..) */
62
List<String> interval_list;
63
const CHARSET_INFO *charset; /**< Character set for the column -- @TODO should be deleted */
64
Field *field; // For alter table
66
uint8_t interval_id; // For rea_create_table
70
CreateField() :after(0) {}
71
CreateField(Field *field, Field *orig_field);
72
/* Used to make a clone of this object for ALTER/CREATE TABLE */
73
CreateField *clone(memory::Root *mem_root) const
74
{ return new (mem_root) CreateField(*this); }
75
void create_length_to_internal_length(void);
77
inline enum column_format_type column_format() const
79
return (enum column_format_type)
80
((flags >> COLUMN_FORMAT_FLAGS) & COLUMN_FORMAT_MASK);
84
* Init for a tmp table field. To be extended if need be.
86
* @note This is currently ONLY used in Item_sum_distinct::setup()
88
void init_for_tmp_table(enum_field_types sql_type_arg,
94
Initialize field definition for create.
96
@param session Thread handle
97
@param fld_name Field name
98
@param fld_type Field type
99
@param fld_length Field length
100
@param fld_decimals Decimal (if any)
101
@param fld_type_modifier Additional type information
102
@param fld_default_value Field default value (if any)
103
@param fld_on_update_value The value of ON UPDATE clause
104
@param fld_comment Field comment
105
@param fld_change Field change
106
@param fld_interval_list Interval list (if any)
107
@param fld_charset Field charset
114
bool init(Session *session,
116
enum_field_types type,
119
uint32_t type_modifier,
121
Item *on_update_value,
124
List<String> *interval_list,
125
const CHARSET_INFO * const cs,
126
uint32_t uint_geom_type,
127
enum column_format_type column_format);
130
} /* namespace drizzled */
132
#endif /* DRIZZLED_CREATE_FIELD_H */