~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/transactional_storage_engine.cc

Completes the work of removing the weirdness around transaction
boundaries in the storage engine API.

* Transactional storage engines are now all explicitly notified
  of the start of a new "normal" transaction in the new PSE API
  method plugin::TransactionalStorageEngine::doStartTransaction()
  This new method takes a start_transaction_option_t as one of its
  parameters, and passing this option allows the storage engine
  API to cleanly signal the start of a consistent snapshot (and in
  the future additional transaction attributes).  This meant the
  removal of the old start_consistent_snapshot() method.

* The TransactionServices component now fully manages the transaction
  boundaries, notification of transaction boundaries to participating
  resource managers (transactional storage engines)

Adds a simple test case (to be expanded with future XA work) for
transaction behaviour.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
4
 *  Copyright (C) 2008 Sun Microsystems
 
5
 *  Copyright (c) 2009-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
92
93
  return 0;
93
94
}
94
95
 
95
 
int TransactionalStorageEngine::startConsistentSnapshot(Session *session)
96
 
{
97
 
  for_each(vector_of_transactional_engines.begin(), vector_of_transactional_engines.end(),
98
 
           bind2nd(mem_fun(&TransactionalStorageEngine::doStartConsistentSnapshot),
99
 
                   session));
100
 
  return 0;
 
96
struct StartTransactionFunc :public unary_function<TransactionalStorageEngine *, int>
 
97
{
 
98
  Session *session;
 
99
  start_transaction_option_t options;
 
100
  StartTransactionFunc(Session *in_session, start_transaction_option_t in_options) :
 
101
    session(in_session),
 
102
    options(in_options)
 
103
  {}
 
104
  result_type operator()(argument_type engine) const
 
105
  {
 
106
    return engine->startTransaction(session, options);
 
107
  }
 
108
};
 
109
 
 
110
int TransactionalStorageEngine::notifyStartTransaction(Session *session, start_transaction_option_t options)
 
111
{
 
112
  if (vector_of_transactional_engines.empty())
 
113
    return 0;
 
114
  else
 
115
  {
 
116
    StartTransactionFunc functor(session, options);
 
117
    vector<int> results;
 
118
    results.reserve(vector_of_transactional_engines.size());
 
119
    transform(vector_of_transactional_engines.begin(),
 
120
              vector_of_transactional_engines.end(),
 
121
              results.begin(),
 
122
              functor);
 
123
    return *max_element(results.begin(), results.end());
 
124
  }
101
125
}
102
126
 
103
127
bool TransactionalStorageEngine::addPlugin(TransactionalStorageEngine *engine)