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