Skip to main content

SqlCatalog

Trait SqlCatalog 

Source
pub trait SqlCatalog {
    // Required method
    fn get_collection(
        &self,
        database_id: DatabaseId,
        name: &str,
    ) -> Result<Option<CollectionInfo>, SqlCatalogError>;

    // Provided methods
    fn lookup_array(&self, _name: &str) -> Option<ArrayCatalogView> { ... }
    fn array_exists(&self, name: &str) -> bool { ... }
}
Expand description

Trait for looking up collection metadata during planning.

Both Origin (via CredentialStore) and Lite (via the embedded redb catalog) implement this trait.

The return type is Result<Option<CollectionInfo>, _> with a three-way semantics:

  • Ok(Some(info)) — the collection exists and is usable. An Origin implementation will have acquired a descriptor lease at the current version before returning; subsequent planning against the same collection within the lease window is drain-safe.
  • Ok(None) — the collection does not exist. Callers should surface this as SqlError::UnknownTable.
  • Err(SqlCatalogError::RetryableSchemaChanged { .. }) — the collection exists but a DDL drain is in progress. Callers propagate this up so the pgwire layer can retry the whole statement.

Required Methods§

Provided Methods§

Source

fn lookup_array(&self, _name: &str) -> Option<ArrayCatalogView>

Look up an array by name. Returns None if no array with that name is registered. The default implementation returns None so that catalog adapters predating array support compile without change — the array DML planner falls back to “array not found” in that case.

Source

fn array_exists(&self, name: &str) -> bool

Cheap existence check; the default delegates to lookup_array.

Implementors§