641.2.2
by Monty Taylor
InnoDB Plugin 1.0.3 |
1 |
/*****************************************************************************
|
2 |
||
3 |
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
|
|
4 |
||
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.
|
|
8 |
||
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.
|
|
12 |
||
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
|
|
16 |
||
17 |
*****************************************************************************/
|
|
18 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
19 |
/**************************************************//**
|
20 |
@file include/trx0trx.ic
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
21 |
The transaction
|
22 |
||
23 |
Created 3/26/1996 Heikki Tuuri
|
|
24 |
*******************************************************/
|
|
25 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
26 |
/*************************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
27 |
Starts the transaction if it is not yet started. */
|
28 |
UNIV_INLINE
|
|
29 |
void
|
|
30 |
trx_start_if_not_started( |
|
31 |
/*=====================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
32 |
trx_t* trx) /*!< in: transaction */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
33 |
{
|
34 |
ut_ad(trx->conc_state != TRX_COMMITTED_IN_MEMORY); |
|
35 |
||
36 |
if (trx->conc_state == TRX_NOT_STARTED) { |
|
37 |
||
38 |
trx_start(trx, ULINT_UNDEFINED); |
|
39 |
} |
|
40 |
}
|
|
41 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
42 |
/*************************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
43 |
Starts the transaction if it is not yet started. Assumes we have reserved
|
44 |
the kernel mutex! */
|
|
45 |
UNIV_INLINE
|
|
46 |
void
|
|
47 |
trx_start_if_not_started_low( |
|
48 |
/*=========================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
49 |
trx_t* trx) /*!< in: transaction */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
50 |
{
|
51 |
ut_ad(trx->conc_state != TRX_COMMITTED_IN_MEMORY); |
|
52 |
||
53 |
if (trx->conc_state == TRX_NOT_STARTED) { |
|
54 |
||
55 |
trx_start_low(trx, ULINT_UNDEFINED); |
|
56 |
} |
|
57 |
}
|
|
58 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
59 |
/****************************************************************//**
|
60 |
Retrieves the error_info field from a trx.
|
|
61 |
@return the error info */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
62 |
UNIV_INLINE
|
63 |
const dict_index_t* |
|
64 |
trx_get_error_info( |
|
65 |
/*===============*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
66 |
const trx_t* trx) /*!< in: trx object */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
67 |
{
|
68 |
return(trx->error_info); |
|
69 |
}
|
|
70 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
71 |
/*******************************************************************//**
|
72 |
Retrieves transacion's id, represented as unsigned long long.
|
|
73 |
@return transaction's id */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
74 |
UNIV_INLINE
|
75 |
ullint
|
|
76 |
trx_get_id( |
|
77 |
/*=======*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
78 |
const trx_t* trx) /*!< in: transaction */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
79 |
{
|
80 |
return((ullint)ut_conv_dulint_to_longlong(trx->id)); |
|
81 |
}
|
|
82 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
83 |
/*******************************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
84 |
Retrieves transaction's que state in a human readable string. The string
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
85 |
should not be free()'d or modified.
|
86 |
@return string in the data segment */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
87 |
UNIV_INLINE
|
88 |
const char* |
|
89 |
trx_get_que_state_str( |
|
90 |
/*==================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
91 |
const trx_t* trx) /*!< in: transaction */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
92 |
{
|
93 |
/* be sure to adjust TRX_QUE_STATE_STR_MAX_LEN if you change this */ |
|
94 |
switch (trx->que_state) { |
|
95 |
case TRX_QUE_RUNNING: |
|
96 |
return("RUNNING"); |
|
97 |
case TRX_QUE_LOCK_WAIT: |
|
98 |
return("LOCK WAIT"); |
|
99 |
case TRX_QUE_ROLLING_BACK: |
|
100 |
return("ROLLING BACK"); |
|
101 |
case TRX_QUE_COMMITTING: |
|
102 |
return("COMMITTING"); |
|
103 |
default: |
|
104 |
return("UNKNOWN"); |
|
105 |
} |
|
106 |
}
|
|
107 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
108 |
/**********************************************************************//**
|
109 |
Determine if a transaction is a dictionary operation.
|
|
110 |
@return dictionary operation mode */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
111 |
UNIV_INLINE
|
112 |
enum trx_dict_op |
|
113 |
trx_get_dict_operation( |
|
114 |
/*===================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
115 |
const trx_t* trx) /*!< in: transaction */ |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
116 |
{
|
117 |
enum trx_dict_op op = (enum trx_dict_op) trx->dict_operation; |
|
118 |
||
119 |
#ifdef UNIV_DEBUG |
|
120 |
switch (op) { |
|
121 |
case TRX_DICT_OP_NONE: |
|
122 |
case TRX_DICT_OP_TABLE: |
|
123 |
case TRX_DICT_OP_INDEX: |
|
124 |
return(op); |
|
125 |
} |
|
126 |
ut_error; |
|
127 |
#endif /* UNIV_DEBUG */ |
|
128 |
return((enum trx_dict_op) UNIV_EXPECT(op, TRX_DICT_OP_NONE)); |
|
129 |
}
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
130 |
/**********************************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
131 |
Flag a transaction a dictionary operation. */
|
132 |
UNIV_INLINE
|
|
133 |
void
|
|
134 |
trx_set_dict_operation( |
|
135 |
/*===================*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
136 |
trx_t* trx, /*!< in/out: transaction */ |
137 |
enum trx_dict_op op) /*!< in: operation, not |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
138 |
TRX_DICT_OP_NONE */
|
139 |
{
|
|
140 |
#ifdef UNIV_DEBUG |
|
141 |
enum trx_dict_op old_op = trx_get_dict_operation(trx); |
|
142 |
||
143 |
switch (op) { |
|
144 |
case TRX_DICT_OP_NONE: |
|
145 |
ut_error; |
|
146 |
break; |
|
147 |
case TRX_DICT_OP_TABLE: |
|
148 |
switch (old_op) { |
|
149 |
case TRX_DICT_OP_NONE: |
|
150 |
case TRX_DICT_OP_INDEX: |
|
151 |
case TRX_DICT_OP_TABLE: |
|
152 |
goto ok; |
|
153 |
} |
|
154 |
ut_error; |
|
155 |
break; |
|
156 |
case TRX_DICT_OP_INDEX: |
|
157 |
ut_ad(old_op == TRX_DICT_OP_NONE); |
|
158 |
break; |
|
159 |
} |
|
160 |
ok: |
|
161 |
#endif /* UNIV_DEBUG */ |
|
162 |
||
163 |
trx->dict_operation = op; |
|
164 |
}
|