-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathpostgres_create_info.hpp
63 lines (52 loc) · 1.72 KB
/
postgres_create_info.hpp
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
//===----------------------------------------------------------------------===//
// DuckDB
//
// storage/postgres_create_info.hpp
//
//
//===----------------------------------------------------------------------===//
#pragma once
#include "duckdb/catalog/catalog_entry/table_catalog_entry.hpp"
#include "duckdb/parser/parsed_data/create_table_info.hpp"
#include "postgres_utils.hpp"
namespace duckdb {
enum class PostgresCreateInfoType : uint8_t { TABLE, VIEW };
struct PostgresCreateInfo {
public:
PostgresCreateInfo(PostgresCreateInfoType type) : type(type) {
}
virtual ~PostgresCreateInfo() {
}
public:
virtual CreateInfo &GetCreateInfo() = 0;
virtual const string &GetName() const = 0;
virtual void AddColumn(ColumnDefinition def, PostgresType pg_type, const string &pg_name) = 0;
virtual void GetColumnNamesAndTypes(vector<string> &names, vector<LogicalType> &types) = 0;
virtual idx_t PhysicalColumnCount() const = 0;
virtual void AddConstraint(unique_ptr<Constraint> constraint) = 0;
PostgresCreateInfoType GetType() const {
return type;
}
public:
template <class TARGET>
TARGET &Cast() {
if (type != TARGET::TYPE) {
throw InternalException("Failed to cast PostgresCreateInfo to type - PostgresCreateInfoType mismatch");
}
return reinterpret_cast<TARGET &>(*this);
}
template <class TARGET>
const TARGET &Cast() const {
if (type != TARGET::TYPE) {
throw InternalException("Failed to cast PostgresCreateInfo to type - PostgresCreateInfoType mismatch");
}
return reinterpret_cast<const TARGET &>(*this);
}
public:
idx_t approx_num_pages = 0;
vector<PostgresType> postgres_types;
vector<string> postgres_names;
protected:
PostgresCreateInfoType type;
};
} // namespace duckdb