Commit e1f13fb2 authored by unknown's avatar unknown

Required changes to support recovery of X/Open XA in InnoDB.


innobase/lock/lock0lock.c:
  Add prepared state to concurrency states in lock validate.
innobase/trx/trx0trx.c:
  Prepared transactions are active transactions in file based word.
sql/ha_innodb.cc:
  Add full support of X/Open XA to InnoDB.
parent a7401bf7
...@@ -4417,8 +4417,9 @@ lock_table_queue_validate( ...@@ -4417,8 +4417,9 @@ lock_table_queue_validate(
lock = UT_LIST_GET_FIRST(table->locks); lock = UT_LIST_GET_FIRST(table->locks);
while (lock) { while (lock) {
ut_a(((lock->trx)->conc_state == TRX_ACTIVE) ut_a((lock->trx)->conc_state == TRX_ACTIVE ||
|| ((lock->trx)->conc_state == TRX_COMMITTED_IN_MEMORY)); (lock->trx)->conc_state == TRX_PREPARED ||
(lock->trx)->conc_state == TRX_COMMITTED_IN_MEMORY);
if (!lock_get_wait(lock)) { if (!lock_get_wait(lock)) {
...@@ -4464,9 +4465,9 @@ lock_rec_queue_validate( ...@@ -4464,9 +4465,9 @@ lock_rec_queue_validate(
lock = lock_rec_get_first(rec); lock = lock_rec_get_first(rec);
while (lock) { while (lock) {
ut_a(lock->trx->conc_state == TRX_ACTIVE ut_a(lock->trx->conc_state == TRX_ACTIVE ||
|| lock->trx->conc_state lock->trx->conc_state == TRX_PREPARED ||
== TRX_COMMITTED_IN_MEMORY); lock->trx->conc_state == TRX_COMMITTED_IN_MEMORY);
ut_a(trx_in_trx_list(lock->trx)); ut_a(trx_in_trx_list(lock->trx));
...@@ -4518,8 +4519,10 @@ lock_rec_queue_validate( ...@@ -4518,8 +4519,10 @@ lock_rec_queue_validate(
lock = lock_rec_get_first(rec); lock = lock_rec_get_first(rec);
while (lock) { while (lock) {
ut_a(lock->trx->conc_state == TRX_ACTIVE ut_a(lock->trx->conc_state == TRX_ACTIVE ||
|| lock->trx->conc_state == TRX_COMMITTED_IN_MEMORY); lock->trx->conc_state == TRX_PREPARED ||
lock->trx->conc_state == TRX_COMMITTED_IN_MEMORY);
ut_a(trx_in_trx_list(lock->trx)); ut_a(trx_in_trx_list(lock->trx));
if (index) { if (index) {
...@@ -4600,8 +4603,9 @@ loop: ...@@ -4600,8 +4603,9 @@ loop:
} }
ut_a(trx_in_trx_list(lock->trx)); ut_a(trx_in_trx_list(lock->trx));
ut_a(lock->trx->conc_state == TRX_ACTIVE ut_a(lock->trx->conc_state == TRX_ACTIVE ||
|| lock->trx->conc_state == TRX_COMMITTED_IN_MEMORY); lock->trx->conc_state == TRX_PREPARED ||
lock->trx->conc_state == TRX_COMMITTED_IN_MEMORY);
for (i = nth_bit; i < lock_rec_get_n_bits(lock); i++) { for (i = nth_bit; i < lock_rec_get_n_bits(lock); i++) {
......
...@@ -1612,12 +1612,10 @@ trx_print( ...@@ -1612,12 +1612,10 @@ trx_print(
fputs(", not started", f); fputs(", not started", f);
break; break;
case TRX_ACTIVE: case TRX_ACTIVE:
case TRX_PREPARED:
fprintf(f, ", ACTIVE %lu sec", fprintf(f, ", ACTIVE %lu sec",
(ulong)difftime(time(NULL), trx->start_time)); (ulong)difftime(time(NULL), trx->start_time));
break; break;
case TRX_PREPARED:
fputs(", PREPARED", f);
break;
case TRX_COMMITTED_IN_MEMORY: case TRX_COMMITTED_IN_MEMORY:
fputs(", COMMITTED IN MEMORY", f); fputs(", COMMITTED IN MEMORY", f);
break; break;
......
...@@ -156,18 +156,18 @@ static int innobase_rollback_to_savepoint(THD* thd, void *savepoint); ...@@ -156,18 +156,18 @@ static int innobase_rollback_to_savepoint(THD* thd, void *savepoint);
static int innobase_savepoint(THD* thd, void *savepoint); static int innobase_savepoint(THD* thd, void *savepoint);
static handlerton innobase_hton = { static handlerton innobase_hton = {
0, /* slot */ 0, /* slot */
sizeof(trx_named_savept_t), /* savepoint size. TODO: use it */ sizeof(trx_named_savept_t), /* savepoint size. TODO: use it */
innobase_close_connection, innobase_close_connection,
innobase_savepoint, innobase_savepoint,
innobase_rollback_to_savepoint, innobase_rollback_to_savepoint,
NULL, /* savepoint_release */ NULL, /* savepoint_release */
innobase_commit, innobase_commit, /* commit */
innobase_rollback, innobase_rollback, /* rollback */
innobase_xa_prepare, //makes flush_block_commit test to fail innobase_xa_prepare, /* prepare */
NULL, /* recover */ innobase_xa_recover, /* recover */
NULL, /* commit_by_xid */ innobase_commit_by_xid, /* commit_by_xid */
NULL, /* rollback_by_xid */ innobase_rollback_by_xid, /* rollback_by_xid */
}; };
/********************************************************************* /*********************************************************************
...@@ -6019,36 +6019,4 @@ int innobase_rollback_by_xid( ...@@ -6019,36 +6019,4 @@ int innobase_rollback_by_xid(
} }
} }
/***********************************************************************
This function is used to test commit/rollback of XA transactions */
int innobase_xa_end(
/*================*/
THD* thd) /* in: MySQL thread handle of the user for whom
transactions should be recovered */
{
DBUG_ENTER("innobase_xa_end");
XID trx_list[100];
int trx_num, trx_num_max = 100;
int i;
XID xid;
while((trx_num = innobase_xa_recover(trx_list, trx_num_max))) {
for(i=0;i < trx_num; i++) {
xid = trx_list[i];
if ( i % 2) {
innobase_commit_by_xid(&xid);
} else {
innobase_rollback_by_xid(&xid);
}
}
}
free(trx_list);
DBUG_RETURN(0);
}
#endif /* HAVE_INNOBASE_DB */ #endif /* HAVE_INNOBASE_DB */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment