~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to storage/innodb_plugin/include/trx0trx.ic

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
19
/**************************************************//**
 
20
@file include/trx0trx.ic
 
21
The transaction
 
22
 
 
23
Created 3/26/1996 Heikki Tuuri
 
24
*******************************************************/
 
25
 
 
26
/*************************************************************//**
 
27
Starts the transaction if it is not yet started. */
 
28
UNIV_INLINE
 
29
void
 
30
trx_start_if_not_started(
 
31
/*=====================*/
 
32
        trx_t*  trx)    /*!< in: transaction */
 
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
 
 
42
/*************************************************************//**
 
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
/*=========================*/
 
49
        trx_t*  trx)    /*!< in: transaction */
 
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
 
 
59
/****************************************************************//**
 
60
Retrieves the error_info field from a trx.
 
61
@return the error info */
 
62
UNIV_INLINE
 
63
const dict_index_t*
 
64
trx_get_error_info(
 
65
/*===============*/
 
66
        const trx_t*    trx)    /*!< in: trx object */
 
67
{
 
68
        return(trx->error_info);
 
69
}
 
70
 
 
71
/*******************************************************************//**
 
72
Retrieves transacion's id, represented as unsigned long long.
 
73
@return transaction's id */
 
74
UNIV_INLINE
 
75
ullint
 
76
trx_get_id(
 
77
/*=======*/
 
78
        const trx_t*    trx)    /*!< in: transaction */
 
79
{
 
80
        return((ullint)ut_conv_dulint_to_longlong(trx->id));
 
81
}
 
82
 
 
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 */
 
87
UNIV_INLINE
 
88
const char*
 
89
trx_get_que_state_str(
 
90
/*==================*/
 
91
        const trx_t*    trx)    /*!< in: transaction */
 
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
 
 
108
/**********************************************************************//**
 
109
Determine if a transaction is a dictionary operation.
 
110
@return dictionary operation mode */
 
111
UNIV_INLINE
 
112
enum trx_dict_op
 
113
trx_get_dict_operation(
 
114
/*===================*/
 
115
        const trx_t*    trx)    /*!< in: transaction */
 
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
}
 
130
/**********************************************************************//**
 
131
Flag a transaction a dictionary operation. */
 
132
UNIV_INLINE
 
133
void
 
134
trx_set_dict_operation(
 
135
/*===================*/
 
136
        trx_t*                  trx,    /*!< in/out: transaction */
 
137
        enum trx_dict_op        op)     /*!< in: operation, not
 
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
}