~posulliv/drizzle/optimizer-style-cleanup

« back to all changes in this revision

Viewing changes to drizzled/resource_context.cc

  • Committer: Padraig O'Sullivan
  • Date: 2010-03-15 14:05:26 UTC
  • mfrom: (1237.9.99 staging)
  • Revision ID: osullivan.padraig@gmail.com-20100315140526-opbgwdwn6tfecdkq
MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 */
19
19
 
20
20
#include "config.h"
21
 
#include <drizzled/ha_trx_info.h>
22
 
#include <drizzled/plugin/storage_engine.h>
23
 
#include <drizzled/session.h>
 
21
#include "drizzled/resource_context.h"
 
22
 
 
23
#include <cassert>
 
24
 
 
25
using namespace std;
24
26
 
25
27
namespace drizzled
26
28
{
27
29
 
28
 
void Ha_trx_info::register_ha(Session_TRANS *trans,
29
 
                              plugin::StorageEngine *engine_arg)
30
 
{
31
 
  assert(m_flags == 0);
32
 
  assert(m_engine == NULL);
33
 
  assert(m_next == NULL);
34
 
 
35
 
  m_engine= engine_arg;
36
 
  m_flags= (int) TRX_READ_ONLY; /* Assume read-only at start. */
37
 
 
38
 
  m_next= trans->ha_list;
39
 
  trans->ha_list= this;
40
 
}
41
 
 
42
 
 
43
30
/** Clear, prepare for reuse. */
44
 
void Ha_trx_info::reset()
45
 
{
46
 
  m_next= NULL;
47
 
  m_engine= NULL;
48
 
  m_flags= 0;
49
 
}
50
 
 
51
 
void Ha_trx_info::set_trx_read_write()
52
 
{
53
 
  assert(is_started());
54
 
  m_flags|= (int) TRX_READ_WRITE;
55
 
}
56
 
 
57
 
 
58
 
bool Ha_trx_info::is_trx_read_write() const
59
 
{
60
 
  assert(is_started());
61
 
  return m_flags & (int) TRX_READ_WRITE;
62
 
}
63
 
 
64
 
 
65
 
bool Ha_trx_info::is_started() const
66
 
{
67
 
  return m_engine != NULL;
68
 
}
69
 
 
70
 
 
71
 
/** Mark this transaction read-write if the argument is read-write. */
72
 
void Ha_trx_info::coalesce_trx_with(const Ha_trx_info *stmt_trx)
 
31
void ResourceContext::reset()
 
32
{
 
33
  monitored= NULL;
 
34
  xa_resource_manager= NULL;
 
35
  trx_storage_engine= NULL;
 
36
  modified_data= false;
 
37
}
 
38
 
 
39
void ResourceContext::markModifiedData()
 
40
{
 
41
  assert(isStarted());
 
42
  modified_data= true;
 
43
}
 
44
 
 
45
bool ResourceContext::hasModifiedData() const
 
46
{
 
47
  assert(isStarted());
 
48
  return modified_data;
 
49
}
 
50
 
 
51
bool ResourceContext::isStarted() const
 
52
{
 
53
  return monitored != NULL;
 
54
}
 
55
 
 
56
void ResourceContext::coalesceWith(const ResourceContext *stmt_ctx)
73
57
{
74
58
  /*
75
59
    Must be called only after the transaction has been started.
76
60
    Can be called many times, e.g. when we have many
77
61
    read-write statements in a transaction.
78
62
  */
79
 
  assert(is_started());
80
 
  if (stmt_trx->is_trx_read_write())
81
 
    set_trx_read_write();
82
 
}
83
 
 
84
 
 
85
 
Ha_trx_info *Ha_trx_info::next() const
86
 
{
87
 
  assert(is_started());
88
 
  return m_next;
89
 
}
90
 
 
91
 
 
92
 
plugin::StorageEngine *Ha_trx_info::engine() const
93
 
{
94
 
  assert(is_started());
95
 
  return m_engine;
 
63
  assert(isStarted());
 
64
  if (stmt_ctx->hasModifiedData())
 
65
    markModifiedData();
96
66
}
97
67
 
98
68
} /* namespace drizzled */