summaryrefslogtreecommitdiff
path: root/ndb/src/old_files/client/odbc/codegen/Code_select.hpp
blob: eaa9b801f29b970c92bdb09da78ee82339274e40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/* Copyright (C) 2003 MySQL AB

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

#ifndef ODBC_CODEGEN_Code_select_hpp
#define ODBC_CODEGEN_Code_select_hpp

#include <common/common.hpp>
#include "Code_stmt.hpp"
#include "Code_expr_row.hpp"
#include "Code_table_list.hpp"
#include "Code_pred.hpp"

/**
 * @class Plan_select
 * @brief General select in PlanTree
 *
 * General select.  An initial PlanTree node.
 */
class Plan_select : public Plan_stmt {
public:
    Plan_select(Plan_root* root);
    virtual ~Plan_select();
    Plan_base* analyze(Ctx& ctx, Ctl& ctl);
    Exec_base* codegen(Ctx& ctx, Ctl& ctl);
    void print(Ctx& ctx);
    // children
    void setList(Plan_table_list* tableList);
    void setRow(Plan_expr_row* exprRow);
    void setPred(Plan_pred* pred);
    void setSort(Plan_expr_row* sortRow);
    void setDistinct(bool distinct);
    void setGroup(Plan_expr_row* groupRow);
    void setHaving(Plan_pred* havingPred);
    void setLimit(int off, int cnt);
protected:
    Plan_table_list* m_tableList;
    Plan_expr_row* m_exprRow;
    Plan_pred* m_pred;
    Plan_expr_row* m_sortRow;
    bool m_distinct;
    Plan_expr_row* m_groupRow;
    Plan_pred* m_havingPred;
    int m_limitOff;
    int m_limitCnt;
};

inline
Plan_select::Plan_select(Plan_root* root) :
    Plan_stmt(root),
    m_tableList(0),
    m_exprRow(0),
    m_pred(0),
    m_sortRow(0),
    m_distinct(false),
    m_groupRow(0),
    m_havingPred(0),
    m_limitOff(0),
    m_limitCnt(-1)
{
}

// children

inline void
Plan_select::setList(Plan_table_list* tableList)
{
    ctx_assert(tableList != 0);
    m_tableList = tableList;
}

inline void
Plan_select::setRow(Plan_expr_row* exprRow)
{
    ctx_assert(exprRow != 0);
    m_exprRow = exprRow;
}

inline void
Plan_select::setPred(Plan_pred* pred)
{
    ctx_assert(pred != 0);
    m_pred = pred;
}

inline void
Plan_select::setSort(Plan_expr_row* sortRow)
{
    ctx_assert(sortRow != 0);
    m_sortRow = sortRow;
}

inline void
Plan_select::setDistinct(bool distinct)
{
    m_distinct = distinct;
}

inline void
Plan_select::setGroup(Plan_expr_row* groupRow)
{
    ctx_assert(groupRow != 0);
    m_groupRow = groupRow;
}

inline void
Plan_select::setHaving(Plan_pred* havingPred)
{
    ctx_assert(havingPred != 0);
    m_havingPred = havingPred;
}

inline void
Plan_select::setLimit(int off, int cnt)
{
    m_limitOff = off;
    m_limitCnt = cnt;
}

#endif