~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/transactional_storage_engine.h

* Completes the blueprint for splitting the XA Resource Manager
  API from the storage engine API:

We add a new plugin::XaResourceManager abstract interface class
which exposes the X/Open XA distributed transaction protocol for
resource managers.

We add a new plugin::MonitoredInTransaction base class from
which all plugins that need monitored by Drizzle's transaction
manager (drizzled::TransactionServices component) derive.

All plugin::StorageEngine's now derive from plugin::MonitoredInTransaction
since all storage engines a monitored by the transaction manager
and the Session keeps a "slot" available for keeping the engine's
per-session data state.  In a future patch, the transaction log's
XaApplier plugin will also derive from MonitoredInTransaction, as
the transaction log, in XA mode, is also monitored by Drizzle's
transaction manager and automatically enlisted in XA transactions.

* Updates all documentation in /drizzled/transaction_services.cc
  to accurately reflect Drizzle's new transaction management
  process and explicit transaction and statement boundaries.

* Kills off dead code:

  binlog_format_names
  ha_init()
  total_ha, total_ha_2pc (no longer necessary, as the above-mentioned
  abstract base classes provide all of this functionality)
  StorageEngine::slot (now plugin::MonitoredInTransaction::getId())
  TransactionalStorageEngine::two_phase_commit (same as above)

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
{
61
61
public:
62
62
  TransactionalStorageEngine(const std::string name_arg,
63
 
                             const std::bitset<HTON_BIT_SIZE> &flags_arg= HTON_NO_FLAGS,
64
 
                             bool two_phase_commit= false);
 
63
                             const std::bitset<HTON_BIT_SIZE> &flags_arg= HTON_NO_FLAGS);
65
64
 
66
65
  virtual ~TransactionalStorageEngine();
67
66
 
68
 
  int startTransaction(Session *session, start_transaction_option_t options)
 
67
  virtual int startTransaction(Session *session, start_transaction_option_t options)
69
68
  {
70
69
    TransactionServices &transaction_services= TransactionServices::singleton();
71
 
    transaction_services.registerResourceForTransaction(session, this);
 
70
    transaction_services.registerResourceForTransaction(session, this, this);
72
71
    return doStartTransaction(session, options);
73
72
  }
74
73
 
75
 
  void startStatement(Session *session)
 
74
  virtual void startStatement(Session *session)
76
75
  {
77
76
    TransactionServices &transaction_services= TransactionServices::singleton();
78
 
    transaction_services.registerResourceForStatement(session, this);
 
77
    transaction_services.registerResourceForStatement(session, this, this);
79
78
    doStartStatement(session);
80
79
  }
81
80
 
82
 
  int commit(Session *session, bool normal_transaction)
 
81
  virtual int commit(Session *session, bool normal_transaction)
83
82
  {
84
83
    return doCommit(session, normal_transaction);
85
84
  }
86
85
 
87
 
  int rollback(Session *session, bool normal_transaction)
 
86
  virtual int rollback(Session *session, bool normal_transaction)
88
87
  {
89
88
    return doRollback(session, normal_transaction);
90
89
  }
104
103
    return doReleaseSavepoint(session, sp);
105
104
  }
106
105
 
107
 
  bool hasTwoPhaseCommit()
108
 
  {
109
 
    return two_phase_commit;
 
106
  /* 
 
107
   * The below are simple virtual overrides for the plugin::MonitoredInTransaction
 
108
   * interface.
 
109
   */
 
110
  virtual bool participatesInSqlTransaction() const
 
111
  {
 
112
    return true; /* We DO participate in the SQL transaction */
 
113
  }
 
114
  virtual bool participatesInXaTransaction() const
 
115
  {
 
116
    return false; /* We DON'T participate in the XA transaction */
 
117
  }
 
118
  virtual bool alwaysRegisterForXaTransaction() const
 
119
  {
 
120
    return false;
110
121
  }
111
122
 
112
123
  /** 
213
224
    (void) session;
214
225
    return 0;
215
226
  }
216
 
  const bool two_phase_commit;
217
227
};
218
228
 
219
229
} /* namespace plugin */