mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / storage / innodb_plugin / include / row0sel.ic
blob03c30e80dfe2202d6e90174fa3f8d64359186682
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
21 Select
23 Created 12/19/1997 Heikki Tuuri
24 *******************************************************/
26 #include "que0que.h"
28 /*********************************************************************//**
29 Gets the plan node for the nth table in a join.
30 @return plan node */
31 UNIV_INLINE
32 plan_t*
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. */
47 UNIV_INLINE
48 void
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 */
59 UNIV_INLINE
60 que_thr_t*
61 open_step(
62 /*======*/
63         que_thr_t*      thr)    /*!< in: query thread */
65         sel_node_t*     sel_node;
66         open_node_t*    node;
67         ulint           err;
69         ut_ad(thr);
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;
76         err = DB_SUCCESS;
78         if (node->op_type == ROW_SEL_OPEN_CURSOR) {
80                 /*              if (sel_node->state == SEL_NODE_CLOSED) { */
82                 sel_node_reset_cursor(sel_node);
83                 /*              } else {
84                 err = DB_ERROR;
85                 } */
86         } else {
87                 if (sel_node->state != SEL_NODE_CLOSED) {
89                         sel_node->state = SEL_NODE_CLOSED;
90                 } else {
91                         err = DB_ERROR;
92                 }
93         }
95         if (UNIV_EXPECT(err, DB_SUCCESS) != DB_SUCCESS) {
96                 /* SQL error detected */
97                 fprintf(stderr, "SQL error %lu\n", (ulong) err);
99                 ut_error;
100         }
102         thr->run_node = que_node_get_parent(node);
104         return(thr);