~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
 *
4
 *  Copyright (C) 2008 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; 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
21
#ifndef DRIZZLED_FOREIGN_KEY_H
22
#define DRIZZLED_FOREIGN_KEY_H
23
1253.1.4 by Monty Taylor
Moved sql_alloc into memory.
24
#include "drizzled/memory/sql_alloc.h"
1237.9.4 by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file.
25
#include "drizzled/key.h"
26
#include "drizzled/key_part_spec.h"
27
#include "drizzled/sql_list.h"
1237.9.3 by Padraig O'Sullivan
Removed one the includes I put in server_includes.h for the last commit to get rid of the inclusion
28
#include "drizzled/cursor.h" /* for default_key_create_info */
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
1237.9.4 by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file.
38
class Foreign_key: public Key 
39
{
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.
40
public:
934.2.20 by Jay Pipes
Move Foreign_key implementation into its own implementation file and out of session.cc
41
  enum fk_match_opt 
42
  {
1089.1.6 by Brian Aker
Removed dead flag code, style cleanup in FK. Removed dead structs.
43
    FK_MATCH_UNDEF, 
44
    FK_MATCH_FULL, 
45
    FK_MATCH_PARTIAL, 
46
    FK_MATCH_SIMPLE
934.2.20 by Jay Pipes
Move Foreign_key implementation into its own implementation file and out of session.cc
47
  };
48
  enum fk_option 
49
  {
1089.1.6 by Brian Aker
Removed dead flag code, style cleanup in FK. Removed dead structs.
50
    FK_OPTION_UNDEF, 
51
    FK_OPTION_RESTRICT, 
52
    FK_OPTION_CASCADE, 
53
    FK_OPTION_SET_NULL, 
54
    FK_OPTION_NO_ACTION, 
55
    FK_OPTION_DEFAULT
934.2.20 by Jay Pipes
Move Foreign_key implementation into its own implementation file and out of session.cc
56
  };
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.
57
58
  Table_ident *ref_table;
59
  List<Key_part_spec> ref_columns;
60
  uint32_t delete_opt, update_opt, match_opt;
1089.1.6 by Brian Aker
Removed dead flag code, style cleanup in FK. Removed dead structs.
61
  Foreign_key(const LEX_STRING &name_arg,
62
              List<Key_part_spec> &cols,
63
              Table_ident *table,
64
              List<Key_part_spec> &ref_cols,
65
              uint32_t delete_opt_arg,
66
              uint32_t update_opt_arg,
67
              uint32_t match_opt_arg) :
68
    Key(FOREIGN_KEY, name_arg, &default_key_create_info, 0, cols), ref_table(table),
69
    ref_columns(ref_cols),
70
    delete_opt(delete_opt_arg),
71
    update_opt(update_opt_arg),
72
    match_opt(match_opt_arg)
73
  { }
74
75
934.2.20 by Jay Pipes
Move Foreign_key implementation into its own implementation file and out of session.cc
76
  /**
77
   * Constructs an (almost) deep copy of this foreign key. Only those
78
   * elements that are known to never change are not copied.
79
   * If out of memory, a partial copy is returned and an error is set
80
   * in Session.
81
   */
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
82
  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.
83
84
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.
85
  /**
934.2.20 by Jay Pipes
Move Foreign_key implementation into its own implementation file and out of session.cc
86
   * Used to make a clone of this object for ALTER/CREATE TABLE
87
   * 
88
   * @see comment for Key_part_spec::clone
89
   */
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
90
  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
91
  {
92
    return new (mem_root) Foreign_key(*this, mem_root);
93
  }
1089.1.6 by Brian Aker
Removed dead flag code, style cleanup in FK. Removed dead structs.
94
95
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
  /* 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.
97
  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.
98
};
99
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
100
} /* namespace drizzled */
101
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.
102
#endif /* DRIZZLED_FOREIGN_KEY_H */