1 /*****************************************************************************
3 Copyright (c) 1997, 2009, Innobase Oy. All Rights Reserved.
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.
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.
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 St, Fifth Floor, Boston, MA 02110-1301 USA
17 *****************************************************************************/
19 /**************************************************//**
20 @file include/row0sel.ic
23 Created 12/19/1997 Heikki Tuuri
24 *******************************************************/
28 /*********************************************************************//**
29 Gets the plan node for the nth table in a join.
33 sel_node_get_nth_plan(
34 /*==================*/
35 sel_node_t* node, /*!< in: select node */
36 ulint i) /*!< in: get ith plan node */
38 ut_ad(i < node->n_tables);
40 return(node->plans + i);
43 /*********************************************************************//**
44 Resets the cursor defined by sel_node to the SEL_NODE_OPEN state, which means
45 that it will start fetching from the start of the result set again, regardless
46 of where it was before, and it will set intention locks on the tables. */
49 sel_node_reset_cursor(
50 /*==================*/
51 sel_node_t* node) /*!< in: select node */
53 node->state = SEL_NODE_OPEN;
56 /**********************************************************************//**
57 Performs an execution step of an open or close cursor statement node.
58 @return query thread to run next or NULL */
63 que_thr_t* thr) /*!< in: query thread */
71 node = (open_node_t*) thr->run_node;
72 ut_ad(que_node_get_type(node) == QUE_NODE_OPEN);
74 sel_node = node->cursor_def;
78 if (node->op_type == ROW_SEL_OPEN_CURSOR) {
80 /* if (sel_node->state == SEL_NODE_CLOSED) { */
82 sel_node_reset_cursor(sel_node);
87 if (sel_node->state != SEL_NODE_CLOSED) {
89 sel_node->state = SEL_NODE_CLOSED;
95 if (UNIV_EXPECT(err, DB_SUCCESS) != DB_SUCCESS) {
96 /* SQL error detected */
97 fprintf(stderr, "SQL error %lu\n", (ulong) err);
102 thr->run_node = que_node_get_parent(node);