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
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
#include "drizzled/plugin/transactional_storage_engine.h"
23
#include "drizzled/resource_context.h"
24
#include "drizzled/session.h"
38
static vector<TransactionalStorageEngine *> vector_of_transactional_engines;
40
TransactionalStorageEngine::TransactionalStorageEngine(const string name_arg,
41
const bitset<HTON_BIT_SIZE> &flags_arg,
42
bool two_phase_commit_arg)
43
: StorageEngine(name_arg, flags_arg),
44
two_phase_commit(two_phase_commit_arg)
48
TransactionalStorageEngine::~TransactionalStorageEngine()
52
void TransactionalStorageEngine::setTransactionReadWrite(Session& session)
54
ResourceContext *resource_context= session.getResourceContext(this);
57
When a storage engine method is called, the transaction must
58
have been started, unless it's a DDL call, for which the
59
storage engine starts the transaction internally, and commits
60
it internally, without registering in the ha_list.
61
Unfortunately here we can't know know for sure if the engine
62
has registered the transaction or not, so we must check.
64
if (resource_context->isStarted())
66
resource_context->markModifiedData();
72
This function should be called when MySQL sends rows of a SELECT result set
73
or the EOF mark to the client. It releases a possible adaptive hash index
74
S-latch held by session in InnoDB and also releases a possible InnoDB query
75
FIFO ticket to enter InnoDB. To save CPU time, InnoDB allows a session to
76
keep them over several calls of the InnoDB Cursor interface when a join
77
is executed. But when we let the control to pass to the client they have
78
to be released because if the application program uses mysql_use_result(),
79
it may deadlock on the S-latch if the application on another connection
80
performs another SQL query. In MySQL-4.1 this is even more important because
81
there a connection can have several SELECT queries open at the same time.
83
@param session the thread handle of the current connection
88
int TransactionalStorageEngine::releaseTemporaryLatches(Session *session)
90
for_each(vector_of_transactional_engines.begin(), vector_of_transactional_engines.end(),
91
bind2nd(mem_fun(&TransactionalStorageEngine::doReleaseTemporaryLatches),session));
95
int TransactionalStorageEngine::startConsistentSnapshot(Session *session)
97
for_each(vector_of_transactional_engines.begin(), vector_of_transactional_engines.end(),
98
bind2nd(mem_fun(&TransactionalStorageEngine::doStartConsistentSnapshot),
103
bool TransactionalStorageEngine::addPlugin(TransactionalStorageEngine *engine)
105
vector_of_transactional_engines.push_back(engine);
107
return StorageEngine::addPlugin(engine);
110
void TransactionalStorageEngine::removePlugin(TransactionalStorageEngine *)
112
vector_of_transactional_engines.clear();
115
} /* namespace plugin */
116
} /* namespace drizzled */