Commit 843f38fc authored by unknown's avatar unknown
Browse files

This is a code cleanup patch for X/Open XA.


BitKeeper/deleted/.del-xa.h~4021d7e61ff515b:
  Delete: innobase/include/xa.h
innobase/include/trx0trx.h:
  Change xa.h to trx0ha.h.
innobase/include/trx0undo.h:
  Split TRX_UNDO_DICT_OPERATION field to two fiels: first contains
  TRX_UNDO_XID_EXISTS flag which is TRUE if log header contains
  X/Open XA XID and the second one contains TRX_UNDO_DICT_TRANS
  flag which is TRUE if the transaction is dictionary transaction.
innobase/trx/trx0trx.c:
  Remove unnecessary and erroneus code from prepare. Add some 
  informative printouts of prepared transactions.
innobase/trx/trx0undo.c:
  Split TRX_UNDO_DICT_OPERATION field to two fields: the first field
  is TRX_UNDO_XID_EXISTS flag which is true if the log header contains
  X/Open XA XID and the second field is TRX_UNDO_DICT_TRANS flag
  which is true if the transaction was a dictionary transaction.
sql/ha_innodb.cc:
  Code cleanup.
parent 739b630e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ Created 3/26/1996 Heikki Tuuri
#include "que0types.h"
#include "mem0mem.h"
#include "read0types.h"
#include "xa.h"
#include "trx0xa.h"

extern ulint	trx_n_mysql_transactions;

+5 −3
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@ Created 3/26/1996 Heikki Tuuri
#include "mtr0mtr.h"
#include "trx0sys.h"
#include "page0types.h"
#include "xa.h"
#include "trx0xa.h"

/***************************************************************************
Builds a roll pointer dulint. */
@@ -469,7 +469,10 @@ page of an update undo log segment. */
					log start, and therefore this is not
					necessarily the same as this log
					header end offset */
#define	TRX_UNDO_DICT_OPERATION	20	/* TRUE if the transaction is a table
#define	TRX_UNDO_XID_EXISTS	20	/* TRUE if undo log header includes
					X/Open XA transaction identification
					XID */
#define	TRX_UNDO_DICT_TRANS	21	/* TRUE if the transaction is a table
					create, index create, or drop
					transaction: in recovery
					the transaction cannot be rolled back
@@ -492,7 +495,6 @@ page of an update undo log segment. */
#define	TRX_UNDO_XA_BQUAL_LEN	(TRX_UNDO_XA_TRID_LEN + 4)
#define	TRX_UNDO_XA_XID		(TRX_UNDO_XA_BQUAL_LEN + 4)
#define	TRX_UNDO_XA_LEN		(TRX_UNDO_XA_XID + XIDDATASIZE)
#define	TRX_UNDO_XA_EXISTS	256

/*-------------------------------------------------------------*/
#define	TRX_UNDO_LOG_HDR_SIZE	(TRX_UNDO_XA_LEN)
+0 −0

File moved.

+12 −11
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ Created 3/26/1996 Heikki Tuuri
#include "thr0loc.h"
#include "btr0sea.h"
#include "os0proc.h"
#include "xa.h"
#include "trx0xa.h"

/* Copy of the prototype for innobase_mysql_print_thd: this
copy MUST be equal to the one in mysql/sql/ha_innodb.cc ! */
@@ -1740,10 +1740,6 @@ trx_prepare_off_kernel(
		undo = trx->update_undo;

		if (undo) {
			mutex_enter(&kernel_mutex);
			trx->no = trx_sys_get_new_trx_no();
			
			mutex_exit(&kernel_mutex);

			/* It is not necessary to obtain trx->undo_mutex here
			because only a single OS thread is allowed to do the
@@ -1781,11 +1777,6 @@ trx_prepare_off_kernel(

		mutex_exit(&kernel_mutex);
	
		if (trx->insert_undo != NULL) {

			trx_undo_insert_cleanup(trx);
		}

		/* Write the log to the log files AND flush them to disk */

		/*-------------------------------------*/
@@ -1860,6 +1851,16 @@ trx_recover_for_mysql(
	while (trx) {
		if (trx->conc_state == TRX_PREPARED) {
			xid_list[num_of_transactions] = trx->xid;

			fprintf(stderr,
"InnoDB: Transaction %lu %lu in prepared state after recovery\n",
				(ulong) ut_dulint_get_high(trx->id),
				(ulong) ut_dulint_get_low(trx->id));

			fprintf(stderr,
"InnoDB: Transaction contains changes to %lu rows\n",
			(ulong)ut_conv_dulint_to_longlong(trx->undo_no));

			num_of_transactions++;
		
			if ((uint)num_of_transactions == len ) {
+30 −33
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ Created 3/26/1996 Heikki Tuuri
#include "srv0srv.h"
#include "trx0rec.h"
#include "trx0purge.h"
#include "xa.h"
#include "trx0xa.h"

/* How should the old versions in the history list be managed?
   ----------------------------------------------------------
@@ -537,17 +537,18 @@ trx_undo_header_create(
	/* If X/Open XID exits in the log header we store a
	flag of it in upper byte of dict operation flag. */

	if ( xid == NULL ||  xid->formatID == -1) {
		mach_write_to_2(log_hdr + TRX_UNDO_DICT_OPERATION, FALSE);
	if (xid != NULL ||  xid->formatID != -1) {
		mach_write_to_1(log_hdr + TRX_UNDO_XID_EXISTS, TRUE);
	} else {
		mach_write_to_2(log_hdr + TRX_UNDO_DICT_OPERATION, 
					TRX_UNDO_XA_EXISTS|FALSE);
		mach_write_to_1(log_hdr + TRX_UNDO_XID_EXISTS, FALSE);
	}

	mach_write_to_1(log_hdr + TRX_UNDO_DICT_TRANS, FALSE);
	mach_write_to_2(log_hdr + TRX_UNDO_NEXT_LOG, 0);
	mach_write_to_2(log_hdr + TRX_UNDO_PREV_LOG, prev_log);

	/* Write X/Open XA transaction identification if exists */

	if (xid && xid->formatID != -1) {
		trx_undo_write_xid(log_hdr, xid);
	}
@@ -659,18 +660,18 @@ trx_undo_insert_header_reuse(
	mach_write_to_8(log_hdr + TRX_UNDO_TRX_ID, trx_id);
	mach_write_to_2(log_hdr + TRX_UNDO_LOG_START, new_free);

	/* If X/Open XID exits in the log header we store a
	flag of it in upper byte of dict operation flag and
	then write the xid. */
	/* If X/Open XID exits in the log header we store it
	to log header. */

	if (xid && xid->formatID != -1) {
		mach_write_to_2(log_hdr + TRX_UNDO_DICT_OPERATION, 
					TRX_UNDO_XA_EXISTS|FALSE);
		mach_write_to_1(log_hdr + TRX_UNDO_XID_EXISTS, TRUE); 

		trx_undo_write_xid(log_hdr, xid);
	} else {
		mach_write_to_2(log_hdr + TRX_UNDO_DICT_OPERATION, FALSE);
		mach_write_to_1(log_hdr + TRX_UNDO_XID_EXISTS, FALSE);
	}

	mach_write_to_1(log_hdr + TRX_UNDO_DICT_TRANS, FALSE);
	trx_undo_insert_header_reuse_log(undo_page, trx_id, mtr);
	
	return(free);
@@ -1203,7 +1204,7 @@ trx_undo_mem_create_at_db_start(
	page_t*		last_page;
	trx_undo_rec_t*	rec;
	XID		xid;
	ulint		dict_op;
	ibool		xid_exists = FALSE;

	if (id >= TRX_RSEG_N_SLOTS) {
		fprintf(stderr,
@@ -1227,9 +1228,8 @@ trx_undo_mem_create_at_db_start(

	trx_id = mtr_read_dulint(undo_header + TRX_UNDO_TRX_ID, mtr);

	dict_op = mtr_read_ulint(
				undo_header + TRX_UNDO_DICT_OPERATION,
							MLOG_2BYTES, mtr);
	xid_exists = mtr_read_ulint(undo_header + TRX_UNDO_XID_EXISTS, 
						MLOG_1BYTE, mtr);

	/* Read X/Open XA transaction identification if exists or
	set it to NULL. */
@@ -1237,7 +1237,7 @@ trx_undo_mem_create_at_db_start(
	memset(&xid, 0, sizeof(xid));
	xid.formatID = -1;

	if (dict_op & TRX_UNDO_XA_EXISTS) {
	if (xid_exists == TRUE) {
		trx_undo_read_xid(undo_header, &xid);
	} 

@@ -1248,7 +1248,10 @@ trx_undo_mem_create_at_db_start(
	
	mutex_exit(&(rseg->mutex));

	undo->dict_operation = (dict_op & 1);
	undo->dict_operation = 	mtr_read_ulint(
					undo_header + TRX_UNDO_DICT_TRANS,
					MLOG_1BYTE, mtr);

	undo->table_id = mtr_read_dulint(undo_header + TRX_UNDO_TABLE_ID, mtr);
	undo->state = state;
	undo->size = flst_get_len(seg_header + TRX_UNDO_PAGE_LIST, mtr);
@@ -1609,18 +1612,9 @@ trx_undo_mark_as_dict_operation(
	
	hdr_page = trx_undo_page_get(undo->space, undo->hdr_page_no, mtr);

	/* Mark X/Open XA XID if it is not NULL to dict operation bit */

	if ( trx->xid.formatID == -1) {
	mlog_write_ulint(hdr_page + undo->hdr_offset + 
				TRX_UNDO_DICT_OPERATION,
				trx->dict_operation, MLOG_2BYTES, mtr);
	} else {
		mlog_write_ulint(hdr_page + undo->hdr_offset + 
				TRX_UNDO_DICT_OPERATION,
				trx->dict_operation | TRX_UNDO_XA_EXISTS, 
				MLOG_2BYTES, mtr);
	}
				TRX_UNDO_DICT_TRANS,
				trx->dict_operation, MLOG_1BYTE, mtr);

	mlog_write_dulint(hdr_page + undo->hdr_offset + TRX_UNDO_TABLE_ID,
			trx->table_id, mtr);	
@@ -1788,6 +1782,9 @@ trx_undo_set_state_at_prepare(
	offset = mach_read_from_2(seg_hdr + TRX_UNDO_LAST_LOG);
        undo_header = undo_page + offset;

	mlog_write_ulint(undo_header + TRX_UNDO_XID_EXISTS,
					TRUE, MLOG_1BYTE, mtr);

	trx_undo_write_xid(undo_header, &undo->xid);	
	return(undo_page);
}
Loading