~drizzle-trunk/drizzle/development

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
2252.1.3 by Olaf van der Spek
Common fwd
24
namespace drizzled {
1110.1.3 by Monty Taylor
Added ListenHandler as a member of PluginRegistry.
25
1055.2.8 by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field.
26
/**
27
 * Class representing a field in a CREATE TABLE statement.
28
 *
29
 * Basically, all information for a new or altered field
30
 * definition is contained in the Create_field class.
31
 */
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
32
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.
33
{
34
public:
35
  const char *field_name; /**< Name of the field to be created */
36
  const char *change; /**< If done with alter table */
37
  const char *after; /**< Put this new Field after this Field */
2371.1.2 by Brian Aker
Remove the typedef on lexkey
38
  lex_string_t comment; /**< A comment for this 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.
39
  Item *def; /**< Default value for the new field */
2318.8.3 by Olaf van der Spek
CreateField includes
40
  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
41
42
  enum_field_types type() const
43
  {
44
    return sql_type;
45
  }
46
1055.2.8 by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field.
47
  /**
48
   * At various stages in execution this can be length of field in bytes or
49
   * max number of characters.
50
   */
51
  uint32_t length;
52
  /**
53
   * The value of `length' as set by parser: is the number of characters
54
   * for most of the types, or of bytes for BLOBs or numeric types.
55
   */
56
  uint32_t char_length;
57
  uint32_t decimals;
58
  uint32_t flags;
59
  uint32_t pack_length;
60
  uint32_t key_length;
61
  Field::utype unireg_check; /**< See Field::unireg_check */
62
  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.
63
  List<String> interval_list;
2254 by Brian Aker
Shift CHARSET_INFO to charset_info_st
64
  const charset_info_st *charset; /**< Character set for the column -- @TODO should be deleted */
1055.2.8 by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field.
65
  Field *field; // For alter table
66
67
  uint8_t interval_id;	// For rea_create_table
68
  uint32_t offset;
69
1101.1.24 by Monty Taylor
Reverted my change to interval_list
70
  CreateField() :after(0) {}
1052.2.7 by Nathan Williams
Merged trunk and resolved conflicts.
71
  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.
72
  void create_length_to_internal_length(void);
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
80
  /**
81
   * Init for a tmp table field. To be extended if need be. 
82
   *
83
   * @note This is currently ONLY used in Item_sum_distinct::setup()
84
   */
85
  void init_for_tmp_table(enum_field_types sql_type_arg,
86
                          uint32_t max_length,
87
                          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)
88
                          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.
89
90
  /**
91
    Initialize field definition for create.
92
93
    @param session                   Thread handle
94
    @param fld_name              Field name
95
    @param fld_type              Field type
96
    @param fld_length            Field length
97
    @param fld_decimals          Decimal (if any)
98
    @param fld_type_modifier     Additional type information
99
    @param fld_default_value     Field default value (if any)
100
    @param fld_on_update_value   The value of ON UPDATE clause
101
    @param fld_comment           Field comment
102
    @param fld_change            Field change
103
    @param fld_interval_list     Interval list (if any)
104
    @param fld_charset           Field charset
105
106
    @retval
107
      false on success
108
    @retval
109
      true  on error
110
  */
2318.8.3 by Olaf van der Spek
CreateField includes
111
  bool init(Session*,
112
            const char *field_name,
1055.2.8 by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field.
113
            enum_field_types type,
2318.8.3 by Olaf van der Spek
CreateField includes
114
            const char *length,
115
            const char *decimals,
1055.2.8 by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field.
116
            uint32_t type_modifier,
2371.1.2 by Brian Aker
Remove the typedef on lexkey
117
            lex_string_t *comment,
2318.8.3 by Olaf van der Spek
CreateField includes
118
            const char *change,
1055.2.8 by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field.
119
            List<String> *interval_list,
2318.8.3 by Olaf van der Spek
CreateField includes
120
            const charset_info_st*,
1055.2.8 by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field.
121
            uint32_t uint_geom_type,
2318.8.3 by Olaf van der Spek
CreateField includes
122
            column_format_type column_format);
2221.12.5 by Stewart Smith
factor out setting default value out from CreatField::init and into new CreateField::setDefaultValue. This also means we fix up a error message to be correct in type_blob.
123
124
  bool setDefaultValue(Item *default_value, Item *on_update_item);
1055.2.8 by Jay Pipes
Breaks Create_field definition out into its own header file. More documentation and style cleanups around Create_field.
125
};
126
2318.8.3 by Olaf van der Spek
CreateField includes
127
std::ostream& operator<<(std::ostream&, const CreateField&);
2008.2.4 by Brian Aker
Merge in additional fixes for sign, plus alter table, plus TIME on
128
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
129
} /* namespace drizzled */
130