/src/duckdb/src/parser/statement/copy_database_statement.cpp
Line | Count | Source |
1 | | #include "duckdb/parser/statement/copy_database_statement.hpp" |
2 | | #include "duckdb/parser/keyword_helper.hpp" |
3 | | |
4 | | namespace duckdb { |
5 | | |
6 | | CopyDatabaseStatement::CopyDatabaseStatement(Identifier from_database_p, Identifier to_database_p, |
7 | | CopyDatabaseType copy_type) |
8 | 0 | : SQLStatement(StatementType::COPY_DATABASE_STATEMENT), from_database(std::move(from_database_p)), |
9 | 0 | to_database(std::move(to_database_p)), copy_type(copy_type) { |
10 | 0 | } |
11 | | |
12 | | CopyDatabaseStatement::CopyDatabaseStatement(const CopyDatabaseStatement &other) |
13 | 0 | : SQLStatement(other), from_database(other.from_database), to_database(other.to_database), |
14 | 0 | copy_type(other.copy_type) { |
15 | 0 | } |
16 | | |
17 | 0 | unique_ptr<SQLStatement> CopyDatabaseStatement::Copy() const { |
18 | 0 | return unique_ptr<CopyDatabaseStatement>(new CopyDatabaseStatement(*this)); |
19 | 0 | } |
20 | | |
21 | 0 | string CopyDatabaseStatement::ToString() const { |
22 | 0 | string result; |
23 | 0 | result = "COPY FROM DATABASE "; |
24 | 0 | result += SQLIdentifier(from_database); |
25 | 0 | result += " TO "; |
26 | 0 | result += SQLIdentifier(to_database); |
27 | 0 | result += " ("; |
28 | 0 | switch (copy_type) { |
29 | 0 | case CopyDatabaseType::COPY_DATA: |
30 | 0 | result += "DATA"; |
31 | 0 | break; |
32 | 0 | case CopyDatabaseType::COPY_SCHEMA: |
33 | 0 | result += "SCHEMA"; |
34 | 0 | break; |
35 | 0 | default: |
36 | 0 | throw InternalException("Unsupported CopyDatabaseType"); |
37 | 0 | } |
38 | 0 | result += ")"; |
39 | 0 | return result; |
40 | 0 | } |
41 | | |
42 | | } // namespace duckdb |