~ubuntu-branches/ubuntu/trusty/mariadb-5.5/trusty-proposed

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Otto Kekäläinen
  • Date: 2013-12-22 10:27:05 UTC
  • Revision ID: package-import@ubuntu.com-20131222102705-mndw7s12mz0szrcn
Tags: upstream-5.5.32
Import upstream version 5.5.32

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->state != TRX_COMMITTED_IN_MEMORY);
 
35
 
 
36
        if (trx->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->state != TRX_COMMITTED_IN_MEMORY);
 
52
 
 
53
        if (trx->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 transaction's que state in a human readable string. The string
 
73
should not be free()'d or modified.
 
74
@return string in the data segment */
 
75
UNIV_INLINE
 
76
const char*
 
77
trx_get_que_state_str(
 
78
/*==================*/
 
79
        const trx_t*    trx)    /*!< in: transaction */
 
80
{
 
81
        /* be sure to adjust TRX_QUE_STATE_STR_MAX_LEN if you change this */
 
82
        switch (trx->que_state) {
 
83
        case TRX_QUE_RUNNING:
 
84
                return("RUNNING");
 
85
        case TRX_QUE_LOCK_WAIT:
 
86
                return("LOCK WAIT");
 
87
        case TRX_QUE_ROLLING_BACK:
 
88
                return("ROLLING BACK");
 
89
        case TRX_QUE_COMMITTING:
 
90
                return("COMMITTING");
 
91
        default:
 
92
                return("UNKNOWN");
 
93
        }
 
94
}
 
95
 
 
96
/**********************************************************************//**
 
97
Determine if a transaction is a dictionary operation.
 
98
@return dictionary operation mode */
 
99
UNIV_INLINE
 
100
enum trx_dict_op
 
101
trx_get_dict_operation(
 
102
/*===================*/
 
103
        const trx_t*    trx)    /*!< in: transaction */
 
104
{
 
105
        enum trx_dict_op op = (enum trx_dict_op) trx->dict_operation;
 
106
 
 
107
#ifdef UNIV_DEBUG
 
108
        switch (op) {
 
109
        case TRX_DICT_OP_NONE:
 
110
        case TRX_DICT_OP_TABLE:
 
111
        case TRX_DICT_OP_INDEX:
 
112
                return(op);
 
113
        }
 
114
        ut_error;
 
115
#endif /* UNIV_DEBUG */
 
116
        return((enum trx_dict_op) UNIV_EXPECT(op, TRX_DICT_OP_NONE));
 
117
}
 
118
/**********************************************************************//**
 
119
Flag a transaction a dictionary operation. */
 
120
UNIV_INLINE
 
121
void
 
122
trx_set_dict_operation(
 
123
/*===================*/
 
124
        trx_t*                  trx,    /*!< in/out: transaction */
 
125
        enum trx_dict_op        op)     /*!< in: operation, not
 
126
                                        TRX_DICT_OP_NONE */
 
127
{
 
128
#ifdef UNIV_DEBUG
 
129
        enum trx_dict_op        old_op = trx_get_dict_operation(trx);
 
130
 
 
131
        switch (op) {
 
132
        case TRX_DICT_OP_NONE:
 
133
                ut_error;
 
134
                break;
 
135
        case TRX_DICT_OP_TABLE:
 
136
                switch (old_op) {
 
137
                case TRX_DICT_OP_NONE:
 
138
                case TRX_DICT_OP_INDEX:
 
139
                case TRX_DICT_OP_TABLE:
 
140
                        goto ok;
 
141
                }
 
142
                ut_error;
 
143
                break;
 
144
        case TRX_DICT_OP_INDEX:
 
145
                ut_ad(old_op == TRX_DICT_OP_NONE);
 
146
                break;
 
147
        }
 
148
ok:
 
149
#endif /* UNIV_DEBUG */
 
150
 
 
151
        trx->dict_operation = op;
 
152
}