Drizzled Public API Documentation

que0que.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (C) 1996, 2010, 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 /**************************************************/
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
42 of SQL execution in the UNIV_SQL_DEBUG version */
43 extern ibool que_trace_on;
44 
45 /***********************************************************************/
47 UNIV_INTERN
48 void
50 /*==============*/
51  que_t* graph,
52  sess_t* sess);
53 /***********************************************************************/
56 UNIV_INTERN
59 /*============*/
60  que_t* graph,
63  que_node_t* parent,
64  ulint fork_type,
65  mem_heap_t* heap);
66 /***********************************************************************/
68 UNIV_INLINE
69 que_thr_t*
71 /*===================*/
72  que_fork_t* fork);
73 /***********************************************************************/
75 UNIV_INLINE
76 que_node_t*
78 /*===============*/
79  que_fork_t* fork);
80 /***********************************************************************/
82 UNIV_INLINE
83 void
85 /*================*/
86  que_node_t* node,
87  que_node_t* parent);
88 /***********************************************************************/
91 UNIV_INTERN
92 que_thr_t*
94 /*===========*/
95  que_fork_t* parent,
96  mem_heap_t* heap);
97 /**********************************************************************/
100 UNIV_INTERN
101 void
103 /*=====================*/
104  que_node_t* node);
105 /**********************************************************************/
107 UNIV_INTERN
108 void
110 /*===========*/
111  que_t* graph);
116 /**********************************************************************/
121 UNIV_INTERN
122 ibool
124 /*=========*/
125  que_thr_t* thr);
126 /**********************************************************************/
129 UNIV_INTERN
130 void
132 /*================================*/
133  que_thr_t* thr,
134  trx_t* trx);
135 /**********************************************************************/
138 UNIV_INTERN
139 void
141 /*============================*/
142  que_thr_t* thr,
143  trx_t* trx);
144 /**********************************************************************/
149 UNIV_INTERN
150 void
152 /*===================*/
153  que_thr_t* thr);
154 /**********************************************************************/
156 UNIV_INTERN
157 void
159 /*============*/
160  que_thr_t* thr);
161 /**********************************************************************/
165 UNIV_INTERN
166 void
168 /*==================*/
169  trx_t* trx,
170  que_t* fork);
172 /**********************************************************************/
177 UNIV_INTERN
178 void
180 /*=============*/
181  que_thr_t* thr,
185  que_thr_t** next_thr);
190 /**********************************************************************/
192 UNIV_INTERN
193 void
195 /*=========================*/
196  que_thr_t* thr);
200 /**********************************************************************/
208 UNIV_INTERN
209 que_thr_t*
211 /*===================*/
212  que_fork_t* fork);
213 /***********************************************************************/
215 UNIV_INLINE
216 trx_t*
218 /*========*/
219  que_thr_t* thr);
220 /*******************************************************************/
225 UNIV_INLINE
226 ibool
228 /*========*/
229  const que_thr_t* thr);
230 /***********************************************************************/
232 UNIV_INLINE
233 ulint
235 /*==============*/
236  que_node_t* node);
237 /***********************************************************************/
239 UNIV_INLINE
240 dtype_t*
242 /*===================*/
243  que_node_t* node);
244 /***********************************************************************/
246 UNIV_INLINE
247 dfield_t*
249 /*=============*/
250  que_node_t* node);
251 /***********************************************************************/
254 UNIV_INLINE
255 ulint
257 /*======================*/
258  que_node_t* node);
259 /***********************************************************************/
261 UNIV_INLINE
262 void
264 /*======================*/
265  que_node_t* node,
266  ulint size);
267 /*********************************************************************/
269 UNIV_INLINE
270 que_node_t*
272 /*==============*/
273  que_node_t* node);
274 /*********************************************************************/
277 UNIV_INLINE
278 que_node_t*
280 /*================*/
281  que_node_t* node);
282 /****************************************************************/
286 UNIV_INTERN
287 que_node_t*
289 /*==============================*/
290  que_node_t* node);
291 /*********************************************************************/
294 UNIV_INLINE
295 que_node_t*
297 /*===================*/
298  que_node_t* node_list,
299  que_node_t* node);
300 /*********************************************************************/
303 UNIV_INLINE
304 ulint
306 /*==================*/
307  que_node_t* node_list);
308 /**********************************************************************/
314 UNIV_INLINE
315 ibool
317 /*==============*/
318  que_thr_t* thr);
319 /***********************************************************************/
322 UNIV_INLINE
323 ibool
325 /*================*/
326  que_t* graph);
327 /**********************************************************************/
329 UNIV_INTERN
330 void
332 /*================*/
333  que_node_t* node);
334 /*********************************************************************/
337 UNIV_INTERN
338 ulint
340 /*=========*/
341  pars_info_t* info,
342  const char* sql,
343  ibool reserve_dict_mutex,
346  trx_t* trx);
348 /* Query graph query thread node: the fields are protected by the kernel
349 mutex with the exceptions named below */
350 
353  ulint magic_n;
355  que_node_t* child;
357  ibool is_active;
362  ulint state;
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;
383  ulint lock_state;
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 */
397  ulint fork_type;
405  ulint state;
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;
425  ibool cur_on_row;
428  sel_node_t* last_sel_node;
431  graphs;
433  /*------------------------------*/
434  mem_heap_t* heap;
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_no_error(que_thr_t *thr, trx_t *trx)
Definition: que0que.cc:1033
ulint magic_n
Definition: que0que.h:353
que_thr_t * caller
Definition: que0que.h:406
ulint fk_cascade_depth
Definition: que0que.h:385
ulint lock_state
Definition: que0que.h:383
UNIV_INLINE ulint que_node_get_val_buf_size(que_node_t *node)
UNIV_INLINE que_node_t * que_fork_get_child(que_fork_t *fork)
UNIV_INLINE que_node_t * que_node_list_add_last(que_node_t *node_list, que_node_t *node)
UNIV_INLINE void que_node_set_val_buf_size(que_node_t *node, ulint size)
ulint n_active_thrs
Definition: que0que.h:398
que_t * graph
Definition: que0que.h:356
que_common_t common
Definition: que0que.h:352
UNIV_INTERN void que_run_threads(que_thr_t *thr)
Definition: que0que.cc:1336
que_node_t * run_node
Definition: que0que.h:376
UNIV_INLINE ibool que_graph_is_select(que_t *graph)
UNIV_INTERN void que_thr_end_wait(que_thr_t *thr, que_thr_t **next_thr)
Definition: que0que.cc:240
UNIV_INLINE ulint que_node_list_get_len(que_node_t *node_list)
typedef UT_LIST_BASE_NODE_T(mutex_t) ut_list_base_node_t
UNIV_INTERN void que_fork_error_handle(trx_t *trx, que_t *fork)
Definition: que0que.cc:426
UNIV_INLINE ibool que_thr_peek_stop(que_thr_t *thr)
UNIV_INTERN que_node_t * que_node_get_containing_loop_node(que_node_t *node)
Definition: que0que.cc:1067
UNIV_INLINE dtype_t * que_node_get_data_type(que_node_t *node)
UNIV_INTERN ibool que_thr_stop(que_thr_t *thr)
Definition: que0que.cc:908
UNIV_INTERN void que_graph_free(que_t *graph)
Definition: que0que.cc:679
UNIV_INLINE void que_node_set_parent(que_node_t *node, que_node_t *parent)
#define UT_LIST_NODE_T(TYPE)
Definition: ut0lst.h:73
ulint fork_type
Definition: que0que.h:397
ulint resource
Definition: que0que.h:381
UNIV_INTERN void que_graph_free_recursive(que_node_t *node)
Definition: que0que.cc:508
UNIV_INTERN ulint que_eval_sql(pars_info_t *info, const char *sql, ibool reserve_dict_mutex, trx_t *trx)
Definition: que0que.cc:1392
UNIV_INLINE que_thr_t * que_fork_get_first_thr(que_fork_t *fork)
que_common_t common
Definition: que0que.h:395
UNIV_INTERN void que_thr_stop_for_mysql(que_thr_t *thr)
Definition: que0que.cc:955
UNIV_INTERN void que_thr_move_to_run_state_for_mysql(que_thr_t *thr, trx_t *trx)
Definition: que0que.cc:1001
UNIV_INLINE que_node_t * que_node_get_parent(que_node_t *node)
trx_t * trx
Definition: que0que.h:403
UNIV_INLINE ulint que_node_get_type(que_node_t *node)
ibool is_active
Definition: que0que.h:357
ulint state
Definition: que0que.h:362
UNIV_INLINE ibool thr_is_recv(const que_thr_t *thr)
UNIV_INLINE trx_t * thr_get_trx(que_thr_t *thr)
que_node_t * prev_node
Definition: que0que.h:379
que_node_t * child
Definition: que0que.h:355
UNIV_INLINE dfield_t * que_node_get_val(que_node_t *node)
UNIV_INTERN que_thr_t * que_thr_create(que_fork_t *parent, mem_heap_t *heap)
Definition: que0que.cc:202
UNIV_INTERN void que_thr_end_wait_no_next_thr(que_thr_t *thr)
Definition: que0que.cc:285
UNIV_INLINE que_node_t * que_node_get_next(que_node_t *node)
UNIV_INTERN que_thr_t * que_fork_start_command(que_fork_t *fork)
Definition: que0que.cc:342
que_t * graph
Definition: que0que.h:396
UNIV_INTERN void que_graph_publish(que_t *graph, sess_t *sess)
Definition: que0que.cc:141
UNIV_INTERN void que_node_print_info(que_node_t *node)
Definition: que0que.cc:1096
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:156