1
/*****************************************************************************
3
Copyright (C) 1996, 2010, 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
Determines if this thread is rolling back an incomplete transaction
44
@return TRUE if thr is rolling back an incomplete transaction in crash
50
const que_thr_t* thr) /*!< in: query thread */
52
return(trx_is_recv(thr->graph->trx));
55
/***********************************************************************//**
56
Gets the first thr in a fork. */
59
que_fork_get_first_thr(
60
/*===================*/
61
que_fork_t* fork) /*!< in: query fork */
63
return(UT_LIST_GET_FIRST(fork->thrs));
66
/***********************************************************************//**
67
Gets the child node of the first thr in a fork. */
72
que_fork_t* fork) /*!< in: query fork */
76
thr = UT_LIST_GET_FIRST(fork->thrs);
81
/***********************************************************************//**
82
Gets the type of a graph node. */
87
que_node_t* node) /*!< in: graph node */
91
return(((que_common_t*)node)->type);
94
/***********************************************************************//**
95
Gets pointer to the value dfield of a graph node. */
100
que_node_t* node) /*!< in: graph node */
104
return(&(((que_common_t*)node)->val));
107
/***********************************************************************//**
108
Gets the value buffer size of a graph node.
109
@return val buffer size, not defined if val.data == NULL in node */
112
que_node_get_val_buf_size(
113
/*======================*/
114
que_node_t* node) /*!< in: graph node */
118
return(((que_common_t*)node)->val_buf_size);
121
/***********************************************************************//**
122
Sets the value buffer size of a graph node. */
125
que_node_set_val_buf_size(
126
/*======================*/
127
que_node_t* node, /*!< in: graph node */
128
ulint size) /*!< in: size */
132
((que_common_t*)node)->val_buf_size = size;
135
/***********************************************************************//**
136
Sets the parent of a graph node. */
141
que_node_t* node, /*!< in: graph node */
142
que_node_t* parent) /*!< in: parent */
146
((que_common_t*)node)->parent = parent;
149
/***********************************************************************//**
150
Gets pointer to the value data type field of a graph node. */
153
que_node_get_data_type(
154
/*===================*/
155
que_node_t* node) /*!< in: graph node */
159
return(dfield_get_type(&((que_common_t*) node)->val));
162
/*********************************************************************//**
163
Catenates a query graph node to a list of them, possible empty list.
164
@return one-way list of nodes */
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 */
173
que_common_t* cnode2;
175
cnode = (que_common_t*) node;
177
cnode->brother = NULL;
179
if (node_list == NULL) {
184
cnode2 = (que_common_t*) node_list;
186
while (cnode2->brother != NULL) {
187
cnode2 = (que_common_t*) cnode2->brother;
190
cnode2->brother = node;
195
/*********************************************************************//**
196
Gets the next list node in a list of query graph nodes.
197
@return next node in a list of nodes */
202
que_node_t* node) /*!< in: node in a list */
204
return(((que_common_t*)node)->brother);
207
/*********************************************************************//**
208
Gets a query graph node list length.
209
@return length, for NULL list 0 */
212
que_node_list_get_len(
213
/*==================*/
214
que_node_t* node_list) /*!< in: node list, or NULL */
216
const que_common_t* cnode;
219
cnode = (const que_common_t*) node_list;
222
while (cnode != NULL) {
224
cnode = (const que_common_t*) cnode->brother;
230
/*********************************************************************//**
231
Gets the parent node of a query graph node.
232
@return parent node or NULL */
237
que_node_t* node) /*!< in: node */
239
return(((que_common_t*)node)->parent);
242
/**********************************************************************//**
243
Checks if graph, trx, or session is in a state where the query thread should
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 */
252
que_thr_t* thr) /*!< in: query thread */
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)) {
271
/***********************************************************************//**
272
Returns TRUE if the query graph is for a SELECT statement.
273
@return TRUE if a select */
278
que_t* graph) /*!< in: graph */
280
if (graph->fork_type == QUE_FORK_SELECT_SCROLL
281
|| graph->fork_type == QUE_FORK_SELECT_NON_SCROLL) {