Struct coord::catalog::Catalog[][src]

pub struct Catalog {
    state: CatalogState,
    storage: Arc<Mutex<Connection>>,
    oid_counter: u32,
    transient_revision: u64,
    config: CatalogConfig,
}
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 FullName, which fully and unambiguously specifies the item, or a PartialName, 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 Catalog::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>>oid_counter: u32transient_revision: u64config: CatalogConfig

Implementations

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.

Retuns 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 at path 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.

Resolves name to a non-function CatalogEntry.

Resolves name to a function CatalogEntry.

Resolves PartialName into a FullName.

If name does not specify a database, the current_database is used. If name does not specify a schema, then the schemas in search_path are searched in order.

Returns the named catalog item, if it exists.

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

Returns the Ops necessary to enable an index.

Panics

Panics if id is not the id of a CatalogItem::Index.

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

Insert timestamp bindings into SQLite, and ignores duplicate timestamp bindings.

Each individual binding is listed as (source_id, partition_id, timestamp, offset) and it indicates that all data from (source, partition) for offsets < offset, can be assigned timestamp iff offset is the minimal such offset (this is a way to encode a [start, end) offset interval without having to duplicate adjacent starts and ends in storage). TODO: we intentionally ignore duplicates because BYO sources can send multiple copies of the same timestamp.

Read all available timestamp bindings for a source

Returns its output sorted by (partition, timestamp)

Compact timestamp bindings for a source

In practice this ends up being “remove all bindings less than a given timestamp” because all offsets are then assigned to the next available binding.

Returns the default value for an Index’s enabled field.

Note that it is the caller’s responsibility to ensure that the id is used for an Index.

Returns a mapping that indicates all indices that are available for each item in the catalog.

Note that when self.config.disable_user_indexes is true, this does not include any user indexes.

Returns whether or not an index is enabled.

Panics

Panics if id does not belong to a CatalogItem::Index.

Returns all indexes on this object known in the catalog.

Returns the default index for the specified id.

Panics if id does not exist, or if id is not an object on which indexes can be built.

Returns an error if the object’s default index is disabled.

Note that this function is really only meant to be used with tables.

Panics

Panics if the object identified with id does not have a default index.

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.

Returns all tables, views, and sources in the same schemas as a set of input ids. The indexes of all relations are included.

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

Performs the conversion.

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

Performs the conversion.

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