Repository navigation
Expand file tree
/
Copy pathCreateStatement.h
More file actions
78 lines (66 loc) · 2.04 KB
/
Copy pathCreateStatement.h
File metadata and controls
78 lines (66 loc) · 2.04 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
70
71
72
73
74
75
76
77
#pragma once
#include "SQLStatement.h"
#include "TableAccess.h"
#include "Database.h"
#include <ostream>
// Note: Implementations of constructors and destructors can be found in statements.cpp.
namespace hsql {
struct SelectStatement;
enum class DataType {
UNKNOWN,
INT,
LONG,
FLOAT,
DOUBLE,
CHAR,
VARCHAR,
TEXT
};
// Represents the type of a column, e.g., FLOAT or VARCHAR(10)
struct ColumnType {
ColumnType() = default;
ColumnType(DataType data_type, int64_t length = 0);
DataType data_type;
int64_t length; // Used for, e.g., VARCHAR(10)
};
bool operator==(const ColumnType& lhs, const ColumnType& rhs);
bool operator!=(const ColumnType& lhs, const ColumnType& rhs);
std::ostream& operator<<(std::ostream&, const ColumnType&);
// Represents definition of a table column
struct ColumnDefinition {
ColumnDefinition(char* name, ColumnType type, bool nullable);
virtual ~ColumnDefinition();
char* name;
ColumnType type;
bool nullable;
};
enum CreateType {
kCreateTable,
kCreateTableFromTbl, // Hyrise file format
kCreateView,
kCreateDatabase
};
// Represents SQL Create statements.
// Example: "CREATE TABLE students (name TEXT, student_number INTEGER, city TEXT, grade DOUBLE)"
struct CreateStatement : SQLStatement {
CreateStatement(CreateType type);
virtual ~CreateStatement();
void tablesAccessed(TableAccessMap& accessMap) const override {
if (select != nullptr) {
select->tablesAccessed(accessMap);
}
if (tableName != nullptr) {
TableAccess::addOperation(accessMap, tableName, schema, TableAccess::OpCreate);
}
};
CreateType type;
bool temporary; // default: false
bool ifNotExists; // default: false
char* filePath; // default: nullptr
char* schema; // default: nullptr
char* tableName; // default: nullptr
std::vector<ColumnDefinition*>* columns; // default: nullptr
std::vector<char*>* viewColumns;
SelectStatement* select;
};
} // namespace hsql