~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/transactional_storage_engine.h

Completes the work of removing the weirdness around transaction
boundaries in the storage engine API.

* Transactional storage engines are now all explicitly notified
  of the start of a new "normal" transaction in the new PSE API
  method plugin::TransactionalStorageEngine::doStartTransaction()
  This new method takes a start_transaction_option_t as one of its
  parameters, and passing this option allows the storage engine
  API to cleanly signal the start of a consistent snapshot (and in
  the future additional transaction attributes).  This meant the
  removal of the old start_consistent_snapshot() method.

* The TransactionServices component now fully manages the transaction
  boundaries, notification of transaction boundaries to participating
  resource managers (transactional storage engines)

Adds a simple test case (to be expanded with future XA work) for
transaction behaviour.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
4
 *  Copyright (C) 2008 Sun Microsystems
 
5
 *  Copyright (c) 2009-2010 Jay Pipes <jaypipes@gmail.com>
5
6
 *
6
7
 *  This program is free software; you can redistribute it and/or modify
7
8
 *  it under the terms of the GNU General Public License as published by
20
21
#ifndef DRIZZLED_PLUGIN_TRANSACTIONAL_STORAGE_ENGINE_H
21
22
#define DRIZZLED_PLUGIN_TRANSACTIONAL_STORAGE_ENGINE_H
22
23
 
 
24
#include "drizzled/definitions.h" /* for start_transaction_option_t */
23
25
#include "drizzled/plugin/storage_engine.h"
24
26
#include "drizzled/transaction_services.h"
25
27
 
63
65
 
64
66
  virtual ~TransactionalStorageEngine();
65
67
 
 
68
  int startTransaction(Session *session, start_transaction_option_t options)
 
69
  {
 
70
    TransactionServices &transaction_services= TransactionServices::singleton();
 
71
    transaction_services.registerResourceForTransaction(session, this);
 
72
    return doStartTransaction(session, options);
 
73
  }
 
74
 
66
75
  void startStatement(Session *session)
67
76
  {
68
77
    TransactionServices &transaction_services= TransactionServices::singleton();
103
112
  /** 
104
113
   * The below static class methods wrap the interaction
105
114
   * of the vector of transactional storage engines.
106
 
   *
107
 
   * @todo kill these. they belong in TransactionServices.
108
115
   */
 
116
  static int notifyStartTransaction(Session *session, start_transaction_option_t options);
109
117
  /**
110
118
   * @todo Kill this one entirely.  It's implementation, not interface...
111
119
   */
112
120
  static int releaseTemporaryLatches(Session *session);
113
 
  static int startConsistentSnapshot(Session *session);
114
121
 
115
122
  /* Class Methods for operating on plugin */
116
123
  static bool addPlugin(plugin::TransactionalStorageEngine *engine);
121
128
 
122
129
  /*
123
130
   * Indicates to a storage engine the start of a
 
131
   * new SQL transaction.  This is called ONLY in the following
 
132
   * scenarios:
 
133
   *
 
134
   * 1) An explicit BEGIN WORK/START TRANSACTION is called
 
135
   * 2) After an explicit COMMIT AND CHAIN is called
 
136
   * 3) After an explicit ROLLBACK AND RELEASE is called
 
137
   * 4) When in AUTOCOMMIT mode and directly before a new
 
138
   *    SQL statement is started.
 
139
   *
 
140
   * Engines should typically use the doStartStatement()
 
141
   * and doEndStatement() methods to manage transaction state,
 
142
   * since the kernel ALWAYS notifies engines at the start
 
143
   * and end of statement transactions and at the end of the
 
144
   * normal transaction by calling doCommit() or doRollback().
 
145
   */
 
146
  virtual int doStartTransaction(Session *session, start_transaction_option_t options)
 
147
  {
 
148
    (void) session;
 
149
    (void) options;
 
150
    return 0;
 
151
  }
 
152
 
 
153
  /*
 
154
   * Indicates to a storage engine the start of a
124
155
   * new SQL statement.
125
156
   */
126
157
  virtual void doStartStatement(Session *session)