Skip to main content

Module catalog

Module catalog 

Source
Expand description

Catalog entry lookup (DuckDB 1.5.0+).

Provides read-only access to catalog entries (tables, views, types, etc.) from within extension callbacks.

§Lookups that could autoload an extension are refused

duckdb_catalog_get_entry has no try/catch. When a TYPE or COLLATION lookup misses, DuckDB 1.5.5 tries to autoload the extension that owns the name — json and inet for types, icu for 130 collation names such as de or en_us — even though the lookup asked for RETURN_NULL (Catalog::GetEntry → AutoLoadExtensionByCatalogEntry, src/catalog/catalog.cpp). If that autoload fails (autoinstall off and the extension not installed, no network, a signature problem, …), ExtensionHelper::AutoLoadExtension rethrows, the exception crosses the C API and the process aborts. If it succeeds, a catalog lookup has just downloaded and loaded an extension.

The C API offers no way to ask whether that extension is already loaded from a client context, so CatalogEntry::lookup refuses — with an Err, without calling DuckDB — a Type or Collation lookup whose name is on those lists while the autoload_known_extensions setting is on. With SET autoload_known_extensions = false no autoload is attempted and the lookup runs normally. Every other name and entry type is unaffected.

§Lookups in a catalog an extension provides are refused

For a catalog DuckDB does not implement itself — one a storage extension attaches — duckdb_catalog_get_entry starts that catalog’s transaction (Transaction::Get, reached from Catalog::TryLookupEntry) and calls its LookupSchema and its schema’s LookupEntry (Catalog::TryLookupEntryInternal, catalog.cpp), all extension code, again with no try. Whether they throw cannot be known from here, so CatalogEntry::lookup refuses any catalog whose type is not "duckdb". DuckDB’s own catalogs — the database’s, temp and system — all have that type.

§Example

use quack_rs::catalog::{CatalogEntryType, CatalogEntry};

Structs§

Catalog
RAII wrapper for a duckdb_catalog.
CatalogEntry
A catalog entry found by CatalogEntry::lookup: its name and type, as they were at lookup time.

Enums§

CatalogEntryType
Types of entries in the DuckDB catalog.