package
25.1.0+incompatible
Repository: https://github.com/cockroachdb/cockroach.git
Documentation: pkg.go.dev

# Packages

Package bootstrap contains the metadata required to bootstrap the sql schema for a fresh cockroach cluster.
Package catalogkeys describes keys used by the SQL catalog.
Package catenumpb contains enum definitions from catalog in order to keep catenumpb very low dependency.
Package catpb contains definitions of low-level serializations of catalog concepts which can be shared by descriptors and schema change elements.
Package colinfo contains type information and related structures for dealing with columns returned from sql operations.
Package dbdesc contains the concrete implementations of catalog.DatabaseDescriptor.
Package descpb exposes the "Descriptor" type and related utilities.
Package descs provides abstractions for dealing with sets of descriptors.
Package hydrateddesccache contains logic to cache descriptors with user defined types hydrated.
Package lease provides functionality to create and manage sql schema leases.
Package multiregion provides functions and structs for interacting with the static multi-region state configured by users on their databases.
Package nstree provides a data structure for storing and retrieving descriptors namespace entry-like data.
Package redact contains utilities to redact sensitive fields from descriptors.
Package schemaexpr provides utilities for dealing with expressions with table schemas, such as check constraints, computed columns, and partial index predicates.
Package seqexpr provides functionality to find usages of sequences in expressions.
Package tabledesc provides concrete implementations of catalog.TableDesc.
Package typedesc contains the concrete implementations of catalog.TypeDescriptor.

# Functions

AsDatabaseDescriptor tries to cast desc to a DatabaseDescriptor.
AsFunctionDescriptor tries to case a descriptor to a FunctionDescriptor.
AsSchemaDescriptor tries to cast desc to a SchemaDescriptor.
AsTableDescriptor tries to cast desc to a TableDescriptor.
AsTypeDescriptor tries to cast desc to a TypeDescriptor.
ColumnIDToOrdinalMap returns a map from Column ID to the ordinal position of that column.
ColumnNamesForIDs returns the names for the given column IDs, or an error if one or more column ids was missing.
ColumnNeedsBackfill returns true if adding or dropping (according to the direction) the given column requires backfill.
ColumnsByIDs returns a map of Columns keyed by their ID for the given table.
ColumnTypesWithInvertedCol returns the types of all given columns, If invertedCol is non-nil, substitutes the type of the inverted column instead of the column with the same ID.
FilterAddingDescriptor returns an error if the descriptor state is ADD.
FilterDroppedDescriptor returns an error if the descriptor state is DROP.
FilterOfflineDescriptor returns an error if the descriptor state is OFFLINE.
FindActiveIndex returns the first index in ActiveIndex() for which test returns true.
FindColumnByID traverses the slice returned by the AllColumns method on the table descriptor and returns the first Column that matches the desired ID, or nil if none was found.
FindColumnByName is like FindColumnByID but with names instead of IDs.
FindColumnByPGAttributeNum traverses the slice returned by the AllColumns method on the table descriptor and returns the first Column that matches the desired PGAttributeNum, or the ID if not set.
FindColumnByTreeName is like FindColumnByID but with names instead of IDs.
FindConstraintByID traverses the slice returned by the AllConstraints method on the table descriptor and returns the first Constraint that matches the desired ID, or nil if none was found.
FindConstraintByName is like FindConstraintByID but with names instead of IDs.
FindCorrespondingTemporaryIndexByID finds the temporary index that corresponds to the currently mutated index identified by ID.
FindDeletableNonPrimaryIndex returns the first index in DeletableNonPrimaryIndex() for which test returns true.
FindDeleteOnlyNonPrimaryIndex returns the first index in DeleteOnlyNonPrimaryIndex() for which test returns true.
FindFamilyByID traverses the family descriptors on the table descriptor and returns the first column family with the desired ID, or nil if none was found.
FindFKReferencedUniqueConstraint finds the first index in the supplied referencedTable that can satisfy a foreign key of the supplied column ids.
FindIndex returns the first index for which test returns true, nil otherwise, according to the parameters in opts just like ForEachIndex.
FindIndexByID returns the first Index that matches the ID in the set of all indexes, or nil if none was found.
FindIndexByName is like FindIndexByID but with names instead of IDs.
FindNonDropIndex returns the first index in NonDropIndex() for which test returns true.
FindNonPrimaryIndex returns the first index in NonPrimaryIndex() for which test returns true.
FindPartialIndex returns the first index in PartialIndex() for which test returns true.
FindPolicyByID traverses the slice returned by the GetPolicies method on the table descriptor and returns the first policy that matches the desired ID, or nil if none was found.
FindPublicNonPrimaryIndex returns the first index in PublicNonPrimaryIndex() for which test returns true.
FindTargetIndexNameByID returns the name of an index based on an ID, taking into account any ongoing declarative schema changes.
FindTriggerByID traverses the slice returned by the GetTriggers method on the table descriptor and returns the first trigger that matches the desired ID, or nil if none was found.
FindWritableNonPrimaryIndex returns the first index in WritableNonPrimaryIndex() for which test returns true.
ForEachActiveIndex is like ForEachIndex over ActiveIndexes().
ForEachDeletableNonPrimaryIndex is like ForEachIndex over DeletableNonPrimaryIndexes().
ForEachDeleteOnlyNonPrimaryIndex is like ForEachIndex over DeleteOnlyNonPrimaryIndexes().
ForEachIndex runs f over each index in the table descriptor according to filter parameters in opts.
ForEachNonDropIndex is like ForEachIndex over NonDropIndexes().
ForEachNonPrimaryIndex is like ForEachIndex over NonPrimaryIndexes().
ForEachPartialIndex is like ForEachIndex over PartialIndexes().
ForEachPublicNonPrimaryIndex is like ForEachIndex over PublicNonPrimaryIndexes().
ForEachWritableNonPrimaryIndex is like ForEachIndex over WritableNonPrimaryIndexes().
FormatSafeDescriptorProperties is a shared helper function for writing un-redacted, common parts of a descriptor.
GetConstraintType finds the type of constraint.
HasAddingDescriptorError returns true if the error contains errTableAdding.
HasConcurrentDeclarativeSchemaChange returns true iff the descriptors has a concurrent declarative schema change.
HasInactiveDescriptorError returns true if the error contains an inactiveDescriptorError.
IsCorrespondingTemporaryIndex returns true iff idx is a temporary index created during a backfill and is the corresponding temporary index for otherIdx.
IsSystemDescriptor returns true iff the descriptor is a system or a reserved descriptor.
MakeConstraintIDSet returns a set initialized with the given values.
MakeDescriptorIDSet returns a set initialized with the given values.
MakeTableColSet returns a set initialized with the given values.
MustFindColumnByID is like FindColumnByID but returns an error when no Column was found.
MustFindColumnByName is like MustFindColumnByID but with names instead of IDs.
MustFindColumnByPGAttributeNum is like FindColumnByPGAttributeNum but returns an error when no column is found.
MustFindColumnByTreeName is like MustFindColumnByID but with names instead of IDs.
MustFindConstraintByID is like FindConstraintByID but returns an error when no Constraint was found.
MustFindConstraintWithName is like MustFindConstraintByID but with names instead of IDs.
MustFindFamilyByID is like FindFamilyByID but returns an error if no column family was found.
MustFindIndexByID is like FindIndexByID but returns an error when no Index was found.
MustFindIndexByName is like MustFindIndexByID but with names instead of IDs.
MustFindPublicColumnByID is a convenience function which behaves exactly like FindColumnByID except it ignores column mutations.
MustFindPublicColumnByTreeName is a convenience function which behaves exactly like FindColumnByName except it ignores column mutations.
MustFindPublicColumnsByNameList is a convenience function which behaves exactly like MustFindPublicColumnByTreeName applied repeatedly to the names in the provided list, returning early at the first encountered error.
NewDescriptorTypeError returns ErrDescriptorWrongType prefixed with the actual go type of the descriptor.
NewInactiveDescriptorError wraps an error in a new inactiveDescriptorError.
NewMutableAccessToDescriptorlessSchemaError is returned when trying to mutably access a descriptorless schema object, including - descriptorless public schemas (deprecated), - temporary schemas, - virtual schemas (pg_catalog, pg_extension, information_schema, and crdb_internal).
NewMutableAccessToVirtualObjectError is returned when trying to mutably access a virtual schema object.
SequenceOptionsFromNormalizationMode modifies the column defintion and returns the sequence options to support the current serialization mode.
UserDefinedTypeColsHaveSameVersion returns whether one table descriptor's columns with user defined type metadata have the same versions of metadata as in the other descriptor.
UserDefinedTypeColsInFamilyHaveSameVersion returns whether one table descriptor's columns with user defined type metadata have the same versions of metadata as in the other descriptor, for all columns in the same family.
ValidateName validates a name.
ValidateOutboundFunctionRef validates outbound reference to a function descriptor depID.
ValidateOutboundTableRef validates outbound reference to relation descriptor depID from descriptor selfID.
ValidateOutboundTableRefBackReference validates that the outbound reference to a table descriptor has a matching back-reference.
ValidateOutboundTypeRef validates outbound reference to type descriptor.
ValidateOutboundTypeRefBackReference validates that the outbound reference to a type descriptor has a matching back-reference.
ValidateRolesInDefaultPrivilegeDescriptor validates roles within a catalog.DefaultPrivilegeDescriptor.
ValidateRolesInDescriptor validates roles within a descriptor.
WrapDatabaseDescRefErr wraps an error pertaining to a database descriptor id.
WrapFunctionDescRefErr wraps an error pertaining to a function descriptor id.
WrapSchemaDescRefErr wraps an error pertaining to a schema descriptor id.
WrapTableDescRefErr wraps an error pertaining to a table descriptor id.
WrapTypeDescRefErr wraps an error pertaining to a type descriptor id.

# Constants

AddedConstraintIDs indicates that table descriptors had constraint ID added.
Any represents any descriptor.
Database is for database descriptors.
FixedIncorrectForeignKeyOrigins indicates that foreign key origin / reference IDs that should point to the current descriptor were fixed.
FixedUsesSequencesIDForIdentityColumns indicates sequence ID references are fixed for identity / serial columns.
FixSecondaryIndexEncodingType indicates that a secondary index had its encoding type fixed, so it is not incorrectly marked as a primary index.
Function is for function descriptors.
GrantExecuteOnFunctionToPublicRole indicates that EXECUTE was granted to the public role for a function.
IgnoreConstraints is used in MakeFirstMutationPublic to indicate that the table descriptor returned should not include newly added constraints, which is useful when passing the returned table descriptor to be used in validating constraints to be added.
IgnorePKSwaps is used in MakeFirstMutationPublic to indicate that the table descriptor returned should include newly added constraints.
NoValidation means don't perform any validation checks at all.
NoValidationTelemetry means no telemetry keys are added.
NumSystemColumns defines the number of supported system columns and must be equal to colinfo.numSystemColumns (enforced in colinfo package to avoid an import cycle).
PLpgSQLStmt is a serialized PLpgSQL statement or series of statements.
RemovedDuplicateIDsInRefs indicates that the table has redundant IDs in its DependsOn, DependsOnTypes and DependedOnBy references.
RemovedSelfEntryInSchemas corresponds to a change which occurred in database descriptors to recover from an earlier bug whereby when dropping a schema, we'd mark the database itself as though it was the schema which was dropped.
RetainDroppingColumns is used in MakeFirstMutationPublic to indicate that the table descriptor should include newly dropped columns.
Schema is for schema descriptors.
SchemaPublic represents the public schema.
SchemaTemporary represents a temporary schema.
SchemaUserDefined represents a user defined schema.
SchemaVirtual represents a virtual schema.
SetCreateAsOfTimeUsingModTime indicates that a table's CreateAsOfTime field was unset and the ModificationTime value was assigned to it.
SetIndexInvisibility indicates that the invisibility of at least one index descriptor was updated to a non-zero value.
SetModTimeToMVCCTimestamp indicates that a descriptor's ModificationTime field was unset and that the MVCC timestamp value was assigned to it.
SetSystemDatabaseDescriptorVersion indicates that the system database descriptor did not have its version set.
SmallestSystemColumnColumnID is a descpb.ColumnID with the smallest value among all system columns (enforced in colinfo package to avoid an import cycle).
SQLExpr is a serialized SQL expression, such as "1 * 2".
SQLStmt is a serialized SQL statement or series of statements.
StrippedDanglingBackReferences indicates that at least one dangling back-reference was removed from the descriptor.
StrippedDanglingSelfBackReferences indicates that at least one dangling back-reference to something within the descriptor itself was removed from the descriptor.
StrippedNonExistentRoles indicates that at least one role identified did not exist.
Table is for table descriptors.
Type is for type descriptors.
UpgradedDeclarativeSchemaChangerState indicates the declarative schema changer state was modified.
UpgradedForeignKeyRepresentation indicates that the foreign key representation was upgraded.
UpgradedFormatVersion indicates that the FormatVersion was upgraded.
UpgradedIndexFormatVersion indicates that the format version of at least one index descriptor was upgraded.
UpgradedPrivileges indicates that the PrivilegeDescriptor version was upgraded.
UpgradedSequenceReference indicates that the table/view had upgraded their sequence references, if any, from by-name to by-ID, if not already.
ValidationLevelAllPreTxnCommit means do the above and also perform pre-txn-commit checks.
ValidationLevelBackReferences means do the above and also check backward references.
ValidationLevelForwardReferences means do the above and also check forward references.
ValidationLevelNamespace means do the above and also check namespace table records.
ValidationLevelSelfOnly means only validate internal descriptor consistency.
ValidationReadTelemetry means telemetry keys are added for descriptor reads.
ValidationWriteTelemetry means telemetry keys are added for descriptor writes.

# Variables

ErrDescriptorDropped is returned when the descriptor is being dropped.
ErrDescriptorNotFound is returned to signal that a descriptor could not be found with the given id.
ErrDescriptorWrongType is returned to signal that a descriptor was found but that it wasn't of the expected type.
ErrReferencedDescriptorNotFound is like ErrDescriptorNotFound but for descriptors referenced within another descriptor.

# Structs

ConstraintIDSet stores an unordered set of descriptor ids.
DescriptorIDSet efficiently stores an unordered set of descriptor ids.
IndexOpts configures the behavior of catalog.ForEachIndex and catalog.FindIndex.
PostDeserializationChanges are a set of booleans to indicate which types of upgrades or fixes occurred when filling in the descriptor after deserialization.
ResolvedObjectPrefix represents the resolved components of an object name prefix.
TableColMap is a map from descpb.ColumnID to int.
TableColSet efficiently stores an unordered set of column ids.

# Interfaces

AliasTypeDescriptor is the TypeDescriptor subtype for alias types.
CheckConstraint is an interface around a check constraint.
Column is an interface around the column descriptor types.
CompositeTypeDescriptor is the TypeDescriptor subtype for composite types, which are union types.
ComputedColumnSwap is an interface around a computed column swap mutation.
Constraint is an interface around a constraint.
ConstraintProvider is an interface for something which might unwrap a constraint.
DatabaseDescriptor encapsulates the concept of a database.
DefaultPrivilegeDescriptor is an interface for default privileges to ensure DefaultPrivilegeDescriptor protos are not accessed and interacted with directly.
Descriptor is an interface to be shared by individual descriptor types.
DescriptorBuilder interfaces are used to build catalog.Descriptor objects.
EnumTypeDescriptor is the TypeDescriptor subtype for enums (incl.
ForeignKeyConstraint is an interface around a check constraint.
FunctionDescriptor is an interface around the function descriptor types.
Index is an interface around the index descriptor types.
LeasableDescriptor is an interface for objects which can be leased via the descriptor leasing system.
MaterializedViewRefresh is an interface around a materialized view refresh mutation.
ModifyRowLevelTTL is an interface around a modify row level TTL mutation.
MutableDescriptor represents a descriptor undergoing in-memory mutations as part of a schema change.
MutableTableDescriptor is both a MutableDescriptor and a TableDescriptor.
Mutation is an interface around a table descriptor mutation.
NameEntry corresponds to an entry in the namespace table.
NameKey is an interface for objects which have all the components of their corresponding namespace table entry.
NonAliasTypeDescriptor is the TypeDescriptor subtype for concrete user-defined types.
Partitioning is an interface around an index partitioning.
PrimaryKeySwap is an interface around a primary key swap mutation.
RegionEnumTypeDescriptor is the TypeDescriptor subtype for multi-region enums.
SchemaDescriptor encapsulates the basic.
SystemTableIDResolver is a convenience interface used to resolve the table ID for a system table with a dynamic ID.
TableDescriptor is an interface around the table descriptor types.
TableElementMaybeMutation is an interface used as a subtype for the various table descriptor elements which may be present in a mutation.
TableImplicitRecordTypeDescriptor is the TypeDescriptor subtype for the record type implicitly defined by a table.
TypeDescriptor is an interface around the type descriptor types.
TypeDescriptorResolver is an interface used during hydration of type metadata in types.T's.
UniqueConstraint is an interface for a unique constraint.
UniqueWithIndexConstraint is an interface around a unique constraint which backed by an index.
UniqueWithoutIndexConstraint is an interface around a unique constraint which is not backed by an index.
ValidationDescGetter is used by the validation methods on Descriptor.
ValidationErrorAccumulator is used by the validation methods on Descriptor to accumulate any encountered validation errors which are then processed by the Validate function.
VirtualObject is a virtual schema object.
VirtualSchema represents a collection of VirtualObjects.
VirtualSchemas is a collection of VirtualSchemas.
WithoutIndexConstraint is the supertype of all constraint subtypes which are not backed by an index.
ZoneConfig encapsulates zone config and raw bytes read from storage.
ZoneConfigHydrationHelper is a helper interface for zone config hydration.

# Type aliases

DescExprType describes the type for a serialized expression or statement within a descriptor.
Descriptors is a sortable list of Descriptors.
DescriptorType is a symbol representing the (sub)type of a descriptor.
MutationPublicationFilter is used by MakeFirstMutationPublic to filter the mutation types published.
PostDeserializationChangeType is used to indicate the type of PostDeserializationChange which occurred for a descriptor.
ResolvedSchemaKind is an enum that represents what kind of schema has been resolved.
TableLookupFn is used to resolve a table from an ID, particularly when getting constraint info.
ValidationErrors is the error container returned by Validate which contains all errors accumulated during validation.
ValidationLevel defines up to which degree to perform validation in Validate.
ValidationTelemetry defines the kind of telemetry keys to add to the errors.