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., 51 Franklin
15
St, Fifth Floor, Boston, MA 02110-1301 USA
17
*****************************************************************************/
19
/**************************************************//**
20
@file include/trx0trx.ic
1
/******************************************************
23
6
Created 3/26/1996 Heikki Tuuri
24
7
*******************************************************/
26
/*************************************************************//**
9
/*****************************************************************
27
10
Starts the transaction if it is not yet started. */
30
13
trx_start_if_not_started(
31
14
/*=====================*/
32
trx_t* trx) /*!< in: transaction */
15
trx_t* trx) /* in: transaction */
34
17
ut_ad(trx->conc_state != TRX_COMMITTED_IN_MEMORY);
59
/******************************************************************//**
60
Checks if the commit id should be logged to the sys header file
61
@return TRUE if the commit id should be logged */
42
/*****************************************************************
43
Resets the new record lock info in a transaction struct. */
46
trx_reset_new_rec_lock_info(
47
/*========================*/
48
trx_t* trx) /* in: transaction struct */
50
trx->new_rec_locks[0] = NULL;
51
trx->new_rec_locks[1] = NULL;
54
/*****************************************************************
55
Registers that we have set a new record lock on an index. We only have space
56
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. */
60
trx_register_new_rec_lock(
61
/*======================*/
62
trx_t* trx, /* in: transaction struct */
63
dict_index_t* index) /* in: trx sets a new record lock on this
66
if (trx->new_rec_locks[0] == NULL) {
67
trx->new_rec_locks[0] = index;
72
if (trx->new_rec_locks[0] == index) {
77
if (trx->new_rec_locks[1] != NULL) {
82
trx->new_rec_locks[1] = index;
85
/*****************************************************************
86
Checks if trx has set a new record lock on an index. */
64
trx_log_commit_id(const trx_t* trx)
89
trx_new_rec_locks_contain(
90
/*======================*/
91
/* out: TRUE if trx has set a new record lock
93
trx_t* trx, /* in: transaction struct */
94
dict_index_t* index) /* in: index */
67
return (trx->log_commit_id);
96
return(trx->new_rec_locks[0] == index
97
|| trx->new_rec_locks[1] == index);
70
/****************************************************************//**
71
Retrieves the error_info field from a trx.
72
@return the error info */
100
/********************************************************************
101
Retrieves the error_info field from a trx. */
74
103
const dict_index_t*
75
104
trx_get_error_info(
76
105
/*===============*/
77
const trx_t* trx) /*!< in: trx object */
106
/* out: the error info */
107
const trx_t* trx) /* in: trx object */
79
109
return(trx->error_info);
82
/*******************************************************************//**
112
/***********************************************************************
113
Retrieves transacion's id, represented as unsigned long long. */
118
/* out: transaction's id */
119
const trx_t* trx) /* in: transaction */
121
return((ullint)ut_conv_dulint_to_longlong(trx->id));
124
/***********************************************************************
83
125
Retrieves transaction's que state in a human readable string. The string
84
should not be free()'d or modified.
85
@return string in the data segment */
126
should not be free()'d or modified. */
88
129
trx_get_que_state_str(
89
130
/*==================*/
90
const trx_t* trx) /*!< in: transaction */
131
/* out: string in the data segment */
132
const trx_t* trx) /* in: transaction */
92
134
/* be sure to adjust TRX_QUE_STATE_STR_MAX_LEN if you change this */
93
135
switch (trx->que_state) {
107
/**********************************************************************//**
108
Determine if a transaction is a dictionary operation.
109
@return dictionary operation mode */
149
/**************************************************************************
150
Determine if a transaction is a dictionary operation. */
112
153
trx_get_dict_operation(
113
154
/*===================*/
114
const trx_t* trx) /*!< in: transaction */
155
/* out: dictionary operation mode */
156
const trx_t* trx) /* in: transaction */
116
158
enum trx_dict_op op = (enum trx_dict_op) trx->dict_operation;
126
168
#endif /* UNIV_DEBUG */
127
169
return((enum trx_dict_op) UNIV_EXPECT(op, TRX_DICT_OP_NONE));
129
/**********************************************************************//**
171
/**************************************************************************
130
172
Flag a transaction a dictionary operation. */
133
175
trx_set_dict_operation(
134
176
/*===================*/
135
trx_t* trx, /*!< in/out: transaction */
136
enum trx_dict_op op) /*!< in: operation, not
177
trx_t* trx, /* in/out: transaction */
178
enum trx_dict_op op) /* in: operation, not
137
179
TRX_DICT_OP_NONE */
139
181
#ifdef UNIV_DEBUG