1 | #include "duckdb/parser/statement/create_statement.hpp" |
---|---|
2 | #include "duckdb/parser/parsed_data/create_schema_info.hpp" |
3 | #include "duckdb/parser/transformer.hpp" |
4 | |
5 | using namespace duckdb; |
6 | using namespace std; |
7 | |
8 | unique_ptr<CreateStatement> Transformer::TransformCreateSchema(PGNode *node) { |
9 | auto stmt = reinterpret_cast<PGCreateSchemaStmt *>(node); |
10 | assert(stmt); |
11 | auto result = make_unique<CreateStatement>(); |
12 | auto info = make_unique<CreateSchemaInfo>(); |
13 | |
14 | assert(stmt->schemaname); |
15 | info->schema = stmt->schemaname; |
16 | info->on_conflict = stmt->if_not_exists ? OnCreateConflict::IGNORE : OnCreateConflict::ERROR; |
17 | |
18 | if (stmt->schemaElts) { |
19 | // schema elements |
20 | for (auto cell = stmt->schemaElts->head; cell != nullptr; cell = cell->next) { |
21 | auto node = reinterpret_cast<PGNode *>(cell->data.ptr_value); |
22 | switch (node->type) { |
23 | case T_PGCreateStmt: |
24 | case T_PGViewStmt: |
25 | default: |
26 | throw NotImplementedException("Schema element not supported yet!"); |
27 | } |
28 | } |
29 | } |
30 | result->info = move(info); |
31 | return result; |
32 | } |
33 |