drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
que0que.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (C) 1996, 2010, Innobase Oy. All Rights Reserved.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License as published by the Free Software
7Foundation; version 2 of the License.
8
9This program is distributed in the hope that it will be useful, but WITHOUT
10ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13You should have received a copy of the GNU General Public License along with
14this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15St, Fifth Floor, Boston, MA 02110-1301 USA
16
17*****************************************************************************/
18
19/**************************************************/
25
26#pragma once
27#ifndef que0que_h
28#define que0que_h
29
30#include "univ.i"
31#include "data0data.h"
32#include "dict0types.h"
33#include "trx0trx.h"
34#include "trx0roll.h"
35#include "srv0srv.h"
36#include "usr0types.h"
37#include "que0types.h"
38#include "row0types.h"
39#include "pars0types.h"
40
41/* If the following flag is set TRUE, the module will print trace info
42of SQL execution in the UNIV_SQL_DEBUG version */
43extern ibool que_trace_on;
44
45/***********************************************************************/
47UNIV_INTERN
48void
50/*==============*/
51 que_t* graph,
52 sess_t* sess);
53/***********************************************************************/
56UNIV_INTERN
57que_fork_t*
59/*============*/
60 que_t* graph,
63 que_node_t* parent,
64 ulint fork_type,
65 mem_heap_t* heap);
66/***********************************************************************/
68UNIV_INLINE
69que_thr_t*
71/*===================*/
72 que_fork_t* fork);
73/***********************************************************************/
75UNIV_INLINE
76que_node_t*
78/*===============*/
79 que_fork_t* fork);
80/***********************************************************************/
82UNIV_INLINE
83void
85/*================*/
86 que_node_t* node,
87 que_node_t* parent);
88/***********************************************************************/
91UNIV_INTERN
92que_thr_t*
94/*===========*/
95 que_fork_t* parent,
96 mem_heap_t* heap);
97/**********************************************************************/
100UNIV_INTERN
101void
103/*=====================*/
104 que_node_t* node);
105/**********************************************************************/
107UNIV_INTERN
108void
110/*===========*/
111 que_t* graph);
116/**********************************************************************/
121UNIV_INTERN
122ibool
124/*=========*/
125 que_thr_t* thr);
126/**********************************************************************/
129UNIV_INTERN
130void
132/*================================*/
133 que_thr_t* thr,
134 trx_t* trx);
135/**********************************************************************/
138UNIV_INTERN
139void
141/*============================*/
142 que_thr_t* thr,
143 trx_t* trx);
144/**********************************************************************/
149UNIV_INTERN
150void
152/*===================*/
153 que_thr_t* thr);
154/**********************************************************************/
156UNIV_INTERN
157void
159/*============*/
160 que_thr_t* thr);
161/**********************************************************************/
165UNIV_INTERN
166void
168/*==================*/
169 trx_t* trx,
170 que_t* fork);
172/**********************************************************************/
177UNIV_INTERN
178void
180/*=============*/
181 que_thr_t* thr,
185 que_thr_t** next_thr);
190/**********************************************************************/
192UNIV_INTERN
193void
195/*=========================*/
196 que_thr_t* thr);
200/**********************************************************************/
208UNIV_INTERN
209que_thr_t*
211/*===================*/
212 que_fork_t* fork);
213/***********************************************************************/
215UNIV_INLINE
216trx_t*
218/*========*/
219 que_thr_t* thr);
220/*******************************************************************/
225UNIV_INLINE
226ibool
228/*========*/
229 const que_thr_t* thr);
230/***********************************************************************/
232UNIV_INLINE
233ulint
235/*==============*/
236 que_node_t* node);
237/***********************************************************************/
239UNIV_INLINE
240dtype_t*
242/*===================*/
243 que_node_t* node);
244/***********************************************************************/
246UNIV_INLINE
247dfield_t*
249/*=============*/
250 que_node_t* node);
251/***********************************************************************/
254UNIV_INLINE
255ulint
257/*======================*/
258 que_node_t* node);
259/***********************************************************************/
261UNIV_INLINE
262void
264/*======================*/
265 que_node_t* node,
266 ulint size);
267/*********************************************************************/
269UNIV_INLINE
270que_node_t*
272/*==============*/
273 que_node_t* node);
274/*********************************************************************/
277UNIV_INLINE
278que_node_t*
280/*================*/
281 que_node_t* node);
282/****************************************************************/
286UNIV_INTERN
287que_node_t*
289/*==============================*/
290 que_node_t* node);
291/*********************************************************************/
294UNIV_INLINE
295que_node_t*
297/*===================*/
298 que_node_t* node_list,
299 que_node_t* node);
300/*********************************************************************/
303UNIV_INLINE
304ulint
306/*==================*/
307 que_node_t* node_list);
308/**********************************************************************/
314UNIV_INLINE
315ibool
317/*==============*/
318 que_thr_t* thr);
319/***********************************************************************/
322UNIV_INLINE
323ibool
325/*================*/
326 que_t* graph);
327/**********************************************************************/
329UNIV_INTERN
330void
332/*================*/
333 que_node_t* node);
334/*********************************************************************/
337UNIV_INTERN
338ulint
340/*=========*/
341 pars_info_t* info,
342 const char* sql,
343 ibool reserve_dict_mutex,
346 trx_t* trx);
347
348/* Query graph query thread node: the fields are protected by the kernel
349mutex with the exceptions named below */
350
352 que_common_t common;
353 ulint magic_n;
355 que_node_t* child;
356 que_t* graph;
357 ibool is_active;
362 ulint state;
363 UT_LIST_NODE_T(que_thr_t)
366 UT_LIST_NODE_T(que_thr_t)
369 UT_LIST_NODE_T(que_thr_t)
372 /*------------------------------*/
373 /* The following fields are private to the OS thread executing the
374 query thread, and are not protected by the kernel mutex: */
375
376 que_node_t* run_node;
379 que_node_t* prev_node;
381 ulint resource;
388};
389
390#define QUE_THR_MAGIC_N 8476583
391#define QUE_THR_MAGIC_FREED 123461526
392
393/* Query graph fork node: its fields are protected by the kernel mutex */
395 que_common_t common;
396 que_t* graph;
397 ulint fork_type;
403 trx_t* trx;
405 ulint state;
406 que_thr_t* caller;
408 UT_LIST_BASE_NODE_T(que_thr_t)
410 /*------------------------------*/
411 /* The fields in this section are defined only in the root node */
412 sym_tab_t* sym_tab;
415 pars_info_t* info;
416 /* The following cur_... fields are relevant only in a select graph */
417
418 ulint cur_end;
420 ulint cur_pos;
428 sel_node_t* last_sel_node;
430 UT_LIST_NODE_T(que_fork_t)
433 /*------------------------------*/
434 mem_heap_t* heap;
436
437};
438
439/* Query fork (or graph) types */
440#define QUE_FORK_SELECT_NON_SCROLL 1 /* forward-only cursor */
441#define QUE_FORK_SELECT_SCROLL 2 /* scrollable cursor */
442#define QUE_FORK_INSERT 3
443#define QUE_FORK_UPDATE 4
444#define QUE_FORK_ROLLBACK 5
445 /* This is really the undo graph used in rollback,
446 no signal-sending roll_node in this graph */
447#define QUE_FORK_PURGE 6
448#define QUE_FORK_EXECUTE 7
449#define QUE_FORK_PROCEDURE 8
450#define QUE_FORK_PROCEDURE_CALL 9
451#define QUE_FORK_MYSQL_INTERFACE 10
452#define QUE_FORK_RECOVERY 11
453
454/* Query fork (or graph) states */
455#define QUE_FORK_ACTIVE 1
456#define QUE_FORK_COMMAND_WAIT 2
457#define QUE_FORK_INVALID 3
458#define QUE_FORK_BEING_FREED 4
459
460/* Flag which is ORed to control structure statement node types */
461#define QUE_NODE_CONTROL_STAT 1024
462
463/* Query graph node types */
464#define QUE_NODE_LOCK 1
465#define QUE_NODE_INSERT 2
466#define QUE_NODE_UPDATE 4
467#define QUE_NODE_CURSOR 5
468#define QUE_NODE_SELECT 6
469#define QUE_NODE_AGGREGATE 7
470#define QUE_NODE_FORK 8
471#define QUE_NODE_THR 9
472#define QUE_NODE_UNDO 10
473#define QUE_NODE_COMMIT 11
474#define QUE_NODE_ROLLBACK 12
475#define QUE_NODE_PURGE 13
476#define QUE_NODE_CREATE_TABLE 14
477#define QUE_NODE_CREATE_INDEX 15
478#define QUE_NODE_SYMBOL 16
479#define QUE_NODE_RES_WORD 17
480#define QUE_NODE_FUNC 18
481#define QUE_NODE_ORDER 19
482#define QUE_NODE_PROC (20 + QUE_NODE_CONTROL_STAT)
483#define QUE_NODE_IF (21 + QUE_NODE_CONTROL_STAT)
484#define QUE_NODE_WHILE (22 + QUE_NODE_CONTROL_STAT)
485#define QUE_NODE_ASSIGNMENT 23
486#define QUE_NODE_FETCH 24
487#define QUE_NODE_OPEN 25
488#define QUE_NODE_COL_ASSIGNMENT 26
489#define QUE_NODE_FOR (27 + QUE_NODE_CONTROL_STAT)
490#define QUE_NODE_RETURN 28
491#define QUE_NODE_ROW_PRINTF 29
492#define QUE_NODE_ELSIF 30
493#define QUE_NODE_CALL 31
494#define QUE_NODE_EXIT 32
495
496/* Query thread states */
497#define QUE_THR_RUNNING 1
498#define QUE_THR_PROCEDURE_WAIT 2
499#define QUE_THR_COMPLETED 3 /* in selects this means that the
500 thread is at the end of its result set
501 (or start, in case of a scroll cursor);
502 in other statements, this means the
503 thread has done its task */
504#define QUE_THR_COMMAND_WAIT 4
505#define QUE_THR_LOCK_WAIT 5
506#define QUE_THR_SIG_REPLY_WAIT 6
507#define QUE_THR_SUSPENDED 7
508#define QUE_THR_ERROR 8
509
510/* Query thread lock states */
511#define QUE_THR_LOCK_NOLOCK 0
512#define QUE_THR_LOCK_ROW 1
513#define QUE_THR_LOCK_TABLE 2
514
515/* From where the cursor position is counted */
516#define QUE_CUR_NOT_DEFINED 1
517#define QUE_CUR_START 2
518#define QUE_CUR_END 3
519
520
521#ifndef UNIV_NONINL
522#include "que0que.ic"
523#endif
524
525#endif
UNIV_INTERN void que_thr_stop_for_mysql(que_thr_t *thr)
Definition que0que.cc:953
UNIV_INLINE dfield_t * que_node_get_val(que_node_t *node)
UNIV_INLINE ulint que_node_get_type(que_node_t *node)
UNIV_INTERN void que_thr_move_to_run_state_for_mysql(que_thr_t *thr, trx_t *trx)
Definition que0que.cc:999
UNIV_INLINE void que_node_set_val_buf_size(que_node_t *node, ulint size)
UNIV_INLINE que_node_t * que_node_get_parent(que_node_t *node)
UNIV_INTERN void que_graph_free(que_t *graph)
Definition que0que.cc:677
UNIV_INTERN void que_fork_error_handle(trx_t *trx, que_t *fork)
Definition que0que.cc:424
UNIV_INLINE ulint que_node_list_get_len(que_node_t *node_list)
UNIV_INLINE ulint que_node_get_val_buf_size(que_node_t *node)
UNIV_INTERN ibool que_thr_stop(que_thr_t *thr)
Definition que0que.cc:906
UNIV_INTERN void que_run_threads(que_thr_t *thr)
Definition que0que.cc:1328
UNIV_INTERN ulint que_eval_sql(pars_info_t *info, const char *sql, ibool reserve_dict_mutex, trx_t *trx)
Definition que0que.cc:1384
UNIV_INLINE que_thr_t * que_fork_get_first_thr(que_fork_t *fork)
UNIV_INLINE ibool thr_is_recv(const que_thr_t *thr)
UNIV_INTERN que_thr_t * que_thr_create(que_fork_t *parent, mem_heap_t *heap)
Definition que0que.cc:200
UNIV_INTERN void que_thr_end_wait(que_thr_t *thr, que_thr_t **next_thr)
Definition que0que.cc:238
UNIV_INLINE ibool que_thr_peek_stop(que_thr_t *thr)
UNIV_INLINE dtype_t * que_node_get_data_type(que_node_t *node)
UNIV_INTERN void que_node_print_info(que_node_t *node)
Definition que0que.cc:1094
UNIV_INTERN que_thr_t * que_fork_start_command(que_fork_t *fork)
Definition que0que.cc:340
UNIV_INLINE que_node_t * que_node_list_add_last(que_node_t *node_list, que_node_t *node)
UNIV_INTERN void que_thr_stop_for_mysql_no_error(que_thr_t *thr, trx_t *trx)
Definition que0que.cc:1031
UNIV_INTERN que_fork_t * que_fork_create(que_t *graph, que_node_t *parent, ulint fork_type, mem_heap_t *heap)
Definition que0que.cc:154
UNIV_INTERN void que_graph_publish(que_t *graph, sess_t *sess)
Definition que0que.cc:139
UNIV_INLINE que_node_t * que_node_get_next(que_node_t *node)
UNIV_INLINE ibool que_graph_is_select(que_t *graph)
UNIV_INTERN que_node_t * que_node_get_containing_loop_node(que_node_t *node)
Definition que0que.cc:1065
UNIV_INTERN void que_thr_end_wait_no_next_thr(que_thr_t *thr)
Definition que0que.cc:283
UNIV_INLINE que_node_t * que_fork_get_child(que_fork_t *fork)
UNIV_INLINE void que_node_set_parent(que_node_t *node, que_node_t *parent)
UNIV_INTERN void que_graph_free_recursive(que_node_t *node)
Definition que0que.cc:506
UNIV_INLINE trx_t * thr_get_trx(que_thr_t *thr)
pars_info_t * info
Definition que0que.h:415
que_common_t common
Definition que0que.h:395
mem_heap_t * heap
Definition que0que.h:434
ulint n_active_thrs
Definition que0que.h:398
sym_tab_t * sym_tab
Definition que0que.h:412
que_t * graph
Definition que0que.h:396
que_thr_t * caller
Definition que0que.h:406
ulint fork_type
Definition que0que.h:397
trx_t * trx
Definition que0que.h:403
sel_node_t * last_sel_node
Definition que0que.h:428
ibool cur_on_row
Definition que0que.h:425
que_node_t * child
Definition que0que.h:355
ulint fk_cascade_depth
Definition que0que.h:385
que_node_t * prev_node
Definition que0que.h:379
que_t * graph
Definition que0que.h:356
que_common_t common
Definition que0que.h:352
ulint magic_n
Definition que0que.h:353
ulint lock_state
Definition que0que.h:383
ulint resource
Definition que0que.h:381
que_node_t * run_node
Definition que0que.h:376
ibool is_active
Definition que0que.h:357
#define UT_LIST_NODE_T(TYPE)
Definition ut0lst.h:73
#define UT_LIST_BASE_NODE_T(TYPE)
Definition ut0lst.h:54