cockroach: github.com/cockroachdb/cockroach/pkg/sql/catalog Index | Files | Directories

package catalog

import "github.com/cockroachdb/cockroach/pkg/sql/catalog"

Index

Package Files

accessor.go catalog.go descriptor.go

Variables

var ErrDescriptorDropped = errors.New("descriptor is being dropped")

ErrDescriptorDropped is returned when the descriptor is being dropped. TODO (lucy): Make the error message specific to each descriptor type (e.g., "table is being dropped") and add the pgcodes (UndefinedTable, etc.).

func FilterDescriptorState Uses

func FilterDescriptorState(desc sqlbase.Descriptor) error

FilterDescriptorState inspects the state of a given descriptor and returns an error if the state is anything but public. The error describes the state of the descriptor.

func HasAddingTableError Uses

func HasAddingTableError(err error) bool

HasAddingTableError returns true if the error contains errTableAdding.

func HasInactiveDescriptorError Uses

func HasInactiveDescriptorError(err error) bool

HasInactiveDescriptorError returns true if the error contains an inactiveDescriptorError.

func NewInactiveDescriptorError Uses

func NewInactiveDescriptorError(err error) error

NewInactiveDescriptorError wraps an error in a new inactiveDescriptorError.

type Accessor Uses

type Accessor interface {

    // GetDatabaseDesc looks up a database by name and returns its
    // descriptor. If the database is not found and required is true,
    // an error is returned; otherwise a nil reference is returned.
    GetDatabaseDesc(ctx context.Context, txn *kv.Txn, codec keys.SQLCodec, dbName string, flags tree.DatabaseLookupFlags) (sqlbase.DatabaseDescriptor, error)

    // GetSchema returns true and a ResolvedSchema object if the target schema
    // exists under the target database.
    GetSchema(ctx context.Context, txn *kv.Txn, codec keys.SQLCodec, dbID descpb.ID, scName string) (bool, sqlbase.ResolvedSchema, error)

    // GetObjectNames returns the list of all objects in the given
    // database and schema.
    // TODO(solon): when separate schemas are supported, this
    // API should be extended to use schema descriptors.
    //
    // TODO(ajwerner,rohany): This API is utilized to support glob patterns that
    // are fundamentally sometimes ambiguous (see GRANT and the ambiguity between
    // tables and types). Furthermore, the fact that this buffers everything
    // in ram in unfortunate.
    GetObjectNames(ctx context.Context, txn *kv.Txn, codec keys.SQLCodec,
        db sqlbase.DatabaseDescriptor, scName string, flags tree.DatabaseListFlags,
    ) (tree.TableNames, error)

    // GetObjectDesc looks up an object by name and returns both its
    // descriptor and that of its parent database. If the object is not
    // found and flags.required is true, an error is returned, otherwise
    // a nil reference is returned.
    //
    // TODO(ajwerner): clarify the purpose of the transaction here. It's used in
    // some cases for some lookups but not in others. For example, if a mutable
    // descriptor is requested, it will be utilized however if an immutable
    // descriptor is requested then it will only be used for its timestamp.
    GetObjectDesc(ctx context.Context, txn *kv.Txn, settings *cluster.Settings, codec keys.SQLCodec,
        db, schema, object string, flags tree.ObjectLookupFlags) (Descriptor, error)
}

Accessor provides access to sql object descriptors.

type Descriptor Uses

type Descriptor = sqlbase.Descriptor

Descriptor is an interface for retrieved catalog descriptors.

type MutableDescriptor Uses

type MutableDescriptor interface {
    sqlbase.Descriptor
    // MaybeIncrementVersion sets the version of the descriptor to
    // OriginalVersion()+1.
    // TODO (lucy): It's not a good idea to have callers handle incrementing the
    // version manually. Find a better API for this. Maybe creating a new mutable
    // descriptor should increment the version on the mutable copy from the
    // outset.
    MaybeIncrementVersion()
    // SetDrainingNames sets the draining names for the descriptor.
    SetDrainingNames([]descpb.NameInfo)

    // Accessors for the original state of the descriptor prior to the mutations.
    OriginalName() string
    OriginalID() descpb.ID
    OriginalVersion() descpb.DescriptorVersion
    // Immutable returns an immutable copy of this descriptor.
    Immutable() Descriptor
    // IsNew returns whether the descriptor was created in this transaction.
    IsNew() bool
}

MutableDescriptor represents a descriptor undergoing in-memory mutations as part of a schema change.

type ResolvedObjectPrefix Uses

type ResolvedObjectPrefix struct {
    // Database is the parent database descriptor.
    Database *sqlbase.ImmutableDatabaseDescriptor
    // Schema is the parent schema.
    Schema sqlbase.ResolvedSchema
}

ResolvedObjectPrefix represents the resolved components of an object name prefix. It contains the parent database and schema.

func (*ResolvedObjectPrefix) SchemaMeta Uses

func (*ResolvedObjectPrefix) SchemaMeta()

SchemaMeta implements the SchemaMeta interface.

type TableEntry Uses

type TableEntry struct {
    // Desc is the descriptor of the table. This can be nil if eg.
    // the table is not public.
    Desc *sqlbase.ImmutableTableDescriptor

    // IsAdding indicates the descriptor is being created.
    IsAdding bool
}

TableEntry is the value type of FkTableMetadata: An optional table descriptor, populated when the table is public/leasable, and an IsAdding flag.

type VirtualObject Uses

type VirtualObject interface {
    Desc() Descriptor
}

VirtualObject is a virtual schema object.

type VirtualSchema Uses

type VirtualSchema interface {
    Desc() Descriptor
    NumTables() int
    VisitTables(func(object VirtualObject))
    GetObjectByName(name string, flags tree.ObjectLookupFlags) (VirtualObject, error)
}

VirtualSchema represents a collection of VirtualObjects.

type VirtualSchemas Uses

type VirtualSchemas interface {
    GetVirtualSchema(schemaName string) (VirtualSchema, bool)
}

VirtualSchemas is a collection of VirtualSchemas.

Directories

PathSynopsis
accessors
catalogkvPackage catalogkv provides functions for interacting with the system catalog tables using the kv client.
catconstants
databasePackage database primarily provides the incoherent database cache and related interfaces.
descpb
descsPackage descs provides abstractions for dealing with sets of descriptors.
leasePackage lease provides functionality to create and manage sql schema leases.
resolver

Package catalog imports 8 packages (graph) and is imported by 10 packages. Updated 2020-08-12. Refresh now. Tools for package owners.