1/***************************************************************************** 2 3Copyright (c) 1998, 2011, Oracle and/or its affiliates. All Rights Reserved. 4 5This program is free software; you can redistribute it and/or modify 6it under the terms of the GNU General Public License, version 2.0, 7as published by the Free Software Foundation. 8 9This program is also distributed with certain software (including 10but not limited to OpenSSL) that is licensed under separate terms, 11as designated in a particular file or component or in included license 12documentation. The authors of MySQL hereby grant you an additional 13permission to link the program and your derivative works with the 14separately licensed software that they have included with MySQL. 15 16This program is distributed in the hope that it will be useful, 17but WITHOUT ANY WARRANTY; without even the implied warranty of 18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19GNU General Public License, version 2.0, for more details. 20 21You should have received a copy of the GNU General Public License along with 22this program; if not, write to the Free Software Foundation, Inc., 2351 Franklin Street, Suite 500, Boston, MA 02110-1335 USA 24 25*****************************************************************************/ 26 27/**************************************************//** 28@file include/eval0proc.ic 29Executes SQL stored procedures and their control structures 30 31Created 1/20/1998 Heikki Tuuri 32*******************************************************/ 33 34#include "pars0pars.h" 35#include "que0que.h" 36#include "eval0eval.h" 37 38/**********************************************************************//** 39Performs an execution step of a procedure node. 40@return query thread to run next or NULL */ 41UNIV_INLINE 42que_thr_t* 43proc_step( 44/*======*/ 45 que_thr_t* thr) /*!< in: query thread */ 46{ 47 proc_node_t* node; 48 49 ut_ad(thr); 50 51 node = static_cast<proc_node_t*>(thr->run_node); 52 ut_ad(que_node_get_type(node) == QUE_NODE_PROC); 53 54 if (thr->prev_node == que_node_get_parent(node)) { 55 /* Start execution from the first statement in the statement 56 list */ 57 58 thr->run_node = node->stat_list; 59 } else { 60 /* Move to the next statement */ 61 ut_ad(que_node_get_next(thr->prev_node) == NULL); 62 63 thr->run_node = NULL; 64 } 65 66 if (thr->run_node == NULL) { 67 thr->run_node = que_node_get_parent(node); 68 } 69 70 return(thr); 71} 72 73/**********************************************************************//** 74Performs an execution step of a procedure call node. 75@return query thread to run next or NULL */ 76UNIV_INLINE 77que_thr_t* 78proc_eval_step( 79/*===========*/ 80 que_thr_t* thr) /*!< in: query thread */ 81{ 82 func_node_t* node; 83 84 ut_ad(thr); 85 86 node = static_cast<func_node_t*>(thr->run_node); 87 ut_ad(que_node_get_type(node) == QUE_NODE_FUNC); 88 89 /* Evaluate the procedure */ 90 91 eval_exp(node); 92 93 thr->run_node = que_node_get_parent(node); 94 95 return(thr); 96} 97