1
by brian
clean slate |
1 |
/******************************************************
|
2 |
Executes SQL stored procedures and their control structures
|
|
3 |
||
4 |
(c) 1998 Innobase Oy
|
|
5 |
||
6 |
Created 1/20/1998 Heikki Tuuri
|
|
7 |
*******************************************************/
|
|
8 |
||
9 |
#include "pars0pars.h" |
|
10 |
#include "que0que.h" |
|
11 |
#include "eval0eval.h" |
|
12 |
||
13 |
/**************************************************************************
|
|
14 |
Performs an execution step of a procedure node. */
|
|
15 |
UNIV_INLINE
|
|
16 |
que_thr_t* |
|
17 |
proc_step( |
|
18 |
/*======*/
|
|
19 |
/* out: query thread to run next or NULL */
|
|
20 |
que_thr_t* thr) /* in: query thread */ |
|
21 |
{
|
|
22 |
proc_node_t* node; |
|
23 |
||
24 |
ut_ad(thr); |
|
25 |
||
26 |
node = thr->run_node; |
|
27 |
ut_ad(que_node_get_type(node) == QUE_NODE_PROC); |
|
28 |
||
29 |
if (thr->prev_node == que_node_get_parent(node)) { |
|
30 |
/* Start execution from the first statement in the statement
|
|
31 |
list */
|
|
32 |
||
33 |
thr->run_node = node->stat_list; |
|
34 |
} else { |
|
35 |
/* Move to the next statement */
|
|
36 |
ut_ad(que_node_get_next(thr->prev_node) == NULL); |
|
37 |
||
38 |
thr->run_node = NULL; |
|
39 |
}
|
|
40 |
||
41 |
if (thr->run_node == NULL) { |
|
42 |
thr->run_node = que_node_get_parent(node); |
|
43 |
}
|
|
44 |
||
45 |
return(thr); |
|
46 |
}
|
|
47 |
||
48 |
/**************************************************************************
|
|
49 |
Performs an execution step of a procedure call node. */
|
|
50 |
UNIV_INLINE
|
|
51 |
que_thr_t* |
|
52 |
proc_eval_step( |
|
53 |
/*===========*/
|
|
54 |
/* out: query thread to run next or NULL */
|
|
55 |
que_thr_t* thr) /* in: query thread */ |
|
56 |
{
|
|
57 |
func_node_t* node; |
|
58 |
||
59 |
ut_ad(thr); |
|
60 |
||
61 |
node = thr->run_node; |
|
62 |
ut_ad(que_node_get_type(node) == QUE_NODE_FUNC); |
|
63 |
||
64 |
/* Evaluate the procedure */
|
|
65 |
||
66 |
eval_exp(node); |
|
67 |
||
68 |
thr->run_node = que_node_get_parent(node); |
|
69 |
||
70 |
return(thr); |
|
71 |
}
|