Trait sql::catalog::SessionCatalog[][src]

pub trait SessionCatalog: Debug + ExprHumanizer {
Show 17 methods fn search_path(&self, include_system_schemas: bool) -> Vec<&str>
Notable traits for Vec<u8, A>
impl<A> Write for Vec<u8, A> where
    A: Allocator
;
fn user(&self) -> &str;
fn get_prepared_statement_desc(&self, name: &str) -> Option<&StatementDesc>;
fn default_database(&self) -> &str;
fn resolve_database(
        &self,
        database_name: &str
    ) -> Result<&dyn CatalogDatabase, CatalogError>;
fn resolve_schema(
        &self,
        database_name: Option<String>,
        schema_name: &str
    ) -> Result<&dyn CatalogSchema, CatalogError>;
fn resolve_role(
        &self,
        role_name: &str
    ) -> Result<&dyn CatalogRole, CatalogError>;
fn resolve_item(
        &self,
        item_name: &PartialName
    ) -> Result<&dyn CatalogItem, CatalogError>;
fn resolve_function(
        &self,
        item_name: &PartialName
    ) -> Result<&dyn CatalogItem, CatalogError>;
fn try_get_item_by_id(&self, id: &GlobalId) -> Option<&dyn CatalogItem>;
fn get_item_by_id(&self, id: &GlobalId) -> &dyn CatalogItem;
fn get_item_by_oid(&self, oid: &u32) -> &dyn CatalogItem;
fn item_exists(&self, name: &FullName) -> bool;
fn try_get_lossy_scalar_type_by_id(
        &self,
        id: &GlobalId
    ) -> Option<ScalarType>;
fn config(&self) -> &CatalogConfig;
fn now(&self) -> EpochMillis; fn find_available_name(&self, name: FullName) -> FullName { ... }
}
Expand description

A catalog keeps track of SQL objects and session state available to the planner.

The sql crate is agnostic to any particular catalog implementation. This trait describes the required interface.

The SQL standard mandates a catalog hierarchy of exactly three layers. A catalog contains databases, databases contain schemas, and schemas contain catalog items, like sources, sinks, view, and indexes.

There are two classes of operations provided by a catalog:

  • Resolution operations, like resolve_item. These fill in missing name components based upon connection defaults, e.g., resolving the partial name view42 to the fully-specified name materialize.public.view42.

  • Lookup operations, like SessionCatalog::get_item_by_id. These retrieve metadata about a catalog entity based on a fully-specified name that is known to be valid (i.e., because the name was successfully resolved, or was constructed based on the output of a prior lookup operation). These functions panic if called with invalid input.

Required methods

Returns the search path used by the catalog.

Returns the name of the user who is issuing the query.

Returns the descriptor of the named prepared statement on the session, or None if the prepared statement does not exist.

Returns the database to use if one is not explicitly specified.

Resolves the named database.

If database_name exists in the catalog, it returns the ID of the resolved database; otherwise it returns an error.

Resolves a partially-specified schema name.

If database_name is provided, it searches the named database for a schema named schema_name. If database_name is not provided, it searches the default database instead. It returns the ID of the schema if found; otherwise it returns an error if the database does not exist, or if the database exists but the schema does not.

Resolves the named role.

Resolves a partially-specified item name.

If the partial name has a database component, it searches only the specified database; otherwise, it searches the default database. If the partial name has a schema component, it searches only the specified schema; otherwise, it searches a default set of schemas within the selected database. It returns an error if none of the searched schemas contain an item whose name matches the item component of the partial name.

Note that it is not an error if the named item appears in more than one of the search schemas. The catalog implementation must choose one.

Performs the same operation as SessionCatalog::resolve_item but for functions within the catalog.

Gets an item by its ID.

Gets an item by its ID.

Panics if id does not specify a valid item.

Gets an item by its OID.

Panics if oid does not specify a valid item.

Reports whether the specified type exists in the catalog.

Returns a lossy ScalarType associated with id if one exists.

For example pg_catalog.numeric returns ScalarType::Numeric { scale: None}, meaning that its precision and scale need to be associated with values from elsewhere.

Returns the configuration of the catalog.

Returns the number of milliseconds since the system epoch. For normal use this means the Unix epoch. This can safely be mocked in tests and start at 0.

Provided methods

Finds a name like name that is not already in use.

If name itself is available, it is returned unchanged.

Implementors