~drizzle-trunk/drizzle/development

575.1.3 by Monty Taylor
Moved some stuff out of handler.h.
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) 2010 Jay Pipes <jaypipes@gmail.com>
575.1.3 by Monty Taylor
Moved some stuff out of handler.h.
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
2234 by Brian Aker
Mass removal of ifdef/endif in favor of pragma once.
21
#pragma once
1273.1.10 by Jay Pipes
* Renames Ha_trx_info to drizzled::ResourceContext
22
2252.1.16 by Olaf van der Spek
Common fwd
23
#include <drizzled/common_fwd.h>
1273.1.10 by Jay Pipes
* Renames Ha_trx_info to drizzled::ResourceContext
24
2239.1.7 by Olaf van der Spek
Refactor includes
25
namespace drizzled {
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
26
575.1.3 by Monty Taylor
Moved some stuff out of handler.h.
27
/**
1273.1.12 by Jay Pipes
Cleanup style and documentation for ResourceContext and setTransactionReadWrite
28
 * Either statement transaction or normal transaction - related
1273.1.30 by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager
29
 * session-specific resource manager data state.
1273.1.12 by Jay Pipes
Cleanup style and documentation for ResourceContext and setTransactionReadWrite
30
 *
1273.1.30 by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager
31
 * If a resource manager participates in a statement/transaction,
1273.1.12 by Jay Pipes
Cleanup style and documentation for ResourceContext and setTransactionReadWrite
32
 * an instance of this class is present in
33
 * session->transaction.{stmt|all}.resource_contexts.
34
 *
1273.1.30 by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager
35
 * When it's time to commit or rollback, each resource context
36
 * is used to access the resource manager's prepare()/commit()/rollback()
1273.1.12 by Jay Pipes
Cleanup style and documentation for ResourceContext and setTransactionReadWrite
37
 * methods, and also to evaluate if a full two phase commit is
38
 * necessary.
39
 * 
40
 * @sa General description of transaction handling in drizzled/transaction_services.cc.
41
 */
1273.1.10 by Jay Pipes
* Renames Ha_trx_info to drizzled::ResourceContext
42
class ResourceContext
575.1.3 by Monty Taylor
Moved some stuff out of handler.h.
43
{
44
public:
1273.1.10 by Jay Pipes
* Renames Ha_trx_info to drizzled::ResourceContext
45
  ResourceContext() :
1273.1.30 by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager
46
    monitored(NULL),
47
    xa_resource_manager(NULL),
48
    trx_storage_engine(NULL),
1273.1.10 by Jay Pipes
* Renames Ha_trx_info to drizzled::ResourceContext
49
    modified_data(false)
50
  {}
575.1.3 by Monty Taylor
Moved some stuff out of handler.h.
51
52
  /** Clear, prepare for reuse. */
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
53
  void reset();
575.1.3 by Monty Taylor
Moved some stuff out of handler.h.
54
1273.1.12 by Jay Pipes
Cleanup style and documentation for ResourceContext and setTransactionReadWrite
55
  /**
56
   * Marks that the underlying resource manager
57
   * has modified data state.
58
   */
59
  void markModifiedData();
60
61
  /**
62
   * Returns true if the underlying resource manager
63
   * has modified data state.
64
   */
65
  bool hasModifiedData() const;
66
67
  /**
68
   * Returns true if the underlying resource
69
   * manager has registered with the transaction
70
   * manager for this transaction.
71
   */
72
  bool isStarted() const;
73
74
  /** 
75
   * Mark this context as modifying data if the argument has also modified data
76
   */
77
  void coalesceWith(const ResourceContext *stmt_trx);
78
79
  /**
1273.1.30 by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager
80
   * Returns the underlying descriptor for the resource
1273.1.12 by Jay Pipes
Cleanup style and documentation for ResourceContext and setTransactionReadWrite
81
   * this context tracks.
82
   */
1273.1.30 by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager
83
  plugin::MonitoredInTransaction *getMonitored() const
84
  {
85
    return monitored;
86
  }
87
88
  /**
89
   * Sets the underlying descriptor for the resource
90
   */
91
  void setMonitored(plugin::MonitoredInTransaction *in_monitored)
92
  {
93
    monitored= in_monitored;
94
  }
95
96
  /**
97
   * Returns the underlying transactional storage engine
98
   * this context tracks or NULL if not SQL transactional capable.
99
   */
100
  plugin::TransactionalStorageEngine *getTransactionalStorageEngine() const
101
  {
102
    return trx_storage_engine;
103
  }
104
105
  /**
106
   * Sets the underlying transactional storage engine
107
   */
108
  void setTransactionalStorageEngine(plugin::TransactionalStorageEngine *in_trx_storage_engine)
109
  {
110
    trx_storage_engine= in_trx_storage_engine;
111
  }
112
113
  /**
114
   * Returns the underlying XA resource manager
115
   * this context tracks or NULL if not XA capable.
116
   */
117
  plugin::XaResourceManager *getXaResourceManager() const
118
  {
119
    return xa_resource_manager;
120
  }
121
122
  /**
123
   * Sets the underlying xa resource manager
124
   */
125
  void setXaResourceManager(plugin::XaResourceManager *in_xa_resource_manager)
126
  {
127
    xa_resource_manager= in_xa_resource_manager;
1273.1.10 by Jay Pipes
* Renames Ha_trx_info to drizzled::ResourceContext
128
  }
575.1.3 by Monty Taylor
Moved some stuff out of handler.h.
129
private:
130
  /**
1273.1.30 by Jay Pipes
* Completes the blueprint for splitting the XA Resource Manager
131
   * A descriptor of the monitored resource
132
   */
133
  plugin::MonitoredInTransaction *monitored;
134
  /**
135
   * The XA resource manager or NULL if not XA capable.
136
   */
137
  plugin::XaResourceManager *xa_resource_manager;
138
  /**
139
   * The transactional storage engine or NULL if not SQL transaction capable.
140
   */
141
  plugin::TransactionalStorageEngine *trx_storage_engine;
575.1.3 by Monty Taylor
Moved some stuff out of handler.h.
142
  /**
1273.1.12 by Jay Pipes
Cleanup style and documentation for ResourceContext and setTransactionReadWrite
143
   * Whether the underlying resource manager has changed
144
   * some data state.
145
   */
1273.1.10 by Jay Pipes
* Renames Ha_trx_info to drizzled::ResourceContext
146
  bool modified_data;
575.1.3 by Monty Taylor
Moved some stuff out of handler.h.
147
};
148
1273.1.10 by Jay Pipes
* Renames Ha_trx_info to drizzled::ResourceContext
149
} /* namespace drizzled */
150