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) 2009-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
23
#include "drizzled/plugin/transactional_storage_engine.h"
24
#include "drizzled/resource_context.h"
25
#include "drizzled/session.h"
39
static vector<TransactionalStorageEngine *> vector_of_transactional_engines;
41
TransactionalStorageEngine::TransactionalStorageEngine(const string name_arg,
42
const bitset<HTON_BIT_SIZE> &flags_arg,
43
bool two_phase_commit_arg)
44
: StorageEngine(name_arg, flags_arg),
45
two_phase_commit(two_phase_commit_arg)
49
TransactionalStorageEngine::~TransactionalStorageEngine()
53
void TransactionalStorageEngine::setTransactionReadWrite(Session& session)
55
ResourceContext *resource_context= session.getResourceContext(this);
58
When a storage engine method is called, the transaction must
59
have been started, unless it's a DDL call, for which the
60
storage engine starts the transaction internally, and commits
61
it internally, without registering in the ha_list.
62
Unfortunately here we can't know know for sure if the engine
63
has registered the transaction or not, so we must check.
65
if (resource_context->isStarted())
67
resource_context->markModifiedData();
73
This function should be called when MySQL sends rows of a SELECT result set
74
or the EOF mark to the client. It releases a possible adaptive hash index
75
S-latch held by session in InnoDB and also releases a possible InnoDB query
76
FIFO ticket to enter InnoDB. To save CPU time, InnoDB allows a session to
77
keep them over several calls of the InnoDB Cursor interface when a join
78
is executed. But when we let the control to pass to the client they have
79
to be released because if the application program uses mysql_use_result(),
80
it may deadlock on the S-latch if the application on another connection
81
performs another SQL query. In MySQL-4.1 this is even more important because
82
there a connection can have several SELECT queries open at the same time.
84
@param session the thread handle of the current connection
89
int TransactionalStorageEngine::releaseTemporaryLatches(Session *session)
91
for_each(vector_of_transactional_engines.begin(), vector_of_transactional_engines.end(),
92
bind2nd(mem_fun(&TransactionalStorageEngine::doReleaseTemporaryLatches),session));
96
struct StartTransactionFunc :public unary_function<TransactionalStorageEngine *, int>
99
start_transaction_option_t options;
100
StartTransactionFunc(Session *in_session, start_transaction_option_t in_options) :
104
result_type operator()(argument_type engine) const
106
return engine->startTransaction(session, options);
110
int TransactionalStorageEngine::notifyStartTransaction(Session *session, start_transaction_option_t options)
112
if (vector_of_transactional_engines.empty())
116
StartTransactionFunc functor(session, options);
118
results.reserve(vector_of_transactional_engines.size());
119
transform(vector_of_transactional_engines.begin(),
120
vector_of_transactional_engines.end(),
123
return *max_element(results.begin(), results.end());
127
bool TransactionalStorageEngine::addPlugin(TransactionalStorageEngine *engine)
129
vector_of_transactional_engines.push_back(engine);
131
return StorageEngine::addPlugin(engine);
134
void TransactionalStorageEngine::removePlugin(TransactionalStorageEngine *)
136
vector_of_transactional_engines.clear();
139
} /* namespace plugin */
140
} /* namespace drizzled */