~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/resource_context.cc

* Renames Ha_trx_info to drizzled::ResourceContext
* Renames Sesssion_TRANS to drizzled::TransactionContext
* Replaces homegrown linked-lists of Ha_trx_info pointers
  with vector<drizzled::ResourceContext> operations
* Renames Session::getEngineInfo() to Session::getResourceContext()

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>
24
 
 
25
 
using namespace drizzled;
26
 
 
27
 
void Ha_trx_info::register_ha(Session_TRANS *trans,
28
 
                              plugin::StorageEngine *engine_arg)
 
21
#include "drizzled/resource_context.h"
 
22
 
 
23
#include <cassert>
 
24
 
 
25
using namespace std;
 
26
 
 
27
namespace drizzled
29
28
{
30
 
  assert(m_flags == 0);
31
 
  assert(m_engine == NULL);
32
 
  assert(m_next == NULL);
33
 
 
34
 
  m_engine= engine_arg;
35
 
  m_flags= (int) TRX_READ_ONLY; /* Assume read-only at start. */
36
 
 
37
 
  m_next= trans->ha_list;
38
 
  trans->ha_list= this;
39
 
}
40
 
 
41
29
 
42
30
/** Clear, prepare for reuse. */
43
 
void Ha_trx_info::reset()
44
 
{
45
 
  m_next= NULL;
46
 
  m_engine= NULL;
47
 
  m_flags= 0;
48
 
}
49
 
 
50
 
void Ha_trx_info::set_trx_read_write()
51
 
{
52
 
  assert(is_started());
53
 
  m_flags|= (int) TRX_READ_WRITE;
54
 
}
55
 
 
56
 
 
57
 
bool Ha_trx_info::is_trx_read_write() const
58
 
{
59
 
  assert(is_started());
60
 
  return m_flags & (int) TRX_READ_WRITE;
61
 
}
62
 
 
63
 
 
64
 
bool Ha_trx_info::is_started() const
65
 
{
66
 
  return m_engine != NULL;
67
 
}
68
 
 
 
31
void ResourceContext::reset()
 
32
{
 
33
  resource= NULL;
 
34
  modified_data= false;
 
35
}
 
36
 
 
37
void ResourceContext::set_trx_read_write()
 
38
{
 
39
  assert(is_started());
 
40
  modified_data= true;
 
41
}
 
42
 
 
43
 
 
44
bool ResourceContext::is_trx_read_write() const
 
45
{
 
46
  assert(is_started());
 
47
  return modified_data;
 
48
}
 
49
 
 
50
 
 
51
bool ResourceContext::is_started() const
 
52
{
 
53
  return resource != NULL;
 
54
}
69
55
 
70
56
/** Mark this transaction read-write if the argument is read-write. */
71
 
void Ha_trx_info::coalesce_trx_with(const Ha_trx_info *stmt_trx)
 
57
void ResourceContext::coalesce_trx_with(const ResourceContext *stmt_trx)
72
58
{
73
59
  /*
74
60
    Must be called only after the transaction has been started.
80
66
    set_trx_read_write();
81
67
}
82
68
 
83
 
 
84
 
Ha_trx_info *Ha_trx_info::next() const
85
 
{
86
 
  assert(is_started());
87
 
  return m_next;
88
 
}
89
 
 
90
 
 
91
 
plugin::StorageEngine *Ha_trx_info::engine() const
92
 
{
93
 
  assert(is_started());
94
 
  return m_engine;
95
 
}
 
69
} /* namespace drizzled */