1/***************************************************************************** 2 3Copyright (c) 1997, 2009, 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/row0sel.ic 29Select 30 31Created 12/19/1997 Heikki Tuuri 32*******************************************************/ 33 34#include "que0que.h" 35 36/*********************************************************************//** 37Gets the plan node for the nth table in a join. 38@return plan node */ 39UNIV_INLINE 40plan_t* 41sel_node_get_nth_plan( 42/*==================*/ 43 sel_node_t* node, /*!< in: select node */ 44 ulint i) /*!< in: get ith plan node */ 45{ 46 ut_ad(i < node->n_tables); 47 48 return(node->plans + i); 49} 50 51/*********************************************************************//** 52Resets the cursor defined by sel_node to the SEL_NODE_OPEN state, which means 53that it will start fetching from the start of the result set again, regardless 54of where it was before, and it will set intention locks on the tables. */ 55UNIV_INLINE 56void 57sel_node_reset_cursor( 58/*==================*/ 59 sel_node_t* node) /*!< in: select node */ 60{ 61 node->state = SEL_NODE_OPEN; 62} 63 64/**********************************************************************//** 65Performs an execution step of an open or close cursor statement node. 66@return query thread to run next or NULL */ 67UNIV_INLINE 68que_thr_t* 69open_step( 70/*======*/ 71 que_thr_t* thr) /*!< in: query thread */ 72{ 73 sel_node_t* sel_node; 74 open_node_t* node; 75 ulint err; 76 77 ut_ad(thr); 78 79 node = (open_node_t*) thr->run_node; 80 ut_ad(que_node_get_type(node) == QUE_NODE_OPEN); 81 82 sel_node = node->cursor_def; 83 84 err = DB_SUCCESS; 85 86 if (node->op_type == ROW_SEL_OPEN_CURSOR) { 87 88 /* if (sel_node->state == SEL_NODE_CLOSED) { */ 89 90 sel_node_reset_cursor(sel_node); 91 /* } else { 92 err = DB_ERROR; 93 } */ 94 } else { 95 if (sel_node->state != SEL_NODE_CLOSED) { 96 97 sel_node->state = SEL_NODE_CLOSED; 98 } else { 99 err = DB_ERROR; 100 } 101 } 102 103 if (err != DB_SUCCESS) { 104 /* SQL error detected */ 105 fprintf(stderr, "SQL error %lu\n", (ulong) err); 106 107 ut_error; 108 } 109 110 thr->run_node = que_node_get_parent(node); 111 112 return(thr); 113} 114