Drizzled Public API Documentation

create_field.h

00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2008-2009 Sun Microsystems, Inc.
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; version 2 of the License.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  */
00019 
00020 #pragma once
00021 
00022 #include <drizzled/field.h>
00023 
00024 namespace drizzled
00025 {
00026 class Item;
00027 typedef struct st_typelib TYPELIB;
00028 
00035 class CreateField :public memory::SqlAlloc
00036 {
00037 public:
00038   const char *field_name; 
00039   const char *change; 
00040   const char *after; 
00041   LEX_STRING comment; 
00042   Item *def; 
00043   enum enum_field_types sql_type; 
00045   enum_field_types type() const
00046   {
00047     return sql_type;
00048   }
00049 
00054   uint32_t length;
00059   uint32_t char_length;
00060   uint32_t decimals;
00061   uint32_t flags;
00062   uint32_t pack_length;
00063   uint32_t key_length;
00064   Field::utype unireg_check; 
00065   TYPELIB *interval; 
00066   List<String> interval_list;
00067   const CHARSET_INFO *charset; 
00068   Field *field; // For alter table
00069 
00070   uint8_t interval_id;  // For rea_create_table
00071   uint32_t offset;
00072 
00073   CreateField() :after(0) {}
00074   CreateField(Field *field, Field *orig_field);
00075   /* Used to make a clone of this object for ALTER/CREATE TABLE */
00076   CreateField *clone(memory::Root *mem_root) const
00077     { return new (mem_root) CreateField(*this); }
00078   void create_length_to_internal_length(void);
00079 
00080   inline enum column_format_type column_format() const
00081   {
00082     return (enum column_format_type)
00083       ((flags >> COLUMN_FORMAT_FLAGS) & COLUMN_FORMAT_MASK);
00084   }
00085 
00091   void init_for_tmp_table(enum_field_types sql_type_arg,
00092                           uint32_t max_length,
00093                           uint32_t decimals,
00094                           bool maybe_null);
00095 
00117   bool init(Session *session,
00118             char *field_name,
00119             enum_field_types type,
00120             char *length,
00121             char *decimals,
00122             uint32_t type_modifier,
00123             Item *default_value,
00124             Item *on_update_value,
00125             LEX_STRING *comment,
00126             char *change,
00127             List<String> *interval_list,
00128             const CHARSET_INFO * const cs,
00129             uint32_t uint_geom_type,
00130             enum column_format_type column_format);
00131 };
00132 
00133 std::ostream& operator<<(std::ostream& output, const CreateField &field);
00134 
00135 } /* namespace drizzled */
00136