-
Notifications
You must be signed in to change notification settings - Fork 246
/
Copy pathTable.h
executable file
·69 lines (51 loc) · 1.31 KB
/
Table.h
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
#ifndef SQLPARSER_TABLEREF_H
#define SQLPARSER_TABLEREF_H
#include <stdio.h>
#include <vector>
#include "Expr.h"
namespace hsql {
struct SelectStatement;
struct JoinDefinition;
struct TableRef;
// Possible table reference types.
enum TableRefType { kTableName, kTableSelect, kTableJoin, kTableCrossProduct };
struct TableName {
char* schema;
char* name;
};
struct Alias {
Alias(char* name, std::vector<char*>* columns = nullptr);
~Alias();
char* name;
std::vector<char*>* columns;
};
// Holds reference to tables. Can be either table names or a select statement.
struct TableRef {
TableRef(TableRefType type);
virtual ~TableRef();
TableRefType type;
char* schema;
char* name;
Alias* alias;
SelectStatement* select;
std::vector<TableRef*>* list;
JoinDefinition* join;
// Returns true if a schema is set.
bool hasSchema() const;
// Returns the alias, if it is set. Otherwise the name.
const char* getName() const;
};
// Possible types of joins.
enum JoinType { kJoinInner, kJoinFull, kJoinLeft, kJoinRight, kJoinCross, kJoinNatural };
// Definition of a join construct.
struct JoinDefinition {
JoinDefinition();
virtual ~JoinDefinition();
TableRef* left;
TableRef* right;
Expr* condition;
std::vector<char*>* namedColumns;
JoinType type;
};
} // namespace hsql
#endif