drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
foreign_key.h
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, Inc.
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#pragma once
22
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>
29
30namespace drizzled {
31
32void add_foreign_key_to_table_message(
33 message::Table *table_message,
34 const char* fkey_name,
36 Table_ident *table,
37 List<Key_part_spec> &ref_cols,
38 message::Table::ForeignKeyConstraint::ForeignKeyOption delete_opt_arg,
39 message::Table::ForeignKeyConstraint::ForeignKeyOption update_opt_arg,
40 message::Table::ForeignKeyConstraint::ForeignKeyMatchOption match_opt_arg);
41
42
43class Foreign_key : public Key
44{
45public:
46 Table_ident *ref_table;
47 List<Key_part_spec> ref_columns;
48
49 message::Table::ForeignKeyConstraint::ForeignKeyOption delete_opt;
50 message::Table::ForeignKeyConstraint::ForeignKeyOption update_opt;
51 message::Table::ForeignKeyConstraint::ForeignKeyMatchOption match_opt;
52
53 Foreign_key(str_ref name_arg,
55 Table_ident *table,
56 List<Key_part_spec> &ref_cols,
57 message::Table::ForeignKeyConstraint::ForeignKeyOption delete_opt_arg,
58 message::Table::ForeignKeyConstraint::ForeignKeyOption update_opt_arg,
59 message::Table::ForeignKeyConstraint::ForeignKeyMatchOption match_opt_arg) :
60 Key(FOREIGN_KEY, name_arg, &default_key_create_info, 0, cols), ref_table(table),
61 ref_columns(ref_cols),
62 delete_opt(delete_opt_arg),
63 update_opt(update_opt_arg),
64 match_opt(match_opt_arg)
65 { }
66
67
74 Foreign_key(const Foreign_key &rhs, memory::Root *mem_root);
75
76 /* Used to validate foreign key options */
77 bool validate(List<CreateField> &table_fields);
78};
79
80} /* namespace drizzled */
TODO: Rename this file - func.h is stupid.