1
/*****************************************************************************
3
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
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.
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.
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
17
*****************************************************************************/
19
/**************************************************//**
20
@file include/que0que.ic
23
Created 5/27/1996 Heikki Tuuri
24
*******************************************************/
28
/***********************************************************************//**
29
Gets the trx of a query thread. */
34
que_thr_t* thr) /*!< in: query thread */
38
return(thr->graph->trx);
41
/***********************************************************************//**
42
Gets the first thr in a fork. */
45
que_fork_get_first_thr(
46
/*===================*/
47
que_fork_t* fork) /*!< in: query fork */
49
return(UT_LIST_GET_FIRST(fork->thrs));
52
/***********************************************************************//**
53
Gets the child node of the first thr in a fork. */
58
que_fork_t* fork) /*!< in: query fork */
62
thr = UT_LIST_GET_FIRST(fork->thrs);
67
/***********************************************************************//**
68
Gets the type of a graph node. */
73
que_node_t* node) /*!< in: graph node */
77
return(((que_common_t*)node)->type);
80
/***********************************************************************//**
81
Gets pointer to the value dfield of a graph node. */
86
que_node_t* node) /*!< in: graph node */
90
return(&(((que_common_t*)node)->val));
93
/***********************************************************************//**
94
Gets the value buffer size of a graph node.
95
@return val buffer size, not defined if val.data == NULL in node */
98
que_node_get_val_buf_size(
99
/*======================*/
100
que_node_t* node) /*!< in: graph node */
104
return(((que_common_t*)node)->val_buf_size);
107
/***********************************************************************//**
108
Sets the value buffer size of a graph node. */
111
que_node_set_val_buf_size(
112
/*======================*/
113
que_node_t* node, /*!< in: graph node */
114
ulint size) /*!< in: size */
118
((que_common_t*)node)->val_buf_size = size;
121
/***********************************************************************//**
122
Sets the parent of a graph node. */
127
que_node_t* node, /*!< in: graph node */
128
que_node_t* parent) /*!< in: parent */
132
((que_common_t*)node)->parent = parent;
135
/***********************************************************************//**
136
Gets pointer to the value data type field of a graph node. */
139
que_node_get_data_type(
140
/*===================*/
141
que_node_t* node) /*!< in: graph node */
145
return(dfield_get_type(&((que_common_t*) node)->val));
148
/*********************************************************************//**
149
Catenates a query graph node to a list of them, possible empty list.
150
@return one-way list of nodes */
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 */
159
que_common_t* cnode2;
161
cnode = (que_common_t*) node;
163
cnode->brother = NULL;
165
if (node_list == NULL) {
170
cnode2 = (que_common_t*) node_list;
172
while (cnode2->brother != NULL) {
173
cnode2 = (que_common_t*) cnode2->brother;
176
cnode2->brother = node;
181
/*********************************************************************//**
182
Gets the next list node in a list of query graph nodes.
183
@return next node in a list of nodes */
188
que_node_t* node) /*!< in: node in a list */
190
return(((que_common_t*)node)->brother);
193
/*********************************************************************//**
194
Gets a query graph node list length.
195
@return length, for NULL list 0 */
198
que_node_list_get_len(
199
/*==================*/
200
que_node_t* node_list) /*!< in: node list, or NULL */
202
const que_common_t* cnode;
205
cnode = (const que_common_t*) node_list;
208
while (cnode != NULL) {
210
cnode = (const que_common_t*) cnode->brother;
216
/*********************************************************************//**
217
Gets the parent node of a query graph node.
218
@return parent node or NULL */
223
que_node_t* node) /*!< in: node */
225
return(((que_common_t*)node)->parent);
228
/**********************************************************************//**
229
Checks if graph, trx, or session is in a state where the query thread should
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 */
238
que_thr_t* thr) /*!< in: query thread */
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)) {
257
/***********************************************************************//**
258
Returns TRUE if the query graph is for a SELECT statement.
259
@return TRUE if a select */
264
que_t* graph) /*!< in: graph */
266
if (graph->fork_type == QUE_FORK_SELECT_SCROLL
267
|| graph->fork_type == QUE_FORK_SELECT_NON_SCROLL) {