1 | //===----------------------------------------------------------------------===// |
2 | // DuckDB |
3 | // |
4 | // duckdb/catalog/dcatalog.hpp |
5 | // |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #pragma once |
10 | |
11 | #include "duckdb/catalog/catalog.hpp" |
12 | |
13 | namespace duckdb { |
14 | |
15 | //! The Catalog object represents the catalog of the database. |
16 | class DuckCatalog : public Catalog { |
17 | public: |
18 | explicit DuckCatalog(AttachedDatabase &db); |
19 | ~DuckCatalog(); |
20 | |
21 | public: |
22 | bool IsDuckCatalog() override; |
23 | void Initialize(bool load_builtin) override; |
24 | string GetCatalogType() override { |
25 | return "duckdb" ; |
26 | } |
27 | |
28 | DependencyManager &GetDependencyManager() { |
29 | return *dependency_manager; |
30 | } |
31 | mutex &GetWriteLock() { |
32 | return write_lock; |
33 | } |
34 | |
35 | public: |
36 | DUCKDB_API optional_ptr<CatalogEntry> CreateSchema(CatalogTransaction transaction, CreateSchemaInfo &info) override; |
37 | DUCKDB_API void ScanSchemas(ClientContext &context, std::function<void(SchemaCatalogEntry &)> callback) override; |
38 | DUCKDB_API void ScanSchemas(std::function<void(SchemaCatalogEntry &)> callback); |
39 | |
40 | DUCKDB_API optional_ptr<SchemaCatalogEntry> |
41 | GetSchema(CatalogTransaction transaction, const string &schema_name, OnEntryNotFound if_not_found, |
42 | QueryErrorContext error_context = QueryErrorContext()) override; |
43 | |
44 | DUCKDB_API unique_ptr<PhysicalOperator> PlanCreateTableAs(ClientContext &context, LogicalCreateTable &op, |
45 | unique_ptr<PhysicalOperator> plan) override; |
46 | DUCKDB_API unique_ptr<PhysicalOperator> PlanInsert(ClientContext &context, LogicalInsert &op, |
47 | unique_ptr<PhysicalOperator> plan) override; |
48 | DUCKDB_API unique_ptr<PhysicalOperator> PlanDelete(ClientContext &context, LogicalDelete &op, |
49 | unique_ptr<PhysicalOperator> plan) override; |
50 | DUCKDB_API unique_ptr<PhysicalOperator> PlanUpdate(ClientContext &context, LogicalUpdate &op, |
51 | unique_ptr<PhysicalOperator> plan) override; |
52 | DUCKDB_API unique_ptr<LogicalOperator> BindCreateIndex(Binder &binder, CreateStatement &stmt, |
53 | TableCatalogEntry &table, |
54 | unique_ptr<LogicalOperator> plan) override; |
55 | |
56 | DatabaseSize GetDatabaseSize(ClientContext &context) override; |
57 | |
58 | DUCKDB_API bool InMemory() override; |
59 | DUCKDB_API string GetDBPath() override; |
60 | |
61 | private: |
62 | DUCKDB_API void DropSchema(CatalogTransaction transaction, DropInfo &info); |
63 | DUCKDB_API void DropSchema(ClientContext &context, DropInfo &info) override; |
64 | optional_ptr<CatalogEntry> CreateSchemaInternal(CatalogTransaction transaction, CreateSchemaInfo &info); |
65 | void Verify() override; |
66 | |
67 | private: |
68 | //! The DependencyManager manages dependencies between different catalog objects |
69 | unique_ptr<DependencyManager> dependency_manager; |
70 | //! Write lock for the catalog |
71 | mutex write_lock; |
72 | //! The catalog set holding the schemas |
73 | unique_ptr<CatalogSet> schemas; |
74 | }; |
75 | |
76 | } // namespace duckdb |
77 | |