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
20
#ifndef DRIZZLED_HA_TRX_INFO_H
21
#define DRIZZLED_HA_TRX_INFO_H
24
Either statement transaction or normal transaction - related
25
thread-specific storage engine data.
27
If a storage engine participates in a statement/transaction,
28
an instance of this class is present in
29
session->transaction.{stmt|all}.ha_list. The addition to
30
{stmt|all}.ha_list is made by trans_register_ha().
32
When it's time to commit or rollback, each element of ha_list
33
is used to access storage engine's prepare()/commit()/rollback()
34
methods, and also to evaluate if a full two phase commit is
37
@sa General description of transaction handling in handler.cc.
43
/** Register this storage engine in the given transaction context. */
44
void register_ha(Session_TRANS *trans, handlerton *ht_arg)
48
assert(m_next == NULL);
51
m_flags= (int) TRX_READ_ONLY; /* Assume read-only at start. */
53
m_next= trans->ha_list;
57
/** Clear, prepare for reuse. */
65
Ha_trx_info() { reset(); }
67
void set_trx_read_write()
70
m_flags|= (int) TRX_READ_WRITE;
72
bool is_trx_read_write() const
75
return m_flags & (int) TRX_READ_WRITE;
77
bool is_started() const { return m_ht != NULL; }
78
/** Mark this transaction read-write if the argument is read-write. */
79
void coalesce_trx_with(const Ha_trx_info *stmt_trx)
82
Must be called only after the transaction has been started.
83
Can be called many times, e.g. when we have many
84
read-write statements in a transaction.
87
if (stmt_trx->is_trx_read_write())
90
Ha_trx_info *next() const
95
handlerton *ht() const
101
enum { TRX_READ_ONLY= 0, TRX_READ_WRITE= 1 };
102
/** Auxiliary, used for ha_list management */
105
Although a given Ha_trx_info instance is currently always used
106
for the same storage engine, 'ht' is not-NULL only when the
107
corresponding storage is a part of a transaction.
111
Transaction flags related to this engine.
112
Not-null only if this instance is a part of transaction.
113
May assume a combination of enum values above.
115
unsigned char m_flags;
118
#endif /* DRIZZLED_HA_TRX_INFO_H */