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 namespace statement {
00030 
00031 class CreateTable : public Statement
00032 {
00033   virtual bool check(const identifier::Table&);
00034 
00035 public:
00036   CreateTable(Session *in_session, Table_ident *ident, bool is_temporary);
00037   CreateTable(Session *in_session);
00038 
00039   virtual bool is_alter() const
00040   {
00041     return false;
00042   }
00043 
00044   bool execute();
00045 
00046   virtual bool executeInner(const identifier::Table&);
00047 
00048 public:
00049   message::Table &createTableMessage()
00050   {
00051     return *lex().table();
00052   };
00053 
00054 private:
00055   HA_CREATE_INFO _create_info;
00056 
00057 public:
00058 
00059   HA_CREATE_INFO &create_info()
00060   {
00061     if (createTableMessage().options().auto_increment_value())
00062     {
00063       _create_info.auto_increment_value= createTableMessage().options().auto_increment_value();
00064       _create_info.used_fields|= HA_CREATE_USED_AUTO;
00065     }
00066 
00067     return _create_info;
00068   }
00069 
00070   AlterInfo alter_info;
00071   KEY_CREATE_INFO key_create_info;
00072   message::Table::ForeignKeyConstraint::ForeignKeyMatchOption fk_match_option;
00073   message::Table::ForeignKeyConstraint::ForeignKeyOption fk_update_opt;
00074   message::Table::ForeignKeyConstraint::ForeignKeyOption fk_delete_opt;
00075 
00076   /* The text in a CHANGE COLUMN clause in ALTER TABLE */
00077   const char *change;
00078 
00079   /* An item representing the DEFAULT clause in CREATE/ALTER TABLE */
00080   Item *default_value;
00081 
00082   /* An item representing the ON UPDATE clause in CREATE/ALTER TABLE */
00083   Item *on_update_value;
00084 
00085   column_format_type column_format;
00086 
00087   /* Poly-use */
00088   str_ref comment;
00089 
00090   bool is_engine_set;
00091   bool is_create_table_like;
00092   bool lex_identified_temp_table;
00093   bool link_to_local;
00094   TableList *create_table_list;
00095 
00096   bool validateCreateTableOption();
00097 };
00098 
00099 } /* namespace statement */
00100 
00101 } /* namespace drizzled */
00102