~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/ha_trx_info.h

Merged in latest plugin-slot-reorg.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2008 Sun Microsystems
 
5
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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
 
18
 */
 
19
 
 
20
#ifndef DRIZZLED_HA_TRX_INFO_H
 
21
#define DRIZZLED_HA_TRX_INFO_H
 
22
 
 
23
 
 
24
class Session_TRANS;
 
25
namespace drizzled
 
26
{
 
27
namespace plugin
 
28
{
 
29
class StorageEngine;
 
30
}
 
31
}
 
32
 
 
33
/**
 
34
  Either statement transaction or normal transaction - related
 
35
  thread-specific storage engine data.
 
36
 
 
37
  If a storage engine participates in a statement/transaction,
 
38
  an instance of this class is present in
 
39
  session->transaction.{stmt|all}.ha_list. The addition to
 
40
  {stmt|all}.ha_list is made by trans_register_ha().
 
41
 
 
42
  When it's time to commit or rollback, each element of ha_list
 
43
  is used to access storage engine's prepare()/commit()/rollback()
 
44
  methods, and also to evaluate if a full two phase commit is
 
45
  necessary.
 
46
 
 
47
  @sa General description of transaction handling in handler.cc.
 
48
*/
 
49
 
 
50
class Ha_trx_info
 
51
{
 
52
public:
 
53
  /** Register this storage engine in the given transaction context. */
 
54
  void register_ha(Session_TRANS *trans,
 
55
                   drizzled::plugin::StorageEngine *engine_arg);
 
56
 
 
57
  /** Clear, prepare for reuse. */
 
58
  void reset();
 
59
  Ha_trx_info() { reset(); }
 
60
 
 
61
  void set_trx_read_write();
 
62
  bool is_trx_read_write() const;
 
63
  bool is_started() const;
 
64
 
 
65
  /** Mark this transaction read-write if the argument is read-write. */
 
66
  void coalesce_trx_with(const Ha_trx_info *stmt_trx);
 
67
  Ha_trx_info *next() const;
 
68
  drizzled::plugin::StorageEngine *engine() const;
 
69
 
 
70
private:
 
71
  enum { TRX_READ_ONLY= 0, TRX_READ_WRITE= 1 };
 
72
  /** Auxiliary, used for ha_list management */
 
73
  Ha_trx_info *m_next;
 
74
  /**
 
75
    Although a given Ha_trx_info instance is currently always used
 
76
    for the same storage engine, 'engine' is not-NULL only when the
 
77
    corresponding storage is a part of a transaction.
 
78
  */
 
79
  drizzled::plugin::StorageEngine *m_engine;
 
80
  /**
 
81
    Transaction flags related to this engine.
 
82
    Not-null only if this instance is a part of transaction.
 
83
    May assume a combination of enum values above.
 
84
  */
 
85
  unsigned char       m_flags;
 
86
};
 
87
 
 
88
#endif /* DRIZZLED_HA_TRX_INFO_H */