-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathql_select.h
More file actions
70 lines (58 loc) · 1.6 KB
/
ql_select.h
File metadata and controls
70 lines (58 loc) · 1.6 KB
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
#pragma once
#include <algorithm>
#include "Table.h"
#include "Praser.h"
class ql_select
{
public:
ql_select(string q_line);
void run();
~ql_select();
private:
const string m_sSelect;
const string select = "select";
const string where = "where";
const string from = "from";
const string distinct = "dictinct";
const string group_by = "group by";
const string order_by = "order by";
const string having = "having";
const string count = "count(";
const string max = "max(";
const string min = "min(";
const string ave = "ave(";
const string sum = "sum(";
enum AggregateFunc {
None,
Count,
Max,
Min,
Ave,
Sum
};
std::exception ex_do_not_have_table = std::exception("±í²»´æÔÚ!");
bool isdistinct = false;
struct FieldsPosition {
int pos;
string name;
std::shared_ptr<std::vector<string> > posPtr;
bool operator < (const FieldsPosition& rhs) const {
return pos < rhs.pos;
}
};
//std::shared_ptr<BaseTable> selectTable;
int run_select(string q_line, Table& ret);
int get_select(
Table & m_table,
std::shared_ptr<std::vector<string> > m_fields,
std::shared_ptr<std::vector<string> > m_where,
std::shared_ptr<std::vector<string> > m_group_by,
std::shared_ptr<std::vector<string> > m_order_by,
std::shared_ptr<std::vector<string> > m_having
);
int runWhere(Table& m_table, string s_condition);
int runGroupBy(Table& m_table, string s_condition, std::vector<string> v_fields);
int runOrderBy(Table& m_table, std::vector<string> v_condition);
int runFrom(Table& m_table, std::vector<string> v_fields);
int runHaving(Table& m_table, std::string s_condition);
};