~drizzle-trunk/drizzle/development

1100.3.65 by Padraig O'Sullivan
Extracted the CREATE TABLE command into its own class and implementation
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2009 Sun Microsystems
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; either version 2 of the License, or
9
 *  (at your option) any later version.
10
 *
11
 *  This program is distributed in the hope that it will be useful,
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 *  GNU General Public License for more details.
15
 *
16
 *  You should have received a copy of the GNU General Public License
17
 *  along with this program; if not, write to the Free Software
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
 */
20
21
#ifndef DRIZZLED_STATEMENT_CREATE_TABLE_H
22
#define DRIZZLED_STATEMENT_CREATE_TABLE_H
23
1237.9.4 by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file.
24
#include "drizzled/statement.h"
25
#include "drizzled/foreign_key.h"
1100.3.65 by Padraig O'Sullivan
Extracted the CREATE TABLE command into its own class and implementation
26
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
27
namespace drizzled
28
{
1100.3.65 by Padraig O'Sullivan
Extracted the CREATE TABLE command into its own class and implementation
29
class Session;
30
31
namespace statement
32
{
33
34
class CreateTable : public Statement
35
{
36
public:
37
  CreateTable(Session *in_session)
38
    :
1222.2.3 by Brian Aker
Remove a few more options, from options in HA_CREATE_INFO.
39
      Statement(in_session),
40
      is_create_table_like(false),
1222.1.3 by Brian Aker
Remove used flag for engine.
41
      is_if_not_exists(false),
42
      is_engine_set(false)
1128.2.3 by Brian Aker
Remove create_info from global
43
  {
44
    memset(&create_info, 0, sizeof(create_info));
1340.1.4 by Brian Aker
A first pass through adding a timestamp to our proto.
45
46
    create_table_message.set_creation_timestamp(time(NULL));
47
    create_table_message.set_update_timestamp(time(NULL));
1128.2.3 by Brian Aker
Remove create_info from global
48
  }
1100.3.65 by Padraig O'Sullivan
Extracted the CREATE TABLE command into its own class and implementation
49
50
  bool execute();
1340.1.4 by Brian Aker
A first pass through adding a timestamp to our proto.
51
  message::Table create_table_message;
1372.1.3 by Brian Aker
Refactor for table message.
52
  message::Table &createTableMessage()
53
  {
54
    return create_table_message;
55
  };
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
56
  message::Table::Field *current_proto_field;
1128.2.3 by Brian Aker
Remove create_info from global
57
  HA_CREATE_INFO create_info;
1128.2.4 by Brian Aker
AlterInfo refactor back to class.
58
  AlterInfo alter_info;
1128.2.9 by Brian Aker
Remove KEY_CREATE_INFO from global lex.
59
  KEY_CREATE_INFO key_create_info;
1638.9.2 by Stewart Smith
use the ENUM in the table proto instead of duplicating it for Foreign key options and match option. A move in the direction of just having foreign keys in the proto
60
  message::Table::ForeignKeyConstraint::ForeignKeyMatchOption fk_match_option;
61
  message::Table::ForeignKeyConstraint::ForeignKeyOption fk_update_opt;
62
  message::Table::ForeignKeyConstraint::ForeignKeyOption fk_delete_opt;
1128.2.11 by Brian Aker
More rework of Lex for "how tiny can she be..."
63
64
  /* The text in a CHANGE COLUMN clause in ALTER TABLE */
65
  char *change;
66
67
  /* An item representing the DEFAULT clause in CREATE/ALTER TABLE */
68
  Item *default_value;
69
70
  /* An item representing the ON UPDATE clause in CREATE/ALTER TABLE */
71
  Item *on_update_value;
72
73
  enum column_format_type column_format;
74
75
  /* Poly-use */
76
  LEX_STRING comment;
1222.2.3 by Brian Aker
Remove a few more options, from options in HA_CREATE_INFO.
77
78
  bool is_create_table_like;
79
  bool is_if_not_exists;
1222.1.3 by Brian Aker
Remove used flag for engine.
80
  bool is_engine_set;
1245.3.2 by Stewart Smith
small addition of custom engine options in parser and statement/create_table. No error checking performed yet (although the list is constructed). We are parsing them in () after ENGINE=FOO in CREATE TABLE and not as first class options to CREATE TABLE (like ENGINE=) currently due to shift/reduce conflicts in parser if we do. We must first reimpliment the existing CREATE TABLE options as these options before we can have this.
81
1502.1.30 by Brian Aker
First pass on cleanup of Stewart's patch, plus re-engineer to make it work a
82
  bool validateCreateTableOption();
1100.3.65 by Padraig O'Sullivan
Extracted the CREATE TABLE command into its own class and implementation
83
};
84
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
85
} /* namespace statement */
1100.3.65 by Padraig O'Sullivan
Extracted the CREATE TABLE command into its own class and implementation
86
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
87
} /* namespace drizzled */
1100.3.65 by Padraig O'Sullivan
Extracted the CREATE TABLE command into its own class and implementation
88
89
#endif /* DRIZZLED_STATEMENT_CREATE_TABLE_H */