~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/ha_trx_info.cc

  • Committer: Devananda
  • Date: 2009-07-04 01:55:13 UTC
  • mto: (1086.10.1 length-plugin)
  • mto: This revision was merged to the branch mainline in revision 1095.
  • Revision ID: deva@myst-20090704015513-gtqliazxtfm7sdvf
refactored function/length into plugin/length

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, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
21
 
#include "drizzled/resource_context.h"
22
 
 
23
 
#include <cassert>
24
 
 
25
 
using namespace std;
26
 
 
27
 
namespace drizzled
 
20
#include <drizzled/server_includes.h>
 
21
#include <drizzled/ha_trx_info.h>
 
22
#include <drizzled/plugin/storage_engine.h>
 
23
#include <drizzled/session.h>
 
24
 
 
25
 
 
26
void Ha_trx_info::register_ha(Session_TRANS *trans, StorageEngine *engine_arg)
28
27
{
 
28
  assert(m_flags == 0);
 
29
  assert(m_engine == NULL);
 
30
  assert(m_next == NULL);
 
31
 
 
32
  m_engine= engine_arg;
 
33
  m_flags= (int) TRX_READ_ONLY; /* Assume read-only at start. */
 
34
 
 
35
  m_next= trans->ha_list;
 
36
  trans->ha_list= this;
 
37
}
 
38
 
29
39
 
30
40
/** Clear, prepare for reuse. */
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)
 
41
void Ha_trx_info::reset()
 
42
{
 
43
  m_next= NULL;
 
44
  m_engine= NULL;
 
45
  m_flags= 0;
 
46
}
 
47
 
 
48
void Ha_trx_info::set_trx_read_write()
 
49
{
 
50
  assert(is_started());
 
51
  m_flags|= (int) TRX_READ_WRITE;
 
52
}
 
53
 
 
54
 
 
55
bool Ha_trx_info::is_trx_read_write() const
 
56
{
 
57
  assert(is_started());
 
58
  return m_flags & (int) TRX_READ_WRITE;
 
59
}
 
60
 
 
61
 
 
62
bool Ha_trx_info::is_started() const
 
63
{
 
64
  return m_engine != NULL;
 
65
}
 
66
 
 
67
 
 
68
/** Mark this transaction read-write if the argument is read-write. */
 
69
void Ha_trx_info::coalesce_trx_with(const Ha_trx_info *stmt_trx)
57
70
{
58
71
  /*
59
72
    Must be called only after the transaction has been started.
60
73
    Can be called many times, e.g. when we have many
61
74
    read-write statements in a transaction.
62
75
  */
63
 
  assert(isStarted());
64
 
  if (stmt_ctx->hasModifiedData())
65
 
    markModifiedData();
66
 
}
67
 
 
68
 
} /* namespace drizzled */
 
76
  assert(is_started());
 
77
  if (stmt_trx->is_trx_read_write())
 
78
    set_trx_read_write();
 
79
}
 
80
 
 
81
 
 
82
Ha_trx_info *Ha_trx_info::next() const
 
83
{
 
84
  assert(is_started());
 
85
  return m_next;
 
86
}
 
87
 
 
88
 
 
89
StorageEngine *Ha_trx_info::engine() const
 
90
{
 
91
  assert(is_started());
 
92
  return m_engine;
 
93
}