pub struct Catalog<S> {
    state: CatalogState,
    storage: Arc<Mutex<Connection<S>>>,
    transient_revision: u64,
}
Expand description

A Catalog keeps track of the SQL objects known to the planner.

For each object, it keeps track of both forward and reverse dependencies: i.e., which objects are depended upon by the object, and which objects depend upon the object. It enforces the SQL rules around dropping: an object cannot be dropped until all of the objects that depend upon it are dropped. It also enforces uniqueness of names.

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

To the outside world, databases, schemas, and items are all identified by name. Items can be referred to by their FullObjectName, which fully and unambiguously specifies the item, or a PartialObjectName, which can omit the database name and/or the schema name. Partial names can be converted into full names via a complicated resolution process documented by the CatalogState::resolve method.

The catalog also maintains special “ambient schemas”: virtual schemas, implicitly present in all databases, that house various system views. The big examples of ambient schemas are pg_catalog and mz_catalog.

Fields

state: CatalogStatestorage: Arc<Mutex<Connection<S>>>transient_revision: u64

Implementations

Opens a debug in-memory sqlite catalog.

See Catalog::open_debug.

Opens a debug postgres catalog at url.

If specified, schema will set the connection’s search_path to schema.

See Catalog::open_debug.

Opens or creates a catalog that stores data at path.

Returns the catalog and a list of updates to builtin tables that describe the initial state of the catalog.

Loads built-in system types into the catalog.

Built-in types sometimes have references to other built-in types, and sometimes these references are circular. This makes loading built-in types more complicated than other built-in objects, and requires us to make multiple passes over the types to correctly resolve all references.

Returns the catalog’s transient revision, which starts at 1 and is incremented on every change. This is not persisted to disk, and will restart on every load.

Takes a catalog which only has items in its on-disk storage (“unloaded”) and cannot yet resolve names, and returns a catalog loaded with those items.

This function requires transactions to support loading a catalog with the transaction’s currently in-flight updates to existing catalog objects, which is necessary for at least one catalog migration.

TODO(justin): it might be nice if these were two different types.

Opens the catalog from stash with parameters set appropriately for debug contexts, like in tests.

WARNING! This function can arbitrarily fail because it does not make any effort to adjust the catalog’s contents’ structure or semantics to the currently running version, i.e. it does not apply any migrations.

This function should not be called in production contexts. Use Catalog::open with appropriately set configuration parameters instead.

Allocate new system ids for any new builtin objects and looks up existing system ids for existing builtin objects

source

pub fn resolve_entry(
    &self,
    current_database: Option<&DatabaseId>,
    search_path: &Vec<(ResolvedDatabaseSpecifier, SchemaSpecifier)>,
    name: &PartialObjectName,
    conn_id: u32
) -> Result<&CatalogEntry, SqlCatalogError>

Resolves name to a non-function CatalogEntry.

Resolves a BuiltinTable.

Resolves a BuiltinLog.

Resolves name to a function CatalogEntry.

source

pub fn try_get_entry_in_schema(
    &self,
    name: &QualifiedObjectName,
    conn_id: u32
) -> Option<&CatalogEntry>

Returns the named catalog item, if it exists.

source

pub fn try_get_entry(&self, id: &GlobalId) -> Option<&CatalogEntry>

source

pub fn get_entry(&self, id: &GlobalId) -> &CatalogEntry

Creates a new schema in the Catalog for temporary items indicated by the TEMPORARY or TEMP keywords.

Gets GlobalIds of temporary items to be created, checks for name collisions within a connection id.

Return the names of all log sources the given object depends on.

Serializes the catalog’s in-memory state.

There are no guarantees about the format of the serialized state, except that the serialized state for two identical catalogs will compare identically.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Attaches the provided Context to this type, returning a WithContext wrapper. Read more

Attaches the current Context to this type, returning a WithContext wrapper. Read more

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

Wrap the input message T in a tonic::Request

Upcasts this ProgressEventTimestamp to Any. Read more

Returns the name of the concrete type of this object. Read more

Should always be Self

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more