1#include "duckdb/parser/statement/alter_statement.hpp"
2#include "duckdb/parser/statement/transaction_statement.hpp"
3#include "duckdb/planner/operator/logical_simple.hpp"
4#include "duckdb/catalog/catalog.hpp"
5#include "duckdb/catalog/catalog_entry/schema_catalog_entry.hpp"
6#include "duckdb/catalog/catalog_entry/table_catalog_entry.hpp"
7#include "duckdb/catalog/catalog_entry/view_catalog_entry.hpp"
8#include "duckdb/planner/binder.hpp"
9
10//! This file contains the binder definitions for statements that do not need to be bound at all and only require a
11//! straightforward conversion
12
13namespace duckdb {
14
15BoundStatement Binder::Bind(AlterStatement &stmt) {
16 BoundStatement result;
17 result.names = {"Success"};
18 result.types = {LogicalType::BOOLEAN};
19 BindSchemaOrCatalog(catalog&: stmt.info->catalog, schema&: stmt.info->schema);
20 auto entry = Catalog::GetEntry(context, type: stmt.info->GetCatalogType(), catalog: stmt.info->catalog, schema: stmt.info->schema,
21 name: stmt.info->name, if_not_found: stmt.info->if_not_found);
22 if (entry) {
23 auto &catalog = entry->ParentCatalog();
24 if (!entry->temporary) {
25 // we can only alter temporary tables/views in read-only mode
26 properties.modified_databases.insert(x: catalog.GetName());
27 }
28 stmt.info->catalog = catalog.GetName();
29 stmt.info->schema = entry->ParentSchema().name;
30 }
31 result.plan = make_uniq<LogicalSimple>(args: LogicalOperatorType::LOGICAL_ALTER, args: std::move(stmt.info));
32 properties.return_type = StatementReturnType::NOTHING;
33 return result;
34}
35
36BoundStatement Binder::Bind(TransactionStatement &stmt) {
37 // transaction statements do not require a valid transaction
38 properties.requires_valid_transaction = stmt.info->type == TransactionType::BEGIN_TRANSACTION;
39
40 BoundStatement result;
41 result.names = {"Success"};
42 result.types = {LogicalType::BOOLEAN};
43 result.plan = make_uniq<LogicalSimple>(args: LogicalOperatorType::LOGICAL_TRANSACTION, args: std::move(stmt.info));
44 properties.return_type = StatementReturnType::NOTHING;
45 return result;
46}
47
48} // namespace duckdb
49