~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
2252.1.14 by Olaf van der Spek
Common fwd
30
namespace drizzled {
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.
31
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
32
void add_foreign_key_to_table_message(
33
    message::Table *table_message,
34
    const char* fkey_name,
35
    List<Key_part_spec> &cols,
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
2440.2.9 by Olaf van der Spek
Refactor
43
class Foreign_key : public Key 
1237.9.4 by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file.
44
{
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.
45
public:
46
  Table_ident *ref_table;
47
  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
48
49
  message::Table::ForeignKeyConstraint::ForeignKeyOption delete_opt;
50
  message::Table::ForeignKeyConstraint::ForeignKeyOption update_opt;
51
  message::Table::ForeignKeyConstraint::ForeignKeyMatchOption match_opt;
52
2445.1.11 by Olaf van der Spek
Use str_ref
53
  Foreign_key(str_ref name_arg,
1089.1.6 by Brian Aker
Removed dead flag code, style cleanup in FK. Removed dead structs.
54
              List<Key_part_spec> &cols,
55
              Table_ident *table,
56
              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
57
              message::Table::ForeignKeyConstraint::ForeignKeyOption delete_opt_arg,
58
              message::Table::ForeignKeyConstraint::ForeignKeyOption update_opt_arg,
59
              message::Table::ForeignKeyConstraint::ForeignKeyMatchOption match_opt_arg) :
1089.1.6 by Brian Aker
Removed dead flag code, style cleanup in FK. Removed dead structs.
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
934.2.20 by Jay Pipes
Move Foreign_key implementation into its own implementation file and out of session.cc
68
  /**
69
   * Constructs an (almost) deep copy of this foreign key. Only those
70
   * elements that are known to never change are not copied.
71
   * If out of memory, a partial copy is returned and an error is set
72
   * in Session.
73
   */
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
74
  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.
75
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.
76
  /* 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.
77
  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.
78
};
79
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
80
} /* namespace drizzled */