drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
create_field.h
1/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3 *
4 * Copyright (C) 2008-2009 Sun Microsystems, Inc.
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#pragma once
21
22#include <drizzled/field.h>
23
24namespace drizzled {
25
32class CreateField : public memory::SqlAlloc
33{
34public:
35 const char *field_name= nullptr;
36 const char *change= nullptr;
37 const char *after= nullptr;
38 str_ref comment;
39 Item *def= nullptr;
40 enum_field_types sql_type= enum_field_types();
41
42 enum_field_types type() const
43 {
44 return sql_type;
45 }
46
51 uint32_t length= 0;
56 uint32_t char_length= 0;
57 uint32_t decimals= 0;
58 uint32_t flags= 0;
59 uint32_t pack_length= 0;
60 uint32_t key_length= 0;
61 Field::utype unireg_check= Field::utype();
62 TYPELIB *interval= nullptr;
63 List<String> interval_list;
64 const charset_info_st *charset= nullptr;
65 Field *field= nullptr; // For alter table
66
67 uint8_t interval_id= 0; // For rea_create_table
68 uint32_t offset= 0;
69
70 CreateField() = default;
71 CreateField(Field *field, Field *orig_field);
73
74 inline enum column_format_type column_format() const
75 {
76 return (enum column_format_type)
77 ((flags >> COLUMN_FORMAT_FLAGS) & COLUMN_FORMAT_MASK);
78 }
79
85 void init_for_tmp_table(enum_field_types sql_type_arg,
86 uint32_t max_length,
87 uint32_t decimals,
88 bool maybe_null);
89
111 bool init(Session*,
112 const char *field_name,
113 enum_field_types type,
114 const char *length,
115 const char *decimals,
116 uint32_t type_modifier,
117 str_ref comment,
118 const char *change,
119 List<String> *interval_list,
120 const charset_info_st*,
121 uint32_t uint_geom_type,
122 column_format_type column_format);
123
124 bool setDefaultValue(Item *default_value, Item *on_update_item);
125};
126
127std::ostream& operator<<(std::ostream&, const CreateField&);
128
129} /* namespace drizzled */
130
void init_for_tmp_table(enum_field_types sql_type_arg, uint32_t max_length, uint32_t decimals, bool maybe_null)
const char * field_name
bool init(Session *, const char *field_name, enum_field_types type, const char *length, const char *decimals, uint32_t type_modifier, str_ref comment, const char *change, List< String > *interval_list, const charset_info_st *, uint32_t uint_geom_type, column_format_type column_format)
enum_field_types sql_type
const charset_info_st * charset
void create_length_to_internal_length(void)
Convert from decimal to binary representation.
Definition common_fwd.h:215
TODO: Rename this file - func.h is stupid.