Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::DuckCatalog Class Reference

The Catalog object represents the catalog of the database. More...

Inheritance diagram for duckdb::DuckCatalog:
Collaboration diagram for duckdb::DuckCatalog:

Public Member Functions

 DuckCatalog (AttachedDatabase &db)
bool IsDuckCatalog () override
void Initialize (bool load_builtin) override
string GetCatalogType () override
mutex & GetWriteLock ()
void SetEncryptionKeyId (const string &key_id)
string & GetEncryptionKeyId ()
void SetIsEncrypted ()
bool GetIsEncrypted ()
DUCKDB_API optional_ptr< CatalogEntry > CreateSchema (CatalogTransaction transaction, CreateSchemaInfo &info) override
 Creates a schema in the catalog.
DUCKDB_API void ScanSchemas (ClientContext &context, std::function< void(SchemaCatalogEntry &)> callback) override
 Scans all the schemas in the system one-by-one, invoking the callback for each entry.
DUCKDB_API void ScanSchemas (std::function< void(SchemaCatalogEntry &)> callback)
DUCKDB_API optional_ptr< SchemaCatalogEntry > LookupSchema (CatalogTransaction transaction, const EntryLookupInfo &schema_lookup, OnEntryNotFound if_not_found) override
DUCKDB_API PhysicalOperator & PlanCreateTableAs (ClientContext &context, PhysicalPlanGenerator &planner, LogicalCreateTable &op, PhysicalOperator &plan) override
DUCKDB_API PhysicalOperator & PlanInsert (ClientContext &context, PhysicalPlanGenerator &planner, LogicalInsert &op, optional_ptr< PhysicalOperator > plan) override
DUCKDB_API PhysicalOperator & PlanDelete (ClientContext &context, PhysicalPlanGenerator &planner, LogicalDelete &op, PhysicalOperator &plan) override
DUCKDB_API PhysicalOperator & PlanUpdate (ClientContext &context, PhysicalPlanGenerator &planner, LogicalUpdate &op, PhysicalOperator &plan) override
DUCKDB_API PhysicalOperator & PlanMergeInto (ClientContext &context, PhysicalPlanGenerator &planner, LogicalMergeInto &op, PhysicalOperator &plan) override
DUCKDB_API unique_ptr< LogicalOperator > BindCreateIndex (Binder &binder, CreateStatement &stmt, TableCatalogEntry &table, unique_ptr< LogicalOperator > plan) override
DUCKDB_API unique_ptr< LogicalOperator > BindAlterAddIndex (Binder &binder, TableCatalogEntry &table_entry, unique_ptr< LogicalOperator > plan, unique_ptr< CreateIndexInfo > create_info, unique_ptr< AlterTableInfo > alter_info) override
CatalogSet & GetSchemaCatalogSet ()
DatabaseSize GetDatabaseSize (ClientContext &context) override
vector< MetadataBlockInfo > GetMetadataInfo (ClientContext &context) override
DUCKDB_API bool InMemory () override
DUCKDB_API string GetDBPath () override
DUCKDB_API bool IsEncrypted () const override
DUCKDB_API string GetEncryptionCipher () const override
DUCKDB_API optional_idx GetCatalogVersion (ClientContext &context) override
optional_ptr< DependencyManager > GetDependencyManager () override
 Returns the dependency manager of this catalog - if the catalog has anye.
Public Member Functions inherited from duckdb::Catalog
 Catalog (AttachedDatabase &db)
DUCKDB_API AttachedDatabase & GetAttached ()
DUCKDB_API const AttachedDatabase & GetAttached () const
DUCKDB_API DatabaseInstance & GetDatabase ()
virtual void Initialize (optional_ptr< ClientContext > context, bool load_builtin)
virtual void FinalizeLoad (optional_ptr< ClientContext > context)
bool IsSystemCatalog () const
bool IsTemporaryCatalog () const
DUCKDB_API const string & GetName () const
 Returns the catalog name - based on how the catalog was attached.
DUCKDB_API idx_t GetOid ()
DUCKDB_API CatalogTransaction GetCatalogTransaction (ClientContext &context)
DUCKDB_API optional_ptr< CatalogEntry > CreateSchema (ClientContext &context, CreateSchemaInfo &info)
DUCKDB_API optional_ptr< CatalogEntry > CreateTable (CatalogTransaction transaction, BoundCreateTableInfo &info)
 Creates a table in the catalog.
DUCKDB_API optional_ptr< CatalogEntry > CreateTable (ClientContext &context, BoundCreateTableInfo &info)
DUCKDB_API optional_ptr< CatalogEntry > CreateTable (ClientContext &context, unique_ptr< CreateTableInfo > info)
 Creates a table in the catalog.
DUCKDB_API optional_ptr< CatalogEntry > CreateTableFunction (CatalogTransaction transaction, CreateTableFunctionInfo &info)
 Create a table function in the catalog.
DUCKDB_API optional_ptr< CatalogEntry > CreateTableFunction (ClientContext &context, CreateTableFunctionInfo &info)
DUCKDB_API optional_ptr< CatalogEntry > CreateTableFunction (ClientContext &context, optional_ptr< CreateTableFunctionInfo > info)
DUCKDB_API optional_ptr< CatalogEntry > CreateCopyFunction (CatalogTransaction transaction, CreateCopyFunctionInfo &info)
 Create a copy function in the catalog.
DUCKDB_API optional_ptr< CatalogEntry > CreateCopyFunction (ClientContext &context, CreateCopyFunctionInfo &info)
DUCKDB_API optional_ptr< CatalogEntry > CreatePragmaFunction (CatalogTransaction transaction, CreatePragmaFunctionInfo &info)
 Create a pragma function in the catalog.
DUCKDB_API optional_ptr< CatalogEntry > CreatePragmaFunction (ClientContext &context, CreatePragmaFunctionInfo &info)
DUCKDB_API optional_ptr< CatalogEntry > CreateFunction (CatalogTransaction transaction, CreateFunctionInfo &info)
 Create a scalar or aggregate function in the catalog.
DUCKDB_API optional_ptr< CatalogEntry > CreateFunction (ClientContext &context, CreateFunctionInfo &info)
DUCKDB_API optional_ptr< CatalogEntry > CreateView (CatalogTransaction transaction, CreateViewInfo &info)
 Creates a table in the catalog.
DUCKDB_API optional_ptr< CatalogEntry > CreateView (ClientContext &context, CreateViewInfo &info)
DUCKDB_API optional_ptr< CatalogEntry > CreateSequence (CatalogTransaction transaction, CreateSequenceInfo &info)
 Creates a sequence in the catalog.
DUCKDB_API optional_ptr< CatalogEntry > CreateSequence (ClientContext &context, CreateSequenceInfo &info)
DUCKDB_API optional_ptr< CatalogEntry > CreateType (CatalogTransaction transaction, CreateTypeInfo &info)
 Creates a Enum in the catalog.
DUCKDB_API optional_ptr< CatalogEntry > CreateType (ClientContext &context, CreateTypeInfo &info)
DUCKDB_API optional_ptr< CatalogEntry > CreateCollation (CatalogTransaction transaction, CreateCollationInfo &info)
 Creates a collation in the catalog.
DUCKDB_API optional_ptr< CatalogEntry > CreateCollation (ClientContext &context, CreateCollationInfo &info)
DUCKDB_API optional_ptr< CatalogEntry > CreateCoordinateSystem (CatalogTransaction transaction, CreateCoordinateSystemInfo &info)
 Creates a coordinate system in the catalog.
DUCKDB_API optional_ptr< CatalogEntry > CreateCoordinateSystem (ClientContext &context, CreateCoordinateSystemInfo &info)
DUCKDB_API optional_ptr< CatalogEntry > CreateIndex (CatalogTransaction transaction, CreateIndexInfo &info)
 Creates an index in the catalog.
DUCKDB_API optional_ptr< CatalogEntry > CreateIndex (ClientContext &context, CreateIndexInfo &info)
DUCKDB_API optional_ptr< CatalogEntry > CreateTable (CatalogTransaction transaction, SchemaCatalogEntry &schema, BoundCreateTableInfo &info)
 Creates a table in the catalog.
DUCKDB_API optional_ptr< CatalogEntry > CreateTableFunction (CatalogTransaction transaction, SchemaCatalogEntry &schema, CreateTableFunctionInfo &info)
 Create a table function in the catalog.
DUCKDB_API optional_ptr< CatalogEntry > CreateCopyFunction (CatalogTransaction transaction, SchemaCatalogEntry &schema, CreateCopyFunctionInfo &info)
 Create a copy function in the catalog.
DUCKDB_API optional_ptr< CatalogEntry > CreatePragmaFunction (CatalogTransaction transaction, SchemaCatalogEntry &schema, CreatePragmaFunctionInfo &info)
 Create a pragma function in the catalog.
DUCKDB_API optional_ptr< CatalogEntry > CreateFunction (CatalogTransaction transaction, SchemaCatalogEntry &schema, CreateFunctionInfo &info)
 Create a scalar or aggregate function in the catalog.
DUCKDB_API optional_ptr< CatalogEntry > CreateView (CatalogTransaction transaction, SchemaCatalogEntry &schema, CreateViewInfo &info)
 Creates a view in the catalog.
DUCKDB_API optional_ptr< CatalogEntry > CreateSequence (CatalogTransaction transaction, SchemaCatalogEntry &schema, CreateSequenceInfo &info)
 Creates a table in the catalog.
DUCKDB_API optional_ptr< CatalogEntry > CreateType (CatalogTransaction transaction, SchemaCatalogEntry &schema, CreateTypeInfo &info)
 Creates a enum in the catalog.
DUCKDB_API void DropEntry (ClientContext &context, DropInfo &info)
 Drops an entry from the catalog.
DUCKDB_API SchemaCatalogEntry & GetSchema (ClientContext &context, const EntryLookupInfo &schema_lookup)
 Returns the schema object with the specified name, or throws an exception if it does not exist.
DUCKDB_API optional_ptr< SchemaCatalogEntry > GetSchema (ClientContext &context, const EntryLookupInfo &schema_lookup, OnEntryNotFound if_not_found)
virtual DUCKDB_API bool CheckAmbiguousCatalogOrSchema (ClientContext &context, const string &schema)
 Overloadable method for giving warnings on ambiguous naming id.tab due to a database and schema with name id.
DUCKDB_API SchemaCatalogEntry & GetSchema (ClientContext &context, const string &schema)
DUCKDB_API SchemaCatalogEntry & GetSchema (CatalogTransaction transaction, const string &schema)
DUCKDB_API SchemaCatalogEntry & GetSchema (CatalogTransaction transaction, const EntryLookupInfo &schema_lookup)
DUCKDB_API optional_ptr< SchemaCatalogEntry > GetSchema (ClientContext &context, const string &schema, OnEntryNotFound if_not_found)
DUCKDB_API optional_ptr< SchemaCatalogEntry > GetSchema (CatalogTransaction transaction, const string &schema, OnEntryNotFound if_not_found)
DUCKDB_API optional_ptr< CatalogEntry > GetEntry (ClientContext &context, const string &schema, const EntryLookupInfo &lookup_info, OnEntryNotFound if_not_found)
 Gets the "schema.name" entry of the specified type, if entry does not exist behavior depends on OnEntryNotFound.
DUCKDB_API optional_ptr< CatalogEntry > GetEntry (ClientContext &context, CatalogType catalog_type, const string &schema, const string &name, OnEntryNotFound if_not_found)
DUCKDB_API optional_ptr< CatalogEntry > GetEntry (CatalogEntryRetriever &retriever, const string &schema, const EntryLookupInfo &lookup_info, OnEntryNotFound if_not_found)
DUCKDB_API CatalogEntry & GetEntry (ClientContext &context, const string &schema, const EntryLookupInfo &lookup_info)
template<class T>
optional_ptr< T > GetEntry (ClientContext &context, const string &schema_name, const string &name, OnEntryNotFound if_not_found, QueryErrorContext error_context=QueryErrorContext())
template<class T>
T & GetEntry (ClientContext &context, const string &schema_name, const string &name, QueryErrorContext error_context=QueryErrorContext())
CatalogEntry & GetEntry (ClientContext &context, CatalogType catalog_type, const string &schema_name, const string &name)
DUCKDB_API optional_ptr< CatalogEntry > AddFunction (ClientContext &context, CreateFunctionInfo &info)
 Append a scalar or aggregate function to the catalog.
DUCKDB_API void Alter (CatalogTransaction transaction, AlterInfo &info)
 Alter an existing entry in the catalog.
DUCKDB_API void Alter (ClientContext &context, AlterInfo &info)
virtual PhysicalOperator & PlanDelete (ClientContext &context, PhysicalPlanGenerator &planner, LogicalDelete &op)
virtual PhysicalOperator & PlanUpdate (ClientContext &context, PhysicalPlanGenerator &planner, LogicalUpdate &op)
virtual bool SupportsTimeTravel () const
virtual ErrorData SupportsCreateTable (BoundCreateTableInfo &info)
virtual DUCKDB_API CatalogLookupBehavior CatalogTypeLookupRule (CatalogType type) const
 Whether or not this catalog should search a specific type with the standard priority.
virtual string GetDefaultSchema () const
 Returns the default schema of the catalog.
DUCKDB_API bool HasDefaultTable () const
 Whether this catalog has a default table. Catalogs with a default table can be queries by their catalog name.
DUCKDB_API void SetDefaultTable (const string &schema, const string &name)
DUCKDB_API string GetDefaultTable () const
DUCKDB_API string GetDefaultTableSchema () const
virtual bool HasConflictingAttachOptions (const string &path, const AttachOptions &options)
 Whether attaching a catalog with the given path and attach options would be considered a conflict.
DUCKDB_API vector< reference< SchemaCatalogEntry > > GetSchemas (ClientContext &context)
virtual DUCKDB_API void OnDetach (ClientContext &context)
 Called when the catalog is detached.
CatalogEntryLookup LookupEntry (CatalogEntryRetriever &retriever, const string &schema, const EntryLookupInfo &lookup_info, OnEntryNotFound if_not_found)
 Lookup an entry using TryLookupEntry, throws if entry not found and if_not_found == THROW_EXCEPTION.
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const

Private Member Functions

DUCKDB_API void DropSchema (CatalogTransaction transaction, DropInfo &info)
DUCKDB_API void DropSchema (ClientContext &context, DropInfo &info) override
optional_ptr< CatalogEntry > CreateSchemaInternal (CatalogTransaction transaction, CreateSchemaInfo &info)
void Verify () override

Private Attributes

unique_ptr< DependencyManager > dependency_manager
 The DependencyManager manages dependencies between different catalog objects.
mutex write_lock
 Write lock for the catalog.
unique_ptr< CatalogSet > schemas
 The catalog set holding the schemas.
bool is_encrypted = false
 Identifies whether the db is encrypted.
string encryption_key_id
 If is encrypted, store the encryption key_id.

Additional Inherited Members

Static Public Member Functions inherited from duckdb::Catalog
static DUCKDB_API Catalog & GetSystemCatalog (ClientContext &context)
 Get the SystemCatalog from the ClientContext.
static DUCKDB_API Catalog & GetSystemCatalog (DatabaseInstance &db)
 Get the SystemCatalog from the DatabaseInstance.
static DUCKDB_API Catalog & GetCatalog (ClientContext &context, const string &catalog_name)
 Get the specified Catalog from the ClientContext.
static DUCKDB_API Catalog & GetCatalog (CatalogEntryRetriever &retriever, const string &catalog_name)
 Get the specified Catalog from the ClientContext.
static DUCKDB_API Catalog & GetCatalog (DatabaseInstance &db, const string &catalog_name)
 Get the specified Catalog from the DatabaseInstance.
static DUCKDB_API optional_ptr< Catalog > GetCatalogEntry (ClientContext &context, const string &catalog_name)
 Gets the specified Catalog from the database if it exists.
static DUCKDB_API optional_ptr< Catalog > GetCatalogEntry (CatalogEntryRetriever &retriever, const string &catalog_name)
 Gets the specified Catalog from the database if it exists.
static DUCKDB_API Catalog & GetCatalog (AttachedDatabase &db)
 Get the specific Catalog from the AttachedDatabase.
static DUCKDB_API optional_ptr< CatalogEntry > CreateCollation (CatalogTransaction transaction, SchemaCatalogEntry &schema, CreateCollationInfo &info)
 Creates a collation in the catalog.
static DUCKDB_API optional_ptr< CatalogEntry > CreateCoordinateSystem (CatalogTransaction transaction, SchemaCatalogEntry &schema, CreateCoordinateSystemInfo &info)
 Creates a coordinate system in the catalog.
static DUCKDB_API SchemaCatalogEntry & GetSchema (ClientContext &context, const string &catalog_name, const EntryLookupInfo &schema_lookup)
static DUCKDB_API optional_ptr< SchemaCatalogEntry > GetSchema (ClientContext &context, const string &catalog_name, const EntryLookupInfo &schema_lookup, OnEntryNotFound if_not_found)
static DUCKDB_API SchemaCatalogEntry & GetSchema (ClientContext &context, const string &catalog_name, const string &schema)
static DUCKDB_API optional_ptr< SchemaCatalogEntry > GetSchema (ClientContext &context, const string &catalog_name, const string &schema, OnEntryNotFound if_not_found)
static DUCKDB_API optional_ptr< SchemaCatalogEntry > GetSchema (CatalogEntryRetriever &retriever, const string &catalog_name, const EntryLookupInfo &schema_lookup, OnEntryNotFound if_not_found)
static DUCKDB_API optional_ptr< CatalogEntry > GetEntry (ClientContext &context, const string &catalog, const string &schema, const EntryLookupInfo &lookup_info, OnEntryNotFound if_not_found)
static DUCKDB_API optional_ptr< CatalogEntry > GetEntry (CatalogEntryRetriever &retriever, const string &catalog, const string &schema, const EntryLookupInfo &lookup_info, OnEntryNotFound if_not_found)
static DUCKDB_API CatalogEntry & GetEntry (ClientContext &context, const string &catalog, const string &schema, const EntryLookupInfo &lookup_info)
static CatalogEntry & GetEntry (ClientContext &context, CatalogType catalog_type, const string &catalog_name, const string &schema_name, const string &name)
template<class T>
static optional_ptr< T > GetEntry (ClientContext &context, const string &catalog_name, const string &schema_name, const string &name, OnEntryNotFound if_not_found, QueryErrorContext error_context=QueryErrorContext())
template<class T>
static T & GetEntry (ClientContext &context, const string &catalog_name, const string &schema_name, const string &name, QueryErrorContext error_context=QueryErrorContext())
static DUCKDB_API vector< reference< SchemaCatalogEntry > > GetSchemas (ClientContext &context, const string &catalog_name)
static DUCKDB_API vector< reference< SchemaCatalogEntry > > GetSchemas (CatalogEntryRetriever &retriever, const string &catalog_name)
static DUCKDB_API vector< reference< SchemaCatalogEntry > > GetAllSchemas (ClientContext &context)
static vector< reference< CatalogEntry > > GetAllEntries (ClientContext &context, CatalogType catalog_type)
static CatalogException UnrecognizedConfigurationError (ClientContext &context, const string &name)
static String AutoloadExtensionByConfigName (ClientContext &context, const String &configuration_name)
 Autoload the extension required for configuration_name or throw a CatalogException.
static bool AutoLoadExtensionByCatalogEntry (DatabaseInstance &db, CatalogType type, const string &entry_name)
 Autoload the extension required for function_name or throw a CatalogException.
static DUCKDB_API bool TryAutoLoad (ClientContext &context, const string &extension_name) noexcept
Protected Attributes inherited from duckdb::Catalog
AttachedDatabase & db
 Reference to the database.
string default_table
 (optionally) a default table to query for SELECT * FROM <catalog_name>;
string default_table_schema

Detailed Description

The Catalog object represents the catalog of the database.

Constructor & Destructor Documentation

◆ DuckCatalog()

duckdb::DuckCatalog::DuckCatalog ( AttachedDatabase & db)
explicit
26369 : Catalog(db), dependency_manager(make_uniq<DependencyManager>(*this)),
26370 schemas(make_uniq<CatalogSet>(*this, IsSystemCatalog() ? make_uniq<DefaultSchemaGenerator>(*this) : nullptr)) {
26371}
AttachedDatabase & db
Reference to the database.
Definition duckdb.hpp:7405
unique_ptr< DependencyManager > dependency_manager
The DependencyManager manages dependencies between different catalog objects.
Definition duckdb.cpp:22683
unique_ptr< CatalogSet > schemas
The catalog set holding the schemas.
Definition duckdb.cpp:22687

◆ ~DuckCatalog()

duckdb::DuckCatalog::~DuckCatalog ( )
override
26373 {
26374}

Member Function Documentation

◆ IsDuckCatalog()

bool duckdb::DuckCatalog::IsDuckCatalog ( )
overridevirtual

Reimplemented from duckdb::Catalog.

26400 {
26401 return true;
26402}

◆ Initialize()

void duckdb::DuckCatalog::Initialize ( bool load_builtin)
overridevirtual

Implements duckdb::Catalog.

26376 {
26377 // first initialize the base system catalogs
26378 // these are never written to the WAL
26379 // we start these at 1 because deleted entries default to 0
26380 auto data = CatalogTransaction::GetSystemTransaction(GetDatabase());
26381
26382 // create the default schema
26383 CreateSchemaInfo info;
26384 info.schema = DEFAULT_SCHEMA;
26385 info.internal = true;
26386 info.on_conflict = OnCreateConflict::IGNORE_ON_CONFLICT;
26387 CreateSchema(data, info);
26388
26389 if (load_builtin) {
26390 BuiltinFunctions builtin(data, *this);
26391 builtin.Initialize();
26392
26393 // initialize default functions
26394 FunctionList::RegisterFunctions(*this, data);
26395 }
26396
26397 Verify();
26398}
DUCKDB_API optional_ptr< CatalogEntry > CreateSchema(CatalogTransaction transaction, CreateSchemaInfo &info) override
Creates a schema in the catalog.
Definition duckdb.cpp:26425

◆ GetCatalogType()

string duckdb::DuckCatalog::GetCatalogType ( )
inlineoverridevirtual

Implements duckdb::Catalog.

22620 {
22621 return "duckdb";
22622 }

◆ GetWriteLock()

mutex & duckdb::DuckCatalog::GetWriteLock ( )
inline
22624 {
22625 return write_lock;
22626 }
mutex write_lock
Write lock for the catalog.
Definition duckdb.cpp:22685

◆ SetEncryptionKeyId()

void duckdb::DuckCatalog::SetEncryptionKeyId ( const string & key_id)
26540 {
26541 encryption_key_id = key_id;
26542}
string encryption_key_id
If is encrypted, store the encryption key_id.
Definition duckdb.cpp:22692

◆ GetEncryptionKeyId()

string & duckdb::DuckCatalog::GetEncryptionKeyId ( )
26544 {
26545 return encryption_key_id;
26546}

◆ SetIsEncrypted()

void duckdb::DuckCatalog::SetIsEncrypted ( )
26548 {
26549 is_encrypted = true;
26550}
bool is_encrypted
Identifies whether the db is encrypted.
Definition duckdb.cpp:22690

◆ GetIsEncrypted()

bool duckdb::DuckCatalog::GetIsEncrypted ( )
26552 {
26553 return is_encrypted;
26554}

◆ CreateSchema()

optional_ptr< CatalogEntry > duckdb::DuckCatalog::CreateSchema ( CatalogTransaction transaction,
CreateSchemaInfo & info )
overridevirtual

Creates a schema in the catalog.

Implements duckdb::Catalog.

26425 {
26426 D_ASSERT(!info.schema.empty());
26427 auto result = CreateSchemaInternal(transaction, info);
26428 if (!result) {
26429 switch (info.on_conflict) {
26430 case OnCreateConflict::ERROR_ON_CONFLICT:
26431 throw CatalogException::EntryAlreadyExists(CatalogType::SCHEMA_ENTRY, info.schema);
26432 case OnCreateConflict::REPLACE_ON_CONFLICT: {
26433 DropInfo drop_info;
26434 drop_info.type = CatalogType::SCHEMA_ENTRY;
26435 drop_info.catalog = info.catalog;
26436 drop_info.name = info.schema;
26437 DropSchema(transaction, drop_info);
26438 result = CreateSchemaInternal(transaction, info);
26439 if (!result) {
26440 throw InternalException("Failed to create schema entry in CREATE_OR_REPLACE");
26441 }
26442 break;
26443 }
26444 case OnCreateConflict::IGNORE_ON_CONFLICT:
26445 break;
26446 default:
26447 throw InternalException("Unsupported OnCreateConflict for CreateSchema");
26448 }
26449 return nullptr;
26450 }
26451 return result;
26452}

◆ ScanSchemas() [1/2]

void duckdb::DuckCatalog::ScanSchemas ( ClientContext & context,
std::function< void(SchemaCatalogEntry &)> callback )
overridevirtual

Scans all the schemas in the system one-by-one, invoking the callback for each entry.

Implements duckdb::Catalog.

26467 {
26468 schemas->Scan(GetCatalogTransaction(context),
26469 [&](CatalogEntry &entry) { callback(entry.Cast<SchemaCatalogEntry>()); });
26470}
Here is the caller graph for this function:

◆ ScanSchemas() [2/2]

void duckdb::DuckCatalog::ScanSchemas ( std::function< void(SchemaCatalogEntry &)> callback)
26472 {
26473 schemas->Scan([&](CatalogEntry &entry) { callback(entry.Cast<SchemaCatalogEntry>()); });
26474}

◆ LookupSchema()

optional_ptr< SchemaCatalogEntry > duckdb::DuckCatalog::LookupSchema ( CatalogTransaction transaction,
const EntryLookupInfo & schema_lookup,
OnEntryNotFound if_not_found )
overridevirtual

Implements duckdb::Catalog.

26482 {
26483 auto &schema_name = schema_lookup.GetEntryName();
26484 D_ASSERT(!schema_name.empty());
26485 auto entry = schemas->GetEntry(transaction, schema_name);
26486 if (!entry) {
26487 if (if_not_found == OnEntryNotFound::THROW_EXCEPTION) {
26488 throw CatalogException(schema_lookup.GetErrorContext(), "Schema with name %s does not exist!", schema_name);
26489 }
26490 return nullptr;
26491 }
26492 return &entry->Cast<SchemaCatalogEntry>();
26493}

◆ PlanCreateTableAs()

PhysicalOperator & duckdb::DuckCatalog::PlanCreateTableAs ( ClientContext & context,
PhysicalPlanGenerator & planner,
LogicalCreateTable & op,
PhysicalOperator & plan )
overridevirtual

Implements duckdb::Catalog.

203408 {
203409 bool parallel_streaming_insert = !PhysicalPlanGenerator::PreserveInsertionOrder(context, plan);
203410 bool use_batch_index = PhysicalPlanGenerator::UseBatchIndex(context, plan);
203411 auto num_threads = TaskScheduler::GetScheduler(context).NumberOfThreads();
203412 if (!parallel_streaming_insert && use_batch_index) {
203413 auto &insert = planner.Make<PhysicalBatchInsert>(op, op.schema, std::move(op.info), 0U);
203414 D_ASSERT(op.children.size() == 1);
203415 insert.children.push_back(plan);
203416 return insert;
203417 }
203418
203419 auto parallel = parallel_streaming_insert && num_threads > 1;
203420 auto &insert = planner.Make<PhysicalInsert>(op, op.schema, std::move(op.info), 0U, parallel);
203421 D_ASSERT(op.children.size() == 1);
203422 insert.children.push_back(plan);
203423 return insert;
203424}
static bool PreserveInsertionOrder(ClientContext &context, PhysicalOperator &plan)
Whether or not we should preserve insertion order for executing the given sink.
Definition duckdb.cpp:204829
static bool UseBatchIndex(ClientContext &context, PhysicalOperator &plan)
Whether or not we can (or should) use a batch-index based operator for executing the given sink.
Definition duckdb.cpp:204851

◆ PlanInsert()

PhysicalOperator & duckdb::DuckCatalog::PlanInsert ( ClientContext & context,
PhysicalPlanGenerator & planner,
LogicalInsert & op,
optional_ptr< PhysicalOperator > plan )
overridevirtual

Implements duckdb::Catalog.

204893 {
204894 D_ASSERT(plan);
204895 bool parallel_streaming_insert = !PhysicalPlanGenerator::PreserveInsertionOrder(context, *plan);
204896 bool use_batch_index = PhysicalPlanGenerator::UseBatchIndex(context, *plan);
204897 auto num_threads = TaskScheduler::GetScheduler(context).NumberOfThreads();
204898 if (op.return_chunk) {
204899 // not supported for RETURNING (yet?)
204900 parallel_streaming_insert = false;
204901 use_batch_index = false;
204902 }
204903 if (op.on_conflict_info.action_type != OnConflictAction::THROW) {
204904 // We don't support ON CONFLICT clause in batch insertion operation currently
204905 use_batch_index = false;
204906 }
204907 if (op.on_conflict_info.action_type == OnConflictAction::UPDATE) {
204908 // When we potentially need to perform updates, we have to check that row is not updated twice
204909 // that currently needs to be done for every chunk, which would add a huge bottleneck to parallelized insertion
204910 parallel_streaming_insert = false;
204911 }
204912 if (!op.column_index_map.empty()) {
204913 plan = planner.ResolveDefaultsProjection(op, *plan);
204914 }
204915 if (use_batch_index && !parallel_streaming_insert) {
204916 auto &insert = planner.Make<PhysicalBatchInsert>(op.types, op.table, std::move(op.bound_constraints),
204917 op.estimated_cardinality);
204918 insert.children.push_back(*plan);
204919 return insert;
204920 }
204921
204922 auto &insert = planner.Make<PhysicalInsert>(
204923 op.types, op.table, std::move(op.bound_constraints), std::move(op.expressions),
204924 std::move(op.on_conflict_info.set_columns), std::move(op.on_conflict_info.set_types), op.estimated_cardinality,
204925 op.return_chunk, parallel_streaming_insert && num_threads > 1, op.on_conflict_info.action_type,
204926 std::move(op.on_conflict_info.on_conflict_condition), std::move(op.on_conflict_info.do_update_condition),
204927 std::move(op.on_conflict_info.on_conflict_filter), std::move(op.on_conflict_info.columns_to_fetch),
204928 op.on_conflict_info.update_is_del_and_insert);
204929 insert.children.push_back(*plan);
204930 return insert;
204931}

◆ PlanDelete()

PhysicalOperator & duckdb::DuckCatalog::PlanDelete ( ClientContext & context,
PhysicalPlanGenerator & planner,
LogicalDelete & op,
PhysicalOperator & plan )
overridevirtual

Implements duckdb::Catalog.

203714 {
203715 // Get the row_id column index.
203716 auto &bound_ref = op.expressions[0]->Cast<BoundReferenceExpression>();
203717 auto &del = planner.Make<PhysicalDelete>(op.types, op.table, op.table.GetStorage(), std::move(op.bound_constraints),
203718 bound_ref.index, op.estimated_cardinality, op.return_chunk);
203719 del.children.push_back(plan);
203720 return del;
203721}

◆ PlanUpdate()

PhysicalOperator & duckdb::DuckCatalog::PlanUpdate ( ClientContext & context,
PhysicalPlanGenerator & planner,
LogicalUpdate & op,
PhysicalOperator & plan )
overridevirtual

Implements duckdb::Catalog.

206384 {
206385 auto &update = planner.Make<PhysicalUpdate>(
206386 op.types, op.table, op.table.GetStorage(), op.columns, std::move(op.expressions), std::move(op.bound_defaults),
206387 std::move(op.bound_constraints), op.estimated_cardinality, op.return_chunk);
206388 auto &cast_update = update.Cast<PhysicalUpdate>();
206389 cast_update.update_is_del_and_insert = op.update_is_del_and_insert;
206390 cast_update.children.push_back(plan);
206391 return update;
206392}

◆ PlanMergeInto()

PhysicalOperator & duckdb::DuckCatalog::PlanMergeInto ( ClientContext & context,
PhysicalPlanGenerator & planner,
LogicalMergeInto & op,
PhysicalOperator & plan )
overridevirtual

Reimplemented from duckdb::Catalog.

205235 {
205236 map<MergeActionCondition, vector<unique_ptr<MergeIntoOperator>>> actions;
205237
205238 // plan the merge into clauses
205239 // FIXME: disable parallelism when we have multiple INSERTs because they do not work nicely together currently
205240 idx_t append_count = 0;
205241 for (auto &entry : op.actions) {
205242 vector<unique_ptr<MergeIntoOperator>> planned_actions;
205243 for (auto &action : entry.second) {
205244 if (action->action_type == MergeActionType::MERGE_INSERT) {
205245 append_count++;
205246 }
205247 if (action->action_type == MergeActionType::MERGE_UPDATE && action->update_is_del_and_insert) {
205248 append_count++;
205249 }
205250 planned_actions.push_back(PlanMergeIntoAction(context, op, planner, *action));
205251 }
205252 actions.emplace(entry.first, std::move(planned_actions));
205253 }
205254
205255 bool parallel = append_count <= 1 && !op.return_chunk;
205256
205257 auto &result = planner.Make<PhysicalMergeInto>(op.types, std::move(actions), op.row_id_start, op.source_marker,
205258 parallel, op.return_chunk);
205259 result.children.push_back(plan);
205260 return result;
205261}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ BindCreateIndex()

unique_ptr< LogicalOperator > duckdb::DuckCatalog::BindCreateIndex ( Binder & binder,
CreateStatement & stmt,
TableCatalogEntry & table,
unique_ptr< LogicalOperator > plan )
overridevirtual

Reimplemented from duckdb::Catalog.

367411 {
367412 D_ASSERT(plan->type == LogicalOperatorType::LOGICAL_GET);
367413 auto create_index_info = unique_ptr_cast<CreateInfo, CreateIndexInfo>(std::move(stmt.info));
367414 IndexBinder index_binder(binder, binder.context);
367415 return index_binder.BindCreateIndex(binder.context, std::move(create_index_info), table, std::move(plan), nullptr);
367416}

◆ BindAlterAddIndex()

unique_ptr< LogicalOperator > duckdb::DuckCatalog::BindAlterAddIndex ( Binder & binder,
TableCatalogEntry & table_entry,
unique_ptr< LogicalOperator > plan,
unique_ptr< CreateIndexInfo > create_info,
unique_ptr< AlterTableInfo > alter_info )
overridevirtual

Reimplemented from duckdb::Catalog.

370541 {
370542 D_ASSERT(plan->type == LogicalOperatorType::LOGICAL_GET);
370543 IndexBinder index_binder(binder, binder.context);
370544 return index_binder.BindCreateIndex(binder.context, std::move(create_info), table_entry, std::move(plan),
370545 std::move(alter_info));
370546}

◆ GetSchemaCatalogSet()

CatalogSet & duckdb::DuckCatalog::GetSchemaCatalogSet ( )
26476 {
26477 return *schemas;
26478}

◆ GetDatabaseSize()

DatabaseSize duckdb::DuckCatalog::GetDatabaseSize ( ClientContext & context)
overridevirtual

Implements duckdb::Catalog.

26495 {
26496 auto &transaction = DuckTransactionManager::Get(db);
26497 auto lock = transaction.SharedCheckpointLock();
26498 return db.GetStorageManager().GetDatabaseSize();
26499}

◆ GetMetadataInfo()

vector< MetadataBlockInfo > duckdb::DuckCatalog::GetMetadataInfo ( ClientContext & context)
overridevirtual

Reimplemented from duckdb::Catalog.

26501 {
26502 auto &transaction = DuckTransactionManager::Get(db);
26503 auto lock = transaction.SharedCheckpointLock();
26504 return db.GetStorageManager().GetMetadataInfo();
26505}

◆ InMemory()

bool duckdb::DuckCatalog::InMemory ( )
overridevirtual

Implements duckdb::Catalog.

26507 {
26508 return db.GetStorageManager().InMemory();
26509}

◆ GetDBPath()

string duckdb::DuckCatalog::GetDBPath ( )
overridevirtual

Implements duckdb::Catalog.

26511 {
26512 return db.GetStorageManager().GetDBPath();
26513}

◆ IsEncrypted()

bool duckdb::DuckCatalog::IsEncrypted ( ) const
overridevirtual

Reimplemented from duckdb::Catalog.

26515 {
26516 return IsSystemCatalog() ? false : db.GetStorageManager().IsEncrypted();
26517}

◆ GetEncryptionCipher()

string duckdb::DuckCatalog::GetEncryptionCipher ( ) const
overridevirtual

Reimplemented from duckdb::Catalog.

26519 {
26520 return IsSystemCatalog() ? string() : EncryptionTypes::CipherToString(db.GetStorageManager().GetCipher());
26521}

◆ GetCatalogVersion()

optional_idx duckdb::DuckCatalog::GetCatalogVersion ( ClientContext & context)
overridevirtual

Returns a version number that uniquely characterizes the current catalog snapshot. If there are transaction-local changes, the version returned is >= TRANSACTION_START, o.w. it is a simple number starting at 0 that is incremented at each commit that has had catalog changes. If the catalog does not support versioning, no index is returned.

Reimplemented from duckdb::Catalog.

26530 {
26531 auto &transaction_manager = DuckTransactionManager::Get(db);
26532 auto transaction = GetCatalogTransaction(context);
26533 D_ASSERT(transaction.transaction);
26534 return transaction_manager.GetCatalogVersion(*transaction.transaction);
26535}

◆ GetDependencyManager()

optional_ptr< DependencyManager > duckdb::DuckCatalog::GetDependencyManager ( )
overridevirtual

Returns the dependency manager of this catalog - if the catalog has anye.

Reimplemented from duckdb::Catalog.

26404 {
26405 return dependency_manager.get();
26406}

◆ DropSchema() [1/2]

void duckdb::DuckCatalog::DropSchema ( CatalogTransaction transaction,
DropInfo & info )
private
26454 {
26455 D_ASSERT(!info.name.empty());
26456 if (!schemas->DropEntry(transaction, info.name, info.cascade)) {
26457 if (info.if_not_found == OnEntryNotFound::THROW_EXCEPTION) {
26458 throw CatalogException::MissingEntry(CatalogType::SCHEMA_ENTRY, info.name, string());
26459 }
26460 }
26461}

◆ DropSchema() [2/2]

void duckdb::DuckCatalog::DropSchema ( ClientContext & context,
DropInfo & info )
overrideprivatevirtual

Implements duckdb::Catalog.

26463 {
26464 DropSchema(GetCatalogTransaction(context), info);
26465}

◆ CreateSchemaInternal()

optional_ptr< CatalogEntry > duckdb::DuckCatalog::CreateSchemaInternal ( CatalogTransaction transaction,
CreateSchemaInfo & info )
private
26411 {
26412 LogicalDependencyList dependencies;
26413
26414 if (!info.internal && DefaultSchemaGenerator::IsDefaultSchema(info.schema)) {
26415 return nullptr;
26416 }
26417 auto entry = make_uniq<DuckSchemaEntry>(*this, info);
26418 auto result = entry.get();
26419 if (!schemas->CreateEntry(transaction, info.schema, std::move(entry), dependencies)) {
26420 return nullptr;
26421 }
26422 return result;
26423}

◆ Verify()

void duckdb::DuckCatalog::Verify ( )
overrideprivatevirtual

Reimplemented from duckdb::Catalog.

26523 {
26524#ifdef DEBUG
26525 Catalog::Verify();
26526 schemas->Verify(*this);
26527#endif
26528}

The documentation for this class was generated from the following file: