~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2008-12-15 19:32:58 UTC
  • mfrom: (677.1.2 devel)
  • Revision ID: brian@tangent.org-20081215193258-fsvc1sh9h7a9sb1t
Merge from Monty

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., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/**************************************************//**
20
 
@file include/trx0trx.ic
 
1
/******************************************************
21
2
The transaction
22
3
 
 
4
(c) 1996 Innobase Oy
 
5
 
23
6
Created 3/26/1996 Heikki Tuuri
24
7
*******************************************************/
25
8
 
26
 
/*************************************************************//**
 
9
/*****************************************************************
27
10
Starts the transaction if it is not yet started. */
28
11
UNIV_INLINE
29
12
void
30
13
trx_start_if_not_started(
31
14
/*=====================*/
32
 
        trx_t*  trx)    /*!< in: transaction */
 
15
        trx_t*  trx)    /* in: transaction */
33
16
{
34
17
        ut_ad(trx->conc_state != TRX_COMMITTED_IN_MEMORY);
35
18
 
39
22
        }
40
23
}
41
24
 
42
 
/*************************************************************//**
 
25
/*****************************************************************
43
26
Starts the transaction if it is not yet started. Assumes we have reserved
44
27
the kernel mutex! */
45
28
UNIV_INLINE
46
29
void
47
30
trx_start_if_not_started_low(
48
31
/*=========================*/
49
 
        trx_t*  trx)    /*!< in: transaction */
 
32
        trx_t*  trx)    /* in: transaction */
50
33
{
51
34
        ut_ad(trx->conc_state != TRX_COMMITTED_IN_MEMORY);
52
35
 
56
39
        }
57
40
}
58
41
 
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. */
 
44
UNIV_INLINE
 
45
void
 
46
trx_reset_new_rec_lock_info(
 
47
/*========================*/
 
48
        trx_t*  trx)    /* in: transaction struct */
 
49
{
 
50
        trx->new_rec_locks[0] = NULL;
 
51
        trx->new_rec_locks[1] = NULL;
 
52
}
 
53
 
 
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. */
 
58
UNIV_INLINE
 
59
void
 
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
 
64
                                index */
 
65
{
 
66
        if (trx->new_rec_locks[0] == NULL) {
 
67
                trx->new_rec_locks[0] = index;
 
68
 
 
69
                return;
 
70
        }
 
71
 
 
72
        if (trx->new_rec_locks[0] == index) {
 
73
 
 
74
                return;
 
75
        }
 
76
 
 
77
        if (trx->new_rec_locks[1] != NULL) {
 
78
 
 
79
                return;
 
80
        }
 
81
 
 
82
        trx->new_rec_locks[1] = index;
 
83
}
 
84
 
 
85
/*****************************************************************
 
86
Checks if trx has set a new record lock on an index. */
62
87
UNIV_INLINE
63
88
ibool
64
 
trx_log_commit_id(const trx_t*  trx)
65
 
/*===============*/
 
89
trx_new_rec_locks_contain(
 
90
/*======================*/
 
91
                                /* out: TRUE if trx has set a new record lock
 
92
                                on index */
 
93
        trx_t*          trx,    /* in: transaction struct */
 
94
        dict_index_t*   index)  /* in: index */
66
95
{
67
 
        return (trx->log_commit_id);
 
96
        return(trx->new_rec_locks[0] == index
 
97
               || trx->new_rec_locks[1] == index);
68
98
}
69
99
 
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. */
73
102
UNIV_INLINE
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 */
78
108
{
79
109
        return(trx->error_info);
80
110
}
81
111
 
82
 
/*******************************************************************//**
 
112
/***********************************************************************
 
113
Retrieves transacion's id, represented as unsigned long long. */
 
114
UNIV_INLINE
 
115
ullint
 
116
trx_get_id(
 
117
/*=======*/
 
118
                                /* out: transaction's id */
 
119
        const trx_t*    trx)    /* in: transaction */
 
120
{
 
121
        return((ullint)ut_conv_dulint_to_longlong(trx->id));
 
122
}
 
123
 
 
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. */
86
127
UNIV_INLINE
87
128
const char*
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 */
91
133
{
92
134
        /* be sure to adjust TRX_QUE_STATE_STR_MAX_LEN if you change this */
93
135
        switch (trx->que_state) {
104
146
        }
105
147
}
106
148
 
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. */
110
151
UNIV_INLINE
111
152
enum trx_dict_op
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 */
115
157
{
116
158
        enum trx_dict_op op = (enum trx_dict_op) trx->dict_operation;
117
159
 
126
168
#endif /* UNIV_DEBUG */
127
169
        return((enum trx_dict_op) UNIV_EXPECT(op, TRX_DICT_OP_NONE));
128
170
}
129
 
/**********************************************************************//**
 
171
/**************************************************************************
130
172
Flag a transaction a dictionary operation. */
131
173
UNIV_INLINE
132
174
void
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 */
138
180
{
139
181
#ifdef UNIV_DEBUG