Skip to main content

CatalogEntry

Struct CatalogEntry 

Source
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

Source

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_type that is not a schema-level entry (Schema, Database, PreparedStatement, Invalid) — see CatalogEntryType::is_lookup_supported;
  • a Type or Collation whose name DuckDB would try to autoload an extension for, while autoload_known_extensions is on — see the module docs and CatalogEntryType::may_autoload_extension;
  • any lookup in a catalog that is not DuckDB’s own (type "duckdb"), such as one a storage extension attaches: DuckDB runs that extension’s schema lookup and transaction start with no try, so whatever it throws would abort the process. This reads the catalog’s type name, which cannot throw.
§Safety
  • catalog must be a valid duckdb_catalog handle.
  • context must be a valid duckdb_client_context handle.
  • Must be called from within an active transaction.
Source

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.

Source

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

Source§

fn clone(&self) -> CatalogEntry

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CatalogEntry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for CatalogEntry

Source§

impl PartialEq for CatalogEntry

Source§

fn eq(&self, other: &CatalogEntry) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CatalogEntry

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.