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 
00032 class CreateField : public memory::SqlAlloc
00033 {
00034 public:
00035   const char *field_name; 
00036   const char *change; 
00037   const char *after; 
00038   str_ref comment; 
00039   Item *def; 
00040   enum_field_types sql_type; 
00042   enum_field_types type() const
00043   {
00044     return sql_type;
00045   }
00046 
00051   uint32_t length;
00056   uint32_t char_length;
00057   uint32_t decimals;
00058   uint32_t flags;
00059   uint32_t pack_length;
00060   uint32_t key_length;
00061   Field::utype unireg_check; 
00062   TYPELIB *interval; 
00063   List<String> interval_list;
00064   const charset_info_st *charset; 
00065   Field *field; // For alter table
00066 
00067   uint8_t interval_id;  // For rea_create_table
00068   uint32_t offset;
00069 
00070   CreateField() :after(0) {}
00071   CreateField(Field *field, Field *orig_field);
00072   void create_length_to_internal_length(void);
00073 
00074   inline enum column_format_type column_format() const
00075   {
00076     return (enum column_format_type)
00077       ((flags >> COLUMN_FORMAT_FLAGS) & COLUMN_FORMAT_MASK);
00078   }
00079 
00085   void init_for_tmp_table(enum_field_types sql_type_arg,
00086                           uint32_t max_length,
00087                           uint32_t decimals,
00088                           bool maybe_null);
00089 
00111   bool init(Session*,
00112             const char *field_name,
00113             enum_field_types type,
00114             const char *length,
00115             const char *decimals,
00116             uint32_t type_modifier,
00117             str_ref comment,
00118             const char *change,
00119             List<String> *interval_list,
00120             const charset_info_st*,
00121             uint32_t uint_geom_type,
00122             column_format_type column_format);
00123 
00124   bool setDefaultValue(Item *default_value, Item *on_update_item);
00125 };
00126 
00127 std::ostream& operator<<(std::ostream&, const CreateField&);
00128 
00129 } /* namespace drizzled */
00130