Drizzled Public API Documentation

create_table.h

00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 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; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00021 #pragma once
00022 
00023 #include <drizzled/alter_info.h>
00024 #include <drizzled/statement.h>
00025 #include <drizzled/foreign_key.h>
00026 #include <drizzled/sql_lex.h>
00027 
00028 namespace drizzled {
00029 
00030 class Session;
00031 
00032 namespace statement {
00033 
00034 class CreateTable : public Statement
00035 {
00036   virtual bool check(const identifier::Table&);
00037 
00038 public:
00039   CreateTable(Session *in_session, Table_ident *ident, bool is_temporary);
00040   CreateTable(Session *in_session);
00041 
00042   virtual bool is_alter() const
00043   {
00044     return false;
00045   }
00046 
00047   bool execute();
00048 
00049   virtual bool executeInner(identifier::Table::const_reference);
00050 
00051 public:
00052   message::Table &createTableMessage()
00053   {
00054     return *lex().table();
00055   };
00056 
00057 private:
00058   HA_CREATE_INFO _create_info;
00059 
00060 public:
00061 
00062   HA_CREATE_INFO &create_info()
00063   {
00064     if (createTableMessage().options().auto_increment_value())
00065     {
00066       _create_info.auto_increment_value= createTableMessage().options().auto_increment_value();
00067       _create_info.used_fields|= HA_CREATE_USED_AUTO;
00068     }
00069 
00070     return _create_info;
00071   }
00072 
00073   AlterInfo alter_info;
00074   KEY_CREATE_INFO key_create_info;
00075   message::Table::ForeignKeyConstraint::ForeignKeyMatchOption fk_match_option;
00076   message::Table::ForeignKeyConstraint::ForeignKeyOption fk_update_opt;
00077   message::Table::ForeignKeyConstraint::ForeignKeyOption fk_delete_opt;
00078 
00079   /* The text in a CHANGE COLUMN clause in ALTER TABLE */
00080   char *change;
00081 
00082   /* An item representing the DEFAULT clause in CREATE/ALTER TABLE */
00083   Item *default_value;
00084 
00085   /* An item representing the ON UPDATE clause in CREATE/ALTER TABLE */
00086   Item *on_update_value;
00087 
00088   enum column_format_type column_format;
00089 
00090   /* Poly-use */
00091   LEX_STRING comment;
00092 
00093   bool is_engine_set;
00094   bool is_create_table_like;
00095   bool lex_identified_temp_table;
00096   bool link_to_local;
00097   TableList *create_table_list;
00098 
00099   bool validateCreateTableOption();
00100 };
00101 
00102 } /* namespace statement */
00103 
00104 } /* namespace drizzled */
00105