~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2010-10-15 17:18:02 UTC
  • mto: (1859.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1860.
  • Revision ID: mordred@inaugust.com-20101015171802-qhk6zyfhrkvprr1n
Added support for registering regular sys_var instances via module::Context.

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