~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/xid.h

This patch significantly reworks the way that
savepoints are handled:

1) Memory management

   Removes the trans_prealloc_size and trans_block_size
   variables which set up a separate mem_root for storing
   "savepoint data".  Without the binlog, this separate
   memory root, which by default allocated 1M *for every
   single transaction regardless of whether savepoints
   were used*, was not useful any more.

2) No more DIY linked lists of SAVEPOINT pointers

   The Session::transaction struct used to contain a 
   member "savepoints" which was of type pointer to
   SAVEPOINT.  This has been replaced with an STL
   std::deque<drizzled::NamedSavepoint> and the pointeri and
   linked-list fiddling is gone, replaced with STL conventions.

3) SAVEPOINT struct is now drizzled::NamedSavepoint

   The SAVEPOINT struct has been converted to an STL container-
   safe class called drizzled::NamedSavepoint.

4) RollbackToSavepoint, Savepoint, and ReleaseSavepoint

   RollbackToSavepoint, Savepoint, and ReleaseSavepoint classes
   have had their logic revamped and documented.

5) The innodb.test case had (has?) an error in it

   The innodb.test case was testing a wrong assertion that
   a ROLLBACK TO SAVEPOINT x; should result in an error if
   called twice in a row.  This is incorrect behaviour.  If
   a ROLLBACK TO SAVEPOINT x; is executed, the savepoint x
   should stay on the top of the savepoint stack.

6) XID and XID_STATE classes made STL-container-safe

   Places proper initializer lists and constructors for
   the XID and XID_STATE classes and removes use of the
   horrible memset(this, 0, sizeof(*this)); usage.

7) The various savepoint-handling routines use references

   A switch was made to the various savepoint-handling routines
   of TransactionServices to ensure only references to a 
   drizzled::NamedSavepoint were being passed, and not void pointers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#ifndef DRIZZLED_XID_H
21
21
#define DRIZZLED_XID_H
22
22
 
 
23
#include <cstring>
 
24
 
23
25
extern uint32_t server_id;
24
26
 
25
27
/**
49
51
  long bqual_length;
50
52
  char data[XIDDATASIZE];  // not \0-terminated !
51
53
 
52
 
  XID();
 
54
  XID() :
 
55
    formatID(-1), /* -1 == null */
 
56
    gtrid_length(0),
 
57
    bqual_length(0)
 
58
  {
 
59
    memset(data, 0, XIDDATASIZE);
 
60
  }
53
61
  bool eq(XID *xid);
54
62
  bool eq(long g, long b, const char *d);
55
63
  void set(XID *xid);
87
95
#define MIN_XID_LIST_SIZE  128
88
96
#define MAX_XID_LIST_SIZE  (1024*128)
89
97
 
90
 
typedef struct st_xid_state {
 
98
class XID_STATE 
 
99
{
 
100
public:
 
101
  XID_STATE() :
 
102
    xid(),
 
103
    xa_state(XA_NOTR),
 
104
    in_session(false)
 
105
  {}
91
106
  /* For now, this is only used to catch duplicated external xids */
92
107
  XID  xid;                           // transaction identifier
93
108
  enum xa_states xa_state;            // used by external XA only
94
109
  bool in_session;
95
 
} XID_STATE;
 
110
};
96
111
 
97
112
bool xid_cache_init(void);
98
113
void xid_cache_free(void);