1
/*****************************************************************************
3
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
5
This program is free software; you can redistribute it and/or modify it under
6
the terms of the GNU General Public License as published by the Free Software
7
Foundation; version 2 of the License.
9
This program is distributed in the hope that it will be useful, but WITHOUT
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
You should have received a copy of the GNU General Public License along with
14
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15
Place, Suite 330, Boston, MA 02111-1307 USA
17
*****************************************************************************/
19
/**************************************************//**
20
@file include/trx0trx.ic
23
Created 3/26/1996 Heikki Tuuri
24
*******************************************************/
26
/*************************************************************//**
27
Starts the transaction if it is not yet started. */
30
trx_start_if_not_started(
31
/*=====================*/
32
trx_t* trx) /*!< in: transaction */
34
ut_ad(trx->conc_state != TRX_COMMITTED_IN_MEMORY);
36
if (trx->conc_state == TRX_NOT_STARTED) {
38
trx_start(trx, ULINT_UNDEFINED);
42
/*************************************************************//**
43
Starts the transaction if it is not yet started. Assumes we have reserved
47
trx_start_if_not_started_low(
48
/*=========================*/
49
trx_t* trx) /*!< in: transaction */
51
ut_ad(trx->conc_state != TRX_COMMITTED_IN_MEMORY);
53
if (trx->conc_state == TRX_NOT_STARTED) {
55
trx_start_low(trx, ULINT_UNDEFINED);
59
/****************************************************************//**
60
Retrieves the error_info field from a trx.
61
@return the error info */
66
const trx_t* trx) /*!< in: trx object */
68
return(trx->error_info);
71
/*******************************************************************//**
72
Retrieves transacion's id, represented as unsigned long long.
73
@return transaction's id */
78
const trx_t* trx) /*!< in: transaction */
80
return((ullint)ut_conv_dulint_to_longlong(trx->id));
83
/*******************************************************************//**
84
Retrieves transaction's que state in a human readable string. The string
85
should not be free()'d or modified.
86
@return string in the data segment */
89
trx_get_que_state_str(
90
/*==================*/
91
const trx_t* trx) /*!< in: transaction */
93
/* be sure to adjust TRX_QUE_STATE_STR_MAX_LEN if you change this */
94
switch (trx->que_state) {
97
case TRX_QUE_LOCK_WAIT:
99
case TRX_QUE_ROLLING_BACK:
100
return("ROLLING BACK");
101
case TRX_QUE_COMMITTING:
102
return("COMMITTING");
108
/**********************************************************************//**
109
Determine if a transaction is a dictionary operation.
110
@return dictionary operation mode */
113
trx_get_dict_operation(
114
/*===================*/
115
const trx_t* trx) /*!< in: transaction */
117
enum trx_dict_op op = (enum trx_dict_op) trx->dict_operation;
121
case TRX_DICT_OP_NONE:
122
case TRX_DICT_OP_TABLE:
123
case TRX_DICT_OP_INDEX:
127
#endif /* UNIV_DEBUG */
128
return((enum trx_dict_op) UNIV_EXPECT(op, TRX_DICT_OP_NONE));
130
/**********************************************************************//**
131
Flag a transaction a dictionary operation. */
134
trx_set_dict_operation(
135
/*===================*/
136
trx_t* trx, /*!< in/out: transaction */
137
enum trx_dict_op op) /*!< in: operation, not
141
enum trx_dict_op old_op = trx_get_dict_operation(trx);
144
case TRX_DICT_OP_NONE:
147
case TRX_DICT_OP_TABLE:
149
case TRX_DICT_OP_NONE:
150
case TRX_DICT_OP_INDEX:
151
case TRX_DICT_OP_TABLE:
156
case TRX_DICT_OP_INDEX:
157
ut_ad(old_op == TRX_DICT_OP_NONE);
161
#endif /* UNIV_DEBUG */
163
trx->dict_operation = op;