1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
5
* Copyright (c) 2010 Jay Pipes <jaypipes@gmail.com>
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; version 2 of the License.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
#ifndef DRIZZLED_PLUGIN_XA_STORAGE_ENGINE_H
22
#define DRIZZLED_PLUGIN_XA_STORAGE_ENGINE_H
24
#include "drizzled/plugin/transactional_storage_engine.h"
25
#include "drizzled/plugin/xa_resource_manager.h"
36
* A type of storage engine which supports distributed
37
* transactions in the XA protocol.
39
* The real XA resource manager interface is in the
40
* plugin::XaResourceManager class. We would extend
41
* XaResourceManager from plugin::Plugin but unfortunately
42
* that would lead to member name ambiguity (because plugin::Plugin
43
* has member data). So, in this case, TransactionalStorageEngine
44
* inherits from plugin::Plugin and XaResourceManager is a pure
45
* virtual abstract base class with the X/Open XA distributed
46
* transaction protocol interface for resource managers.
48
class XaStorageEngine :public TransactionalStorageEngine,
49
public XaResourceManager
52
XaStorageEngine(const std::string name_arg,
53
const std::bitset<HTON_BIT_SIZE> &flags_arg= HTON_NO_FLAGS);
55
virtual ~XaStorageEngine();
57
int startTransaction(Session *session, start_transaction_option_t options)
59
TransactionServices &transaction_services= TransactionServices::singleton();
60
transaction_services.registerResourceForTransaction(session, this, this, this);
61
return doStartTransaction(session, options);
64
void startStatement(Session *session)
66
TransactionServices &transaction_services= TransactionServices::singleton();
67
transaction_services.registerResourceForStatement(session, this, this, this);
68
doStartStatement(session);
72
* The below are simple virtual overrides for the plugin::MonitoredInTransaction
75
bool participatesInSqlTransaction() const
77
return true; /* We DO participate in the SQL transaction */
79
bool participatesInXaTransaction() const
81
return true; /* We DO participate in the XA transaction */
83
bool alwaysRegisterForXaTransaction() const
85
return false; /* We only register in the XA transaction if the engine's data is modified */
88
/* Class Methods for operating on plugin */
89
static bool addPlugin(plugin::XaStorageEngine *engine);
90
static void removePlugin(plugin::XaStorageEngine *engine);
94
* Indicates to a storage engine the start of a
95
* new SQL transaction. This is called ONLY in the following
98
* 1) An explicit BEGIN WORK/START TRANSACTION is called
99
* 2) After an explicit COMMIT AND CHAIN is called
100
* 3) After an explicit ROLLBACK AND RELEASE is called
101
* 4) When in AUTOCOMMIT mode and directly before a new
102
* SQL statement is started.
104
* Engines should typically use the doStartStatement()
105
* and doEndStatement() methods to manage transaction state,
106
* since the kernel ALWAYS notifies engines at the start
107
* and end of statement transactions and at the end of the
108
* normal transaction by calling doCommit() or doRollback().
110
virtual int doStartTransaction(Session *session, start_transaction_option_t options)
118
* Indicates to a storage engine the start of a
121
virtual void doStartStatement(Session *session)
127
} /* namespace plugin */
128
} /* namespace drizzled */
130
#endif /* DRIZZLED_PLUGIN_XA_STORAGE_ENGINE_H */