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
22
* @file Transaction processing code
25
#ifndef DRIZZLED_TRANSACTION_SERVICES_H
26
#define DRIZZLED_TRANSACTION_SERVICES_H
31
/* some forward declarations needed */
34
class MonitoredInTransaction;
35
class XaResourceManager;
36
class TransactionalStorageEngine;
43
* This is a class which manages the XA transaction processing
46
class TransactionServices
52
TransactionServices() {}
56
* Returns the singleton instance of TransactionServices
58
static inline TransactionServices &singleton()
60
static TransactionServices transaction_services;
61
return transaction_services;
63
/* transactions: interface to plugin::StorageEngine functions */
64
int ha_commit_one_phase(Session *session, bool all);
65
int ha_rollback_trans(Session *session, bool all);
67
/* transactions: these functions never call plugin::StorageEngine functions directly */
68
int ha_commit_trans(Session *session, bool all);
69
int ha_autocommit_or_rollback(Session *session, int error);
72
int ha_rollback_to_savepoint(Session *session, NamedSavepoint &sv);
73
int ha_savepoint(Session *session, NamedSavepoint &sv);
74
int ha_release_savepoint(Session *session, NamedSavepoint &sv);
75
bool mysql_xa_recover(Session *session);
78
* Marks a storage engine as participating in a statement
83
* This method is idempotent
87
* This method should not be called more than once per resource
88
* per statement, and therefore should not need to be idempotent.
89
* Put in assert()s to test this.
91
* @param[in] Session pointer
92
* @param[in] Descriptor for the resource which will be participating
93
* @param[in] Pointer to the TransactionalStorageEngine resource
95
void registerResourceForStatement(Session *session,
96
plugin::MonitoredInTransaction *monitored,
97
plugin::TransactionalStorageEngine *engine);
100
* Marks an XA storage engine as participating in a statement
105
* This method is idempotent
109
* This method should not be called more than once per resource
110
* per statement, and therefore should not need to be idempotent.
111
* Put in assert()s to test this.
113
* @param[in] Session pointer
114
* @param[in] Descriptor for the resource which will be participating
115
* @param[in] Pointer to the TransactionalStorageEngine resource
116
* @param[in] Pointer to the XaResourceManager resource manager
118
void registerResourceForStatement(Session *session,
119
plugin::MonitoredInTransaction *monitored,
120
plugin::TransactionalStorageEngine *engine,
121
plugin::XaResourceManager *resource_manager);
124
* Registers a resource manager in the "normal" transaction.
128
* This method is idempotent and must be idempotent
129
* because it can be called both by the above
130
* TransactionServices::registerResourceForStatement(),
131
* which occurs at the beginning of each SQL statement,
132
* and also manually when a BEGIN WORK/START TRANSACTION
133
* statement is executed. If the latter case (BEGIN WORK)
134
* is called, then subsequent contained statement transactions
135
* will call this method as well.
139
* This method checks to see if the supplied resource
140
* is also registered in the statement transaction, and
141
* if not, registers the resource in the statement
142
* transaction. This happens ONLY when the user has
143
* called BEGIN WORK/START TRANSACTION, which is the only
144
* time when this method is called except from the
145
* TransactionServices::registerResourceForStatement method.
147
void registerResourceForTransaction(Session *session,
148
plugin::MonitoredInTransaction *monitored,
149
plugin::TransactionalStorageEngine *engine);
150
void registerResourceForTransaction(Session *session,
151
plugin::MonitoredInTransaction *monitored,
152
plugin::TransactionalStorageEngine *engine,
153
plugin::XaResourceManager *resource_manager);
156
} /* namespace drizzled */
158
#endif /* DRIZZLED_TRANSACTION_SERVICES_H */