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) 2009-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 |
||
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
21 |
#include <config.h> |
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/resource_context.h> |
|
25 |
#include <drizzled/session.h> |
|
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
26 |
|
27 |
#include <vector> |
|
28 |
#include <algorithm> |
|
29 |
#include <functional> |
|
30 |
||
2280.1.1
by Olaf van der Spek
Refactor |
31 |
namespace drizzled { |
32 |
namespace plugin { |
|
33 |
||
34 |
static std::vector<TransactionalStorageEngine*> g_engines; |
|
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
35 |
|
2353.2.8
by Stewart Smith
TransactionalStorageEngine: Function parameter 'name_arg' is passed by value. It could be passed by reference instead. |
36 |
TransactionalStorageEngine::TransactionalStorageEngine(const std::string &name_arg, |
1966.2.9
by Brian Aker
Remove the use of "using std" from the plugin interface .cc files. |
37 |
const std::bitset<HTON_BIT_SIZE> &flags_arg) |
1273.1.30
by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager |
38 |
: StorageEngine(name_arg, flags_arg) |
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
39 |
{
|
40 |
}
|
|
41 |
||
42 |
void TransactionalStorageEngine::setTransactionReadWrite(Session& session) |
|
43 |
{
|
|
2241.2.9
by Olaf van der Spek
Refactor |
44 |
ResourceContext& resource_context= session.getResourceContext(*this); |
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
45 |
|
46 |
/*
|
|
47 |
When a storage engine method is called, the transaction must
|
|
48 |
have been started, unless it's a DDL call, for which the
|
|
49 |
storage engine starts the transaction internally, and commits
|
|
50 |
it internally, without registering in the ha_list.
|
|
51 |
Unfortunately here we can't know know for sure if the engine
|
|
52 |
has registered the transaction or not, so we must check.
|
|
53 |
*/
|
|
2241.2.9
by Olaf van der Spek
Refactor |
54 |
if (resource_context.isStarted()) |
55 |
resource_context.markModifiedData(); |
|
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
56 |
}
|
57 |
||
58 |
/**
|
|
59 |
@details
|
|
60 |
This function should be called when MySQL sends rows of a SELECT result set
|
|
61 |
or the EOF mark to the client. It releases a possible adaptive hash index
|
|
62 |
S-latch held by session in InnoDB and also releases a possible InnoDB query
|
|
63 |
FIFO ticket to enter InnoDB. To save CPU time, InnoDB allows a session to
|
|
64 |
keep them over several calls of the InnoDB Cursor interface when a join
|
|
65 |
is executed. But when we let the control to pass to the client they have
|
|
2026.2.1
by Monty Taylor
Renamed things prefixed mysql_ or mysqld_ |
66 |
to be released because if the application program uses use_result(),
|
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
67 |
it may deadlock on the S-latch if the application on another connection
|
68 |
performs another SQL query. In MySQL-4.1 this is even more important because
|
|
69 |
there a connection can have several SELECT queries open at the same time.
|
|
70 |
||
71 |
@param session the thread handle of the current connection
|
|
72 |
||
73 |
@return
|
|
74 |
always 0
|
|
75 |
*/
|
|
2280.1.3
by Olaf van der Spek
Refactor |
76 |
void TransactionalStorageEngine::releaseTemporaryLatches(Session *session) |
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
77 |
{
|
2280.1.1
by Olaf van der Spek
Refactor |
78 |
BOOST_FOREACH(TransactionalStorageEngine* it, g_engines) |
79 |
it->doReleaseTemporaryLatches(session); |
|
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
80 |
}
|
81 |
||
1273.1.27
by Jay Pipes
Completes the work of removing the weirdness around transaction |
82 |
int TransactionalStorageEngine::notifyStartTransaction(Session *session, start_transaction_option_t options) |
83 |
{
|
|
2280.1.1
by Olaf van der Spek
Refactor |
84 |
if (g_engines.empty()) |
1273.1.27
by Jay Pipes
Completes the work of removing the weirdness around transaction |
85 |
return 0; |
2280.1.2
by Olaf van der Spek
Refactor |
86 |
std::vector<int> results; |
87 |
results.reserve(g_engines.size()); |
|
88 |
BOOST_FOREACH(TransactionalStorageEngine* it, g_engines) |
|
89 |
results.push_back(it->startTransaction(session, options)); |
|
90 |
return *std::max_element(results.begin(), results.end()); |
|
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
91 |
}
|
92 |
||
93 |
bool TransactionalStorageEngine::addPlugin(TransactionalStorageEngine *engine) |
|
94 |
{
|
|
2280.1.1
by Olaf van der Spek
Refactor |
95 |
g_engines.push_back(engine); |
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
96 |
return StorageEngine::addPlugin(engine); |
97 |
}
|
|
98 |
||
2280.1.1
by Olaf van der Spek
Refactor |
99 |
void TransactionalStorageEngine::removePlugin(TransactionalStorageEngine*) |
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
100 |
{
|
2280.1.1
by Olaf van der Spek
Refactor |
101 |
g_engines.clear(); |
1273.1.15
by Jay Pipes
This patch completes the first step in the splitting of |
102 |
}
|
103 |
||
104 |
} /* namespace plugin */ |
|
105 |
} /* namespace drizzled */ |