1 | #include "duckdb/parser/statement/vacuum_statement.hpp" |
---|---|
2 | #include "duckdb/parser/transformer.hpp" |
3 | |
4 | namespace duckdb { |
5 | |
6 | VacuumOptions ParseOptions(int options) { |
7 | VacuumOptions result; |
8 | if (options & duckdb_libpgquery::PGVacuumOption::PG_VACOPT_VACUUM) { |
9 | result.vacuum = true; |
10 | } |
11 | if (options & duckdb_libpgquery::PGVacuumOption::PG_VACOPT_ANALYZE) { |
12 | result.analyze = true; |
13 | } |
14 | if (options & duckdb_libpgquery::PGVacuumOption::PG_VACOPT_VERBOSE) { |
15 | throw NotImplementedException("Verbose vacuum option"); |
16 | } |
17 | if (options & duckdb_libpgquery::PGVacuumOption::PG_VACOPT_FREEZE) { |
18 | throw NotImplementedException("Freeze vacuum option"); |
19 | } |
20 | if (options & duckdb_libpgquery::PGVacuumOption::PG_VACOPT_FULL) { |
21 | throw NotImplementedException("Full vacuum option"); |
22 | } |
23 | if (options & duckdb_libpgquery::PGVacuumOption::PG_VACOPT_NOWAIT) { |
24 | throw NotImplementedException("No Wait vacuum option"); |
25 | } |
26 | if (options & duckdb_libpgquery::PGVacuumOption::PG_VACOPT_SKIPTOAST) { |
27 | throw NotImplementedException("Skip Toast vacuum option"); |
28 | } |
29 | if (options & duckdb_libpgquery::PGVacuumOption::PG_VACOPT_DISABLE_PAGE_SKIPPING) { |
30 | throw NotImplementedException("Disable Page Skipping vacuum option"); |
31 | } |
32 | return result; |
33 | } |
34 | |
35 | unique_ptr<SQLStatement> Transformer::TransformVacuum(duckdb_libpgquery::PGVacuumStmt &stmt) { |
36 | auto result = make_uniq<VacuumStatement>(args: ParseOptions(options: stmt.options)); |
37 | |
38 | if (stmt.relation) { |
39 | result->info->ref = TransformRangeVar(root&: *stmt.relation); |
40 | result->info->has_table = true; |
41 | } |
42 | |
43 | if (stmt.va_cols) { |
44 | D_ASSERT(result->info->has_table); |
45 | for (auto col_node = stmt.va_cols->head; col_node != nullptr; col_node = col_node->next) { |
46 | result->info->columns.emplace_back( |
47 | args&: reinterpret_cast<duckdb_libpgquery::PGValue *>(col_node->data.ptr_value)->val.str); |
48 | } |
49 | } |
50 | return std::move(result); |
51 | } |
52 | |
53 | } // namespace duckdb |
54 |