| 1 | /***************************************************************************** |
| 2 | |
| 3 | Copyright (c) 1998, 2013, Oracle and/or its affiliates. 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., |
| 15 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA |
| 16 | |
| 17 | *****************************************************************************/ |
| 18 | |
| 19 | /**************************************************//** |
| 20 | @file include/eval0proc.ic |
| 21 | Executes SQL stored procedures and their control structures |
| 22 | |
| 23 | Created 1/20/1998 Heikki Tuuri |
| 24 | *******************************************************/ |
| 25 | |
| 26 | #include "pars0pars.h" |
| 27 | #include "que0que.h" |
| 28 | #include "eval0eval.h" |
| 29 | |
| 30 | /**********************************************************************//** |
| 31 | Performs an execution step of a procedure node. |
| 32 | @return query thread to run next or NULL */ |
| 33 | UNIV_INLINE |
| 34 | que_thr_t* |
| 35 | proc_step( |
| 36 | /*======*/ |
| 37 | que_thr_t* thr) /*!< in: query thread */ |
| 38 | { |
| 39 | proc_node_t* node; |
| 40 | |
| 41 | ut_ad(thr); |
| 42 | |
| 43 | node = static_cast<proc_node_t*>(thr->run_node); |
| 44 | ut_ad(que_node_get_type(node) == QUE_NODE_PROC); |
| 45 | |
| 46 | if (thr->prev_node == que_node_get_parent(node)) { |
| 47 | /* Start execution from the first statement in the statement |
| 48 | list */ |
| 49 | |
| 50 | thr->run_node = node->stat_list; |
| 51 | } else { |
| 52 | /* Move to the next statement */ |
| 53 | ut_ad(que_node_get_next(thr->prev_node) == NULL); |
| 54 | |
| 55 | thr->run_node = NULL; |
| 56 | } |
| 57 | |
| 58 | if (thr->run_node == NULL) { |
| 59 | thr->run_node = que_node_get_parent(node); |
| 60 | } |
| 61 | |
| 62 | return(thr); |
| 63 | } |
| 64 | |
| 65 | /**********************************************************************//** |
| 66 | Performs an execution step of a procedure call node. |
| 67 | @return query thread to run next or NULL */ |
| 68 | UNIV_INLINE |
| 69 | que_thr_t* |
| 70 | proc_eval_step( |
| 71 | /*===========*/ |
| 72 | que_thr_t* thr) /*!< in: query thread */ |
| 73 | { |
| 74 | func_node_t* node; |
| 75 | |
| 76 | ut_ad(thr); |
| 77 | |
| 78 | node = static_cast<func_node_t*>(thr->run_node); |
| 79 | ut_ad(que_node_get_type(node) == QUE_NODE_FUNC); |
| 80 | |
| 81 | /* Evaluate the procedure */ |
| 82 | |
| 83 | eval_exp(node); |
| 84 | |
| 85 | thr->run_node = que_node_get_parent(node); |
| 86 | |
| 87 | return(thr); |
| 88 | } |
| 89 | |