~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/resource_context.h

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
 
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
5
 *  Copyright (C) 2010 Jay Pipes <jaypipes@gmail.com>
5
6
 *
6
7
 *  This program is free software; you can redistribute it and/or modify
7
8
 *  it under the terms of the GNU General Public License as published by
27
28
 
28
29
namespace plugin
29
30
{
30
 
class StorageEngine;
 
31
class MonitoredInTransaction;
 
32
class TransactionalStorageEngine;
 
33
class XaResourceManager;
31
34
}
32
35
 
33
36
/**
34
37
 * Either statement transaction or normal transaction - related
35
 
 * session-specific storage engine data.
 
38
 * session-specific resource manager data state.
36
39
 *
37
 
 * If a storage engine participates in a statement/transaction,
 
40
 * If a resource manager participates in a statement/transaction,
38
41
 * an instance of this class is present in
39
42
 * session->transaction.{stmt|all}.resource_contexts.
40
43
 *
41
 
 * When it's time to commit or rollback, each element of ha_list
42
 
 * is used to access resource manager's prepare()/commit()/rollback()
 
44
 * When it's time to commit or rollback, each resource context
 
45
 * is used to access the resource manager's prepare()/commit()/rollback()
43
46
 * methods, and also to evaluate if a full two phase commit is
44
47
 * necessary.
45
48
 * 
49
52
{
50
53
public:
51
54
  ResourceContext() :
52
 
    resource(NULL),
 
55
    monitored(NULL),
 
56
    xa_resource_manager(NULL),
 
57
    trx_storage_engine(NULL),
53
58
    modified_data(false)
54
59
  {}
55
60
 
81
86
  void coalesceWith(const ResourceContext *stmt_trx);
82
87
 
83
88
  /**
84
 
   * Returns the underlying resource manager
 
89
   * Returns the underlying descriptor for the resource
85
90
   * this context tracks.
86
91
   */
87
 
  drizzled::plugin::StorageEngine *getResource() const
88
 
  {
89
 
    return resource;
90
 
  }
91
 
 
92
 
  /**
93
 
   * Sets the underlying resource
94
 
   */
95
 
  void setResource(drizzled::plugin::StorageEngine *in_engine)
96
 
  {
97
 
    resource= in_engine;
 
92
  plugin::MonitoredInTransaction *getMonitored() const
 
93
  {
 
94
    return monitored;
 
95
  }
 
96
 
 
97
  /**
 
98
   * Sets the underlying descriptor for the resource
 
99
   */
 
100
  void setMonitored(plugin::MonitoredInTransaction *in_monitored)
 
101
  {
 
102
    monitored= in_monitored;
 
103
  }
 
104
 
 
105
  /**
 
106
   * Returns the underlying transactional storage engine
 
107
   * this context tracks or NULL if not SQL transactional capable.
 
108
   */
 
109
  plugin::TransactionalStorageEngine *getTransactionalStorageEngine() const
 
110
  {
 
111
    return trx_storage_engine;
 
112
  }
 
113
 
 
114
  /**
 
115
   * Sets the underlying transactional storage engine
 
116
   */
 
117
  void setTransactionalStorageEngine(plugin::TransactionalStorageEngine *in_trx_storage_engine)
 
118
  {
 
119
    trx_storage_engine= in_trx_storage_engine;
 
120
  }
 
121
 
 
122
  /**
 
123
   * Returns the underlying XA resource manager
 
124
   * this context tracks or NULL if not XA capable.
 
125
   */
 
126
  plugin::XaResourceManager *getXaResourceManager() const
 
127
  {
 
128
    return xa_resource_manager;
 
129
  }
 
130
 
 
131
  /**
 
132
   * Sets the underlying xa resource manager
 
133
   */
 
134
  void setXaResourceManager(plugin::XaResourceManager *in_xa_resource_manager)
 
135
  {
 
136
    xa_resource_manager= in_xa_resource_manager;
98
137
  }
99
138
private:
100
139
  /**
101
 
    Although a given ResourceContext instance is always used
102
 
    for the same resource manager, 'resource' is not-NULL only when the
103
 
    corresponding resource manager is a part of a transaction.
104
 
  */
105
 
  drizzled::plugin::StorageEngine *resource;
 
140
   * A descriptor of the monitored resource
 
141
   */
 
142
  plugin::MonitoredInTransaction *monitored;
 
143
  /**
 
144
   * The XA resource manager or NULL if not XA capable.
 
145
   */
 
146
  plugin::XaResourceManager *xa_resource_manager;
 
147
  /**
 
148
   * The transactional storage engine or NULL if not SQL transaction capable.
 
149
   */
 
150
  plugin::TransactionalStorageEngine *trx_storage_engine;
106
151
  /**
107
152
   * Whether the underlying resource manager has changed
108
153
   * some data state.