~drizzle-trunk/drizzle/development

584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
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; version 2 of the License.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, write to the Free Software
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
19
20
2234 by Brian Aker
Mass removal of ifdef/endif in favor of pragma once.
21
#pragma once
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
22
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
23
#include <drizzled/memory/sql_alloc.h>
24
#include <drizzled/key.h>
25
#include <drizzled/key_part_spec.h>
26
#include <drizzled/sql_list.h>
27
#include <drizzled/cursor.h> /* for default_key_create_info */
28
#include <drizzled/message/table.pb.h>
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
29
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
30
namespace drizzled
31
{
32
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
33
class Item;
934.2.20 by Jay Pipes
Move Foreign_key implementation into its own implementation file and out of session.cc
34
class Table_ident;
35
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
36
namespace memory { class Root; }
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
37
1638.10.78 by Stewart Smith
separate out adding the foreign key to the table protobuf message from mysql_prepare_create_table and call a function to do it directly from the parser where we set up the foreign key structures
38
void add_foreign_key_to_table_message(
39
    message::Table *table_message,
40
    const char* fkey_name,
41
    List<Key_part_spec> &cols,
42
    Table_ident *table,
43
    List<Key_part_spec> &ref_cols,
44
    message::Table::ForeignKeyConstraint::ForeignKeyOption delete_opt_arg,
45
    message::Table::ForeignKeyConstraint::ForeignKeyOption update_opt_arg,
46
    message::Table::ForeignKeyConstraint::ForeignKeyMatchOption match_opt_arg);
47
48
1237.9.4 by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file.
49
class Foreign_key: public Key 
50
{
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
51
public:
52
  Table_ident *ref_table;
53
  List<Key_part_spec> ref_columns;
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
54
55
  message::Table::ForeignKeyConstraint::ForeignKeyOption delete_opt;
56
  message::Table::ForeignKeyConstraint::ForeignKeyOption update_opt;
57
  message::Table::ForeignKeyConstraint::ForeignKeyMatchOption match_opt;
58
1089.1.6 by Brian Aker
Removed dead flag code, style cleanup in FK. Removed dead structs.
59
  Foreign_key(const LEX_STRING &name_arg,
60
              List<Key_part_spec> &cols,
61
              Table_ident *table,
62
              List<Key_part_spec> &ref_cols,
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
63
              message::Table::ForeignKeyConstraint::ForeignKeyOption delete_opt_arg,
64
              message::Table::ForeignKeyConstraint::ForeignKeyOption update_opt_arg,
65
              message::Table::ForeignKeyConstraint::ForeignKeyMatchOption match_opt_arg) :
1089.1.6 by Brian Aker
Removed dead flag code, style cleanup in FK. Removed dead structs.
66
    Key(FOREIGN_KEY, name_arg, &default_key_create_info, 0, cols), ref_table(table),
67
    ref_columns(ref_cols),
68
    delete_opt(delete_opt_arg),
69
    update_opt(update_opt_arg),
70
    match_opt(match_opt_arg)
71
  { }
72
73
934.2.20 by Jay Pipes
Move Foreign_key implementation into its own implementation file and out of session.cc
74
  /**
75
   * Constructs an (almost) deep copy of this foreign key. Only those
76
   * elements that are known to never change are not copied.
77
   * If out of memory, a partial copy is returned and an error is set
78
   * in Session.
79
   */
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
80
  Foreign_key(const Foreign_key &rhs, memory::Root *mem_root);
1089.1.6 by Brian Aker
Removed dead flag code, style cleanup in FK. Removed dead structs.
81
82
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
83
  /**
934.2.20 by Jay Pipes
Move Foreign_key implementation into its own implementation file and out of session.cc
84
   * Used to make a clone of this object for ALTER/CREATE TABLE
85
   * 
86
   * @see comment for Key_part_spec::clone
87
   */
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
88
  virtual Key *clone(memory::Root *mem_root) const
934.2.20 by Jay Pipes
Move Foreign_key implementation into its own implementation file and out of session.cc
89
  {
90
    return new (mem_root) Foreign_key(*this, mem_root);
91
  }
1089.1.6 by Brian Aker
Removed dead flag code, style cleanup in FK. Removed dead structs.
92
93
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
94
  /* Used to validate foreign key options */
1052.2.3 by Nathan Williams
No actual code changes. Changed Create_field to CreateField to be consistent with coding standards.
95
  bool validate(List<CreateField> &table_fields);
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
96
};
97
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
98
} /* namespace drizzled */
99