pub struct CatalogEntry { /* private fields */ }Expand description
A catalog entry found by CatalogEntry::lookup: its name and type, as
they were at lookup time.
§Why this holds copies rather than the handle
A duckdb_catalog_entry is a plain reference to DuckDB’s own
CatalogEntry (CCatalogEntryWrapper { CatalogEntry &entry; },
catalog-c.cpp), valid only while the transaction that found it lasts.
Kept in a value with safe methods, it outlived that: after a
DROP TABLE and a commit, name() returned the name of a different,
newly created table, with valgrind reporting an invalid read in
duckdb_catalog_entry_get_name. So the name and type are copied during
lookup and the handle is released there.
Implementations§
Source§impl CatalogEntry
impl CatalogEntry
Sourcepub unsafe fn lookup(
catalog: duckdb_catalog,
context: duckdb_client_context,
schema: &CStr,
name: &CStr,
entry_type: CatalogEntryType,
) -> Result<Option<Self>, ExtensionError>
pub unsafe fn lookup( catalog: duckdb_catalog, context: duckdb_client_context, schema: &CStr, name: &CStr, entry_type: CatalogEntryType, ) -> Result<Option<Self>, ExtensionError>
Look up a catalog entry by type, schema, and name.
Returns Ok(None) if no such entry exists.
§Errors
Refuses, without calling DuckDB, a lookup that would abort the
process from inside the C API:
- an
entry_typethat is not a schema-level entry (Schema,Database,PreparedStatement,Invalid) — seeCatalogEntryType::is_lookup_supported; - a
TypeorCollationwhose nameDuckDBwould try to autoload an extension for, whileautoload_known_extensionsis on — see the module docs andCatalogEntryType::may_autoload_extension; - any lookup in a catalog that is not
DuckDB’s own (type"duckdb"), such as one a storage extension attaches:DuckDBruns that extension’s schema lookup and transaction start with notry, so whatever it throws would abort the process. This reads the catalog’s type name, which cannot throw.
§Safety
catalogmust be a validduckdb_cataloghandle.contextmust be a validduckdb_client_contexthandle.- Must be called from within an active transaction.
Sourcepub fn name(&self) -> Option<&str>
pub fn name(&self) -> Option<&str>
Returns the name of this catalog entry, as it was at lookup time.
Returns None if the name is not valid UTF-8.
Sourcepub const fn entry_type(&self) -> CatalogEntryType
pub const fn entry_type(&self) -> CatalogEntryType
Returns the type of this catalog entry, as it was at lookup time.
A lookup for CatalogEntryType::Table also finds a view of that name
(DuckDB resolves both through the same table-or-view lookup), so
check this when the difference matters.
Trait Implementations§
Source§impl Clone for CatalogEntry
impl Clone for CatalogEntry
Source§fn clone(&self) -> CatalogEntry
fn clone(&self) -> CatalogEntry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more