1055.2.8
by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field. |
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.8
by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field. |
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 |
||
2234
by Brian Aker
Mass removal of ifdef/endif in favor of pragma once. |
20 |
#pragma once
|
1055.2.8
by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field. |
21 |
|
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
22 |
#include <drizzled/field.h> |
1237.9.4
by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file. |
23 |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
24 |
namespace drizzled |
25 |
{
|
|
1110.1.3
by Monty Taylor
Added ListenHandler as a member of PluginRegistry. |
26 |
class Item; |
1241.9.51
by Monty Taylor
More mysys stuff out of headers. |
27 |
typedef struct st_typelib TYPELIB; |
1110.1.3
by Monty Taylor
Added ListenHandler as a member of PluginRegistry. |
28 |
|
1055.2.8
by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field. |
29 |
/**
|
30 |
* Class representing a field in a CREATE TABLE statement.
|
|
31 |
*
|
|
32 |
* Basically, all information for a new or altered field
|
|
33 |
* definition is contained in the Create_field class.
|
|
34 |
*/
|
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
35 |
class CreateField :public memory::SqlAlloc |
1055.2.8
by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field. |
36 |
{
|
37 |
public: |
|
38 |
const char *field_name; /**< Name of the field to be created */ |
|
39 |
const char *change; /**< If done with alter table */ |
|
40 |
const char *after; /**< Put this new Field after this Field */ |
|
41 |
LEX_STRING comment; /**< A comment for this field */ |
|
42 |
Item *def; /**< Default value for the new field */ |
|
43 |
enum enum_field_types sql_type; /**< The data type of the new field */ |
|
2008.2.4
by Brian Aker
Merge in additional fixes for sign, plus alter table, plus TIME on |
44 |
|
45 |
enum_field_types type() const |
|
46 |
{
|
|
47 |
return sql_type; |
|
48 |
}
|
|
49 |
||
1055.2.8
by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field. |
50 |
/**
|
51 |
* At various stages in execution this can be length of field in bytes or
|
|
52 |
* max number of characters.
|
|
53 |
*/
|
|
54 |
uint32_t length; |
|
55 |
/**
|
|
56 |
* The value of `length' as set by parser: is the number of characters
|
|
57 |
* for most of the types, or of bytes for BLOBs or numeric types.
|
|
58 |
*/
|
|
59 |
uint32_t char_length; |
|
60 |
uint32_t decimals; |
|
61 |
uint32_t flags; |
|
62 |
uint32_t pack_length; |
|
63 |
uint32_t key_length; |
|
64 |
Field::utype unireg_check; /**< See Field::unireg_check */ |
|
65 |
TYPELIB *interval; /**< Which interval to use (ENUM types..) */ |
|
1101.3.1
by Nathan Williams
Reverted CreateField::interval_list to a List<String>. Fixes memory leaks I introduced by converting it to a vector in branch listed below. |
66 |
List<String> interval_list; |
1055.2.8
by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field. |
67 |
const CHARSET_INFO *charset; /**< Character set for the column -- @TODO should be deleted */ |
68 |
Field *field; // For alter table |
|
69 |
||
70 |
uint8_t interval_id; // For rea_create_table |
|
71 |
uint32_t offset; |
|
72 |
||
1101.1.24
by Monty Taylor
Reverted my change to interval_list |
73 |
CreateField() :after(0) {} |
1052.2.7
by Nathan Williams
Merged trunk and resolved conflicts. |
74 |
CreateField(Field *field, Field *orig_field); |
1055.2.8
by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field. |
75 |
/* Used to make a clone of this object for ALTER/CREATE TABLE */
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
76 |
CreateField *clone(memory::Root *mem_root) const |
1052.2.7
by Nathan Williams
Merged trunk and resolved conflicts. |
77 |
{ return new (mem_root) CreateField(*this); } |
1055.2.8
by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field. |
78 |
void create_length_to_internal_length(void); |
79 |
||
80 |
inline enum column_format_type column_format() const |
|
81 |
{
|
|
82 |
return (enum column_format_type) |
|
83 |
((flags >> COLUMN_FORMAT_FLAGS) & COLUMN_FORMAT_MASK); |
|
84 |
}
|
|
85 |
||
86 |
/**
|
|
87 |
* Init for a tmp table field. To be extended if need be.
|
|
88 |
*
|
|
89 |
* @note This is currently ONLY used in Item_sum_distinct::setup()
|
|
90 |
*/
|
|
91 |
void init_for_tmp_table(enum_field_types sql_type_arg, |
|
92 |
uint32_t max_length, |
|
93 |
uint32_t decimals, |
|
1119.9.18
by Stewart Smith
Fix maybe_null for CreateField created for temp table in item/sum.cc (Item_sum_distinct) |
94 |
bool maybe_null); |
1055.2.8
by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field. |
95 |
|
96 |
/**
|
|
97 |
Initialize field definition for create.
|
|
98 |
||
99 |
@param session Thread handle
|
|
100 |
@param fld_name Field name
|
|
101 |
@param fld_type Field type
|
|
102 |
@param fld_length Field length
|
|
103 |
@param fld_decimals Decimal (if any)
|
|
104 |
@param fld_type_modifier Additional type information
|
|
105 |
@param fld_default_value Field default value (if any)
|
|
106 |
@param fld_on_update_value The value of ON UPDATE clause
|
|
107 |
@param fld_comment Field comment
|
|
108 |
@param fld_change Field change
|
|
109 |
@param fld_interval_list Interval list (if any)
|
|
110 |
@param fld_charset Field charset
|
|
111 |
||
112 |
@retval
|
|
113 |
false on success
|
|
114 |
@retval
|
|
115 |
true on error
|
|
116 |
*/
|
|
117 |
bool init(Session *session, |
|
118 |
char *field_name, |
|
119 |
enum_field_types type, |
|
120 |
char *length, |
|
121 |
char *decimals, |
|
122 |
uint32_t type_modifier, |
|
123 |
Item *default_value, |
|
124 |
Item *on_update_value, |
|
125 |
LEX_STRING *comment, |
|
126 |
char *change, |
|
127 |
List<String> *interval_list, |
|
128 |
const CHARSET_INFO * const cs, |
|
129 |
uint32_t uint_geom_type, |
|
130 |
enum column_format_type column_format); |
|
131 |
};
|
|
132 |
||
2008.2.4
by Brian Aker
Merge in additional fixes for sign, plus alter table, plus TIME on |
133 |
std::ostream& operator<<(std::ostream& output, const CreateField &field); |
134 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
135 |
} /* namespace drizzled */ |
136 |