~percona-dev/percona-innodb-plugin/percona-innodb-1.0

« back to all changes in this revision

Viewing changes to include/row0sel.ic

  • Committer: Vadim Tkachenko
  • Date: 2008-12-01 02:05:57 UTC
  • Revision ID: vadim@percona.com-20081201020557-p7k2m94mjtdg1a83
New rw-locks

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************
 
2
Select
 
3
 
 
4
(c) 1997 Innobase Oy
 
5
 
 
6
Created 12/19/1997 Heikki Tuuri
 
7
*******************************************************/
 
8
 
 
9
#include "que0que.h"
 
10
 
 
11
/*************************************************************************
 
12
Gets the plan node for the nth table in a join. */
 
13
UNIV_INLINE
 
14
plan_t*
 
15
sel_node_get_nth_plan(
 
16
/*==================*/
 
17
                                /* out: plan node */
 
18
        sel_node_t*     node,   /* in: select node */
 
19
        ulint           i)      /* in: get ith plan node */
 
20
{
 
21
        ut_ad(i < node->n_tables);
 
22
 
 
23
        return(node->plans + i);
 
24
}
 
25
 
 
26
/*************************************************************************
 
27
Resets the cursor defined by sel_node to the SEL_NODE_OPEN state, which means
 
28
that it will start fetching from the start of the result set again, regardless
 
29
of where it was before, and it will set intention locks on the tables. */
 
30
UNIV_INLINE
 
31
void
 
32
sel_node_reset_cursor(
 
33
/*==================*/
 
34
        sel_node_t*     node)   /* in: select node */
 
35
{
 
36
        node->state = SEL_NODE_OPEN;
 
37
}
 
38
 
 
39
/**************************************************************************
 
40
Performs an execution step of an open or close cursor statement node. */
 
41
UNIV_INLINE
 
42
que_thr_t*
 
43
open_step(
 
44
/*======*/
 
45
                                /* out: query thread to run next or NULL */
 
46
        que_thr_t*      thr)    /* in: query thread */
 
47
{
 
48
        sel_node_t*     sel_node;
 
49
        open_node_t*    node;
 
50
        ulint           err;
 
51
 
 
52
        ut_ad(thr);
 
53
 
 
54
        node = (open_node_t*) thr->run_node;
 
55
        ut_ad(que_node_get_type(node) == QUE_NODE_OPEN);
 
56
 
 
57
        sel_node = node->cursor_def;
 
58
 
 
59
        err = DB_SUCCESS;
 
60
 
 
61
        if (node->op_type == ROW_SEL_OPEN_CURSOR) {
 
62
 
 
63
                /*              if (sel_node->state == SEL_NODE_CLOSED) { */
 
64
 
 
65
                sel_node_reset_cursor(sel_node);
 
66
                /*              } else {
 
67
                err = DB_ERROR;
 
68
                } */
 
69
        } else {
 
70
                if (sel_node->state != SEL_NODE_CLOSED) {
 
71
 
 
72
                        sel_node->state = SEL_NODE_CLOSED;
 
73
                } else {
 
74
                        err = DB_ERROR;
 
75
                }
 
76
        }
 
77
 
 
78
        if (UNIV_EXPECT(err, DB_SUCCESS) != DB_SUCCESS) {
 
79
                /* SQL error detected */
 
80
                fprintf(stderr, "SQL error %lu\n", (ulong) err);
 
81
 
 
82
                ut_error;
 
83
        }
 
84
 
 
85
        thr->run_node = que_node_get_parent(node);
 
86
 
 
87
        return(thr);
 
88
}