~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/foreign_key.h

* Fixes drizzled's atomics:

- fetch_and_add() was actually add_and_fetch() - fixed to have both methods correct
- compare_and_swap() was incorrect for all traits classes.  Fixed to return a bool
true only when the supplied value is actually swapped
- fixes increment() and decrement() methods and operator+=() in outer atomics class
template to call proper add_and_fetch() methods on traits classes
- Now that above are fixed, removed the hacks in Query_id and TransactionLog to
have query ID and the new transactoin ID start properly at 1.

* Transaction messages sent over replication stream now use
a real transaction ID, managed by drizzled::TransactionServices.  Previously, 
the Query_id was being used, resulting in SELECT statements incrementing the
transaction ID.

* Added a test case to ensure that DDL ops are given a transaction ID and SELECT
ops do not increment the transaction ID.

The transaction ID will be paired with a channel ID to become the global
transaction identifier.  ReplicationServices will manage the pairing of
channel and transaction ID and understand how far a particular subscriber
node has applied.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
21
21
#ifndef DRIZZLED_FOREIGN_KEY_H
22
22
#define DRIZZLED_FOREIGN_KEY_H
23
23
 
24
 
#include <drizzled/memory/sql_alloc.h>
25
 
#include <drizzled/key.h>
26
 
#include <drizzled/key_part_spec.h>
27
 
#include <drizzled/sql_list.h>
28
 
#include <drizzled/cursor.h> /* for default_key_create_info */
29
 
#include <drizzled/message/table.pb.h>
 
24
#include "drizzled/memory/sql_alloc.h"
 
25
#include "drizzled/key.h"
 
26
#include "drizzled/key_part_spec.h"
 
27
#include "drizzled/sql_list.h"
 
28
#include "drizzled/cursor.h" /* for default_key_create_info */
30
29
 
31
30
namespace drizzled
32
31
{
36
35
 
37
36
namespace memory { class Root; }
38
37
 
39
 
void add_foreign_key_to_table_message(
40
 
    message::Table *table_message,
41
 
    const char* fkey_name,
42
 
    List<Key_part_spec> &cols,
43
 
    Table_ident *table,
44
 
    List<Key_part_spec> &ref_cols,
45
 
    message::Table::ForeignKeyConstraint::ForeignKeyOption delete_opt_arg,
46
 
    message::Table::ForeignKeyConstraint::ForeignKeyOption update_opt_arg,
47
 
    message::Table::ForeignKeyConstraint::ForeignKeyMatchOption match_opt_arg);
48
 
 
49
 
 
50
38
class Foreign_key: public Key 
51
39
{
52
40
public:
 
41
  enum fk_match_opt 
 
42
  {
 
43
    FK_MATCH_UNDEF, 
 
44
    FK_MATCH_FULL, 
 
45
    FK_MATCH_PARTIAL, 
 
46
    FK_MATCH_SIMPLE
 
47
  };
 
48
  enum fk_option 
 
49
  {
 
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
 
56
  };
 
57
 
53
58
  Table_ident *ref_table;
54
59
  List<Key_part_spec> ref_columns;
55
 
 
56
 
  message::Table::ForeignKeyConstraint::ForeignKeyOption delete_opt;
57
 
  message::Table::ForeignKeyConstraint::ForeignKeyOption update_opt;
58
 
  message::Table::ForeignKeyConstraint::ForeignKeyMatchOption match_opt;
59
 
 
 
60
  uint32_t delete_opt, update_opt, match_opt;
60
61
  Foreign_key(const LEX_STRING &name_arg,
61
62
              List<Key_part_spec> &cols,
62
63
              Table_ident *table,
63
64
              List<Key_part_spec> &ref_cols,
64
 
              message::Table::ForeignKeyConstraint::ForeignKeyOption delete_opt_arg,
65
 
              message::Table::ForeignKeyConstraint::ForeignKeyOption update_opt_arg,
66
 
              message::Table::ForeignKeyConstraint::ForeignKeyMatchOption match_opt_arg) :
 
65
              uint32_t delete_opt_arg,
 
66
              uint32_t update_opt_arg,
 
67
              uint32_t match_opt_arg) :
67
68
    Key(FOREIGN_KEY, name_arg, &default_key_create_info, 0, cols), ref_table(table),
68
69
    ref_columns(ref_cols),
69
70
    delete_opt(delete_opt_arg),