1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
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.
|
5 |
* Copyright (C) 2010 Jay Pipes <jaypipes@gmail.com>
|
|
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
6 |
*
|
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.
|
|
10 |
*
|
|
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.
|
|
15 |
*
|
|
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
|
|
19 |
*/
|
|
20 |
||
2234
by Brian Aker
Mass removal of ifdef/endif in favor of pragma once. |
21 |
#pragma once
|
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
22 |
|
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
23 |
#include <drizzled/plugin/transactional_storage_engine.h> |
24 |
#include <drizzled/plugin/xa_resource_manager.h> |
|
25 |
#include <drizzled/visibility.h> |
|
2119.4.1
by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by |
26 |
|
2252.1.25
by Olaf van der Spek
Common fwd |
27 |
namespace drizzled { |
28 |
namespace plugin { |
|
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
29 |
|
30 |
/**
|
|
31 |
* A type of storage engine which supports distributed
|
|
32 |
* transactions in the XA protocol.
|
|
1273.1.30
by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager |
33 |
*
|
34 |
* The real XA resource manager interface is in the
|
|
35 |
* plugin::XaResourceManager class. We would extend
|
|
36 |
* XaResourceManager from plugin::Plugin but unfortunately
|
|
37 |
* that would lead to member name ambiguity (because plugin::Plugin
|
|
38 |
* has member data). So, in this case, TransactionalStorageEngine
|
|
39 |
* inherits from plugin::Plugin and XaResourceManager is a pure
|
|
40 |
* virtual abstract base class with the X/Open XA distributed
|
|
41 |
* transaction protocol interface for resource managers.
|
|
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
42 |
*/
|
2119.4.1
by Monty Taylor
Turns on -fvisibility=hidden by default. Symbols intended to be used by |
43 |
class DRIZZLED_API XaStorageEngine : |
44 |
public TransactionalStorageEngine, |
|
45 |
public XaResourceManager |
|
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
46 |
{
|
47 |
public: |
|
2353.2.2
by Stewart Smith
XaStorageEngine: Function parameter 'name_arg' is passed by value. It could be passed by reference instead. |
48 |
XaStorageEngine(const std::string &name_arg, |
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
49 |
const std::bitset<HTON_BIT_SIZE> &flags_arg= HTON_NO_FLAGS); |
50 |
||
51 |
virtual ~XaStorageEngine(); |
|
52 |
||
1273.1.30
by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager |
53 |
int startTransaction(Session *session, start_transaction_option_t options) |
54 |
{
|
|
2318.6.62
by Olaf van der Spek
Refactor |
55 |
TransactionServices::registerResourceForTransaction(*session, this, this, this); |
1273.1.30
by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager |
56 |
return doStartTransaction(session, options); |
57 |
}
|
|
58 |
||
59 |
void startStatement(Session *session) |
|
60 |
{
|
|
2318.6.62
by Olaf van der Spek
Refactor |
61 |
TransactionServices::registerResourceForStatement(*session, this, this, this); |
1273.1.30
by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager |
62 |
doStartStatement(session); |
63 |
}
|
|
64 |
||
65 |
/*
|
|
66 |
* The below are simple virtual overrides for the plugin::MonitoredInTransaction
|
|
67 |
* interface.
|
|
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
68 |
*/
|
1273.1.30
by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager |
69 |
bool participatesInSqlTransaction() const |
70 |
{
|
|
71 |
return true; /* We DO participate in the SQL transaction */ |
|
72 |
}
|
|
73 |
bool participatesInXaTransaction() const |
|
74 |
{
|
|
75 |
return true; /* We DO participate in the XA transaction */ |
|
76 |
}
|
|
77 |
bool alwaysRegisterForXaTransaction() const |
|
78 |
{
|
|
79 |
return false; /* We only register in the XA transaction if the engine's data is modified */ |
|
80 |
}
|
|
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
81 |
|
82 |
/* Class Methods for operating on plugin */
|
|
83 |
static bool addPlugin(plugin::XaStorageEngine *engine); |
|
84 |
static void removePlugin(plugin::XaStorageEngine *engine); |
|
85 |
||
86 |
private: |
|
1273.1.30
by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager |
87 |
/*
|
88 |
* Indicates to a storage engine the start of a
|
|
89 |
* new SQL transaction. This is called ONLY in the following
|
|
90 |
* scenarios:
|
|
91 |
*
|
|
92 |
* 1) An explicit BEGIN WORK/START TRANSACTION is called
|
|
93 |
* 2) After an explicit COMMIT AND CHAIN is called
|
|
94 |
* 3) After an explicit ROLLBACK AND RELEASE is called
|
|
95 |
* 4) When in AUTOCOMMIT mode and directly before a new
|
|
96 |
* SQL statement is started.
|
|
97 |
*
|
|
98 |
* Engines should typically use the doStartStatement()
|
|
99 |
* and doEndStatement() methods to manage transaction state,
|
|
100 |
* since the kernel ALWAYS notifies engines at the start
|
|
101 |
* and end of statement transactions and at the end of the
|
|
102 |
* normal transaction by calling doCommit() or doRollback().
|
|
103 |
*/
|
|
104 |
virtual int doStartTransaction(Session *session, start_transaction_option_t options) |
|
105 |
{
|
|
106 |
(void) session; |
|
107 |
(void) options; |
|
108 |
return 0; |
|
109 |
}
|
|
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
110 |
|
1273.1.30
by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager |
111 |
/*
|
112 |
* Indicates to a storage engine the start of a
|
|
113 |
* new SQL statement.
|
|
114 |
*/
|
|
115 |
virtual void doStartStatement(Session *session) |
|
116 |
{
|
|
117 |
(void) session; |
|
118 |
}
|
|
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
119 |
};
|
120 |
||
121 |
} /* namespace plugin */ |
|
122 |
} /* namespace drizzled */ |
|
123 |