trx0trx.ic 2.35 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/******************************************************
The transaction

(c) 1996 Innobase Oy

Created 3/26/1996 Heikki Tuuri
*******************************************************/

/*****************************************************************
Starts the transaction if it is not yet started. */
UNIV_INLINE
void
trx_start_if_not_started(
/*=====================*/
	trx_t*	trx)	/* in: transaction */
16
{
17 18 19 20 21 22 23
	ut_ad(trx->conc_state != TRX_COMMITTED_IN_MEMORY);

	if (trx->conc_state == TRX_NOT_STARTED) {

		trx_start(trx, ULINT_UNDEFINED);
	}
}
24 25 26 27 28 29 30 31 32

/*****************************************************************
Starts the transaction if it is not yet started. Assumes we have reserved
the kernel mutex! */
UNIV_INLINE
void
trx_start_if_not_started_low(
/*=========================*/
	trx_t*	trx)	/* in: transaction */
33
{
34 35 36 37 38 39 40 41
	ut_ad(trx->conc_state != TRX_COMMITTED_IN_MEMORY);

	if (trx->conc_state == TRX_NOT_STARTED) {

		trx_start_low(trx, ULINT_UNDEFINED);
	}
}

heikki@hundin.mysql.fi's avatar
heikki@hundin.mysql.fi committed
42 43 44 45 46 47 48 49 50 51 52 53 54
/*****************************************************************
Resets the new record lock info in a transaction struct. */
UNIV_INLINE
void
trx_reset_new_rec_lock_info(
/*========================*/
	trx_t*	trx)	/* in: transaction struct */
{
	trx->new_rec_locks[0] = NULL;
	trx->new_rec_locks[1] = NULL;
}

/*****************************************************************
55 56
Registers that we have set a new record lock on an index. We only have space
to store 2 indexes! If this is called to store more than 2 indexes after
57
trx_reset_new_rec_lock_info(), then this function does nothing. */
heikki@hundin.mysql.fi's avatar
heikki@hundin.mysql.fi committed
58 59 60 61 62 63
UNIV_INLINE
void
trx_register_new_rec_lock(
/*======================*/
	trx_t*		trx,	/* in: transaction struct */
	dict_index_t*	index)	/* in: trx sets a new record lock on this
64
				index */
heikki@hundin.mysql.fi's avatar
heikki@hundin.mysql.fi committed
65 66 67
{
	if (trx->new_rec_locks[0] == NULL) {
		trx->new_rec_locks[0] = index;
68

heikki@hundin.mysql.fi's avatar
heikki@hundin.mysql.fi committed
69 70 71
		return;
	}

72 73 74 75 76 77 78 79 80
	if (trx->new_rec_locks[0] == index) {

		return;
	}

	if (trx->new_rec_locks[1] != NULL) {

		return;
	}
heikki@hundin.mysql.fi's avatar
heikki@hundin.mysql.fi committed
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96

	trx->new_rec_locks[1] = index;
}

/*****************************************************************
Checks if trx has set a new record lock on an index. */
UNIV_INLINE
ibool
trx_new_rec_locks_contain(
/*======================*/
				/* out: TRUE if trx has set a new record lock
				on index */
	trx_t*		trx,	/* in: transaction struct */
	dict_index_t*	index)	/* in: index */
{
	return(trx->new_rec_locks[0] == index
97
		|| trx->new_rec_locks[1] == index);
heikki@hundin.mysql.fi's avatar
heikki@hundin.mysql.fi committed
98
}