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::Catalog Class Referenceabstract

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

#include <duckdb.hpp>

Inheritance diagram for duckdb::Catalog:
Collaboration diagram for duckdb::Catalog:

Public Member Functions

 Catalog (AttachedDatabase &db)
 
DUCKDB_API AttachedDatabaseGetAttached ()
 
DUCKDB_API const AttachedDatabaseGetAttached () const
 
DUCKDB_API DatabaseInstanceGetDatabase ()
 
virtual bool IsDuckCatalog ()
 
virtual void Initialize (bool load_builtin)=0
 
virtual void Initialize (optional_ptr< ClientContext > context, bool load_builtin)
 
virtual void FinalizeLoad (optional_ptr< ClientContext > context)
 
bool IsSystemCatalog () const
 
bool IsTemporaryCatalog () const
 
virtual DUCKDB_API optional_idx GetCatalogVersion (ClientContext &context)
 
DUCKDB_API const string & GetName () const
 Returns the catalog name - based on how the catalog was attached.
 
DUCKDB_API idx_t GetOid ()
 
virtual DUCKDB_API string GetCatalogType ()=0
 
DUCKDB_API CatalogTransaction GetCatalogTransaction (ClientContext &context)
 
virtual DUCKDB_API optional_ptr< CatalogEntryCreateSchema (CatalogTransaction transaction, CreateSchemaInfo &info)=0
 Creates a schema in the catalog.
 
DUCKDB_API optional_ptr< CatalogEntryCreateSchema (ClientContext &context, CreateSchemaInfo &info)
 
DUCKDB_API optional_ptr< CatalogEntryCreateTable (CatalogTransaction transaction, BoundCreateTableInfo &info)
 Creates a table in the catalog.
 
DUCKDB_API optional_ptr< CatalogEntryCreateTable (ClientContext &context, BoundCreateTableInfo &info)
 
DUCKDB_API optional_ptr< CatalogEntryCreateTable (ClientContext &context, unique_ptr< CreateTableInfo > info)
 Creates a table in the catalog.
 
DUCKDB_API optional_ptr< CatalogEntryCreateTableFunction (CatalogTransaction transaction, CreateTableFunctionInfo &info)
 Create a table function in the catalog.
 
DUCKDB_API optional_ptr< CatalogEntryCreateTableFunction (ClientContext &context, CreateTableFunctionInfo &info)
 
DUCKDB_API optional_ptr< CatalogEntryCreateTableFunction (ClientContext &context, optional_ptr< CreateTableFunctionInfo > info)
 
DUCKDB_API optional_ptr< CatalogEntryCreateCopyFunction (CatalogTransaction transaction, CreateCopyFunctionInfo &info)
 Create a copy function in the catalog.
 
DUCKDB_API optional_ptr< CatalogEntryCreateCopyFunction (ClientContext &context, CreateCopyFunctionInfo &info)
 
DUCKDB_API optional_ptr< CatalogEntryCreatePragmaFunction (CatalogTransaction transaction, CreatePragmaFunctionInfo &info)
 Create a pragma function in the catalog.
 
DUCKDB_API optional_ptr< CatalogEntryCreatePragmaFunction (ClientContext &context, CreatePragmaFunctionInfo &info)
 
DUCKDB_API optional_ptr< CatalogEntryCreateFunction (CatalogTransaction transaction, CreateFunctionInfo &info)
 Create a scalar or aggregate function in the catalog.
 
DUCKDB_API optional_ptr< CatalogEntryCreateFunction (ClientContext &context, CreateFunctionInfo &info)
 
DUCKDB_API optional_ptr< CatalogEntryCreateView (CatalogTransaction transaction, CreateViewInfo &info)
 Creates a table in the catalog.
 
DUCKDB_API optional_ptr< CatalogEntryCreateView (ClientContext &context, CreateViewInfo &info)
 
DUCKDB_API optional_ptr< CatalogEntryCreateSequence (CatalogTransaction transaction, CreateSequenceInfo &info)
 Creates a sequence in the catalog.
 
DUCKDB_API optional_ptr< CatalogEntryCreateSequence (ClientContext &context, CreateSequenceInfo &info)
 
DUCKDB_API optional_ptr< CatalogEntryCreateType (CatalogTransaction transaction, CreateTypeInfo &info)
 Creates a Enum in the catalog.
 
DUCKDB_API optional_ptr< CatalogEntryCreateType (ClientContext &context, CreateTypeInfo &info)
 
DUCKDB_API optional_ptr< CatalogEntryCreateCollation (CatalogTransaction transaction, CreateCollationInfo &info)
 Creates a collation in the catalog.
 
DUCKDB_API optional_ptr< CatalogEntryCreateCollation (ClientContext &context, CreateCollationInfo &info)
 
DUCKDB_API optional_ptr< CatalogEntryCreateCoordinateSystem (CatalogTransaction transaction, CreateCoordinateSystemInfo &info)
 Creates a coordinate system in the catalog.
 
DUCKDB_API optional_ptr< CatalogEntryCreateCoordinateSystem (ClientContext &context, CreateCoordinateSystemInfo &info)
 
DUCKDB_API optional_ptr< CatalogEntryCreateIndex (CatalogTransaction transaction, CreateIndexInfo &info)
 Creates an index in the catalog.
 
DUCKDB_API optional_ptr< CatalogEntryCreateIndex (ClientContext &context, CreateIndexInfo &info)
 
DUCKDB_API optional_ptr< CatalogEntryCreateTable (CatalogTransaction transaction, SchemaCatalogEntry &schema, BoundCreateTableInfo &info)
 Creates a table in the catalog.
 
DUCKDB_API optional_ptr< CatalogEntryCreateTableFunction (CatalogTransaction transaction, SchemaCatalogEntry &schema, CreateTableFunctionInfo &info)
 Create a table function in the catalog.
 
DUCKDB_API optional_ptr< CatalogEntryCreateCopyFunction (CatalogTransaction transaction, SchemaCatalogEntry &schema, CreateCopyFunctionInfo &info)
 Create a copy function in the catalog.
 
DUCKDB_API optional_ptr< CatalogEntryCreatePragmaFunction (CatalogTransaction transaction, SchemaCatalogEntry &schema, CreatePragmaFunctionInfo &info)
 Create a pragma function in the catalog.
 
DUCKDB_API optional_ptr< CatalogEntryCreateFunction (CatalogTransaction transaction, SchemaCatalogEntry &schema, CreateFunctionInfo &info)
 Create a scalar or aggregate function in the catalog.
 
DUCKDB_API optional_ptr< CatalogEntryCreateView (CatalogTransaction transaction, SchemaCatalogEntry &schema, CreateViewInfo &info)
 Creates a view in the catalog.
 
DUCKDB_API optional_ptr< CatalogEntryCreateSequence (CatalogTransaction transaction, SchemaCatalogEntry &schema, CreateSequenceInfo &info)
 Creates a table in the catalog.
 
DUCKDB_API optional_ptr< CatalogEntryCreateType (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.
 
virtual DUCKDB_API optional_ptr< SchemaCatalogEntryLookupSchema (CatalogTransaction transaction, const EntryLookupInfo &schema_lookup, OnEntryNotFound if_not_found)=0
 
DUCKDB_API SchemaCatalogEntryGetSchema (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< SchemaCatalogEntryGetSchema (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 SchemaCatalogEntryGetSchema (ClientContext &context, const string &schema)
 
DUCKDB_API SchemaCatalogEntryGetSchema (CatalogTransaction transaction, const string &schema)
 
DUCKDB_API SchemaCatalogEntryGetSchema (CatalogTransaction transaction, const EntryLookupInfo &schema_lookup)
 
DUCKDB_API optional_ptr< SchemaCatalogEntryGetSchema (ClientContext &context, const string &schema, OnEntryNotFound if_not_found)
 
DUCKDB_API optional_ptr< SchemaCatalogEntryGetSchema (CatalogTransaction transaction, const string &schema, OnEntryNotFound if_not_found)
 
virtual DUCKDB_API void ScanSchemas (ClientContext &context, std::function< void(SchemaCatalogEntry &)> callback)=0
 Scans all the schemas in the system one-by-one, invoking the callback for each entry.
 
DUCKDB_API optional_ptr< CatalogEntryGetEntry (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< CatalogEntryGetEntry (ClientContext &context, CatalogType catalog_type, const string &schema, const string &name, OnEntryNotFound if_not_found)
 
DUCKDB_API optional_ptr< CatalogEntryGetEntry (CatalogEntryRetriever &retriever, const string &schema, const EntryLookupInfo &lookup_info, OnEntryNotFound if_not_found)
 
DUCKDB_API CatalogEntryGetEntry (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())
 
CatalogEntryGetEntry (ClientContext &context, CatalogType catalog_type, const string &schema_name, const string &name)
 
DUCKDB_API optional_ptr< CatalogEntryAddFunction (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 PhysicalOperatorPlanCreateTableAs (ClientContext &context, PhysicalPlanGenerator &planner, LogicalCreateTable &op, PhysicalOperator &plan)=0
 
virtual PhysicalOperatorPlanInsert (ClientContext &context, PhysicalPlanGenerator &planner, LogicalInsert &op, optional_ptr< PhysicalOperator > plan)=0
 
virtual PhysicalOperatorPlanDelete (ClientContext &context, PhysicalPlanGenerator &planner, LogicalDelete &op, PhysicalOperator &plan)=0
 
virtual PhysicalOperatorPlanDelete (ClientContext &context, PhysicalPlanGenerator &planner, LogicalDelete &op)
 
virtual PhysicalOperatorPlanUpdate (ClientContext &context, PhysicalPlanGenerator &planner, LogicalUpdate &op, PhysicalOperator &plan)=0
 
virtual PhysicalOperatorPlanUpdate (ClientContext &context, PhysicalPlanGenerator &planner, LogicalUpdate &op)
 
virtual PhysicalOperatorPlanMergeInto (ClientContext &context, PhysicalPlanGenerator &planner, LogicalMergeInto &op, PhysicalOperator &plan)
 
virtual unique_ptr< LogicalOperatorBindCreateIndex (Binder &binder, CreateStatement &stmt, TableCatalogEntry &table, unique_ptr< LogicalOperator > plan)
 
virtual unique_ptr< LogicalOperatorBindAlterAddIndex (Binder &binder, TableCatalogEntry &table_entry, unique_ptr< LogicalOperator > plan, unique_ptr< CreateIndexInfo > create_info, unique_ptr< AlterTableInfo > alter_info)
 
virtual DatabaseSize GetDatabaseSize (ClientContext &context)=0
 
virtual vector< MetadataBlockInfoGetMetadataInfo (ClientContext &context)
 
virtual bool InMemory ()=0
 
virtual string GetDBPath ()=0
 
virtual bool SupportsTimeTravel () const
 
virtual bool IsEncrypted () const
 
virtual string GetEncryptionCipher () 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 optional_ptr< DependencyManagerGetDependencyManager ()
 Returns the dependency manager of this catalog - if the catalog has anye.
 
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 void Verify ()
 
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 >
TARGETCast ()
 
template<class TARGET >
const TARGETCast () const
 

Static Public Member Functions

static DUCKDB_API CatalogGetSystemCatalog (ClientContext &context)
 Get the SystemCatalog from the ClientContext.
 
static DUCKDB_API CatalogGetSystemCatalog (DatabaseInstance &db)
 Get the SystemCatalog from the DatabaseInstance.
 
static DUCKDB_API CatalogGetCatalog (ClientContext &context, const string &catalog_name)
 Get the specified Catalog from the ClientContext.
 
static DUCKDB_API CatalogGetCatalog (CatalogEntryRetriever &retriever, const string &catalog_name)
 Get the specified Catalog from the ClientContext.
 
static DUCKDB_API CatalogGetCatalog (DatabaseInstance &db, const string &catalog_name)
 Get the specified Catalog from the DatabaseInstance.
 
static DUCKDB_API optional_ptr< CatalogGetCatalogEntry (ClientContext &context, const string &catalog_name)
 Gets the specified Catalog from the database if it exists.
 
static DUCKDB_API optional_ptr< CatalogGetCatalogEntry (CatalogEntryRetriever &retriever, const string &catalog_name)
 Gets the specified Catalog from the database if it exists.
 
static DUCKDB_API CatalogGetCatalog (AttachedDatabase &db)
 Get the specific Catalog from the AttachedDatabase.
 
static DUCKDB_API optional_ptr< CatalogEntryCreateCollation (CatalogTransaction transaction, SchemaCatalogEntry &schema, CreateCollationInfo &info)
 Creates a collation in the catalog.
 
static DUCKDB_API optional_ptr< CatalogEntryCreateCoordinateSystem (CatalogTransaction transaction, SchemaCatalogEntry &schema, CreateCoordinateSystemInfo &info)
 Creates a coordinate system in the catalog.
 
static DUCKDB_API SchemaCatalogEntryGetSchema (ClientContext &context, const string &catalog_name, const EntryLookupInfo &schema_lookup)
 
static DUCKDB_API optional_ptr< SchemaCatalogEntryGetSchema (ClientContext &context, const string &catalog_name, const EntryLookupInfo &schema_lookup, OnEntryNotFound if_not_found)
 
static DUCKDB_API SchemaCatalogEntryGetSchema (ClientContext &context, const string &catalog_name, const string &schema)
 
static DUCKDB_API optional_ptr< SchemaCatalogEntryGetSchema (ClientContext &context, const string &catalog_name, const string &schema, OnEntryNotFound if_not_found)
 
static DUCKDB_API optional_ptr< SchemaCatalogEntryGetSchema (CatalogEntryRetriever &retriever, const string &catalog_name, const EntryLookupInfo &schema_lookup, OnEntryNotFound if_not_found)
 
static DUCKDB_API optional_ptr< CatalogEntryGetEntry (ClientContext &context, const string &catalog, const string &schema, const EntryLookupInfo &lookup_info, OnEntryNotFound if_not_found)
 
static DUCKDB_API optional_ptr< CatalogEntryGetEntry (CatalogEntryRetriever &retriever, const string &catalog, const string &schema, const EntryLookupInfo &lookup_info, OnEntryNotFound if_not_found)
 
static DUCKDB_API CatalogEntryGetEntry (ClientContext &context, const string &catalog, const string &schema, const EntryLookupInfo &lookup_info)
 
static CatalogEntryGetEntry (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

AttachedDatabasedb
 Reference to the database.
 
string default_table
 (optionally) a default table to query for SELECT * FROM <catalog_name>;
 
string default_table_schema
 

Private Member Functions

virtual CatalogEntryLookup TryLookupEntryInternal (CatalogTransaction transaction, const string &schema, const EntryLookupInfo &lookup_info)
 Lookup an entry in the schema, returning a lookup with the entry and schema if they exist.
 
CatalogEntryLookup TryLookupEntry (CatalogEntryRetriever &retriever, const string &schema, const EntryLookupInfo &lookup_info, OnEntryNotFound if_not_found)
 
virtual void DropSchema (ClientContext &context, DropInfo &info)=0
 

Static Private Member Functions

static CatalogEntryLookup TryLookupEntry (CatalogEntryRetriever &retriever, const vector< CatalogLookup > &lookups, const EntryLookupInfo &lookup_info, OnEntryNotFound if_not_found, bool allow_default_table_lookup)
 
static CatalogEntryLookup TryLookupEntry (CatalogEntryRetriever &retriever, const string &catalog, const string &schema, const EntryLookupInfo &lookup_info, OnEntryNotFound if_not_found)
 
static CatalogEntryLookup TryLookupDefaultTable (CatalogEntryRetriever &retriever, const EntryLookupInfo &lookup_info, bool allow_ignore_at_clause=false)
 Looks for a Catalog with a DefaultTable that matches the lookup.
 
static CatalogException CreateMissingEntryException (CatalogEntryRetriever &retriever, const EntryLookupInfo &lookup_info, const reference_set_t< SchemaCatalogEntry > &schemas)
 Return an exception with did-you-mean suggestion.
 
static vector< SimilarCatalogEntrySimilarEntriesInSchemas (ClientContext &context, const EntryLookupInfo &lookup_info, const reference_set_t< SchemaCatalogEntry > &schemas)
 Return the close entry name, the distance and the belonging schema.
 

Detailed Description

The Catalog object represents the catalog of the database.

Constructor & Destructor Documentation

◆ Catalog()

duckdb::Catalog::Catalog ( AttachedDatabase db)
explicit
7147 : db(db) {
7148}
AttachedDatabase & db
Reference to the database.
Definition duckdb.hpp:7405

◆ ~Catalog()

duckdb::Catalog::~Catalog ( )
virtual
7150 {
7151}

Member Function Documentation

◆ GetSystemCatalog()

Catalog & duckdb::Catalog::GetSystemCatalog ( ClientContext context)
static

Get the SystemCatalog from the ClientContext.

7173 {
7174 return Catalog::GetSystemCatalog(*context.db);
7175}
static DUCKDB_API Catalog & GetSystemCatalog(ClientContext &context)
Get the SystemCatalog from the ClientContext.
Definition duckdb.cpp:7173
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetCatalog() [1/2]

Catalog & duckdb::Catalog::GetCatalog ( ClientContext context,
const string &  catalog_name 
)
static

Get the specified Catalog from the ClientContext.

7211 {
7212 CatalogEntryRetriever entry_retriever(context);
7213 return GetCatalog(entry_retriever, catalog_name);
7214}
static DUCKDB_API Catalog & GetCatalog(ClientContext &context, const string &catalog_name)
Get the specified Catalog from the ClientContext.
Definition duckdb.cpp:7211
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetCatalog() [2/2]

Catalog & duckdb::Catalog::GetCatalog ( CatalogEntryRetriever retriever,
const string &  catalog_name 
)
static

Get the specified Catalog from the ClientContext.

7203 {
7204 auto catalog = Catalog::GetCatalogEntry(retriever, catalog_name);
7205 if (!catalog) {
7206 throw BinderException("Catalog \"%s\" does not exist!", catalog_name);
7207 }
7208 return *catalog;
7209}
static DUCKDB_API optional_ptr< Catalog > GetCatalogEntry(ClientContext &context, const string &catalog_name)
Gets the specified Catalog from the database if it exists.
Definition duckdb.cpp:7198
Here is the call graph for this function:

◆ GetCatalogEntry() [1/2]

optional_ptr< Catalog > duckdb::Catalog::GetCatalogEntry ( ClientContext context,
const string &  catalog_name 
)
static

Gets the specified Catalog from the database if it exists.

7198 {
7199 CatalogEntryRetriever entry_retriever(context);
7200 return GetCatalogEntry(entry_retriever, catalog_name);
7201}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetCatalogEntry() [2/2]

optional_ptr< Catalog > duckdb::Catalog::GetCatalogEntry ( CatalogEntryRetriever retriever,
const string &  catalog_name 
)
static

Gets the specified Catalog from the database if it exists.

7181 {
7182 auto &context = retriever.GetContext();
7183 auto &db_manager = DatabaseManager::Get(context);
7184 if (catalog_name == TEMP_CATALOG) {
7185 return &ClientData::Get(context).temporary_objects->GetCatalog();
7186 }
7187 if (catalog_name == SYSTEM_CATALOG) {
7188 return &GetSystemCatalog(context);
7189 }
7190 auto entry =
7191 db_manager.GetDatabase(context, IsInvalidCatalog(catalog_name) ? GetDefaultCatalog(retriever) : catalog_name);
7192 if (!entry) {
7193 return nullptr;
7194 }
7195 return &entry->GetCatalog();
7196}
Here is the call graph for this function:

◆ GetAttached() [1/2]

AttachedDatabase & duckdb::Catalog::GetAttached ( )
7157 {
7158 return db;
7159}

◆ GetAttached() [2/2]

const AttachedDatabase & duckdb::Catalog::GetAttached ( ) const
7161 {
7162 return db;
7163}

◆ GetDatabase()

DatabaseInstance & duckdb::Catalog::GetDatabase ( )
7153 {
7154 return db.GetDatabase();
7155}

◆ IsDuckCatalog()

virtual bool duckdb::Catalog::IsDuckCatalog ( )
inlinevirtual
7106 {
7107 return false;
7108 }

◆ Initialize()

void duckdb::Catalog::Initialize ( optional_ptr< ClientContext context,
bool  load_builtin 
)
virtual
8385 {
8386 Initialize(load_builtin);
8387}

◆ FinalizeLoad()

void duckdb::Catalog::FinalizeLoad ( optional_ptr< ClientContext context)
virtual
8389 {
8390}

◆ IsSystemCatalog()

bool duckdb::Catalog::IsSystemCatalog ( ) const
8377 {
8378 return db.IsSystem();
8379}

◆ IsTemporaryCatalog()

bool duckdb::Catalog::IsTemporaryCatalog ( ) const
8381 {
8382 return db.IsTemporary();
8383}

◆ GetCatalogVersion()

virtual DUCKDB_API optional_idx duckdb::Catalog::GetCatalogVersion ( ClientContext context)
inlinevirtual

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 in duckdb::DuckCatalog.

7121 {
7122 return {}; // don't return anything by default
7123 }

◆ GetName()

const string & duckdb::Catalog::GetName ( ) const

Returns the catalog name - based on how the catalog was attached.

7165 {
7166 return GetAttached().GetName();
7167}
Here is the caller graph for this function:

◆ GetOid()

idx_t duckdb::Catalog::GetOid ( )
7169 {
7170 return GetAttached().oid;
7171}
idx_t oid
The oid of the entry.
Definition duckdb.hpp:6305

◆ GetCatalogTransaction()

CatalogTransaction duckdb::Catalog::GetCatalogTransaction ( ClientContext context)
7223 {
7224 return CatalogTransaction(*this, context);
7225}

◆ CreateSchema() [1/2]

virtual DUCKDB_API optional_ptr< CatalogEntry > duckdb::Catalog::CreateSchema ( CatalogTransaction  transaction,
CreateSchemaInfo info 
)
pure virtual

Creates a schema in the catalog.

Implemented in duckdb::DuckCatalog.

◆ CreateSchema() [2/2]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateSchema ( ClientContext context,
CreateSchemaInfo info 
)
7219 {
7220 return CreateSchema(GetCatalogTransaction(context), info);
7221}
virtual DUCKDB_API optional_ptr< CatalogEntry > CreateSchema(CatalogTransaction transaction, CreateSchemaInfo &info)=0
Creates a schema in the catalog.

◆ CreateTable() [1/4]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateTable ( CatalogTransaction  transaction,
BoundCreateTableInfo info 
)

Creates a table in the catalog.

7249 {
7250 auto &schema = GetSchema(transaction, info.base->schema);
7251 return CreateTable(transaction, schema, info);
7252}
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.
Definition duckdb.cpp:7493
DUCKDB_API optional_ptr< CatalogEntry > CreateTable(CatalogTransaction transaction, BoundCreateTableInfo &info)
Creates a table in the catalog.
Definition duckdb.cpp:7249
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateTable() [2/4]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateTable ( ClientContext context,
BoundCreateTableInfo info 
)
7230 {
7231 return CreateTable(GetCatalogTransaction(context), info);
7232}

◆ CreateTable() [3/4]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateTable ( ClientContext context,
unique_ptr< CreateTableInfo info 
)

Creates a table in the catalog.

7234 {
7235 auto binder = Binder::CreateBinder(context);
7236 auto bound_info = binder->BindCreateTableInfo(std::move(info));
7237 return CreateTable(context, *bound_info);
7238}
Here is the call graph for this function:

◆ CreateTableFunction() [1/4]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateTableFunction ( CatalogTransaction  transaction,
CreateTableFunctionInfo info 
)

Create a table function in the catalog.

7308 {
7309 auto &schema = GetSchema(transaction, info.schema);
7310 return CreateTableFunction(transaction, schema, info);
7311}
DUCKDB_API optional_ptr< CatalogEntry > CreateTableFunction(CatalogTransaction transaction, CreateTableFunctionInfo &info)
Create a table function in the catalog.
Definition duckdb.cpp:7308
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateTableFunction() [2/4]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateTableFunction ( ClientContext context,
CreateTableFunctionInfo info 
)
7313 {
7314 return CreateTableFunction(GetCatalogTransaction(context), info);
7315}

◆ CreateTableFunction() [3/4]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateTableFunction ( ClientContext context,
optional_ptr< CreateTableFunctionInfo info 
)
7323 {
7324 return CreateTableFunction(context, *info);
7325}

◆ CreateCopyFunction() [1/3]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateCopyFunction ( CatalogTransaction  transaction,
CreateCopyFunctionInfo info 
)

Create a copy function in the catalog.

7330 {
7331 auto &schema = GetSchema(transaction, info.schema);
7332 return CreateCopyFunction(transaction, schema, info);
7333}
DUCKDB_API optional_ptr< CatalogEntry > CreateCopyFunction(CatalogTransaction transaction, CreateCopyFunctionInfo &info)
Create a copy function in the catalog.
Definition duckdb.cpp:7330
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateCopyFunction() [2/3]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateCopyFunction ( ClientContext context,
CreateCopyFunctionInfo info 
)
7335 {
7336 return CreateCopyFunction(GetCatalogTransaction(context), info);
7337}

◆ CreatePragmaFunction() [1/3]

optional_ptr< CatalogEntry > duckdb::Catalog::CreatePragmaFunction ( CatalogTransaction  transaction,
CreatePragmaFunctionInfo info 
)

Create a pragma function in the catalog.

7348 {
7349 auto &schema = GetSchema(transaction, info.schema);
7350 return CreatePragmaFunction(transaction, schema, info);
7351}
DUCKDB_API optional_ptr< CatalogEntry > CreatePragmaFunction(CatalogTransaction transaction, CreatePragmaFunctionInfo &info)
Create a pragma function in the catalog.
Definition duckdb.cpp:7347
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreatePragmaFunction() [2/3]

optional_ptr< CatalogEntry > duckdb::Catalog::CreatePragmaFunction ( ClientContext context,
CreatePragmaFunctionInfo info 
)
7353 {
7354 return CreatePragmaFunction(GetCatalogTransaction(context), info);
7355}

◆ CreateFunction() [1/3]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateFunction ( CatalogTransaction  transaction,
CreateFunctionInfo info 
)

Create a scalar or aggregate function in the catalog.

7365 {
7366 auto &schema = GetSchema(transaction, info.schema);
7367 return CreateFunction(transaction, schema, info);
7368}
DUCKDB_API optional_ptr< CatalogEntry > CreateFunction(CatalogTransaction transaction, CreateFunctionInfo &info)
Create a scalar or aggregate function in the catalog.
Definition duckdb.cpp:7365
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateFunction() [2/3]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateFunction ( ClientContext context,
CreateFunctionInfo info 
)
7370 {
7371 return CreateFunction(GetCatalogTransaction(context), info);
7372}

◆ CreateView() [1/3]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateView ( CatalogTransaction  transaction,
CreateViewInfo info 
)

Creates a table in the catalog.

7257 {
7258 auto &schema = GetSchema(transaction, info.schema);
7259 return CreateView(transaction, schema, info);
7260}
DUCKDB_API optional_ptr< CatalogEntry > CreateView(CatalogTransaction transaction, CreateViewInfo &info)
Creates a table in the catalog.
Definition duckdb.cpp:7257
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateView() [2/3]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateView ( ClientContext context,
CreateViewInfo info 
)
7262 {
7263 return CreateView(GetCatalogTransaction(context), info);
7264}

◆ CreateSequence() [1/3]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateSequence ( CatalogTransaction  transaction,
CreateSequenceInfo info 
)

Creates a sequence in the catalog.

7274 {
7275 auto &schema = GetSchema(transaction, info.schema);
7276 return CreateSequence(transaction, schema, info);
7277}
DUCKDB_API optional_ptr< CatalogEntry > CreateSequence(CatalogTransaction transaction, CreateSequenceInfo &info)
Creates a sequence in the catalog.
Definition duckdb.cpp:7274
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateSequence() [2/3]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateSequence ( ClientContext context,
CreateSequenceInfo info 
)
7279 {
7280 return CreateSequence(GetCatalogTransaction(context), info);
7281}

◆ CreateType() [1/3]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateType ( CatalogTransaction  transaction,
CreateTypeInfo info 
)

Creates a Enum in the catalog.

7291 {
7292 auto &schema = GetSchema(transaction, info.schema);
7293 return CreateType(transaction, schema, info);
7294}
DUCKDB_API optional_ptr< CatalogEntry > CreateType(CatalogTransaction transaction, CreateTypeInfo &info)
Creates a Enum in the catalog.
Definition duckdb.cpp:7291
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateType() [2/3]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateType ( ClientContext context,
CreateTypeInfo info 
)
7296 {
7297 return CreateType(GetCatalogTransaction(context), info);
7298}

◆ CreateCollation() [1/3]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateCollation ( CatalogTransaction  transaction,
CreateCollationInfo info 
)

Creates a collation in the catalog.

7387 {
7388 auto &schema = GetSchema(transaction, info.schema);
7389 return CreateCollation(transaction, schema, info);
7390}
DUCKDB_API optional_ptr< CatalogEntry > CreateCollation(CatalogTransaction transaction, CreateCollationInfo &info)
Creates a collation in the catalog.
Definition duckdb.cpp:7387
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateCollation() [2/3]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateCollation ( ClientContext context,
CreateCollationInfo info 
)
7392 {
7393 return CreateCollation(GetCatalogTransaction(context), info);
7394}

◆ CreateCoordinateSystem() [1/3]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateCoordinateSystem ( CatalogTransaction  transaction,
CreateCoordinateSystemInfo info 
)

Creates a coordinate system in the catalog.

7405 {
7406 auto &schema = GetSchema(transaction, info.schema);
7407 return CreateCoordinateSystem(transaction, schema, info);
7408}
DUCKDB_API optional_ptr< CatalogEntry > CreateCoordinateSystem(CatalogTransaction transaction, CreateCoordinateSystemInfo &info)
Creates a coordinate system in the catalog.
Definition duckdb.cpp:7404
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateCoordinateSystem() [2/3]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateCoordinateSystem ( ClientContext context,
CreateCoordinateSystemInfo info 
)
7410 {
7411 return CreateCoordinateSystem(GetCatalogTransaction(context), info);
7412}

◆ CreateIndex() [1/2]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateIndex ( CatalogTransaction  transaction,
CreateIndexInfo info 
)

Creates an index in the catalog.

7422 {
7423 auto &schema = GetSchema(transaction, info.schema);
7424 auto &table = schema.GetEntry(transaction, CatalogType::TABLE_ENTRY, info.table)->Cast<TableCatalogEntry>();
7425 return schema.CreateIndex(transaction, info, table);
7426}
Here is the call graph for this function:

◆ CreateIndex() [2/2]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateIndex ( ClientContext context,
CreateIndexInfo info 
)
7428 {
7429 return CreateIndex(GetCatalogTransaction(context), info);
7430}
DUCKDB_API optional_ptr< CatalogEntry > CreateIndex(CatalogTransaction transaction, CreateIndexInfo &info)
Creates an index in the catalog.
Definition duckdb.cpp:7422

◆ CreateTable() [4/4]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateTable ( CatalogTransaction  transaction,
SchemaCatalogEntry schema,
BoundCreateTableInfo info 
)

Creates a table in the catalog.

7241 {
7242 auto supports_create_table = SupportsCreateTable(info);
7243 if (supports_create_table.HasError()) {
7244 supports_create_table.Throw();
7245 }
7246 return schema.CreateTable(transaction, info);
7247}
Here is the call graph for this function:

◆ CreateTableFunction() [4/4]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateTableFunction ( CatalogTransaction  transaction,
SchemaCatalogEntry schema,
CreateTableFunctionInfo info 
)

Create a table function in the catalog.

7318 {
7319 return schema.CreateTableFunction(transaction, info);
7320}
Here is the call graph for this function:

◆ CreateCopyFunction() [3/3]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateCopyFunction ( CatalogTransaction  transaction,
SchemaCatalogEntry schema,
CreateCopyFunctionInfo info 
)

Create a copy function in the catalog.

7340 {
7341 return schema.CreateCopyFunction(transaction, info);
7342}
Here is the call graph for this function:

◆ CreatePragmaFunction() [3/3]

optional_ptr< CatalogEntry > duckdb::Catalog::CreatePragmaFunction ( CatalogTransaction  transaction,
SchemaCatalogEntry schema,
CreatePragmaFunctionInfo info 
)

Create a pragma function in the catalog.

7358 {
7359 return schema.CreatePragmaFunction(transaction, info);
7360}
Here is the call graph for this function:

◆ CreateFunction() [3/3]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateFunction ( CatalogTransaction  transaction,
SchemaCatalogEntry schema,
CreateFunctionInfo info 
)

Create a scalar or aggregate function in the catalog.

7375 {
7376 return schema.CreateFunction(transaction, info);
7377}
Here is the call graph for this function:

◆ CreateView() [3/3]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateView ( CatalogTransaction  transaction,
SchemaCatalogEntry schema,
CreateViewInfo info 
)

Creates a view in the catalog.

7267 {
7268 return schema.CreateView(transaction, info);
7269}
Here is the call graph for this function:

◆ CreateSequence() [3/3]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateSequence ( CatalogTransaction  transaction,
SchemaCatalogEntry schema,
CreateSequenceInfo info 
)

Creates a table in the catalog.

7284 {
7285 return schema.CreateSequence(transaction, info);
7286}
Here is the call graph for this function:

◆ CreateType() [3/3]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateType ( CatalogTransaction  transaction,
SchemaCatalogEntry schema,
CreateTypeInfo info 
)

Creates a enum in the catalog.

7301 {
7302 return schema.CreateType(transaction, info);
7303}
Here is the call graph for this function:

◆ CreateCollation() [3/3]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateCollation ( CatalogTransaction  transaction,
SchemaCatalogEntry schema,
CreateCollationInfo info 
)
static

Creates a collation in the catalog.

7397 {
7398 return schema.CreateCollation(transaction, info);
7399}
Here is the call graph for this function:

◆ CreateCoordinateSystem() [3/3]

optional_ptr< CatalogEntry > duckdb::Catalog::CreateCoordinateSystem ( CatalogTransaction  transaction,
SchemaCatalogEntry schema,
CreateCoordinateSystemInfo info 
)
static

Creates a coordinate system in the catalog.

7415 {
7416 return schema.CreateCoordinateSystem(transaction, info);
7417}
Here is the call graph for this function:

◆ DropEntry()

void duckdb::Catalog::DropEntry ( ClientContext context,
DropInfo info 
)

Drops an entry from the catalog.

7467 {
7468 if (info.type == CatalogType::SCHEMA_ENTRY) {
7469 // DROP SCHEMA
7470 DropSchema(context, info);
7471 return;
7472 }
7473
7474 CatalogEntryRetriever retriever(context);
7475 EntryLookupInfo lookup_info(info.type, info.name);
7476 auto lookup = LookupEntry(retriever, info.schema, lookup_info, info.if_not_found);
7477 if (!lookup.Found()) {
7478 return;
7479 }
7480
7481 lookup.schema->DropEntry(context, info);
7482}
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.
Definition duckdb.cpp:7949
Here is the call graph for this function:

◆ GetSchema() [1/12]

SchemaCatalogEntry & duckdb::Catalog::GetSchema ( ClientContext context,
const EntryLookupInfo schema_lookup 
)

Returns the schema object with the specified name, or throws an exception if it does not exist.

7493 {
7494 return *Catalog::GetSchema(context, schema_lookup, OnEntryNotFound::THROW_EXCEPTION);
7495}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSchema() [2/12]

optional_ptr< SchemaCatalogEntry > duckdb::Catalog::GetSchema ( ClientContext context,
const EntryLookupInfo schema_lookup,
OnEntryNotFound  if_not_found 
)
7513 {
7514 return LookupSchema(GetCatalogTransaction(context), schema_lookup, if_not_found);
7515}

◆ CheckAmbiguousCatalogOrSchema()

bool duckdb::Catalog::CheckAmbiguousCatalogOrSchema ( ClientContext context,
const string &  schema 
)
virtual

Overloadable method for giving warnings on ambiguous naming id.tab due to a database and schema with name id.

7532 {
7533 EntryLookupInfo schema_lookup(CatalogType::SCHEMA_ENTRY, schema);
7534 return !!GetSchema(context, schema_lookup, OnEntryNotFound::RETURN_NULL);
7535}
Here is the call graph for this function:

◆ GetSchema() [3/12]

SchemaCatalogEntry & duckdb::Catalog::GetSchema ( ClientContext context,
const string &  schema 
)
7484 {
7485 return GetSchema(GetCatalogTransaction(context), schema);
7486}

◆ GetSchema() [4/12]

SchemaCatalogEntry & duckdb::Catalog::GetSchema ( CatalogTransaction  transaction,
const string &  schema 
)
7488 {
7489 EntryLookupInfo schema_lookup(CatalogType::SCHEMA_ENTRY, schema);
7490 return GetSchema(transaction, schema_lookup);
7491}

◆ GetSchema() [5/12]

SchemaCatalogEntry & duckdb::Catalog::GetSchema ( CatalogTransaction  transaction,
const EntryLookupInfo schema_lookup 
)
7528 {
7529 return *LookupSchema(transaction, schema_lookup, OnEntryNotFound::THROW_EXCEPTION);
7530}

◆ GetSchema() [6/12]

SchemaCatalogEntry & duckdb::Catalog::GetSchema ( ClientContext context,
const string &  catalog_name,
const EntryLookupInfo schema_lookup 
)
static
7524 {
7525 return *Catalog::GetSchema(context, catalog_name, schema_lookup, OnEntryNotFound::THROW_EXCEPTION);
7526}

◆ GetSchema() [7/12]

optional_ptr< SchemaCatalogEntry > duckdb::Catalog::GetSchema ( ClientContext context,
const string &  schema,
OnEntryNotFound  if_not_found 
)
7502 {
7503 return GetSchema(GetCatalogTransaction(context), schema, if_not_found);
7504}

◆ GetSchema() [8/12]

optional_ptr< SchemaCatalogEntry > duckdb::Catalog::GetSchema ( CatalogTransaction  transaction,
const string &  schema,
OnEntryNotFound  if_not_found 
)
7507 {
7508 EntryLookupInfo schema_lookup(CatalogType::SCHEMA_ENTRY, schema);
7509 return LookupSchema(transaction, schema_lookup, if_not_found);
7510}

◆ GetSchema() [9/12]

optional_ptr< SchemaCatalogEntry > duckdb::Catalog::GetSchema ( ClientContext context,
const string &  catalog_name,
const EntryLookupInfo schema_lookup,
OnEntryNotFound  if_not_found 
)
static
8225 {
8226 CatalogEntryRetriever retriever(context);
8227 return GetSchema(retriever, catalog_name, schema_lookup, if_not_found);
8228}

◆ GetSchema() [10/12]

SchemaCatalogEntry & duckdb::Catalog::GetSchema ( ClientContext context,
const string &  catalog_name,
const string &  schema 
)
static
7497 {
7498 return *GetSchema(context, catalog_name, schema, OnEntryNotFound::THROW_EXCEPTION);
7499}

◆ GetSchema() [11/12]

optional_ptr< SchemaCatalogEntry > duckdb::Catalog::GetSchema ( ClientContext context,
const string &  catalog_name,
const string &  schema,
OnEntryNotFound  if_not_found 
)
static
7518 {
7519 EntryLookupInfo schema_lookup(CatalogType::SCHEMA_ENTRY, schema);
7520 return GetSchema(context, catalog_name, schema_lookup, if_not_found);
7521}

◆ GetSchema() [12/12]

optional_ptr< SchemaCatalogEntry > duckdb::Catalog::GetSchema ( CatalogEntryRetriever retriever,
const string &  catalog_name,
const EntryLookupInfo schema_lookup,
OnEntryNotFound  if_not_found 
)
static
8202 {
8203 auto entries = GetCatalogEntries(retriever, catalog_name, schema_lookup.GetEntryName());
8204 for (idx_t i = 0; i < entries.size(); i++) {
8205 auto catalog = Catalog::GetCatalogEntry(retriever, entries[i].catalog);
8206 if (!catalog) {
8207 // skip if it is not an attached database
8208 continue;
8209 }
8210 const auto on_not_found = i + 1 == entries.size() ? if_not_found : OnEntryNotFound::RETURN_NULL;
8211 auto result = catalog->GetSchema(retriever.GetContext(), schema_lookup, on_not_found);
8212 if (result) {
8213 return result;
8214 }
8215 }
8216 // Catalog has not been found.
8217 if (if_not_found == OnEntryNotFound::THROW_EXCEPTION) {
8218 throw CatalogException(schema_lookup.GetErrorContext(), "Catalog with name %s does not exist!", catalog_name);
8219 }
8220 return nullptr;
8221}

◆ ScanSchemas()

virtual DUCKDB_API void duckdb::Catalog::ScanSchemas ( ClientContext context,
std::function< void(SchemaCatalogEntry &)>  callback 
)
pure virtual

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

Implemented in duckdb::DuckCatalog.

◆ GetEntry() [1/13]

optional_ptr< CatalogEntry > duckdb::Catalog::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.

8157 {
8158 CatalogEntryRetriever retriever(context);
8159 return GetEntry(retriever, schema_name, lookup_info, if_not_found);
8160}
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 OnEnt...
Definition duckdb.cpp:8156
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetEntry() [2/13]

optional_ptr< CatalogEntry > duckdb::Catalog::GetEntry ( ClientContext context,
CatalogType  catalog_type,
const string &  schema,
const string &  name,
OnEntryNotFound  if_not_found 
)
8126 {
8127 EntryLookupInfo lookup_info(catalog_type, name);
8128 return GetEntry(context, schema, lookup_info, if_not_found);
8129}

◆ GetEntry() [3/13]

optional_ptr< CatalogEntry > duckdb::Catalog::GetEntry ( CatalogEntryRetriever retriever,
const string &  schema,
const EntryLookupInfo lookup_info,
OnEntryNotFound  if_not_found 
)
8138 {
8139 auto lookup_entry = TryLookupEntry(retriever, schema_name, lookup_info, if_not_found);
8140
8141 // Try autoloading extension to resolve lookup
8142 if (!lookup_entry.Found()) {
8143 if (AutoLoadExtensionByCatalogEntry(*retriever.GetContext().db, lookup_info.GetCatalogType(),
8144 lookup_info.GetEntryName())) {
8145 lookup_entry = TryLookupEntry(retriever, schema_name, lookup_info, if_not_found);
8146 }
8147 }
8148
8149 if (lookup_entry.error.HasError()) {
8150 lookup_entry.error.Throw();
8151 }
8152
8153 return lookup_entry.entry.get();
8154}
static bool AutoLoadExtensionByCatalogEntry(DatabaseInstance &db, CatalogType type, const string &entry_name)
Autoload the extension required for function_name or throw a CatalogException.
Definition duckdb.cpp:7715
CatalogEntryLookup TryLookupEntry(CatalogEntryRetriever &retriever, const string &schema, const EntryLookupInfo &lookup_info, OnEntryNotFound if_not_found)
Definition duckdb.cpp:7905

◆ GetEntry() [4/13]

CatalogEntry & duckdb::Catalog::GetEntry ( ClientContext context,
const string &  schema,
const EntryLookupInfo lookup_info 
)
8162 {
8163 return *Catalog::GetEntry(context, schema, lookup_info, OnEntryNotFound::THROW_EXCEPTION);
8164}

◆ GetEntry() [5/13]

optional_ptr< CatalogEntry > duckdb::Catalog::GetEntry ( ClientContext context,
const string &  catalog,
const string &  schema,
const EntryLookupInfo lookup_info,
OnEntryNotFound  if_not_found 
)
static

Gets the "catalog.schema.name" entry of the specified type, if entry does not exist behavior depends on OnEntryNotFound

8190 {
8191 CatalogEntryRetriever retriever(context);
8192 return GetEntry(retriever, catalog, schema, lookup_info, if_not_found);
8193}
Here is the call graph for this function:

◆ GetEntry() [6/13]

optional_ptr< CatalogEntry > duckdb::Catalog::GetEntry ( CatalogEntryRetriever retriever,
const string &  catalog,
const string &  schema,
const EntryLookupInfo lookup_info,
OnEntryNotFound  if_not_found 
)
static
8168 {
8169 auto result = TryLookupEntry(retriever, catalog, schema, lookup_info, if_not_found);
8170
8171 // Try autoloading extension to resolve lookup
8172 if (!result.Found()) {
8173 if (AutoLoadExtensionByCatalogEntry(*retriever.GetContext().db, lookup_info.GetCatalogType(),
8174 lookup_info.GetEntryName())) {
8175 result = TryLookupEntry(retriever, catalog, schema, lookup_info, if_not_found);
8176 }
8177 }
8178
8179 if (result.error.HasError()) {
8180 result.error.Throw();
8181 }
8182
8183 if (!result.Found()) {
8184 D_ASSERT(if_not_found == OnEntryNotFound::RETURN_NULL);
8185 return nullptr;
8186 }
8187 return result.entry.get();
8188}

◆ GetEntry() [7/13]

CatalogEntry & duckdb::Catalog::GetEntry ( ClientContext context,
const string &  catalog,
const string &  schema,
const EntryLookupInfo lookup_info 
)
static
8196 {
8197 return *Catalog::GetEntry(context, catalog, schema, lookup_info, OnEntryNotFound::THROW_EXCEPTION);
8198}

◆ GetEntry() [8/13]

template<class T >
optional_ptr< T > duckdb::Catalog::GetEntry ( ClientContext context,
const string &  schema_name,
const string &  name,
OnEntryNotFound  if_not_found,
QueryErrorContext  error_context = QueryErrorContext() 
)
inline
7271 {
7272 EntryLookupInfo lookup_info(T::Type, name, error_context);
7273 auto entry = GetEntry(context, schema_name, lookup_info, if_not_found);
7274 if (!entry) {
7275 return nullptr;
7276 }
7277 if (entry->type != T::Type) {
7278 throw CatalogException(error_context, "%s is not an %s", name, T::Name);
7279 }
7280 return &entry->template Cast<T>();
7281 }

◆ GetEntry() [9/13]

template<class T >
T & duckdb::Catalog::GetEntry ( ClientContext context,
const string &  schema_name,
const string &  name,
QueryErrorContext  error_context = QueryErrorContext() 
)
inline
7285 {
7286 auto entry = GetEntry<T>(context, schema_name, name, OnEntryNotFound::THROW_EXCEPTION, error_context);
7287 return *entry;
7288 }

◆ GetEntry() [10/13]

CatalogEntry & duckdb::Catalog::GetEntry ( ClientContext context,
CatalogType  catalog_type,
const string &  catalog_name,
const string &  schema_name,
const string &  name 
)
static
8120 {
8121 EntryLookupInfo lookup_info(catalog_type, name);
8122 return GetEntry(context, catalog_name, schema_name, lookup_info);
8123}

◆ GetEntry() [11/13]

CatalogEntry & duckdb::Catalog::GetEntry ( ClientContext context,
CatalogType  catalog_type,
const string &  schema_name,
const string &  name 
)
8132 {
8133 EntryLookupInfo lookup_info(catalog_type, name);
8134 return GetEntry(context, schema_name, lookup_info);
8135}

◆ AddFunction()

optional_ptr< CatalogEntry > duckdb::Catalog::AddFunction ( ClientContext context,
CreateFunctionInfo info 
)

Append a scalar or aggregate function to the catalog.

7379 {
7380 info.on_conflict = OnCreateConflict::ALTER_ON_CONFLICT;
7381 return CreateFunction(context, info);
7382}
Here is the call graph for this function:

◆ Alter() [1/2]

void duckdb::Catalog::Alter ( CatalogTransaction  transaction,
AlterInfo info 
)

Alter an existing entry in the catalog.

8306 {
8307 if (transaction.HasContext()) {
8308 CatalogEntryRetriever retriever(transaction.GetContext());
8309 EntryLookupInfo lookup_info(info.GetCatalogType(), info.name);
8310 auto lookup = LookupEntry(retriever, info.schema, lookup_info, info.if_not_found);
8311 if (!lookup.Found()) {
8312 return;
8313 }
8314 return lookup.schema->Alter(transaction, info);
8315 }
8316 D_ASSERT(info.if_not_found == OnEntryNotFound::THROW_EXCEPTION);
8317 auto &schema = GetSchema(transaction, info.schema);
8318 return schema.Alter(transaction, info);
8319}

◆ Alter() [2/2]

void duckdb::Catalog::Alter ( ClientContext context,
AlterInfo info 
)
8321 {
8322 Alter(GetCatalogTransaction(context), info);
8323}
DUCKDB_API void Alter(CatalogTransaction transaction, AlterInfo &info)
Alter an existing entry in the catalog.
Definition duckdb.cpp:8306

◆ BindCreateIndex()

unique_ptr< LogicalOperator > duckdb::Catalog::BindCreateIndex ( Binder binder,
CreateStatement stmt,
TableCatalogEntry table,
unique_ptr< LogicalOperator plan 
)
virtual
7433 {
7434 D_ASSERT(plan->type == LogicalOperatorType::LOGICAL_GET);
7435 auto create_index_info = unique_ptr_cast<CreateInfo, CreateIndexInfo>(std::move(stmt.info));
7436 IndexBinder index_binder(binder, binder.context);
7437 return index_binder.BindCreateIndex(binder.context, std::move(create_index_info), table, std::move(plan), nullptr);
7438}

◆ BindAlterAddIndex()

unique_ptr< LogicalOperator > duckdb::Catalog::BindAlterAddIndex ( Binder binder,
TableCatalogEntry table_entry,
unique_ptr< LogicalOperator plan,
unique_ptr< CreateIndexInfo create_info,
unique_ptr< AlterTableInfo alter_info 
)
virtual
7443 {
7444 throw NotImplementedException("BindAlterAddIndex not supported by this catalog");
7445}

◆ GetMetadataInfo()

vector< MetadataBlockInfo > duckdb::Catalog::GetMetadataInfo ( ClientContext context)
virtual
8325 {
8326 return vector<MetadataBlockInfo>();
8327}

◆ SupportsTimeTravel()

virtual bool duckdb::Catalog::SupportsTimeTravel ( ) const
inlinevirtual
7326 {
7327 return false;
7328 }

◆ IsEncrypted()

virtual bool duckdb::Catalog::IsEncrypted ( ) const
inlinevirtual
7329 {
7330 return false;
7331 }

◆ GetEncryptionCipher()

virtual string duckdb::Catalog::GetEncryptionCipher ( ) const
inlinevirtual
7332 {
7333 return string();
7334 }

◆ SupportsCreateTable()

ErrorData duckdb::Catalog::SupportsCreateTable ( BoundCreateTableInfo info)
virtual
8333 {
8334 auto &base = info.Base().Cast<CreateTableInfo>();
8335 if (!base.partition_keys.empty()) {
8336 return ErrorData(
8337 ExceptionType::CATALOG,
8338 StringUtil::Format("PARTITIONED BY is not supported for tables in a %s catalog", GetCatalogType()));
8339 }
8340 if (!base.sort_keys.empty()) {
8341 return ErrorData(ExceptionType::CATALOG,
8342 StringUtil::Format("SORTED BY is not supported for tables in a %s catalog", GetCatalogType()));
8343 }
8344 if (!base.options.empty()) {
8345 return ErrorData(
8346 ExceptionType::CATALOG,
8347 StringUtil::Format("WITH clause is not supported for tables in a %s catalog", GetCatalogType()));
8348 }
8349 return ErrorData();
8350}
static string Format(const string fmt_str, ARGS... params)
Format a string using printf semantics.
Definition duckdb.hpp:4002

◆ CatalogTypeLookupRule()

virtual DUCKDB_API CatalogLookupBehavior duckdb::Catalog::CatalogTypeLookupRule ( CatalogType  type) const
inlinevirtual

Whether or not this catalog should search a specific type with the standard priority.

7338 {
7339 return CatalogLookupBehavior::STANDARD;
7340 }

◆ GetDefaultSchema()

string duckdb::Catalog::GetDefaultSchema ( ) const
virtual

Returns the default schema of the catalog.

8352 {
8353 return DEFAULT_SCHEMA;
8354}

◆ HasDefaultTable()

bool duckdb::Catalog::HasDefaultTable ( ) const

Whether this catalog has a default table. Catalogs with a default table can be queries by their catalog name.

The default table is used for SELECT * FROM <catalog_name>; FIXME: these should be virtual methods

8357 {
8358 return !default_table.empty();
8359}
string default_table
(optionally) a default table to query for SELECT * FROM <catalog_name>;
Definition duckdb.hpp:7408

◆ SetDefaultTable()

void duckdb::Catalog::SetDefaultTable ( const string &  schema,
const string &  name 
)
8361 {
8362 default_table = name;
8363 default_table_schema = schema;
8364}

◆ GetDefaultTable()

string duckdb::Catalog::GetDefaultTable ( ) const
8366 {
8367 return default_table;
8368}

◆ GetDefaultTableSchema()

string duckdb::Catalog::GetDefaultTableSchema ( ) const
8370 {
8371 return !default_table_schema.empty() ? default_table_schema : DEFAULT_SCHEMA;
8372}

◆ GetDependencyManager()

optional_ptr< DependencyManager > duckdb::Catalog::GetDependencyManager ( )
virtual

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

Reimplemented in duckdb::DuckCatalog.

8329 {
8330 return nullptr;
8331}

◆ HasConflictingAttachOptions()

bool duckdb::Catalog::HasConflictingAttachOptions ( const string &  path,
const AttachOptions options 
)
virtual

Whether attaching a catalog with the given path and attach options would be considered a conflict.

8395 {
8396 auto const db_type = options.db_type.empty() ? "duckdb" : options.db_type;
8397 return GetDBPath() != path || GetCatalogType() != db_type;
8398}

◆ GetEntry() [12/13]

template<class T >
static optional_ptr< T > duckdb::Catalog::GetEntry ( ClientContext context,
const string &  catalog_name,
const string &  schema_name,
const string &  name,
OnEntryNotFound  if_not_found,
QueryErrorContext  error_context = QueryErrorContext() 
)
inlinestatic
7362 {
7363 EntryLookupInfo lookup_info(T::Type, name, error_context);
7364 auto entry = GetEntry(context, catalog_name, schema_name, lookup_info, if_not_found);
7365 if (!entry) {
7366 return nullptr;
7367 }
7368 if (entry->type != T::Type) {
7369 throw CatalogException(error_context, "%s is not an %s", name, T::Name);
7370 }
7371 return &entry->template Cast<T>();
7372 }

◆ GetEntry() [13/13]

template<class T >
static T & duckdb::Catalog::GetEntry ( ClientContext context,
const string &  catalog_name,
const string &  schema_name,
const string &  name,
QueryErrorContext  error_context = QueryErrorContext() 
)
inlinestatic
7375 {
7376 auto entry =
7377 GetEntry<T>(context, catalog_name, schema_name, name, OnEntryNotFound::THROW_EXCEPTION, error_context);
7378 return *entry;
7379 }

◆ GetSchemas() [1/3]

vector< reference< SchemaCatalogEntry > > duckdb::Catalog::GetSchemas ( ClientContext context)
8230 {
8231 vector<reference<SchemaCatalogEntry>> schemas;
8232 ScanSchemas(context, [&](SchemaCatalogEntry &entry) { schemas.push_back(entry); });
8233 return schemas;
8234}
virtual DUCKDB_API void ScanSchemas(ClientContext &context, std::function< void(SchemaCatalogEntry &)> callback)=0
Scans all the schemas in the system one-by-one, invoking the callback for each entry.

◆ GetSchemas() [2/3]

vector< reference< SchemaCatalogEntry > > duckdb::Catalog::GetSchemas ( ClientContext context,
const string &  catalog_name 
)
static
8262 {
8263 CatalogEntryRetriever retriever(context);
8264 return GetSchemas(retriever, catalog_name);
8265}

◆ GetSchemas() [3/3]

vector< reference< SchemaCatalogEntry > > duckdb::Catalog::GetSchemas ( CatalogEntryRetriever retriever,
const string &  catalog_name 
)
static
8237 {
8238 vector<reference<Catalog>> catalogs;
8239 if (IsInvalidCatalog(catalog_name)) {
8240 reference_set_t<Catalog> inserted_catalogs;
8241
8242 auto &search_path = retriever.GetSearchPath();
8243 for (auto &entry : search_path.Get()) {
8244 auto &catalog = Catalog::GetCatalog(retriever, entry.catalog);
8245 if (inserted_catalogs.find(catalog) != inserted_catalogs.end()) {
8246 continue;
8247 }
8248 inserted_catalogs.insert(catalog);
8249 catalogs.push_back(catalog);
8250 }
8251 } else {
8252 catalogs.push_back(Catalog::GetCatalog(retriever, catalog_name));
8253 }
8254 vector<reference<SchemaCatalogEntry>> result;
8255 for (auto catalog : catalogs) {
8256 auto schemas = catalog.get().GetSchemas(retriever.GetContext());
8257 result.insert(result.end(), schemas.begin(), schemas.end());
8258 }
8259 return result;
8260}

◆ GetAllSchemas()

vector< reference< SchemaCatalogEntry > > duckdb::Catalog::GetAllSchemas ( ClientContext context)
static
8267 {
8268 vector<reference<SchemaCatalogEntry>> result;
8269
8270 auto &db_manager = DatabaseManager::Get(context);
8271 auto databases = db_manager.GetDatabases(context);
8272 for (auto &database : databases) {
8273 if (database->GetVisibility() == AttachVisibility::HIDDEN) {
8274 continue;
8275 }
8276 auto &catalog = database->GetCatalog();
8277 auto new_schemas = catalog.GetSchemas(context);
8278 result.insert(result.end(), new_schemas.begin(), new_schemas.end());
8279 }
8280 sort(result.begin(), result.end(),
8281 [&](reference<SchemaCatalogEntry> left_p, reference<SchemaCatalogEntry> right_p) {
8282 auto &left = left_p.get();
8283 auto &right = right_p.get();
8284 if (left.catalog.GetName() < right.catalog.GetName()) {
8285 return true;
8286 }
8287 if (left.catalog.GetName() == right.catalog.GetName()) {
8288 return left.name < right.name;
8289 }
8290 return false;
8291 });
8292
8293 return result;
8294}
void sort(InputArray src, OutputArray dst, int flags)

◆ GetAllEntries()

vector< reference< CatalogEntry > > duckdb::Catalog::GetAllEntries ( ClientContext context,
CatalogType  catalog_type 
)
static
8296 {
8297 vector<reference<CatalogEntry>> result;
8298 auto schemas = GetAllSchemas(context);
8299 for (const auto &schema_ref : schemas) {
8300 auto &schema = schema_ref.get();
8301 schema.Scan(context, catalog_type, [&](CatalogEntry &entry) { result.push_back(entry); });
8302 }
8303 return result;
8304}

◆ Verify()

void duckdb::Catalog::Verify ( )
virtual
8374 {
8375}

◆ UnrecognizedConfigurationError()

CatalogException duckdb::Catalog::UnrecognizedConfigurationError ( ClientContext context,
const string &  name 
)
static
7750 {
7751 // check if the setting exists in any extensions
7752 auto extension_name = ExtensionHelper::FindExtensionInEntries(name, EXTENSION_SETTINGS);
7753 if (!extension_name.empty()) {
7754 auto error_message = "Setting with name \"" + name + "\" is not in the catalog, but it exists in the " +
7755 extension_name + " extension.";
7756 error_message = ExtensionHelper::AddExtensionInstallHintToErrorMsg(context, error_message, extension_name);
7757 return CatalogException(error_message);
7758 }
7759 // the setting is not in an extension
7760 // get a list of all options
7761 vector<string> potential_names = DBConfig::GetOptionNames();
7762 for (auto &entry : DBConfig::GetConfig(context).GetExtensionSettings()) {
7763 potential_names.push_back(entry.first);
7764 }
7765 throw CatalogException::MissingEntry("configuration parameter", name, potential_names);
7766}
static string FindExtensionInEntries(const string &name, const ExtensionEntry(&entries)[N])
Lookup a name in an ExtensionEntry list.
Definition duckdb.cpp:6376

◆ AutoloadExtensionByConfigName()

String duckdb::Catalog::AutoloadExtensionByConfigName ( ClientContext context,
const String configuration_name 
)
static

Autoload the extension required for configuration_name or throw a CatalogException.

7659 {
7660#ifndef DUCKDB_DISABLE_EXTENSION_LOAD
7661 if (Settings::Get<AutoloadKnownExtensionsSetting>(context)) {
7662 auto extension_name =
7663 ExtensionHelper::FindExtensionInEntries(configuration_name.ToStdString(), EXTENSION_SETTINGS);
7664 if (ExtensionHelper::CanAutoloadExtension(extension_name)) {
7665 ExtensionHelper::AutoLoadExtension(context, extension_name);
7666 return extension_name;
7667 }
7668 }
7669#endif
7670
7671 throw Catalog::UnrecognizedConfigurationError(context, configuration_name.ToStdString());
7672}
static void AutoLoadExtension(ClientContext &context, const string &extension_name)
Autoload an extension (depending on config, potentially a nop. Throws when installation fails)
static bool CanAutoloadExtension(const string &ext_name)
Here is the call graph for this function:

◆ AutoLoadExtensionByCatalogEntry()

bool duckdb::Catalog::AutoLoadExtensionByCatalogEntry ( DatabaseInstance db,
CatalogType  type,
const string &  entry_name 
)
static

Autoload the extension required for function_name or throw a CatalogException.

7715 {
7716#ifndef DUCKDB_DISABLE_EXTENSION_LOAD
7717 if (Settings::Get<AutoloadKnownExtensionsSetting>(db)) {
7718 string extension_name;
7719 if (IsAutoloadableFunction(type)) {
7720 auto lookup_result = ExtensionHelper::FindExtensionInFunctionEntries(entry_name, EXTENSION_FUNCTIONS);
7721 if (lookup_result.empty()) {
7722 return false;
7723 }
7724 for (auto &function : lookup_result) {
7725 auto function_type = function.second;
7726 // FIXME: what if there are two functions with the same name, from different extensions?
7727 if (CompareCatalogTypes(type, function_type)) {
7728 extension_name = function.first;
7729 break;
7730 }
7731 }
7732 } else if (type == CatalogType::COPY_FUNCTION_ENTRY) {
7733 extension_name = ExtensionHelper::FindExtensionInEntries(entry_name, EXTENSION_COPY_FUNCTIONS);
7734 } else if (type == CatalogType::TYPE_ENTRY) {
7735 extension_name = ExtensionHelper::FindExtensionInEntries(entry_name, EXTENSION_TYPES);
7736 } else if (type == CatalogType::COLLATION_ENTRY) {
7737 extension_name = ExtensionHelper::FindExtensionInEntries(entry_name, EXTENSION_COLLATIONS);
7738 }
7739
7740 if (!extension_name.empty() && ExtensionHelper::CanAutoloadExtension(extension_name)) {
7741 ExtensionHelper::AutoLoadExtension(db, extension_name);
7742 return true;
7743 }
7744 }
7745#endif
7746
7747 return false;
7748}
static vector< pair< string, CatalogType > > FindExtensionInFunctionEntries(const string &name, const ExtensionFunctionEntry(&entries)[N])
Lookup a name + type in an ExtensionFunctionEntry list.
Definition duckdb.cpp:6348
Here is the call graph for this function:

◆ TryAutoLoad()

bool duckdb::Catalog::TryAutoLoad ( ClientContext context,
const string &  extension_name 
)
staticnoexcept
7639 {
7640 string extension_name = ExtensionHelper::ApplyExtensionAlias(original_name);
7641 if (context.db->ExtensionIsLoaded(extension_name)) {
7642 return true;
7643 }
7644#ifndef DUCKDB_DISABLE_EXTENSION_LOAD
7645 if (!Settings::Get<AutoloadKnownExtensionsSetting>(context)) {
7646 return false;
7647 }
7648 try {
7649 if (ExtensionHelper::CanAutoloadExtension(extension_name)) {
7650 return ExtensionHelper::TryAutoLoadExtension(context, extension_name);
7651 }
7652 } catch (...) {
7653 return false;
7654 }
7655#endif
7656 return false;
7657}
static string ApplyExtensionAlias(const string &extension_name)
Apply any known extension aliases, return the lowercase name.
static DUCKDB_API bool TryAutoLoadExtension(DatabaseInstance &db, const string &extension_name) noexcept
Autoload an extension (depending on config, potentially a nop. Returns false on failure)

◆ OnDetach()

void duckdb::Catalog::OnDetach ( ClientContext context)
virtual

Called when the catalog is detached.

8392 {
8393}

◆ LookupEntry()

CatalogEntryLookup duckdb::Catalog::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.

7950 {
7951 auto res = TryLookupEntry(retriever, schema, lookup_info, if_not_found);
7952
7953 if (res.error.HasError()) {
7954 res.error.Throw();
7955 }
7956
7957 return res;
7958}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TryLookupEntryInternal()

CatalogEntryLookup duckdb::Catalog::TryLookupEntryInternal ( CatalogTransaction  transaction,
const string &  schema,
const EntryLookupInfo lookup_info 
)
privatevirtual

Lookup an entry in the schema, returning a lookup with the entry and schema if they exist.

7889 {
7890 if (lookup_info.GetAtClause() && !SupportsTimeTravel()) {
7891 return {nullptr, nullptr, ErrorData(BinderException("Catalog type does not support time travel"))};
7892 }
7893 auto schema_lookup = EntryLookupInfo::SchemaLookup(lookup_info, schema);
7894 auto schema_entry = LookupSchema(transaction, schema_lookup, OnEntryNotFound::RETURN_NULL);
7895 if (!schema_entry) {
7896 return {nullptr, nullptr, ErrorData()};
7897 }
7898 auto entry = schema_entry->LookupEntry(transaction, lookup_info);
7899 if (!entry) {
7900 return {schema_entry, nullptr, ErrorData()};
7901 }
7902 return {schema_entry, entry, ErrorData()};
7903}
Here is the caller graph for this function:

◆ TryLookupEntry() [1/3]

CatalogEntryLookup duckdb::Catalog::TryLookupEntry ( CatalogEntryRetriever retriever,
const string &  schema,
const EntryLookupInfo lookup_info,
OnEntryNotFound  if_not_found 
)
private

Calls LookupEntryInternal on the schema, trying other schemas if the schema is invalid. Sets CatalogEntryLookup->error depending on if_not_found when no entry is found

7906 {
7907 auto &context = retriever.GetContext();
7908 reference_set_t<SchemaCatalogEntry> schemas;
7909 if (IsInvalidSchema(schema)) {
7910 // try all schemas for this catalog
7911 auto entries = GetCatalogEntries(retriever, GetName(), INVALID_SCHEMA);
7912 for (auto &entry : entries) {
7913 auto &candidate_schema = entry.schema;
7914 auto transaction = GetCatalogTransaction(context);
7915 auto result = TryLookupEntryInternal(transaction, candidate_schema, lookup_info);
7916 if (result.Found()) {
7917 return result;
7918 }
7919 if (result.schema) {
7920 schemas.insert(*result.schema);
7921 }
7922 }
7923 } else {
7924 auto transaction = GetCatalogTransaction(context);
7925 auto result = TryLookupEntryInternal(transaction, schema, lookup_info);
7926 if (result.Found()) {
7927 return result;
7928 }
7929 if (result.schema) {
7930 schemas.insert(*result.schema);
7931 }
7932 }
7933
7934 if (if_not_found == OnEntryNotFound::RETURN_NULL) {
7935 return {nullptr, nullptr, ErrorData()};
7936 }
7937 // Check if the default database is actually attached. CreateMissingEntryException will throw binder exception
7938 // otherwise.
7939 if (!GetCatalogEntry(context, GetDefaultCatalog(retriever))) {
7940 auto except = CatalogException("%s with name %s does not exist!",
7941 CatalogTypeToString(lookup_info.GetCatalogType()), lookup_info.GetEntryName());
7942 return {nullptr, nullptr, ErrorData(except)};
7943 } else {
7944 auto except = CreateMissingEntryException(retriever, lookup_info, schemas);
7945 return {nullptr, nullptr, ErrorData(except)};
7946 }
7947}
virtual CatalogEntryLookup TryLookupEntryInternal(CatalogTransaction transaction, const string &schema, const EntryLookupInfo &lookup_info)
Lookup an entry in the schema, returning a lookup with the entry and schema if they exist.
Definition duckdb.cpp:7888
DUCKDB_API const string & GetName() const
Returns the catalog name - based on how the catalog was attached.
Definition duckdb.cpp:7165
static CatalogException CreateMissingEntryException(CatalogEntryRetriever &retriever, const EntryLookupInfo &lookup_info, const reference_set_t< SchemaCatalogEntry > &schemas)
Return an exception with did-you-mean suggestion.
Definition duckdb.cpp:7768
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TryLookupEntry() [2/3]

CatalogEntryLookup duckdb::Catalog::TryLookupEntry ( CatalogEntryRetriever retriever,
const vector< CatalogLookup > &  lookups,
const EntryLookupInfo lookup_info,
OnEntryNotFound  if_not_found,
bool  allow_default_table_lookup 
)
staticprivate
7980 {
7981 auto &context = retriever.GetContext();
7982 reference_set_t<SchemaCatalogEntry> schemas;
7983 bool all_errors = true;
7984 ErrorData error_data;
7985 CatalogEntryLookup result;
7986 for (auto &lookup : lookups) {
7987 auto transaction = lookup.catalog.GetCatalogTransaction(context);
7988 result = lookup.catalog.TryLookupEntryInternal(transaction, lookup.schema, lookup.lookup_info);
7989 if (result.Found()) {
7990 break;
7991 }
7992 if (result.schema) {
7993 schemas.insert(*result.schema);
7994 }
7995 if (!result.error.HasError()) {
7996 all_errors = false;
7997 } else {
7998 error_data = std::move(result.error);
7999 }
8000 }
8001
8002 // Special case for tables: we do a second lookup searching for catalogs with default tables that also match this
8003 // lookup
8004 if (lookup_info.GetCatalogType() == CatalogType::TABLE_ENTRY && allow_default_table_lookup) {
8005 if (!result.Found()) {
8006 result = TryLookupDefaultTable(retriever, lookup_info, false);
8007 if (result.error.HasError()) {
8008 error_data = std::move(result.error);
8009 }
8010 } else {
8011 // allow_ignore_at_clause set to true to ensure `FROM <table_name> AT <version>` is considered
8012 // ambiguous with a default table lookup in a catalog that does not support time travel
8013 auto ambiguity_lookup = TryLookupDefaultTable(retriever, lookup_info, true);
8014 if (ambiguity_lookup.Found()) {
8015 ThrowDefaultTableAmbiguityException(result, ambiguity_lookup, lookup_info.GetEntryName());
8016 }
8017 }
8018 }
8019
8020 if (result.Found()) {
8021 return result;
8022 }
8023
8024 if (all_errors && error_data.HasError()) {
8025 error_data.Throw();
8026 }
8027
8028 if (if_not_found == OnEntryNotFound::RETURN_NULL) {
8029 return {nullptr, nullptr, ErrorData()};
8030 }
8031
8032 // If we have a specific schema name and no schemas were found, the schema doesn't exist.
8033 // Throw an error about the schema instead of the table
8034 if (schemas.empty() && !lookups.empty() && lookup_info.GetCatalogType() == CatalogType::TABLE_ENTRY) {
8035 string schema_name = lookups[0].schema;
8036 if (!IsInvalidSchema(schema_name)) {
8037 EntryLookupInfo schema_lookup(CatalogType::SCHEMA_ENTRY, schema_name, lookup_info.GetErrorContext());
8038 string relation_name = schema_name + "." + lookup_info.GetEntryName();
8039 auto except =
8040 CatalogException(schema_lookup.GetErrorContext(),
8041 "Table with name \"%s\" does not exist because schema \"%s\" does not exist.",
8042 relation_name, schema_name);
8043 return {nullptr, nullptr, ErrorData(except)};
8044 }
8045 }
8046
8047 // Check if the default database is actually attached. CreateMissingEntryException will throw binder exception
8048 // otherwise.
8049 if (!GetCatalogEntry(context, GetDefaultCatalog(retriever))) {
8050 auto except = CatalogException("%s with name %s does not exist!",
8051 CatalogTypeToString(lookup_info.GetCatalogType()), lookup_info.GetEntryName());
8052 return {nullptr, nullptr, ErrorData(except)};
8053 } else {
8054 auto except = CreateMissingEntryException(retriever, lookup_info, schemas);
8055 return {nullptr, nullptr, ErrorData(except)};
8056 }
8057}
static CatalogEntryLookup TryLookupDefaultTable(CatalogEntryRetriever &retriever, const EntryLookupInfo &lookup_info, bool allow_ignore_at_clause=false)
Looks for a Catalog with a DefaultTable that matches the lookup.
Definition duckdb.cpp:8059

◆ TryLookupEntry() [3/3]

CatalogEntryLookup duckdb::Catalog::TryLookupEntry ( CatalogEntryRetriever retriever,
const string &  catalog,
const string &  schema,
const EntryLookupInfo lookup_info,
OnEntryNotFound  if_not_found 
)
staticprivate
8086 {
8087 auto entries = GetCatalogEntries(retriever, catalog, schema);
8088 vector<CatalogLookup> lookups;
8089 vector<CatalogLookup> final_lookups;
8090 lookups.reserve(entries.size());
8091 for (auto &entry : entries) {
8092 optional_ptr<Catalog> catalog_entry;
8093 if (if_not_found == OnEntryNotFound::RETURN_NULL) {
8094 catalog_entry = Catalog::GetCatalogEntry(retriever, entry.catalog);
8095 } else {
8096 catalog_entry = &Catalog::GetCatalog(retriever, entry.catalog);
8097 }
8098 if (!catalog_entry) {
8099 return {nullptr, nullptr, ErrorData()};
8100 }
8101 D_ASSERT(catalog_entry);
8102 auto lookup_behavior = catalog_entry->CatalogTypeLookupRule(lookup_info.GetCatalogType());
8103 if (lookup_behavior == CatalogLookupBehavior::STANDARD) {
8104 lookups.emplace_back(*catalog_entry, entry.schema, lookup_info);
8105 } else if (lookup_behavior == CatalogLookupBehavior::LOWER_PRIORITY) {
8106 final_lookups.emplace_back(*catalog_entry, entry.schema, lookup_info);
8107 }
8108 }
8109
8110 for (auto &lookup : final_lookups) {
8111 lookups.emplace_back(std::move(lookup));
8112 }
8113
8114 bool allow_default_table_lookup = catalog.empty() && schema.empty();
8115
8116 return TryLookupEntry(retriever, lookups, lookup_info, if_not_found, allow_default_table_lookup);
8117}

◆ TryLookupDefaultTable()

CatalogEntryLookup duckdb::Catalog::TryLookupDefaultTable ( CatalogEntryRetriever retriever,
const EntryLookupInfo lookup_info,
bool  allow_ignore_at_clause = false 
)
staticprivate

Looks for a Catalog with a DefaultTable that matches the lookup.

8060 {
8061 auto catalog_by_name = GetCatalogEntry(retriever, lookup_info.GetEntryName());
8062
8063 if (catalog_by_name && catalog_by_name->HasDefaultTable()) {
8064 auto transaction = catalog_by_name->GetCatalogTransaction(retriever.GetContext());
8065 QueryErrorContext context;
8066
8067 string table_schema = catalog_by_name->GetDefaultTableSchema();
8068 string table_name = catalog_by_name->GetDefaultTable();
8069
8070 optional_ptr<BoundAtClause> at_clause;
8071 if (!catalog_by_name->SupportsTimeTravel() && allow_ignore_at_clause) {
8072 at_clause = nullptr;
8073 } else {
8074 at_clause = lookup_info.GetAtClause();
8075 }
8076
8077 EntryLookupInfo info = EntryLookupInfo(CatalogType::TABLE_ENTRY, table_name, at_clause, context);
8078 return catalog_by_name->TryLookupEntryInternal(transaction, table_schema, info);
8079 }
8080
8081 return {nullptr, nullptr, ErrorData()};
8082}
Here is the call graph for this function:

◆ CreateMissingEntryException()

CatalogException duckdb::Catalog::CreateMissingEntryException ( CatalogEntryRetriever retriever,
const EntryLookupInfo lookup_info,
const reference_set_t< SchemaCatalogEntry > &  schemas 
)
staticprivate

Return an exception with did-you-mean suggestion.

7770 {
7771 auto &context = retriever.GetContext();
7772 auto entries = SimilarEntriesInSchemas(context, lookup_info, schemas);
7773 auto max_schema_count = Settings::Get<CatalogErrorMaxSchemasSetting>(context);
7774
7775 reference_set_t<SchemaCatalogEntry> unseen_schemas;
7776 auto &db_manager = DatabaseManager::Get(context);
7777 auto databases = db_manager.GetDatabases(context, max_schema_count);
7778
7779 for (const auto &database : databases) {
7780 if (unseen_schemas.size() >= max_schema_count) {
7781 break;
7782 }
7783 auto &catalog = database->GetCatalog();
7784 auto current_schemas = catalog.GetSchemas(context);
7785 for (auto &current_schema : current_schemas) {
7786 if (unseen_schemas.size() >= max_schema_count) {
7787 break;
7788 }
7789 unseen_schemas.insert(current_schema.get());
7790 }
7791 }
7792
7793 // Check if the entry exists in any extension.
7794 string extension_name;
7795 auto type = lookup_info.GetCatalogType();
7796 auto &entry_name = lookup_info.GetEntryName();
7797 if (type == CatalogType::TABLE_FUNCTION_ENTRY || type == CatalogType::SCALAR_FUNCTION_ENTRY ||
7798 type == CatalogType::AGGREGATE_FUNCTION_ENTRY || type == CatalogType::PRAGMA_FUNCTION_ENTRY) {
7799 auto lookup_result = ExtensionHelper::FindExtensionInFunctionEntries(entry_name, EXTENSION_FUNCTIONS);
7800 do {
7801 if (lookup_result.empty()) {
7802 break;
7803 }
7804 vector<string> other_types;
7805 string extension_for_error;
7806 for (auto &function : lookup_result) {
7807 auto function_type = function.second;
7808 if (CompareCatalogTypes(type, function_type)) {
7809 extension_name = function.first;
7810 break;
7811 }
7812 extension_for_error = function.first;
7813 other_types.push_back(CatalogTypeToString(function_type));
7814 }
7815 if (!extension_name.empty()) {
7816 break;
7817 }
7818 if (other_types.size() == 1) {
7819 auto &function_type = other_types[0];
7820 auto error =
7821 CatalogException("%s with name \"%s\" is not in the catalog, a function by this name exists "
7822 "in the %s extension, but it's of a different type, namely %s",
7823 CatalogTypeToString(type), entry_name, extension_for_error, function_type);
7824 return error;
7825 } else {
7826 D_ASSERT(!other_types.empty());
7827 auto list_of_types = StringUtil::Join(other_types, ", ");
7828 auto error =
7829 CatalogException("%s with name \"%s\" is not in the catalog, functions with this name exist "
7830 "in the %s extension, but they are of different types, namely %s",
7831 CatalogTypeToString(type), entry_name, extension_for_error, list_of_types);
7832 return error;
7833 }
7834 } while (false);
7835 } else if (type == CatalogType::TYPE_ENTRY) {
7836 extension_name = ExtensionHelper::FindExtensionInEntries(entry_name, EXTENSION_TYPES);
7837 } else if (type == CatalogType::COPY_FUNCTION_ENTRY) {
7838 extension_name = ExtensionHelper::FindExtensionInEntries(entry_name, EXTENSION_COPY_FUNCTIONS);
7839 } else if (type == CatalogType::COLLATION_ENTRY) {
7840 extension_name = ExtensionHelper::FindExtensionInEntries(entry_name, EXTENSION_COLLATIONS);
7841 }
7842
7843 // if we found an extension that can handle this catalog entry, create an error hinting the user
7844 if (!extension_name.empty()) {
7845 auto error_message = CatalogTypeToString(type) + " with name \"" + entry_name +
7846 "\" is not in the catalog, but it exists in the " + extension_name + " extension.";
7847 error_message = ExtensionHelper::AddExtensionInstallHintToErrorMsg(context, error_message, extension_name);
7848 return CatalogException(error_message);
7849 }
7850
7851 // entries in other schemas get a penalty
7852 // however, if there is an exact match in another schema, we will always show it
7853 static constexpr const double UNSEEN_PENALTY = 0.2;
7854 auto unseen_entries = SimilarEntriesInSchemas(context, lookup_info, unseen_schemas);
7855 set<string> suggestions;
7856
7857 if (!unseen_entries.empty() && (unseen_entries[0].score == 1.0 || unseen_entries[0].score - UNSEEN_PENALTY >
7858 (entries.empty() ? 0.0 : entries[0].score))) {
7859 // the closest matching entry requires qualification as it is not in the default search path
7860 // check how to minimally qualify this entry
7861 for (auto &unseen_entry : unseen_entries) {
7862 auto catalog_name = unseen_entry.schema->catalog.GetName();
7863 auto schema_name = unseen_entry.schema->name;
7864 bool qualify_database;
7865 bool qualify_schema;
7866 FindMinimalQualification(retriever, catalog_name, schema_name, qualify_database, qualify_schema);
7867 auto qualified_name = unseen_entry.GetQualifiedName(qualify_database, qualify_schema);
7868 suggestions.insert(qualified_name);
7869 }
7870 } else if (!entries.empty()) {
7871 for (auto &entry : entries) {
7872 suggestions.insert(entry.name);
7873 }
7874 }
7875
7876 string did_you_mean;
7877 if (suggestions.size() > 2) {
7878 string last = *suggestions.rbegin();
7879 suggestions.erase(last);
7880 did_you_mean = StringUtil::Join(suggestions, ", ") + ", or " + last;
7881 } else {
7882 did_you_mean = StringUtil::Join(suggestions, " or ");
7883 }
7884
7885 return CatalogException::MissingEntry(lookup_info, did_you_mean);
7886}
static vector< SimilarCatalogEntry > SimilarEntriesInSchemas(ClientContext &context, const EntryLookupInfo &lookup_info, const reference_set_t< SchemaCatalogEntry > &schemas)
Return the close entry name, the distance and the belonging schema.
Definition duckdb.cpp:7540
static DUCKDB_API string Join(const vector< string > &input, const string &separator)
Join multiple strings into one string. Components are concatenated by the given separator.
void error(int _code, const String &_err, const char *_func, const char *_file, int _line)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SimilarEntriesInSchemas()

vector< SimilarCatalogEntry > duckdb::Catalog::SimilarEntriesInSchemas ( ClientContext context,
const EntryLookupInfo lookup_info,
const reference_set_t< SchemaCatalogEntry > &  schemas 
)
staticprivate

Return the close entry name, the distance and the belonging schema.

7541 {
7542 vector<SimilarCatalogEntry> results;
7543 for (auto schema_ref : schemas) {
7544 auto &schema = schema_ref.get();
7545 auto transaction = schema.catalog.GetCatalogTransaction(context);
7546 auto entry = schema.GetSimilarEntry(transaction, lookup_info);
7547 if (!entry.Found()) {
7548 // no similar entry found
7549 continue;
7550 }
7551 if (results.empty() || results[0].score <= entry.score) {
7552 if (!results.empty() && results[0].score < entry.score) {
7553 results.clear();
7554 }
7555
7556 results.push_back(entry);
7557 results.back().schema = &schema;
7558 }
7559 }
7560 return results;
7561}
Here is the caller graph for this function:

◆ Cast() [1/2]

template<class TARGET >
TARGET & duckdb::Catalog::Cast ( )
inline
7450 {
7451 DynamicCastCheck<TARGET>(this);
7452 return reinterpret_cast<TARGET &>(*this);
7453 }

◆ Cast() [2/2]

template<class TARGET >
const TARGET & duckdb::Catalog::Cast ( ) const
inline
7456 {
7457 DynamicCastCheck<TARGET>(this);
7458 return reinterpret_cast<const TARGET &>(*this);
7459 }

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