~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/que0que.ic

  • Committer: Monty Taylor
  • Date: 2010-09-16 23:12:30 UTC
  • mto: (1775.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1773.
  • Revision ID: mordred@inaugust.com-20100916231230-uchkqks21rwzbmpz
Include files in tarball that were being left out.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (C) 1996, 2010, 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/que0que.ic
21
 
Query graph
22
 
 
23
 
Created 5/27/1996 Heikki Tuuri
24
 
*******************************************************/
25
 
 
26
 
#include "usr0sess.h"
27
 
 
28
 
/***********************************************************************//**
29
 
Gets the trx of a query thread. */
30
 
UNIV_INLINE
31
 
trx_t*
32
 
thr_get_trx(
33
 
/*========*/
34
 
        que_thr_t*      thr)    /*!< in: query thread */
35
 
{
36
 
        ut_ad(thr);
37
 
 
38
 
        return(thr->graph->trx);
39
 
}
40
 
 
41
 
/*******************************************************************//**
42
 
Determines if this thread is rolling back an incomplete transaction
43
 
in crash recovery.
44
 
@return TRUE if thr is rolling back an incomplete transaction in crash
45
 
recovery */
46
 
UNIV_INLINE
47
 
ibool
48
 
thr_is_recv(
49
 
/*========*/
50
 
        const que_thr_t*        thr)    /*!< in: query thread */
51
 
{
52
 
        return(trx_is_recv(thr->graph->trx));
53
 
}
54
 
 
55
 
/***********************************************************************//**
56
 
Gets the first thr in a fork. */
57
 
UNIV_INLINE
58
 
que_thr_t*
59
 
que_fork_get_first_thr(
60
 
/*===================*/
61
 
        que_fork_t*     fork)   /*!< in: query fork */
62
 
{
63
 
        return(UT_LIST_GET_FIRST(fork->thrs));
64
 
}
65
 
 
66
 
/***********************************************************************//**
67
 
Gets the child node of the first thr in a fork. */
68
 
UNIV_INLINE
69
 
que_node_t*
70
 
que_fork_get_child(
71
 
/*===============*/
72
 
        que_fork_t*     fork)   /*!< in: query fork */
73
 
{
74
 
        que_thr_t*      thr;
75
 
 
76
 
        thr = UT_LIST_GET_FIRST(fork->thrs);
77
 
 
78
 
        return(thr->child);
79
 
}
80
 
 
81
 
/***********************************************************************//**
82
 
Gets the type of a graph node. */
83
 
UNIV_INLINE
84
 
ulint
85
 
que_node_get_type(
86
 
/*==============*/
87
 
        que_node_t*     node)   /*!< in: graph node */
88
 
{
89
 
        ut_ad(node);
90
 
 
91
 
        return(((que_common_t*)node)->type);
92
 
}
93
 
 
94
 
/***********************************************************************//**
95
 
Gets pointer to the value dfield of a graph node. */
96
 
UNIV_INLINE
97
 
dfield_t*
98
 
que_node_get_val(
99
 
/*=============*/
100
 
        que_node_t*     node)   /*!< in: graph node */
101
 
{
102
 
        ut_ad(node);
103
 
 
104
 
        return(&(((que_common_t*)node)->val));
105
 
}
106
 
 
107
 
/***********************************************************************//**
108
 
Gets the value buffer size of a graph node.
109
 
@return val buffer size, not defined if val.data == NULL in node */
110
 
UNIV_INLINE
111
 
ulint
112
 
que_node_get_val_buf_size(
113
 
/*======================*/
114
 
        que_node_t*     node)   /*!< in: graph node */
115
 
{
116
 
        ut_ad(node);
117
 
 
118
 
        return(((que_common_t*)node)->val_buf_size);
119
 
}
120
 
 
121
 
/***********************************************************************//**
122
 
Sets the value buffer size of a graph node. */
123
 
UNIV_INLINE
124
 
void
125
 
que_node_set_val_buf_size(
126
 
/*======================*/
127
 
        que_node_t*     node,   /*!< in: graph node */
128
 
        ulint           size)   /*!< in: size */
129
 
{
130
 
        ut_ad(node);
131
 
 
132
 
        ((que_common_t*)node)->val_buf_size = size;
133
 
}
134
 
 
135
 
/***********************************************************************//**
136
 
Sets the parent of a graph node. */
137
 
UNIV_INLINE
138
 
void
139
 
que_node_set_parent(
140
 
/*================*/
141
 
        que_node_t*     node,   /*!< in: graph node */
142
 
        que_node_t*     parent) /*!< in: parent */
143
 
{
144
 
        ut_ad(node);
145
 
 
146
 
        ((que_common_t*)node)->parent = parent;
147
 
}
148
 
 
149
 
/***********************************************************************//**
150
 
Gets pointer to the value data type field of a graph node. */
151
 
UNIV_INLINE
152
 
dtype_t*
153
 
que_node_get_data_type(
154
 
/*===================*/
155
 
        que_node_t*     node)   /*!< in: graph node */
156
 
{
157
 
        ut_ad(node);
158
 
 
159
 
        return(dfield_get_type(&((que_common_t*) node)->val));
160
 
}
161
 
 
162
 
/*********************************************************************//**
163
 
Catenates a query graph node to a list of them, possible empty list.
164
 
@return one-way list of nodes */
165
 
UNIV_INLINE
166
 
que_node_t*
167
 
que_node_list_add_last(
168
 
/*===================*/
169
 
        que_node_t*     node_list,      /*!< in: node list, or NULL */
170
 
        que_node_t*     node)           /*!< in: node */
171
 
{
172
 
        que_common_t*   cnode;
173
 
        que_common_t*   cnode2;
174
 
 
175
 
        cnode = (que_common_t*) node;
176
 
 
177
 
        cnode->brother = NULL;
178
 
 
179
 
        if (node_list == NULL) {
180
 
 
181
 
                return(node);
182
 
        }
183
 
 
184
 
        cnode2 = (que_common_t*) node_list;
185
 
 
186
 
        while (cnode2->brother != NULL) {
187
 
                cnode2 = (que_common_t*) cnode2->brother;
188
 
        }
189
 
 
190
 
        cnode2->brother = node;
191
 
 
192
 
        return(node_list);
193
 
}
194
 
 
195
 
/*********************************************************************//**
196
 
Gets the next list node in a list of query graph nodes.
197
 
@return next node in a list of nodes */
198
 
UNIV_INLINE
199
 
que_node_t*
200
 
que_node_get_next(
201
 
/*==============*/
202
 
        que_node_t*     node)   /*!< in: node in a list */
203
 
{
204
 
        return(((que_common_t*)node)->brother);
205
 
}
206
 
 
207
 
/*********************************************************************//**
208
 
Gets a query graph node list length.
209
 
@return length, for NULL list 0 */
210
 
UNIV_INLINE
211
 
ulint
212
 
que_node_list_get_len(
213
 
/*==================*/
214
 
        que_node_t*     node_list)      /*!< in: node list, or NULL */
215
 
{
216
 
        const que_common_t*     cnode;
217
 
        ulint                   len;
218
 
 
219
 
        cnode = (const que_common_t*) node_list;
220
 
        len = 0;
221
 
 
222
 
        while (cnode != NULL) {
223
 
                len++;
224
 
                cnode = (const que_common_t*) cnode->brother;
225
 
        }
226
 
 
227
 
        return(len);
228
 
}
229
 
 
230
 
/*********************************************************************//**
231
 
Gets the parent node of a query graph node.
232
 
@return parent node or NULL */
233
 
UNIV_INLINE
234
 
que_node_t*
235
 
que_node_get_parent(
236
 
/*================*/
237
 
        que_node_t*     node)   /*!< in: node */
238
 
{
239
 
        return(((que_common_t*)node)->parent);
240
 
}
241
 
 
242
 
/**********************************************************************//**
243
 
Checks if graph, trx, or session is in a state where the query thread should
244
 
be stopped.
245
 
@return TRUE if should be stopped; NOTE that if the peek is made
246
 
without reserving the kernel mutex, then another peek with the mutex
247
 
reserved is necessary before deciding the actual stopping */
248
 
UNIV_INLINE
249
 
ibool
250
 
que_thr_peek_stop(
251
 
/*==============*/
252
 
        que_thr_t*      thr)    /*!< in: query thread */
253
 
{
254
 
        trx_t*  trx;
255
 
        que_t*  graph;
256
 
 
257
 
        graph = thr->graph;
258
 
        trx = graph->trx;
259
 
 
260
 
        if (graph->state != QUE_FORK_ACTIVE
261
 
            || trx->que_state == TRX_QUE_LOCK_WAIT
262
 
            || (UT_LIST_GET_LEN(trx->signals) > 0
263
 
                && trx->que_state == TRX_QUE_RUNNING)) {
264
 
 
265
 
                return(TRUE);
266
 
        }
267
 
 
268
 
        return(FALSE);
269
 
}
270
 
 
271
 
/***********************************************************************//**
272
 
Returns TRUE if the query graph is for a SELECT statement.
273
 
@return TRUE if a select */
274
 
UNIV_INLINE
275
 
ibool
276
 
que_graph_is_select(
277
 
/*================*/
278
 
        que_t*          graph)          /*!< in: graph */
279
 
{
280
 
        if (graph->fork_type == QUE_FORK_SELECT_SCROLL
281
 
            || graph->fork_type == QUE_FORK_SELECT_NON_SCROLL) {
282
 
 
283
 
                return(TRUE);
284
 
        }
285
 
 
286
 
        return(FALSE);
287
 
}