~drizzle-trunk/drizzle/development

641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
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., 59 Temple
15
Place, Suite 330, Boston, MA 02111-1307 USA
16
17
*****************************************************************************/
18
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
19
/**************************************************//**
20
@file include/que0que.h
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
21
Query graph
22
23
Created 5/27/1996 Heikki Tuuri
24
*******************************************************/
25
26
#ifndef que0que_h
27
#define que0que_h
28
29
#include "univ.i"
30
#include "data0data.h"
31
#include "dict0types.h"
32
#include "trx0trx.h"
33
#include "srv0srv.h"
34
#include "usr0types.h"
35
#include "que0types.h"
36
#include "row0types.h"
37
#include "pars0types.h"
38
39
/* If the following flag is set TRUE, the module will print trace info
40
of SQL execution in the UNIV_SQL_DEBUG version */
41
extern ibool	que_trace_on;
42
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
43
/***********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
44
Adds a query graph to the session's list of graphs. */
45
UNIV_INTERN
46
void
47
que_graph_publish(
48
/*==============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
49
	que_t*	graph,	/*!< in: graph */
50
	sess_t*	sess);	/*!< in: session */
51
/***********************************************************************//**
52
Creates a query graph fork node.
53
@return	own: fork node */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
54
UNIV_INTERN
55
que_fork_t*
56
que_fork_create(
57
/*============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
58
	que_t*		graph,		/*!< in: graph, if NULL then this
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
59
					fork node is assumed to be the
60
					graph root */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
61
	que_node_t*	parent,		/*!< in: parent node */
62
	ulint		fork_type,	/*!< in: fork type */
63
	mem_heap_t*	heap);		/*!< in: memory heap where created */
64
/***********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
65
Gets the first thr in a fork. */
66
UNIV_INLINE
67
que_thr_t*
68
que_fork_get_first_thr(
69
/*===================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
70
	que_fork_t*	fork);	/*!< in: query fork */
71
/***********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
72
Gets the child node of the first thr in a fork. */
73
UNIV_INLINE
74
que_node_t*
75
que_fork_get_child(
76
/*===============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
77
	que_fork_t*	fork);	/*!< in: query fork */
78
/***********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
79
Sets the parent of a graph node. */
80
UNIV_INLINE
81
void
82
que_node_set_parent(
83
/*================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
84
	que_node_t*	node,	/*!< in: graph node */
85
	que_node_t*	parent);/*!< in: parent */
86
/***********************************************************************//**
87
Creates a query graph thread node.
88
@return	own: query thread node */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
89
UNIV_INTERN
90
que_thr_t*
91
que_thr_create(
92
/*===========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
93
	que_fork_t*	parent,	/*!< in: parent node, i.e., a fork node */
94
	mem_heap_t*	heap);	/*!< in: memory heap where created */
95
/**********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
96
Frees a query graph, but not the heap where it was created. Does not free
97
explicit cursor declarations, they are freed in que_graph_free. */
98
UNIV_INTERN
99
void
100
que_graph_free_recursive(
101
/*=====================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
102
	que_node_t*	node);	/*!< in: query graph node */
103
/**********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
104
Frees a query graph. */
105
UNIV_INTERN
106
void
107
que_graph_free(
108
/*===========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
109
	que_t*	graph);	/*!< in: query graph; we assume that the memory
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
110
			heap where this graph was created is private
111
			to this graph: if not, then use
112
			que_graph_free_recursive and free the heap
113
			afterwards! */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
114
/**********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
115
Stops a query thread if graph or trx is in a state requiring it. The
116
conditions are tested in the order (1) graph, (2) trx. The kernel mutex has
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
117
to be reserved.
118
@return	TRUE if stopped */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
119
UNIV_INTERN
120
ibool
121
que_thr_stop(
122
/*=========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
123
	que_thr_t*	thr);	/*!< in: query thread */
124
/**********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
125
Moves a thread from another state to the QUE_THR_RUNNING state. Increments
126
the n_active_thrs counters of the query graph and transaction. */
127
UNIV_INTERN
128
void
129
que_thr_move_to_run_state_for_mysql(
130
/*================================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
131
	que_thr_t*	thr,	/*!< in: an query thread */
132
	trx_t*		trx);	/*!< in: transaction */
133
/**********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
134
A patch for MySQL used to 'stop' a dummy query thread used in MySQL
135
select, when there is no error or lock wait. */
136
UNIV_INTERN
137
void
138
que_thr_stop_for_mysql_no_error(
139
/*============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
140
	que_thr_t*	thr,	/*!< in: query thread */
141
	trx_t*		trx);	/*!< in: transaction */
142
/**********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
143
A patch for MySQL used to 'stop' a dummy query thread used in MySQL. The
144
query thread is stopped and made inactive, except in the case where
145
it was put to the lock wait state in lock0lock.c, but the lock has already
146
been granted or the transaction chosen as a victim in deadlock resolution. */
147
UNIV_INTERN
148
void
149
que_thr_stop_for_mysql(
150
/*===================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
151
	que_thr_t*	thr);	/*!< in: query thread */
152
/**********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
153
Run a query thread. Handles lock waits. */
154
UNIV_INTERN
155
void
156
que_run_threads(
157
/*============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
158
	que_thr_t*	thr);	/*!< in: query thread */
159
/**********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
160
After signal handling is finished, returns control to a query graph error
161
handling routine. (Currently, just returns the control to the root of the
162
graph so that the graph can communicate an error message to the client.) */
163
UNIV_INTERN
164
void
165
que_fork_error_handle(
166
/*==================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
167
	trx_t*	trx,	/*!< in: trx */
168
	que_t*	fork);	/*!< in: query graph which was run before signal
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
169
			handling started, NULL not allowed */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
170
/**********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
171
Moves a suspended query thread to the QUE_THR_RUNNING state and releases
172
a single worker thread to execute it. This function should be used to end
173
the wait state of a query thread waiting for a lock or a stored procedure
174
completion. */
175
UNIV_INTERN
176
void
177
que_thr_end_wait(
178
/*=============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
179
	que_thr_t*	thr,		/*!< in: query thread in the
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
180
					QUE_THR_LOCK_WAIT,
181
					or QUE_THR_PROCEDURE_WAIT, or
182
					QUE_THR_SIG_REPLY_WAIT state */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
183
	que_thr_t**	next_thr);	/*!< in/out: next query thread to run;
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
184
					if the value which is passed in is
185
					a pointer to a NULL pointer, then the
186
					calling function can start running
187
					a new query thread */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
188
/**********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
189
Same as que_thr_end_wait, but no parameter next_thr available. */
190
UNIV_INTERN
191
void
192
que_thr_end_wait_no_next_thr(
193
/*=========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
194
	que_thr_t*	thr);		/*!< in: query thread in the
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
195
					QUE_THR_LOCK_WAIT,
196
					or QUE_THR_PROCEDURE_WAIT, or
197
					QUE_THR_SIG_REPLY_WAIT state */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
198
/**********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
199
Starts execution of a command in a query fork. Picks a query thread which
200
is not in the QUE_THR_RUNNING state and moves it to that state. If none
201
can be chosen, a situation which may arise in parallelized fetches, NULL
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
202
is returned.
203
@return a query thread of the graph moved to QUE_THR_RUNNING state, or
204
NULL; the query thread should be executed by que_run_threads by the
205
caller */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
206
UNIV_INTERN
207
que_thr_t*
208
que_fork_start_command(
209
/*===================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
210
	que_fork_t*	fork);	/*!< in: a query fork */
211
/***********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
212
Gets the trx of a query thread. */
213
UNIV_INLINE
214
trx_t*
215
thr_get_trx(
216
/*========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
217
	que_thr_t*	thr);	/*!< in: query thread */
218
/***********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
219
Gets the type of a graph node. */
220
UNIV_INLINE
221
ulint
222
que_node_get_type(
223
/*==============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
224
	que_node_t*	node);	/*!< in: graph node */
225
/***********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
226
Gets pointer to the value data type field of a graph node. */
227
UNIV_INLINE
228
dtype_t*
229
que_node_get_data_type(
230
/*===================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
231
	que_node_t*	node);	/*!< in: graph node */
232
/***********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
233
Gets pointer to the value dfield of a graph node. */
234
UNIV_INLINE
235
dfield_t*
236
que_node_get_val(
237
/*=============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
238
	que_node_t*	node);	/*!< in: graph node */
239
/***********************************************************************//**
240
Gets the value buffer size of a graph node.
241
@return	val buffer size, not defined if val.data == NULL in node */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
242
UNIV_INLINE
243
ulint
244
que_node_get_val_buf_size(
245
/*======================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
246
	que_node_t*	node);	/*!< in: graph node */
247
/***********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
248
Sets the value buffer size of a graph node. */
249
UNIV_INLINE
250
void
251
que_node_set_val_buf_size(
252
/*======================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
253
	que_node_t*	node,	/*!< in: graph node */
254
	ulint		size);	/*!< in: size */
255
/*********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
256
Gets the next list node in a list of query graph nodes. */
257
UNIV_INLINE
258
que_node_t*
259
que_node_get_next(
260
/*==============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
261
	que_node_t*	node);	/*!< in: node in a list */
262
/*********************************************************************//**
263
Gets the parent node of a query graph node.
264
@return	parent node or NULL */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
265
UNIV_INLINE
266
que_node_t*
267
que_node_get_parent(
268
/*================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
269
	que_node_t*	node);	/*!< in: node */
270
/****************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
271
Get the first containing loop node (e.g. while_node_t or for_node_t) for the
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
272
given node, or NULL if the node is not within a loop.
273
@return	containing loop node, or NULL. */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
274
UNIV_INTERN
275
que_node_t*
276
que_node_get_containing_loop_node(
277
/*==============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
278
	que_node_t*	node);	/*!< in: node */
279
/*********************************************************************//**
280
Catenates a query graph node to a list of them, possible empty list.
281
@return	one-way list of nodes */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
282
UNIV_INLINE
283
que_node_t*
284
que_node_list_add_last(
285
/*===================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
286
	que_node_t*	node_list,	/*!< in: node list, or NULL */
287
	que_node_t*	node);		/*!< in: node */
288
/*********************************************************************//**
289
Gets a query graph node list length.
290
@return	length, for NULL list 0 */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
291
UNIV_INLINE
292
ulint
293
que_node_list_get_len(
294
/*==================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
295
	que_node_t*	node_list);	/*!< in: node list, or NULL */
296
/**********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
297
Checks if graph, trx, or session is in a state where the query thread should
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
298
be stopped.
299
@return TRUE if should be stopped; NOTE that if the peek is made
300
without reserving the kernel mutex, then another peek with the mutex
301
reserved is necessary before deciding the actual stopping */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
302
UNIV_INLINE
303
ibool
304
que_thr_peek_stop(
305
/*==============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
306
	que_thr_t*	thr);	/*!< in: query thread */
307
/***********************************************************************//**
308
Returns TRUE if the query graph is for a SELECT statement.
309
@return	TRUE if a select */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
310
UNIV_INLINE
311
ibool
312
que_graph_is_select(
313
/*================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
314
	que_t*		graph);		/*!< in: graph */
315
/**********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
316
Prints info of an SQL query graph node. */
317
UNIV_INTERN
318
void
319
que_node_print_info(
320
/*================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
321
	que_node_t*	node);	/*!< in: query graph node */
322
/*********************************************************************//**
323
Evaluate the given SQL
324
@return	error code or DB_SUCCESS */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
325
UNIV_INTERN
326
ulint
327
que_eval_sql(
328
/*=========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
329
	pars_info_t*	info,	/*!< in: info struct, or NULL */
330
	const char*	sql,	/*!< in: SQL string */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
331
	ibool		reserve_dict_mutex,
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
332
				/*!< in: if TRUE, acquire/release
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
333
				dict_sys->mutex around call to pars_sql. */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
334
	trx_t*		trx);	/*!< in: trx */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
335
336
/* Query graph query thread node: the fields are protected by the kernel
337
mutex with the exceptions named below */
338
339
struct que_thr_struct{
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
340
	que_common_t	common;		/*!< type: QUE_NODE_THR */
341
	ulint		magic_n;	/*!< magic number to catch memory
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
342
					corruption */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
343
	que_node_t*	child;		/*!< graph child node */
344
	que_t*		graph;		/*!< graph where this node belongs */
345
	ibool		is_active;	/*!< TRUE if the thread has been set
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
346
					to the run state in
347
					que_thr_move_to_run_state, but not
348
					deactivated in
349
					que_thr_dec_reference_count */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
350
	ulint		state;		/*!< state of the query thread */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
351
	UT_LIST_NODE_T(que_thr_t)
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
352
			thrs;		/*!< list of thread nodes of the fork
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
353
					node */
354
	UT_LIST_NODE_T(que_thr_t)
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
355
			trx_thrs;	/*!< lists of threads in wait list of
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
356
					the trx */
357
	UT_LIST_NODE_T(que_thr_t)
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
358
			queue;		/*!< list of runnable thread nodes in
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
359
					the server task queue */
360
	/*------------------------------*/
361
	/* The following fields are private to the OS thread executing the
362
	query thread, and are not protected by the kernel mutex: */
363
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
364
	que_node_t*	run_node;	/*!< pointer to the node where the
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
365
					subgraph down from this node is
366
					currently executed */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
367
	que_node_t*	prev_node;	/*!< pointer to the node from which
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
368
					the control came */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
369
	ulint		resource;	/*!< resource usage of the query thread
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
370
					thus far */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
371
	ulint		lock_state;	/*!< lock state of thread (table or
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
372
					row) */
373
};
374
375
#define QUE_THR_MAGIC_N		8476583
376
#define QUE_THR_MAGIC_FREED	123461526
377
378
/* Query graph fork node: its fields are protected by the kernel mutex */
379
struct que_fork_struct{
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
380
	que_common_t	common;		/*!< type: QUE_NODE_FORK */
381
	que_t*		graph;		/*!< query graph of this node */
382
	ulint		fork_type;	/*!< fork type */
383
	ulint		n_active_thrs;	/*!< if this is the root of a graph, the
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
384
					number query threads that have been
385
					started in que_thr_move_to_run_state
386
					but for which que_thr_dec_refer_count
387
					has not yet been called */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
388
	trx_t*		trx;		/*!< transaction: this is set only in
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
389
					the root node */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
390
	ulint		state;		/*!< state of the fork node */
391
	que_thr_t*	caller;		/*!< pointer to a possible calling query
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
392
					thread */
393
	UT_LIST_BASE_NODE_T(que_thr_t)
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
394
			thrs;		/*!< list of query threads */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
395
	/*------------------------------*/
396
	/* The fields in this section are defined only in the root node */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
397
	sym_tab_t*	sym_tab;	/*!< symbol table of the query,
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
398
					generated by the parser, or NULL
399
					if the graph was created 'by hand' */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
400
	pars_info_t*	info;		/*!< info struct, or NULL */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
401
	/* The following cur_... fields are relevant only in a select graph */
402
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
403
	ulint		cur_end;	/*!< QUE_CUR_NOT_DEFINED, QUE_CUR_START,
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
404
					QUE_CUR_END */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
405
	ulint		cur_pos;	/*!< if there are n rows in the result
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
406
					set, values 0 and n + 1 mean before
407
					first row, or after last row, depending
408
					on cur_end; values 1...n mean a row
409
					index */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
410
	ibool		cur_on_row;	/*!< TRUE if cursor is on a row, i.e.,
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
411
					it is not before the first row or
412
					after the last row */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
413
	dulint		n_inserts;	/*!< number of rows inserted */
414
	dulint		n_updates;	/*!< number of rows updated */
415
	dulint		n_deletes;	/*!< number of rows deleted */
416
	sel_node_t*	last_sel_node;	/*!< last executed select node, or NULL
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
417
					if none */
418
	UT_LIST_NODE_T(que_fork_t)
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
419
			graphs;		/*!< list of query graphs of a session
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
420
					or a stored procedure */
421
	/*------------------------------*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
422
	mem_heap_t*	heap;		/*!< memory heap where the fork was
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
423
					created */
424
425
};
426
427
/* Query fork (or graph) types */
428
#define QUE_FORK_SELECT_NON_SCROLL	1	/* forward-only cursor */
429
#define QUE_FORK_SELECT_SCROLL		2	/* scrollable cursor */
430
#define QUE_FORK_INSERT			3
431
#define QUE_FORK_UPDATE			4
432
#define QUE_FORK_ROLLBACK		5
433
			/* This is really the undo graph used in rollback,
434
			no signal-sending roll_node in this graph */
435
#define QUE_FORK_PURGE			6
436
#define	QUE_FORK_EXECUTE		7
437
#define QUE_FORK_PROCEDURE		8
438
#define QUE_FORK_PROCEDURE_CALL		9
439
#define QUE_FORK_MYSQL_INTERFACE	10
440
#define	QUE_FORK_RECOVERY		11
441
442
/* Query fork (or graph) states */
443
#define QUE_FORK_ACTIVE		1
444
#define QUE_FORK_COMMAND_WAIT	2
445
#define QUE_FORK_INVALID	3
446
#define QUE_FORK_BEING_FREED	4
447
448
/* Flag which is ORed to control structure statement node types */
449
#define QUE_NODE_CONTROL_STAT	1024
450
451
/* Query graph node types */
452
#define	QUE_NODE_LOCK		1
453
#define	QUE_NODE_INSERT		2
454
#define QUE_NODE_UPDATE		4
455
#define	QUE_NODE_CURSOR		5
456
#define	QUE_NODE_SELECT		6
457
#define	QUE_NODE_AGGREGATE	7
458
#define QUE_NODE_FORK		8
459
#define QUE_NODE_THR		9
460
#define QUE_NODE_UNDO		10
461
#define QUE_NODE_COMMIT		11
462
#define QUE_NODE_ROLLBACK	12
463
#define QUE_NODE_PURGE		13
464
#define QUE_NODE_CREATE_TABLE	14
465
#define QUE_NODE_CREATE_INDEX	15
466
#define QUE_NODE_SYMBOL		16
467
#define QUE_NODE_RES_WORD	17
468
#define QUE_NODE_FUNC		18
469
#define QUE_NODE_ORDER		19
470
#define QUE_NODE_PROC		(20 + QUE_NODE_CONTROL_STAT)
471
#define QUE_NODE_IF		(21 + QUE_NODE_CONTROL_STAT)
472
#define QUE_NODE_WHILE		(22 + QUE_NODE_CONTROL_STAT)
473
#define QUE_NODE_ASSIGNMENT	23
474
#define QUE_NODE_FETCH		24
475
#define QUE_NODE_OPEN		25
476
#define QUE_NODE_COL_ASSIGNMENT	26
477
#define QUE_NODE_FOR		(27 + QUE_NODE_CONTROL_STAT)
478
#define QUE_NODE_RETURN		28
479
#define QUE_NODE_ROW_PRINTF	29
480
#define QUE_NODE_ELSIF		30
481
#define QUE_NODE_CALL		31
482
#define QUE_NODE_EXIT		32
483
484
/* Query thread states */
485
#define QUE_THR_RUNNING		1
486
#define QUE_THR_PROCEDURE_WAIT	2
487
#define	QUE_THR_COMPLETED	3	/* in selects this means that the
488
					thread is at the end of its result set
489
					(or start, in case of a scroll cursor);
490
					in other statements, this means the
491
					thread has done its task */
492
#define QUE_THR_COMMAND_WAIT	4
493
#define QUE_THR_LOCK_WAIT	5
494
#define QUE_THR_SIG_REPLY_WAIT	6
495
#define QUE_THR_SUSPENDED	7
496
#define QUE_THR_ERROR		8
497
498
/* Query thread lock states */
499
#define QUE_THR_LOCK_NOLOCK	0
500
#define QUE_THR_LOCK_ROW	1
501
#define QUE_THR_LOCK_TABLE	2
502
503
/* From where the cursor position is counted */
504
#define QUE_CUR_NOT_DEFINED	1
505
#define QUE_CUR_START		2
506
#define	QUE_CUR_END		3
507
508
509
#ifndef UNIV_NONINL
510
#include "que0que.ic"
511
#endif
512
513
#endif