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

package sqlbase

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

Index

Package Files

cancel_checker.go col_type_info.go column_resolver.go column_type_encoding.go column_type_properties.go computed_exprs.go constants.go data_source.go database.go database_desc.go datum_alloc.go default_exprs.go descriptor.go encoded_datum.go encoded_datum.pb.go errors.go evalctx.go expr_filter.go formatversion_string.go index_encoding.go internal.go join_type.go join_type.pb.go keys.go locking.go locking.pb.go metadata.go namespace.go node_liveness.go ordering.go partition.go prepared_statement.go privilege.go privilege.pb.go result_columns.go roundtrip_format.go schema_desc.go select_name_resolution.go sort.go structured.go structured.pb.go system.go table.go table_col_set.go table_desc.go testutils.go type_desc.go

Constants

const (
    CrdbInternalID = math.MaxUint32 - iota
    CrdbInternalBackwardDependenciesTableID
    CrdbInternalBuildInfoTableID
    CrdbInternalBuiltinFunctionsTableID
    CrdbInternalClusterQueriesTableID
    CrdbInternalClusterTransactionsTableID
    CrdbInternalClusterSessionsTableID
    CrdbInternalClusterSettingsTableID
    CrdbInternalCreateStmtsTableID
    CrdbInternalCreateTypeStmtsTableID
    CrdbInternalDatabasesTableID
    CrdbInternalFeatureUsageID
    CrdbInternalForwardDependenciesTableID
    CrdbInternalGossipNodesTableID
    CrdbInternalGossipAlertsTableID
    CrdbInternalGossipLivenessTableID
    CrdbInternalGossipNetworkTableID
    CrdbInternalIndexColumnsTableID
    CrdbInternalJobsTableID
    CrdbInternalKVNodeStatusTableID
    CrdbInternalKVStoreStatusTableID
    CrdbInternalLeasesTableID
    CrdbInternalLocalQueriesTableID
    CrdbInternalLocalTransactionsTableID
    CrdbInternalLocalSessionsTableID
    CrdbInternalLocalMetricsTableID
    CrdbInternalPartitionsTableID
    CrdbInternalPredefinedCommentsTableID
    CrdbInternalRangesNoLeasesTableID
    CrdbInternalRangesViewID
    CrdbInternalRuntimeInfoTableID
    CrdbInternalSchemaChangesTableID
    CrdbInternalSessionTraceTableID
    CrdbInternalSessionVariablesTableID
    CrdbInternalStmtStatsTableID
    CrdbInternalTableColumnsTableID
    CrdbInternalTableIndexesTableID
    CrdbInternalTablesTableID
    CrdbInternalTxnStatsTableID
    CrdbInternalZonesTableID
    InformationSchemaID
    InformationSchemaAdministrableRoleAuthorizationsID
    InformationSchemaApplicableRolesID
    InformationSchemaCheckConstraints
    InformationSchemaColumnPrivilegesID
    InformationSchemaColumnsTableID
    InformationSchemaConstraintColumnUsageTableID
    InformationSchemaEnabledRolesID
    InformationSchemaKeyColumnUsageTableID
    InformationSchemaParametersTableID
    InformationSchemaReferentialConstraintsTableID
    InformationSchemaRoleTableGrantsID
    InformationSchemaRoutineTableID
    InformationSchemaSchemataTableID
    InformationSchemaSchemataTablePrivilegesID
    InformationSchemaSequencesID
    InformationSchemaStatisticsTableID
    InformationSchemaTableConstraintTableID
    InformationSchemaTablePrivilegesID
    InformationSchemaTablesTableID
    InformationSchemaViewsTableID
    InformationSchemaUserPrivilegesID
    PgCatalogID
    PgCatalogAggregateTableID
    PgCatalogAmTableID
    PgCatalogAttrDefTableID
    PgCatalogAttributeTableID
    PgCatalogAuthIDTableID
    PgCatalogAuthMembersTableID
    PgCatalogAvailableExtensionsTableID
    PgCatalogCastTableID
    PgCatalogClassTableID
    PgCatalogCollationTableID
    PgCatalogConstraintTableID
    PgCatalogConversionTableID
    PgCatalogDatabaseTableID
    PgCatalogDefaultACLTableID
    PgCatalogDependTableID
    PgCatalogDescriptionTableID
    PgCatalogSharedDescriptionTableID
    PgCatalogEnumTableID
    PgCatalogEventTriggerTableID
    PgCatalogExtensionTableID
    PgCatalogForeignDataWrapperTableID
    PgCatalogForeignServerTableID
    PgCatalogForeignTableTableID
    PgCatalogIndexTableID
    PgCatalogIndexesTableID
    PgCatalogInheritsTableID
    PgCatalogLanguageTableID
    PgCatalogLocksTableID
    PgCatalogMatViewsTableID
    PgCatalogNamespaceTableID
    PgCatalogOperatorTableID
    PgCatalogPreparedStatementsTableID
    PgCatalogPreparedXactsTableID
    PgCatalogProcTableID
    PgCatalogRangeTableID
    PgCatalogRewriteTableID
    PgCatalogRolesTableID
    PgCatalogSecLabelsTableID
    PgCatalogSequencesTableID
    PgCatalogSettingsTableID
    PgCatalogShdependTableID
    PgCatalogUserTableID
    PgCatalogUserMappingTableID
    PgCatalogTablesTableID
    PgCatalogTablespaceTableID
    PgCatalogTriggerTableID
    PgCatalogTypeTableID
    PgCatalogViewsTableID
    PgCatalogStatActivityTableID
    PgCatalogSecurityLabelTableID
    PgCatalogSharedSecurityLabelTableID
    PgExtensionSchemaID
    PgExtensionGeographyColumnsTableID
    PgExtensionGeometryColumnsTableID
    PgExtensionSpatialRefSysTableID
    MinVirtualID = PgExtensionSpatialRefSysTableID
)

Oid for virtual database and table.

const (
    InnerJoin        = JoinType_INNER
    LeftOuterJoin    = JoinType_LEFT_OUTER
    RightOuterJoin   = JoinType_RIGHT_OUTER
    FullOuterJoin    = JoinType_FULL_OUTER
    LeftSemiJoin     = JoinType_LEFT_SEMI
    LeftAntiJoin     = JoinType_LEFT_ANTI
    IntersectAllJoin = JoinType_INTERSECT_ALL
    ExceptAllJoin    = JoinType_EXCEPT_ALL
)

Prettier aliases for JoinType values. See the original types for descriptions.

const (
    // DefaultDatabaseName is the name ofthe default CockroachDB database used
    // for connections without a current db set.
    DefaultDatabaseName = "defaultdb"

    // PgDatabaseName is the name of the default postgres system database.
    PgDatabaseName = "postgres"
)
const (
    // PrimaryKeyIndexName is the name of the index for the primary key.
    PrimaryKeyIndexName = "primary"
    // SequenceColumnID is the ID of the sole column in a sequence.
    SequenceColumnID = 1
    // SequenceColumnName is the name of the sole column in a sequence.
    SequenceColumnName = "value"
)
const (
    NamespaceTableSchema = "" /* 173 byte string literal not displayed */

    DescriptorTableSchema = `
CREATE TABLE system.descriptor (
  id         INT8 PRIMARY KEY,
  descriptor BYTES
);`

    UsersTableSchema = "" /* 145 byte string literal not displayed */

    RoleOptionsTableSchema = "" /* 183 byte string literal not displayed */

    ZonesTableSchema = `
CREATE TABLE system.zones (
  id     INT8 PRIMARY KEY,
  config BYTES
);`

    SettingsTableSchema = "" /* 256 byte string literal not displayed */

    DescIDSequenceSchema = `
CREATE SEQUENCE system.descriptor_id_seq;`

    TenantsTableSchema = "" /* 158 byte string literal not displayed */

)

These system tables are part of the system config.

const (
    LeaseTableSchema = "" /* 170 byte string literal not displayed */

    EventLogTableSchema = "" /* 292 byte string literal not displayed */

    RangeEventTableSchema = "" /* 326 byte string literal not displayed */

    UITableSchema = `
CREATE TABLE system.ui (
	key           STRING PRIMARY KEY,
	value         BYTES,
	"lastUpdated" TIMESTAMP NOT NULL
);`

    JobsTableSchema = "" /* 522 byte string literal not displayed */

    WebSessionsTableSchema = "" /* 525 byte string literal not displayed */

    TableStatisticsTableSchema = "" /* 557 byte string literal not displayed */

    LocationsTableSchema = "" /* 286 byte string literal not displayed */

    RoleMembersTableSchema = "" /* 196 byte string literal not displayed */

    CommentsTableSchema = "" /* 398 byte string literal not displayed */

    ProtectedTimestampsMetaTableSchema = "" /* 350 byte string literal not displayed */

    ProtectedTimestampsRecordsTableSchema = "" /* 398 byte string literal not displayed */

    StatementBundleChunksTableSchema = "" /* 204 byte string literal not displayed */

    StatementDiagnosticsRequestsTableSchema = "" /* 427 byte string literal not displayed */

    StatementDiagnosticsTableSchema = "" /* 368 byte string literal not displayed */

    ScheduledJobsTableSchema = "" /* 663 byte string literal not displayed */

)

These system tables are not part of the system config.

const DelegatedAppNamePrefix = "$$ "

DelegatedAppNamePrefix is added to a regular client application name for SQL queries that are ran internally on behalf of other SQL queries inside that application. This is not the same as RepotableAppNamePrefix; in particular the application name with DelegatedAppNamePrefix should be scrubbed in reporting.

const EncDatumOverhead = unsafe.Sizeof(EncDatum{})

EncDatumOverhead is the overhead of EncDatum in bytes.

const EncDatumRowOverhead = unsafe.Sizeof(EncDatumRow{})

EncDatumRowOverhead is the overhead of EncDatumRow in bytes.

const FamilyHeuristicTargetBytes = 256

FamilyHeuristicTargetBytes is the target total byte size of columns that the current heuristic will assign to a family.

const IgnoreConstraints = false

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.

const IncludeConstraints = true

IncludeConstraints is used in MakeFirstMutationPublic to indicate that the table descriptor returned should include newly added constraints.

const InternalAppNamePrefix = ReportableAppNamePrefix + "internal"

InternalAppNamePrefix indicates that the application name identifies an internal task / query / job to CockroachDB. Different application names are used to classify queries in different categories.

const ReportableAppNamePrefix = "$ "

ReportableAppNamePrefix indicates that the application name can be reported in telemetry without scrubbing. (Note this only applies to the application name itself. Query data is still scrubbed as usual.)

const SystemDatabaseName = "system"

SystemDatabaseName is the name of the system database.

Variables

var (
    ErrInvalidLengthPrivilege = fmt.Errorf("proto: negative length found during unmarshaling")
    ErrIntOverflowPrivilege   = fmt.Errorf("proto: integer overflow")
)
var (
    ErrInvalidLengthStructured = fmt.Errorf("proto: negative length found during unmarshaling")
    ErrIntOverflowStructured   = fmt.Errorf("proto: integer overflow")
)
var (
    // SystemDB is the descriptor for the system database.
    SystemDB = MakeSystemDatabaseDesc()

    // NamespaceTableName is "namespace", which is always and forever the
    // user-visible name of the system.namespace table. Tautological, but
    // important.
    NamespaceTableName = "namespace"

    // DeprecatedNamespaceTable is the descriptor for the deprecated namespace table.
    DeprecatedNamespaceTable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    NamespaceTableName,
        ID:                      keys.DeprecatedNamespaceTableID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: "parentID", ID: 1, Type: types.Int},
            {Name: "name", ID: 2, Type: types.String},
            {Name: "id", ID: 3, Type: types.Int, Nullable: true},
        },
        NextColumnID: 4,
        Families: []ColumnFamilyDescriptor{
            {Name: "primary", ID: 0, ColumnNames: []string{"parentID", "name"}, ColumnIDs: []ColumnID{1, 2}},
            {Name: "fam_3_id", ID: 3, ColumnNames: []string{"id"}, ColumnIDs: []ColumnID{3}, DefaultColumnID: 3},
        },
        NextFamilyID: 4,
        PrimaryIndex: IndexDescriptor{
            Name:             "primary",
            ID:               1,
            Unique:           true,
            ColumnNames:      []string{"parentID", "name"},
            ColumnDirections: []IndexDescriptor_Direction{IndexDescriptor_ASC, IndexDescriptor_ASC},
            ColumnIDs:        []ColumnID{1, 2},
            Version:          SecondaryIndexFamilyFormatVersion,
        },
        NextIndexID:    2,
        Privileges:     NewCustomSuperuserPrivilegeDescriptor(SystemAllowedPrivileges[keys.DeprecatedNamespaceTableID]),
        FormatVersion:  InterleavedFormatVersion,
        NextMutationID: 1,
    })

    // NamespaceTable is the descriptor for the namespace table. Note that this
    // table should only be written to via KV puts, not via the SQL layer. Some
    // code assumes that it only has KV entries for column family 4, not the
    // "sentinel" column family 0 which would be written by SQL.
    //
    // Note that the Descriptor.Name of this table is not "namespace", but
    // something else. This is because, in 20.1, we moved the representation of
    // namespaces to a new place, and for various reasons, we can't have two
    // descriptors with the same Name at once.
    //
    // TODO(solon): in 20.2, we should change the Name of this descriptor
    // back to "namespace".
    NamespaceTable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "namespace2",
        ID:                      keys.NamespaceTableID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: "parentID", ID: 1, Type: types.Int},
            {Name: "parentSchemaID", ID: 2, Type: types.Int},
            {Name: "name", ID: 3, Type: types.String},
            {Name: "id", ID: 4, Type: types.Int, Nullable: true},
        },
        NextColumnID: 5,
        Families: []ColumnFamilyDescriptor{
            {Name: "primary", ID: 0, ColumnNames: []string{"parentID", "parentSchemaID", "name"}, ColumnIDs: []ColumnID{1, 2, 3}},
            {Name: "fam_4_id", ID: 4, ColumnNames: []string{"id"}, ColumnIDs: []ColumnID{4}, DefaultColumnID: 4},
        },
        NextFamilyID: 5,
        PrimaryIndex: IndexDescriptor{
            Name:             "primary",
            ID:               1,
            Unique:           true,
            ColumnNames:      []string{"parentID", "parentSchemaID", "name"},
            ColumnDirections: []IndexDescriptor_Direction{IndexDescriptor_ASC, IndexDescriptor_ASC, IndexDescriptor_ASC},
            ColumnIDs:        []ColumnID{1, 2, 3},
            Version:          SecondaryIndexFamilyFormatVersion,
        },
        NextIndexID:    2,
        Privileges:     NewCustomSuperuserPrivilegeDescriptor(SystemAllowedPrivileges[keys.DeprecatedNamespaceTableID]),
        FormatVersion:  InterleavedFormatVersion,
        NextMutationID: 1,
    })

    // DescriptorTable is the descriptor for the descriptor table.
    DescriptorTable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "descriptor",
        ID:                      keys.DescriptorTableID,
        Privileges:              NewCustomSuperuserPrivilegeDescriptor(SystemAllowedPrivileges[keys.DescriptorTableID]),
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: "id", ID: 1, Type: types.Int},
            {Name: "descriptor", ID: keys.DescriptorTableDescriptorColID, Type: types.Bytes, Nullable: true},
        },
        NextColumnID: 3,
        Families: []ColumnFamilyDescriptor{

            {Name: "primary", ID: 0, ColumnNames: []string{"id"}, ColumnIDs: singleID1},
            {Name: "fam_2_descriptor", ID: keys.DescriptorTableDescriptorColFamID,
                ColumnNames: []string{"descriptor"},
                ColumnIDs:   []ColumnID{keys.DescriptorTableDescriptorColID}, DefaultColumnID: keys.DescriptorTableDescriptorColID},
        },
        PrimaryIndex:   pk("id"),
        NextFamilyID:   3,
        NextIndexID:    2,
        FormatVersion:  InterleavedFormatVersion,
        NextMutationID: 1,
    })

    // UsersTable is the descriptor for the users table.
    UsersTable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "users",
        ID:                      keys.UsersTableID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: "username", ID: 1, Type: types.String},
            {Name: "hashedPassword", ID: 2, Type: types.Bytes, Nullable: true},
            {Name: "isRole", ID: 3, Type: types.Bool, DefaultExpr: &falseBoolString},
        },
        NextColumnID: 4,
        Families: []ColumnFamilyDescriptor{
            {Name: "primary", ID: 0, ColumnNames: []string{"username"}, ColumnIDs: singleID1},
            {Name: "fam_2_hashedPassword", ID: 2, ColumnNames: []string{"hashedPassword"}, ColumnIDs: []ColumnID{2}, DefaultColumnID: 2},
            {Name: "fam_3_isRole", ID: 3, ColumnNames: []string{"isRole"}, ColumnIDs: []ColumnID{3}, DefaultColumnID: 3},
        },
        PrimaryIndex:   pk("username"),
        NextFamilyID:   4,
        NextIndexID:    2,
        Privileges:     NewCustomSuperuserPrivilegeDescriptor(SystemAllowedPrivileges[keys.UsersTableID]),
        FormatVersion:  InterleavedFormatVersion,
        NextMutationID: 1,
    })

    // ZonesTable is the descriptor for the zones table.
    ZonesTable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "zones",
        ID:                      keys.ZonesTableID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: "id", ID: 1, Type: types.Int},
            {Name: "config", ID: keys.ZonesTableConfigColumnID, Type: types.Bytes, Nullable: true},
        },
        NextColumnID: 3,
        Families: []ColumnFamilyDescriptor{
            {Name: "primary", ID: 0, ColumnNames: []string{"id"}, ColumnIDs: singleID1},
            {Name: "fam_2_config", ID: keys.ZonesTableConfigColFamID, ColumnNames: []string{"config"},
                ColumnIDs: []ColumnID{keys.ZonesTableConfigColumnID}, DefaultColumnID: keys.ZonesTableConfigColumnID},
        },
        PrimaryIndex: IndexDescriptor{
            Name:             "primary",
            ID:               keys.ZonesTablePrimaryIndexID,
            Unique:           true,
            ColumnNames:      []string{"id"},
            ColumnDirections: singleASC,
            ColumnIDs:        []ColumnID{keys.ZonesTablePrimaryIndexID},
            Version:          SecondaryIndexFamilyFormatVersion,
        },
        NextFamilyID:   3,
        NextIndexID:    2,
        Privileges:     NewCustomSuperuserPrivilegeDescriptor(SystemAllowedPrivileges[keys.ZonesTableID]),
        FormatVersion:  InterleavedFormatVersion,
        NextMutationID: 1,
    })

    // SettingsTable is the descriptor for the settings table.
    // It contains all cluster settings for which a value has been set.
    SettingsTable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "settings",
        ID:                      keys.SettingsTableID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: "name", ID: 1, Type: types.String},
            {Name: "value", ID: 2, Type: types.String},
            {Name: "lastUpdated", ID: 3, Type: types.Timestamp, DefaultExpr: &nowString},
            {Name: "valueType", ID: 4, Type: types.String, Nullable: true},
        },
        NextColumnID: 5,
        Families: []ColumnFamilyDescriptor{
            {
                Name:        "fam_0_name_value_lastUpdated_valueType",
                ID:          0,
                ColumnNames: []string{"name", "value", "lastUpdated", "valueType"},
                ColumnIDs:   []ColumnID{1, 2, 3, 4},
            },
        },
        NextFamilyID:   1,
        PrimaryIndex:   pk("name"),
        NextIndexID:    2,
        Privileges:     NewCustomSuperuserPrivilegeDescriptor(SystemAllowedPrivileges[keys.SettingsTableID]),
        FormatVersion:  InterleavedFormatVersion,
        NextMutationID: 1,
    })

    // DescIDSequence is the descriptor for the descriptor ID sequence.
    DescIDSequence = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "descriptor_id_seq",
        ID:                      keys.DescIDSequenceID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: SequenceColumnName, ID: SequenceColumnID, Type: types.Int},
        },
        Families: []ColumnFamilyDescriptor{{
            Name:            "primary",
            ID:              keys.SequenceColumnFamilyID,
            ColumnNames:     []string{SequenceColumnName},
            ColumnIDs:       []ColumnID{SequenceColumnID},
            DefaultColumnID: SequenceColumnID,
        }},
        PrimaryIndex: IndexDescriptor{
            ID:               keys.SequenceIndexID,
            Name:             PrimaryKeyIndexName,
            ColumnIDs:        []ColumnID{SequenceColumnID},
            ColumnNames:      []string{SequenceColumnName},
            ColumnDirections: []IndexDescriptor_Direction{IndexDescriptor_ASC},
        },
        SequenceOpts: &TableDescriptor_SequenceOpts{
            Increment: 1,
            MinValue:  1,
            MaxValue:  math.MaxInt64,
            Start:     1,
        },
        Privileges:    NewCustomSuperuserPrivilegeDescriptor(SystemAllowedPrivileges[keys.DescIDSequenceID]),
        FormatVersion: InterleavedFormatVersion,
    })

    TenantsTable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "tenants",
        ID:                      keys.TenantsTableID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: "id", ID: 1, Type: types.Int},
            {Name: "active", ID: 2, Type: types.Bool, DefaultExpr: &trueBoolString},

            {Name: "info", ID: 3, Type: types.Bytes, Nullable: true},
        },
        NextColumnID: 4,
        Families: []ColumnFamilyDescriptor{{
            Name:        "primary",
            ID:          0,
            ColumnNames: []string{"id", "active", "info"},
            ColumnIDs:   []ColumnID{1, 2, 3},
        }},
        NextFamilyID:   1,
        PrimaryIndex:   pk("id"),
        NextIndexID:    2,
        Privileges:     NewCustomSuperuserPrivilegeDescriptor(SystemAllowedPrivileges[keys.TenantsTableID]),
        FormatVersion:  InterleavedFormatVersion,
        NextMutationID: 1,
    })
)

These system config TableDescriptor literals should match the descriptor that would be produced by evaluating one of the above `CREATE TABLE` statements. See the `TestSystemTableLiterals` which checks that they do indeed match, and has suggestions on writing and maintaining them.

var (
    // LeaseTable is the descriptor for the leases table.
    LeaseTable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "lease",
        ID:                      keys.LeaseTableID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: "descID", ID: 1, Type: types.Int},
            {Name: "version", ID: 2, Type: types.Int},
            {Name: "nodeID", ID: 3, Type: types.Int},
            {Name: "expiration", ID: 4, Type: types.Timestamp},
        },
        NextColumnID: 5,
        Families: []ColumnFamilyDescriptor{
            {Name: "primary", ID: 0, ColumnNames: []string{"descID", "version", "nodeID", "expiration"}, ColumnIDs: []ColumnID{1, 2, 3, 4}},
        },
        PrimaryIndex: IndexDescriptor{
            Name:             "primary",
            ID:               1,
            Unique:           true,
            ColumnNames:      []string{"descID", "version", "expiration", "nodeID"},
            ColumnDirections: []IndexDescriptor_Direction{IndexDescriptor_ASC, IndexDescriptor_ASC, IndexDescriptor_ASC, IndexDescriptor_ASC},
            ColumnIDs:        []ColumnID{1, 2, 4, 3},
            Version:          SecondaryIndexFamilyFormatVersion,
        },
        NextFamilyID:   1,
        NextIndexID:    2,
        Privileges:     NewCustomSuperuserPrivilegeDescriptor(SystemAllowedPrivileges[keys.LeaseTableID]),
        FormatVersion:  InterleavedFormatVersion,
        NextMutationID: 1,
    })

    // EventLogTable is the descriptor for the event log table.
    EventLogTable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "eventlog",
        ID:                      keys.EventLogTableID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: "timestamp", ID: 1, Type: types.Timestamp},
            {Name: "eventType", ID: 2, Type: types.String},
            {Name: "targetID", ID: 3, Type: types.Int},
            {Name: "reportingID", ID: 4, Type: types.Int},
            {Name: "info", ID: 5, Type: types.String, Nullable: true},
            {Name: "uniqueID", ID: 6, Type: types.Bytes, DefaultExpr: &uuidV4String},
        },
        NextColumnID: 7,
        Families: []ColumnFamilyDescriptor{
            {Name: "primary", ID: 0, ColumnNames: []string{"timestamp", "uniqueID"}, ColumnIDs: []ColumnID{1, 6}},
            {Name: "fam_2_eventType", ID: 2, ColumnNames: []string{"eventType"}, ColumnIDs: []ColumnID{2}, DefaultColumnID: 2},
            {Name: "fam_3_targetID", ID: 3, ColumnNames: []string{"targetID"}, ColumnIDs: []ColumnID{3}, DefaultColumnID: 3},
            {Name: "fam_4_reportingID", ID: 4, ColumnNames: []string{"reportingID"}, ColumnIDs: []ColumnID{4}, DefaultColumnID: 4},
            {Name: "fam_5_info", ID: 5, ColumnNames: []string{"info"}, ColumnIDs: []ColumnID{5}, DefaultColumnID: 5},
        },
        PrimaryIndex: IndexDescriptor{
            Name:             "primary",
            ID:               1,
            Unique:           true,
            ColumnNames:      []string{"timestamp", "uniqueID"},
            ColumnDirections: []IndexDescriptor_Direction{IndexDescriptor_ASC, IndexDescriptor_ASC},
            ColumnIDs:        []ColumnID{1, 6},
            Version:          SecondaryIndexFamilyFormatVersion,
        },
        NextFamilyID:   6,
        NextIndexID:    2,
        Privileges:     NewCustomSuperuserPrivilegeDescriptor(SystemAllowedPrivileges[keys.EventLogTableID]),
        FormatVersion:  InterleavedFormatVersion,
        NextMutationID: 1,
    })

    // RangeEventTable is the descriptor for the range log table.
    RangeEventTable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "rangelog",
        ID:                      keys.RangeEventTableID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: "timestamp", ID: 1, Type: types.Timestamp},
            {Name: "rangeID", ID: 2, Type: types.Int},
            {Name: "storeID", ID: 3, Type: types.Int},
            {Name: "eventType", ID: 4, Type: types.String},
            {Name: "otherRangeID", ID: 5, Type: types.Int, Nullable: true},
            {Name: "info", ID: 6, Type: types.String, Nullable: true},
            {Name: "uniqueID", ID: 7, Type: types.Int, DefaultExpr: &uniqueRowIDString},
        },
        NextColumnID: 8,
        Families: []ColumnFamilyDescriptor{
            {Name: "primary", ID: 0, ColumnNames: []string{"timestamp", "uniqueID"}, ColumnIDs: []ColumnID{1, 7}},
            {Name: "fam_2_rangeID", ID: 2, ColumnNames: []string{"rangeID"}, ColumnIDs: []ColumnID{2}, DefaultColumnID: 2},
            {Name: "fam_3_storeID", ID: 3, ColumnNames: []string{"storeID"}, ColumnIDs: []ColumnID{3}, DefaultColumnID: 3},
            {Name: "fam_4_eventType", ID: 4, ColumnNames: []string{"eventType"}, ColumnIDs: []ColumnID{4}, DefaultColumnID: 4},
            {Name: "fam_5_otherRangeID", ID: 5, ColumnNames: []string{"otherRangeID"}, ColumnIDs: []ColumnID{5}, DefaultColumnID: 5},
            {Name: "fam_6_info", ID: 6, ColumnNames: []string{"info"}, ColumnIDs: []ColumnID{6}, DefaultColumnID: 6},
        },
        PrimaryIndex: IndexDescriptor{
            Name:             "primary",
            ID:               1,
            Unique:           true,
            ColumnNames:      []string{"timestamp", "uniqueID"},
            ColumnDirections: []IndexDescriptor_Direction{IndexDescriptor_ASC, IndexDescriptor_ASC},
            ColumnIDs:        []ColumnID{1, 7},
            Version:          SecondaryIndexFamilyFormatVersion,
        },
        NextFamilyID:   7,
        NextIndexID:    2,
        Privileges:     NewCustomSuperuserPrivilegeDescriptor(SystemAllowedPrivileges[keys.RangeEventTableID]),
        FormatVersion:  InterleavedFormatVersion,
        NextMutationID: 1,
    })

    // UITable is the descriptor for the ui table.
    UITable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "ui",
        ID:                      keys.UITableID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: "key", ID: 1, Type: types.String},
            {Name: "value", ID: 2, Type: types.Bytes, Nullable: true},
            {Name: "lastUpdated", ID: 3, Type: types.Timestamp},
        },
        NextColumnID: 4,
        Families: []ColumnFamilyDescriptor{
            {Name: "primary", ID: 0, ColumnNames: []string{"key"}, ColumnIDs: singleID1},
            {Name: "fam_2_value", ID: 2, ColumnNames: []string{"value"}, ColumnIDs: []ColumnID{2}, DefaultColumnID: 2},
            {Name: "fam_3_lastUpdated", ID: 3, ColumnNames: []string{"lastUpdated"}, ColumnIDs: []ColumnID{3}, DefaultColumnID: 3},
        },
        NextFamilyID:   4,
        PrimaryIndex:   pk("key"),
        NextIndexID:    2,
        Privileges:     NewCustomSuperuserPrivilegeDescriptor(SystemAllowedPrivileges[keys.UITableID]),
        FormatVersion:  InterleavedFormatVersion,
        NextMutationID: 1,
    })

    // JobsTable is the descriptor for the jobs table.
    JobsTable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "jobs",
        ID:                      keys.JobsTableID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: "id", ID: 1, Type: types.Int, DefaultExpr: &uniqueRowIDString},
            {Name: "status", ID: 2, Type: types.String},
            {Name: "created", ID: 3, Type: types.Timestamp, DefaultExpr: &nowString},
            {Name: "payload", ID: 4, Type: types.Bytes},
            {Name: "progress", ID: 5, Type: types.Bytes, Nullable: true},
            {Name: "created_by_type", ID: 6, Type: types.String, Nullable: true},
            {Name: "created_by_id", ID: 7, Type: types.Int, Nullable: true},
        },
        NextColumnID: 8,
        Families: []ColumnFamilyDescriptor{
            {

                Name:        "fam_0_id_status_created_payload",
                ID:          0,
                ColumnNames: []string{"id", "status", "created", "payload", "created_by_type", "created_by_id"},
                ColumnIDs:   []ColumnID{1, 2, 3, 4, 6, 7},
            },
            {
                Name:            "progress",
                ID:              1,
                ColumnNames:     []string{"progress"},
                ColumnIDs:       []ColumnID{5},
                DefaultColumnID: 5,
            },
        },
        NextFamilyID: 2,
        PrimaryIndex: pk("id"),
        Indexes: []IndexDescriptor{
            {
                Name:             "jobs_status_created_idx",
                ID:               2,
                Unique:           false,
                ColumnNames:      []string{"status", "created"},
                ColumnDirections: []IndexDescriptor_Direction{IndexDescriptor_ASC, IndexDescriptor_ASC},
                ColumnIDs:        []ColumnID{2, 3},
                ExtraColumnIDs:   []ColumnID{1},
                Version:          SecondaryIndexFamilyFormatVersion,
            },
            {
                Name:             "jobs_created_by_type_created_by_id_idx",
                ID:               3,
                Unique:           false,
                ColumnNames:      []string{"created_by_type", "created_by_id"},
                ColumnDirections: []IndexDescriptor_Direction{IndexDescriptor_ASC, IndexDescriptor_ASC},
                ColumnIDs:        []ColumnID{6, 7},
                StoreColumnIDs:   []ColumnID{2},
                StoreColumnNames: []string{"status"},
                ExtraColumnIDs:   []ColumnID{1},
                Version:          SecondaryIndexFamilyFormatVersion,
            },
        },
        NextIndexID:    4,
        Privileges:     NewCustomSuperuserPrivilegeDescriptor(SystemAllowedPrivileges[keys.JobsTableID]),
        FormatVersion:  InterleavedFormatVersion,
        NextMutationID: 1,
    })

    // WebSessions table to authenticate sessions over stateless connections.
    WebSessionsTable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "web_sessions",
        ID:                      keys.WebSessionsTableID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: "id", ID: 1, Type: types.Int, DefaultExpr: &uniqueRowIDString},
            {Name: "hashedSecret", ID: 2, Type: types.Bytes},
            {Name: "username", ID: 3, Type: types.String},
            {Name: "createdAt", ID: 4, Type: types.Timestamp, DefaultExpr: &nowString},
            {Name: "expiresAt", ID: 5, Type: types.Timestamp},
            {Name: "revokedAt", ID: 6, Type: types.Timestamp, Nullable: true},
            {Name: "lastUsedAt", ID: 7, Type: types.Timestamp, DefaultExpr: &nowString},
            {Name: "auditInfo", ID: 8, Type: types.String, Nullable: true},
        },
        NextColumnID: 9,
        Families: []ColumnFamilyDescriptor{
            {
                Name: "fam_0_id_hashedSecret_username_createdAt_expiresAt_revokedAt_lastUsedAt_auditInfo",
                ID:   0,
                ColumnNames: []string{
                    "id",
                    "hashedSecret",
                    "username",
                    "createdAt",
                    "expiresAt",
                    "revokedAt",
                    "lastUsedAt",
                    "auditInfo",
                },
                ColumnIDs: []ColumnID{1, 2, 3, 4, 5, 6, 7, 8},
            },
        },
        NextFamilyID: 1,
        PrimaryIndex: pk("id"),
        Indexes: []IndexDescriptor{
            {
                Name:             "web_sessions_expiresAt_idx",
                ID:               2,
                Unique:           false,
                ColumnNames:      []string{"expiresAt"},
                ColumnDirections: []IndexDescriptor_Direction{IndexDescriptor_ASC},
                ColumnIDs:        []ColumnID{5},
                ExtraColumnIDs:   []ColumnID{1},
                Version:          SecondaryIndexFamilyFormatVersion,
            },
            {
                Name:             "web_sessions_createdAt_idx",
                ID:               3,
                Unique:           false,
                ColumnNames:      []string{"createdAt"},
                ColumnDirections: []IndexDescriptor_Direction{IndexDescriptor_ASC},
                ColumnIDs:        []ColumnID{4},
                ExtraColumnIDs:   []ColumnID{1},
                Version:          SecondaryIndexFamilyFormatVersion,
            },
        },
        NextIndexID:    4,
        Privileges:     NewCustomSuperuserPrivilegeDescriptor(SystemAllowedPrivileges[keys.WebSessionsTableID]),
        NextMutationID: 1,
        FormatVersion:  3,
    })

    // TableStatistics table to hold statistics about columns and column groups.
    TableStatisticsTable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "table_statistics",
        ID:                      keys.TableStatisticsTableID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: "tableID", ID: 1, Type: types.Int},
            {Name: "statisticID", ID: 2, Type: types.Int, DefaultExpr: &uniqueRowIDString},
            {Name: "name", ID: 3, Type: types.String, Nullable: true},
            {Name: "columnIDs", ID: 4, Type: types.IntArray},
            {Name: "createdAt", ID: 5, Type: types.Timestamp, DefaultExpr: &nowString},
            {Name: "rowCount", ID: 6, Type: types.Int},
            {Name: "distinctCount", ID: 7, Type: types.Int},
            {Name: "nullCount", ID: 8, Type: types.Int},
            {Name: "histogram", ID: 9, Type: types.Bytes, Nullable: true},
        },
        NextColumnID: 10,
        Families: []ColumnFamilyDescriptor{
            {
                Name: "fam_0_tableID_statisticID_name_columnIDs_createdAt_rowCount_distinctCount_nullCount_histogram",
                ID:   0,
                ColumnNames: []string{
                    "tableID",
                    "statisticID",
                    "name",
                    "columnIDs",
                    "createdAt",
                    "rowCount",
                    "distinctCount",
                    "nullCount",
                    "histogram",
                },
                ColumnIDs: []ColumnID{1, 2, 3, 4, 5, 6, 7, 8, 9},
            },
        },
        NextFamilyID: 1,
        PrimaryIndex: IndexDescriptor{
            Name:             "primary",
            ID:               1,
            Unique:           true,
            ColumnNames:      []string{"tableID", "statisticID"},
            ColumnDirections: []IndexDescriptor_Direction{IndexDescriptor_ASC, IndexDescriptor_ASC},
            ColumnIDs:        []ColumnID{1, 2},
            Version:          SecondaryIndexFamilyFormatVersion,
        },
        NextIndexID:    2,
        Privileges:     NewCustomSuperuserPrivilegeDescriptor(SystemAllowedPrivileges[keys.TableStatisticsTableID]),
        FormatVersion:  InterleavedFormatVersion,
        NextMutationID: 1,
    })

    // LocationsTable is the descriptor for the locations table.
    LocationsTable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "locations",
        ID:                      keys.LocationsTableID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: "localityKey", ID: 1, Type: types.String},
            {Name: "localityValue", ID: 2, Type: types.String},
            {Name: "latitude", ID: 3, Type: latLonDecimal},
            {Name: "longitude", ID: 4, Type: latLonDecimal},
        },
        NextColumnID: 5,
        Families: []ColumnFamilyDescriptor{
            {
                Name:        "fam_0_localityKey_localityValue_latitude_longitude",
                ID:          0,
                ColumnNames: []string{"localityKey", "localityValue", "latitude", "longitude"},
                ColumnIDs:   []ColumnID{1, 2, 3, 4},
            },
        },
        NextFamilyID: 1,
        PrimaryIndex: IndexDescriptor{
            Name:             "primary",
            ID:               1,
            Unique:           true,
            ColumnNames:      []string{"localityKey", "localityValue"},
            ColumnDirections: []IndexDescriptor_Direction{IndexDescriptor_ASC, IndexDescriptor_ASC},
            ColumnIDs:        []ColumnID{1, 2},
            Version:          SecondaryIndexFamilyFormatVersion,
        },
        NextIndexID:    2,
        Privileges:     NewCustomSuperuserPrivilegeDescriptor(SystemAllowedPrivileges[keys.LocationsTableID]),
        FormatVersion:  InterleavedFormatVersion,
        NextMutationID: 1,
    })

    // RoleMembersTable is the descriptor for the role_members table.
    RoleMembersTable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "role_members",
        ID:                      keys.RoleMembersTableID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: "role", ID: 1, Type: types.String},
            {Name: "member", ID: 2, Type: types.String},
            {Name: "isAdmin", ID: 3, Type: types.Bool},
        },
        NextColumnID: 4,
        Families: []ColumnFamilyDescriptor{
            {
                Name:        "primary",
                ID:          0,
                ColumnNames: []string{"role", "member"},
                ColumnIDs:   []ColumnID{1, 2},
            },
            {
                Name:            "fam_3_isAdmin",
                ID:              3,
                ColumnNames:     []string{"isAdmin"},
                ColumnIDs:       []ColumnID{3},
                DefaultColumnID: 3,
            },
        },
        NextFamilyID: 4,
        PrimaryIndex: IndexDescriptor{
            Name:             "primary",
            ID:               1,
            Unique:           true,
            ColumnNames:      []string{"role", "member"},
            ColumnDirections: []IndexDescriptor_Direction{IndexDescriptor_ASC, IndexDescriptor_ASC},
            ColumnIDs:        []ColumnID{1, 2},
            Version:          SecondaryIndexFamilyFormatVersion,
        },
        Indexes: []IndexDescriptor{
            {
                Name:             "role_members_role_idx",
                ID:               2,
                Unique:           false,
                ColumnNames:      []string{"role"},
                ColumnDirections: []IndexDescriptor_Direction{IndexDescriptor_ASC},
                ColumnIDs:        []ColumnID{1},
                ExtraColumnIDs:   []ColumnID{2},
                Version:          SecondaryIndexFamilyFormatVersion,
            },
            {
                Name:             "role_members_member_idx",
                ID:               3,
                Unique:           false,
                ColumnNames:      []string{"member"},
                ColumnDirections: []IndexDescriptor_Direction{IndexDescriptor_ASC},
                ColumnIDs:        []ColumnID{2},
                ExtraColumnIDs:   []ColumnID{1},
                Version:          SecondaryIndexFamilyFormatVersion,
            },
        },
        NextIndexID:    4,
        Privileges:     NewCustomSuperuserPrivilegeDescriptor(SystemAllowedPrivileges[keys.RoleMembersTableID]),
        FormatVersion:  InterleavedFormatVersion,
        NextMutationID: 1,
    })

    // CommentsTable is the descriptor for the comments table.
    CommentsTable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "comments",
        ID:                      keys.CommentsTableID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: "type", ID: 1, Type: types.Int},
            {Name: "object_id", ID: 2, Type: types.Int},
            {Name: "sub_id", ID: 3, Type: types.Int},
            {Name: "comment", ID: 4, Type: types.String},
        },
        NextColumnID: 5,
        Families: []ColumnFamilyDescriptor{
            {Name: "primary", ID: 0, ColumnNames: []string{"type", "object_id", "sub_id"}, ColumnIDs: []ColumnID{1, 2, 3}},
            {Name: "fam_4_comment", ID: 4, ColumnNames: []string{"comment"}, ColumnIDs: []ColumnID{4}, DefaultColumnID: 4},
        },
        NextFamilyID: 5,
        PrimaryIndex: IndexDescriptor{
            Name:             "primary",
            ID:               1,
            Unique:           true,
            ColumnNames:      []string{"type", "object_id", "sub_id"},
            ColumnDirections: []IndexDescriptor_Direction{IndexDescriptor_ASC, IndexDescriptor_ASC, IndexDescriptor_ASC},
            ColumnIDs:        []ColumnID{1, 2, 3},
            Version:          SecondaryIndexFamilyFormatVersion,
        },
        NextIndexID:    2,
        Privileges:     newCommentPrivilegeDescriptor(SystemAllowedPrivileges[keys.CommentsTableID]),
        FormatVersion:  InterleavedFormatVersion,
        NextMutationID: 1,
    })

    ReportsMetaTable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "reports_meta",
        ID:                      keys.ReportsMetaTableID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: "id", ID: 1, Type: types.Int},
            {Name: "generated", ID: 2, Type: types.TimestampTZ},
        },
        NextColumnID: 3,
        Families: []ColumnFamilyDescriptor{
            {
                Name:        "primary",
                ID:          0,
                ColumnNames: []string{"id", "generated"},
                ColumnIDs:   []ColumnID{1, 2},
            },
        },
        NextFamilyID: 1,
        PrimaryIndex: IndexDescriptor{
            Name:        "primary",
            ID:          1,
            Unique:      true,
            ColumnNames: []string{"id"},
            ColumnDirections: []IndexDescriptor_Direction{
                IndexDescriptor_ASC,
            },
            ColumnIDs: []ColumnID{1},
            Version:   SecondaryIndexFamilyFormatVersion,
        },
        NextIndexID:    2,
        Privileges:     NewCustomSuperuserPrivilegeDescriptor(SystemAllowedPrivileges[keys.ReportsMetaTableID]),
        FormatVersion:  InterleavedFormatVersion,
        NextMutationID: 1,
    })

    ReplicationConstraintStatsTableTTL = time.Minute * 10
    // TODO(andrei): In 20.1 we should add a foreign key reference to the
    // reports_meta table. Until then, it would cost us having to create an index
    // on report_id.
    ReplicationConstraintStatsTable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "replication_constraint_stats",
        ID:                      keys.ReplicationConstraintStatsTableID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: "zone_id", ID: 1, Type: types.Int},
            {Name: "subzone_id", ID: 2, Type: types.Int},
            {Name: "type", ID: 3, Type: types.String},
            {Name: "config", ID: 4, Type: types.String},
            {Name: "report_id", ID: 5, Type: types.Int},
            {Name: "violation_start", ID: 6, Type: types.TimestampTZ, Nullable: true},
            {Name: "violating_ranges", ID: 7, Type: types.Int},
        },
        NextColumnID: 8,
        Families: []ColumnFamilyDescriptor{
            {
                Name: "primary",
                ID:   0,
                ColumnNames: []string{
                    "zone_id",
                    "subzone_id",
                    "type",
                    "config",
                    "report_id",
                    "violation_start",
                    "violating_ranges",
                },
                ColumnIDs: []ColumnID{1, 2, 3, 4, 5, 6, 7},
            },
        },
        NextFamilyID: 1,
        PrimaryIndex: IndexDescriptor{
            Name:        "primary",
            ID:          1,
            Unique:      true,
            ColumnNames: []string{"zone_id", "subzone_id", "type", "config"},
            ColumnDirections: []IndexDescriptor_Direction{
                IndexDescriptor_ASC, IndexDescriptor_ASC, IndexDescriptor_ASC, IndexDescriptor_ASC,
            },
            ColumnIDs: []ColumnID{1, 2, 3, 4},
            Version:   SecondaryIndexFamilyFormatVersion,
        },
        NextIndexID:    2,
        Privileges:     NewCustomSuperuserPrivilegeDescriptor(SystemAllowedPrivileges[keys.ReplicationConstraintStatsTableID]),
        FormatVersion:  InterleavedFormatVersion,
        NextMutationID: 1,
    })

    // TODO(andrei): In 20.1 we should add a foreign key reference to the
    // reports_meta table. Until then, it would cost us having to create an index
    // on report_id.
    ReplicationCriticalLocalitiesTable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "replication_critical_localities",
        ID:                      keys.ReplicationCriticalLocalitiesTableID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: "zone_id", ID: 1, Type: types.Int},
            {Name: "subzone_id", ID: 2, Type: types.Int},
            {Name: "locality", ID: 3, Type: types.String},
            {Name: "report_id", ID: 4, Type: types.Int},
            {Name: "at_risk_ranges", ID: 5, Type: types.Int},
        },
        NextColumnID: 6,
        Families: []ColumnFamilyDescriptor{
            {
                Name: "primary",
                ID:   0,
                ColumnNames: []string{
                    "zone_id",
                    "subzone_id",
                    "locality",
                    "report_id",
                    "at_risk_ranges",
                },
                ColumnIDs: []ColumnID{1, 2, 3, 4, 5},
            },
        },
        NextFamilyID: 1,
        PrimaryIndex: IndexDescriptor{
            Name:        "primary",
            ID:          1,
            Unique:      true,
            ColumnNames: []string{"zone_id", "subzone_id", "locality"},
            ColumnDirections: []IndexDescriptor_Direction{
                IndexDescriptor_ASC, IndexDescriptor_ASC, IndexDescriptor_ASC,
            },
            ColumnIDs: []ColumnID{1, 2, 3},
            Version:   SecondaryIndexFamilyFormatVersion,
        },
        NextIndexID:    2,
        Privileges:     NewCustomSuperuserPrivilegeDescriptor(SystemAllowedPrivileges[keys.ReplicationCriticalLocalitiesTableID]),
        FormatVersion:  InterleavedFormatVersion,
        NextMutationID: 1,
    })

    ReplicationStatsTableTTL = time.Minute * 10
    // TODO(andrei): In 20.1 we should add a foreign key reference to the
    // reports_meta table. Until then, it would cost us having to create an index
    // on report_id.
    ReplicationStatsTable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "replication_stats",
        ID:                      keys.ReplicationStatsTableID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: "zone_id", ID: 1, Type: types.Int},
            {Name: "subzone_id", ID: 2, Type: types.Int},
            {Name: "report_id", ID: 3, Type: types.Int},
            {Name: "total_ranges", ID: 4, Type: types.Int},
            {Name: "unavailable_ranges", ID: 5, Type: types.Int},
            {Name: "under_replicated_ranges", ID: 6, Type: types.Int},
            {Name: "over_replicated_ranges", ID: 7, Type: types.Int},
        },
        NextColumnID: 8,
        Families: []ColumnFamilyDescriptor{
            {
                Name: "primary",
                ID:   0,
                ColumnNames: []string{
                    "zone_id",
                    "subzone_id",
                    "report_id",
                    "total_ranges",
                    "unavailable_ranges",
                    "under_replicated_ranges",
                    "over_replicated_ranges",
                },
                ColumnIDs: []ColumnID{1, 2, 3, 4, 5, 6, 7},
            },
        },
        NextFamilyID: 2,
        PrimaryIndex: IndexDescriptor{
            Name:             "primary",
            ID:               1,
            Unique:           true,
            ColumnNames:      []string{"zone_id", "subzone_id"},
            ColumnDirections: []IndexDescriptor_Direction{IndexDescriptor_ASC, IndexDescriptor_ASC},
            ColumnIDs:        []ColumnID{1, 2},
            Version:          SecondaryIndexFamilyFormatVersion,
        },
        NextIndexID:    2,
        Privileges:     NewCustomSuperuserPrivilegeDescriptor(SystemAllowedPrivileges[keys.ReplicationStatsTableID]),
        FormatVersion:  InterleavedFormatVersion,
        NextMutationID: 1,
    })

    ProtectedTimestampsMetaTable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "protected_ts_meta",
        ID:                      keys.ProtectedTimestampsMetaTableID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {
                Name:        "singleton",
                ID:          1,
                Type:        types.Bool,
                DefaultExpr: &trueBoolString,
            },
            {Name: "version", ID: 2, Type: types.Int},
            {Name: "num_records", ID: 3, Type: types.Int},
            {Name: "num_spans", ID: 4, Type: types.Int},
            {Name: "total_bytes", ID: 5, Type: types.Int},
        },
        Checks: []*TableDescriptor_CheckConstraint{
            {
                Name:      "check_singleton",
                Expr:      "singleton",
                ColumnIDs: []ColumnID{1},
            },
        },
        NextColumnID: 6,
        Families: []ColumnFamilyDescriptor{
            {
                Name:        "primary",
                ColumnNames: []string{"singleton", "version", "num_records", "num_spans", "total_bytes"},
                ColumnIDs:   []ColumnID{1, 2, 3, 4, 5},
            },
        },
        NextFamilyID: 1,
        PrimaryIndex: IndexDescriptor{
            Name:        "primary",
            ID:          1,
            Version:     1,
            Unique:      true,
            ColumnNames: []string{"singleton"},
            ColumnIDs:   []ColumnID{1},
            ColumnDirections: []IndexDescriptor_Direction{
                IndexDescriptor_ASC,
            },
        },
        NextIndexID:    2,
        Privileges:     NewCustomSuperuserPrivilegeDescriptor(SystemAllowedPrivileges[keys.ReplicationStatsTableID]),
        FormatVersion:  InterleavedFormatVersion,
        NextMutationID: 1,
    })

    ProtectedTimestampsRecordsTable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "protected_ts_records",
        ID:                      keys.ProtectedTimestampsRecordsTableID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: "id", ID: 1, Type: types.Uuid},
            {Name: "ts", ID: 2, Type: types.Decimal},
            {Name: "meta_type", ID: 3, Type: types.String},
            {Name: "meta", ID: 4, Type: types.Bytes, Nullable: true},
            {Name: "num_spans", ID: 5, Type: types.Int},
            {Name: "spans", ID: 6, Type: types.Bytes},
            {Name: "verified", ID: 7, Type: types.Bool, DefaultExpr: &falseBoolString},
        },
        NextColumnID: 8,
        Families: []ColumnFamilyDescriptor{
            {
                Name:        "primary",
                ColumnNames: []string{"id", "ts", "meta_type", "meta", "num_spans", "spans", "verified"},
                ColumnIDs:   []ColumnID{1, 2, 3, 4, 5, 6, 7},
            },
        },
        NextFamilyID: 1,
        PrimaryIndex: IndexDescriptor{
            Name:        "primary",
            ID:          1,
            Version:     1,
            Unique:      true,
            ColumnNames: []string{"id"},
            ColumnIDs:   []ColumnID{1},
            ColumnDirections: []IndexDescriptor_Direction{
                IndexDescriptor_ASC,
            },
        },
        NextIndexID:    2,
        Privileges:     NewCustomSuperuserPrivilegeDescriptor(SystemAllowedPrivileges[keys.ProtectedTimestampsRecordsTableID]),
        FormatVersion:  InterleavedFormatVersion,
        NextMutationID: 1,
    })

    // RoleOptionsTable is the descriptor for the role_options table.
    RoleOptionsTable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "role_options",
        ID:                      keys.RoleOptionsTableID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: "username", ID: 1, Type: types.String},
            {Name: "option", ID: 2, Type: types.String},
            {Name: "value", ID: 3, Type: types.String, Nullable: true},
        },
        NextColumnID: 4,
        Families: []ColumnFamilyDescriptor{
            {
                Name:            "primary",
                ColumnNames:     []string{"username", "option", "value"},
                ColumnIDs:       []ColumnID{1, 2, 3},
                DefaultColumnID: 3,
            },
        },
        NextFamilyID: 1,
        PrimaryIndex: IndexDescriptor{
            Name:             "primary",
            ID:               1,
            Unique:           true,
            ColumnNames:      []string{"username", "option"},
            ColumnDirections: []IndexDescriptor_Direction{IndexDescriptor_ASC, IndexDescriptor_ASC},
            ColumnIDs:        []ColumnID{1, 2},
            Version:          SecondaryIndexFamilyFormatVersion,
        },
        NextIndexID:    2,
        Privileges:     NewCustomSuperuserPrivilegeDescriptor(SystemAllowedPrivileges[keys.RoleOptionsTableID]),
        FormatVersion:  InterleavedFormatVersion,
        NextMutationID: 1,
    })

    StatementBundleChunksTable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "statement_bundle_chunks",
        ID:                      keys.StatementBundleChunksTableID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: "id", ID: 1, Type: types.Int, DefaultExpr: &uniqueRowIDString},
            {Name: "description", ID: 2, Type: types.String, Nullable: true},
            {Name: "data", ID: 3, Type: types.Bytes},
        },
        NextColumnID: 4,
        Families: []ColumnFamilyDescriptor{
            {
                Name:        "primary",
                ColumnNames: []string{"id", "description", "data"},
                ColumnIDs:   []ColumnID{1, 2, 3},
            },
        },
        NextFamilyID:   1,
        PrimaryIndex:   pk("id"),
        NextIndexID:    2,
        Privileges:     NewCustomSuperuserPrivilegeDescriptor(SystemAllowedPrivileges[keys.StatementBundleChunksTableID]),
        FormatVersion:  InterleavedFormatVersion,
        NextMutationID: 1,
    })

    // TODO(andrei): Add a foreign key reference to the statement_diagnostics table when
    // it no longer requires us to create an index on statement_diagnostics_id.
    StatementDiagnosticsRequestsTable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "statement_diagnostics_requests",
        ID:                      keys.StatementDiagnosticsRequestsTableID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: "id", ID: 1, Type: types.Int, DefaultExpr: &uniqueRowIDString, Nullable: false},
            {Name: "completed", ID: 2, Type: types.Bool, Nullable: false, DefaultExpr: &falseBoolString},
            {Name: "statement_fingerprint", ID: 3, Type: types.String, Nullable: false},
            {Name: "statement_diagnostics_id", ID: 4, Type: types.Int, Nullable: true},
            {Name: "requested_at", ID: 5, Type: types.TimestampTZ, Nullable: false},
        },
        NextColumnID: 6,
        Families: []ColumnFamilyDescriptor{
            {
                Name:        "primary",
                ColumnNames: []string{"id", "completed", "statement_fingerprint", "statement_diagnostics_id", "requested_at"},
                ColumnIDs:   []ColumnID{1, 2, 3, 4, 5},
            },
        },
        NextFamilyID: 1,
        PrimaryIndex: pk("id"),

        Indexes: []IndexDescriptor{
            {
                Name:             "completed_idx",
                ID:               2,
                Unique:           false,
                ColumnNames:      []string{"completed", "id"},
                StoreColumnNames: []string{"statement_fingerprint"},
                ColumnIDs:        []ColumnID{2, 1},
                ColumnDirections: []IndexDescriptor_Direction{IndexDescriptor_ASC, IndexDescriptor_ASC},
                StoreColumnIDs:   []ColumnID{3},
                Version:          SecondaryIndexFamilyFormatVersion,
            },
        },
        NextIndexID: 3,
        Privileges: NewCustomSuperuserPrivilegeDescriptor(
            SystemAllowedPrivileges[keys.StatementDiagnosticsRequestsTableID]),
        FormatVersion:  InterleavedFormatVersion,
        NextMutationID: 1,
    })

    StatementDiagnosticsTable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "statement_diagnostics",
        ID:                      keys.StatementDiagnosticsTableID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: "id", ID: 1, Type: types.Int, DefaultExpr: &uniqueRowIDString, Nullable: false},
            {Name: "statement_fingerprint", ID: 2, Type: types.String, Nullable: false},
            {Name: "statement", ID: 3, Type: types.String, Nullable: false},
            {Name: "collected_at", ID: 4, Type: types.TimestampTZ, Nullable: false},
            {Name: "trace", ID: 5, Type: types.Jsonb, Nullable: true},
            {Name: "bundle_chunks", ID: 6, Type: types.IntArray, Nullable: true},
            {Name: "error", ID: 7, Type: types.String, Nullable: true},
        },
        NextColumnID: 8,
        Families: []ColumnFamilyDescriptor{
            {
                Name: "primary",
                ColumnNames: []string{"id", "statement_fingerprint", "statement",
                    "collected_at", "trace", "bundle_chunks", "error"},
                ColumnIDs: []ColumnID{1, 2, 3, 4, 5, 6, 7},
            },
        },
        NextFamilyID: 1,
        PrimaryIndex: pk("id"),
        NextIndexID:  2,
        Privileges: NewCustomSuperuserPrivilegeDescriptor(
            SystemAllowedPrivileges[keys.StatementDiagnosticsTableID]),
        FormatVersion:  InterleavedFormatVersion,
        NextMutationID: 1,
    })

    // ScheduledJobsTable is the descriptor for the scheduled jobs table.
    ScheduledJobsTable = NewImmutableTableDescriptor(TableDescriptor{
        Name:                    "scheduled_jobs",
        ID:                      keys.ScheduledJobsTableID,
        ParentID:                keys.SystemDatabaseID,
        UnexposedParentSchemaID: keys.PublicSchemaID,
        Version:                 1,
        Columns: []ColumnDescriptor{
            {Name: "schedule_id", ID: 1, Type: types.Int, DefaultExpr: &uniqueRowIDString, Nullable: false},
            {Name: "schedule_name", ID: 2, Type: types.String, Nullable: false},
            {Name: "created", ID: 3, Type: types.TimestampTZ, DefaultExpr: &nowTZString, Nullable: false},
            {Name: "owner", ID: 4, Type: types.String, Nullable: true},
            {Name: "next_run", ID: 5, Type: types.TimestampTZ, Nullable: true},
            {Name: "schedule_expr", ID: 6, Type: types.String, Nullable: true},
            {Name: "schedule_details", ID: 7, Type: types.Bytes, Nullable: true},
            {Name: "executor_type", ID: 8, Type: types.String, Nullable: false},
            {Name: "execution_args", ID: 9, Type: types.Bytes, Nullable: false},
            {Name: "schedule_changes", ID: 10, Type: types.Bytes, Nullable: true},
        },
        NextColumnID: 11,
        Families: []ColumnFamilyDescriptor{
            {
                Name:            "sched",
                ID:              0,
                ColumnNames:     []string{"schedule_id", "next_run"},
                ColumnIDs:       []ColumnID{1, 5},
                DefaultColumnID: 5,
            },
            {
                Name: "other",
                ID:   1,
                ColumnNames: []string{"schedule_name", "created", "owner", "schedule_expr", "schedule_details",
                    "executor_type", "execution_args", "schedule_changes"},
                ColumnIDs: []ColumnID{2, 3, 4, 6, 7, 8, 9, 10},
            },
        },
        NextFamilyID: 2,
        PrimaryIndex: pk("schedule_id"),
        Indexes: []IndexDescriptor{
            {
                Name:             "next_run_idx",
                ID:               2,
                Unique:           false,
                ColumnNames:      []string{"next_run"},
                ColumnDirections: []IndexDescriptor_Direction{IndexDescriptor_ASC},
                ColumnIDs:        []ColumnID{5},
                ExtraColumnIDs:   []ColumnID{1},
                Version:          SecondaryIndexFamilyFormatVersion,
            },
        },
        NextIndexID:    3,
        Privileges:     NewCustomSuperuserPrivilegeDescriptor(SystemAllowedPrivileges[keys.ScheduledJobsTableID]),
        FormatVersion:  InterleavedFormatVersion,
        NextMutationID: 1,
    })
)

These system TableDescriptor literals should match the descriptor that would be produced by evaluating one of the above `CREATE TABLE` statements for system tables that are not system config tables. See the `TestSystemTableLiterals` which checks that they do indeed match, and has suggestions on writing and maintaining them.

var (
    // OneIntCol is a slice of one IntType.
    OneIntCol = []*types.T{types.Int}
    // TwoIntCols is a slice of two IntTypes.
    TwoIntCols = []*types.T{types.Int, types.Int}
    // ThreeIntCols is a slice of three IntTypes.
    ThreeIntCols = []*types.T{types.Int, types.Int, types.Int}
    // FourIntCols is a slice of four IntTypes.
    FourIntCols = []*types.T{types.Int, types.Int, types.Int, types.Int}
)

The following variables are useful for testing.

var AdminRole = "admin"

AdminRole is the default (and non-droppable) role with superuser privileges.

var AlterTableRelocateColumns = ResultColumns{
    {Name: "key", Typ: types.Bytes},
    {Name: "pretty", Typ: types.String},
}

AlterTableRelocateColumns are the result columns of an ALTER TABLE/INDEX .. EXPERIMENTAL_RELOCATE statement.

var AlterTableScatterColumns = ResultColumns{
    {Name: "key", Typ: types.Bytes},
    {Name: "pretty", Typ: types.String},
}

AlterTableScatterColumns are the result columns of an ALTER TABLE/INDEX .. SCATTER statement.

var AlterTableSplitColumns = ResultColumns{
    {Name: "key", Typ: types.Bytes},
    {Name: "pretty", Typ: types.String},
    {Name: "split_enforced_until", Typ: types.Timestamp},
}

AlterTableSplitColumns are the result columns of an ALTER TABLE/INDEX .. SPLIT AT statement.

var AlterTableUnsplitColumns = ResultColumns{
    {Name: "key", Typ: types.Bytes},
    {Name: "pretty", Typ: types.String},
}

AlterTableUnsplitColumns are the result columns of an ALTER TABLE/INDEX .. UNSPLIT statement.

var AnonymousTable = tree.TableName{}

AnonymousTable is the empty table name, used when a data source has no own name, e.g. VALUES, subqueries or the empty source.

var CompositeKeyMatchMethodValue = [...]ForeignKeyReference_Match{
    tree.MatchSimple:  ForeignKeyReference_SIMPLE,
    tree.MatchFull:    ForeignKeyReference_FULL,
    tree.MatchPartial: ForeignKeyReference_PARTIAL,
}

CompositeKeyMatchMethodValue allows the conversion from a tree.ReferenceCompositeKeyMatchMethod to a ForeignKeyReference_Match.

var ConstraintToUpdate_ConstraintType_name = map[int32]string{
    0:  "CHECK",
    1:  "FOREIGN_KEY",
    2:  "NOT_NULL",
}
var ConstraintToUpdate_ConstraintType_value = map[string]int32{
    "CHECK":       0,
    "FOREIGN_KEY": 1,
    "NOT_NULL":    2,
}
var ConstraintValidity_name = map[int32]string{
    0:  "Validated",
    1:  "Unvalidated",
    2:  "Validating",
    3:  "Dropping",
}
var ConstraintValidity_value = map[string]int32{
    "Validated":   0,
    "Unvalidated": 1,
    "Validating":  2,
    "Dropping":    3,
}
var DatumEncoding_name = map[int32]string{
    0:  "ASCENDING_KEY",
    1:  "DESCENDING_KEY",
    2:  "VALUE",
}
var DatumEncoding_value = map[string]int32{
    "ASCENDING_KEY":  0,
    "DESCENDING_KEY": 1,
    "VALUE":          2,
}
var DefaultSearchPath = sessiondata.MakeSearchPath([]string{"public"})

DefaultSearchPath is the search path used by virgin sessions.

var DefaultSuperuserPrivileges = privilege.List{privilege.ALL}

DefaultSuperuserPrivileges is the list of privileges for super users on non-system objects.

var DefaultUserDBs = map[string]struct{}{
    DefaultDatabaseName: {},
    PgDatabaseName:      {},
}

DefaultUserDBs is a set of the databases which are present in a new cluster.

var DescriptorMutation_Direction_name = map[int32]string{
    0:  "NONE",
    1:  "ADD",
    2:  "DROP",
}
var DescriptorMutation_Direction_value = map[string]int32{
    "NONE": 0,
    "ADD":  1,
    "DROP": 2,
}
var DescriptorMutation_State_name = map[int32]string{
    0:  "UNKNOWN",
    1:  "DELETE_ONLY",
    2:  "DELETE_AND_WRITE_ONLY",
}
var DescriptorMutation_State_value = map[string]int32{
    "UNKNOWN":               0,
    "DELETE_ONLY":           1,
    "DELETE_AND_WRITE_ONLY": 2,
}
var ErrDescriptorNotFound = errors.New("descriptor not found")

ErrDescriptorNotFound is returned by GetTableDescFromID to signal that a descriptor could not be found with the given id.

var ErrIndexGCMutationsList = errors.New("index in GC mutations list")

ErrIndexGCMutationsList is returned by FindIndexByID to signal that the index with the given ID does not have a descriptor and is in the garbage collected mutations list.

var ErrMissingColumns = errors.New("table must contain at least 1 column")

ErrMissingColumns indicates a table with no columns.

var ErrMissingPrimaryKey = errors.New("table must contain a primary key")

ErrMissingPrimaryKey indicates a table with no primary key.

var ExplainAnalyzeDebugColumns = ResultColumns{
    {Name: "text", Typ: types.String},
}

ExplainAnalyzeDebugColumns are the result columns of an EXPLAIN ANALYZE (DEBUG) statement.

var ExplainDistSQLColumns = ResultColumns{
    {Name: "automatic", Typ: types.Bool},
    {Name: "url", Typ: types.String},
    {Name: "json", Typ: types.String, Hidden: true},
}

ExplainDistSQLColumns are the result columns of an EXPLAIN (DISTSQL) statement.

var ExplainOptColumns = ResultColumns{
    {Name: "text", Typ: types.String},
}

ExplainOptColumns are the result columns of an EXPLAIN (OPT) statement.

var ExplainPlanColumns = ResultColumns{

    {Name: "tree", Typ: types.String},

    {Name: "field", Typ: types.String},

    {Name: "description", Typ: types.String},
}

ExplainPlanColumns are the result columns of an EXPLAIN (PLAN) ... statement.

var ExplainPlanVerboseColumns = ResultColumns{

    {Name: "tree", Typ: types.String},

    {Name: "level", Typ: types.Int, Hidden: true},

    {Name: "node_type", Typ: types.String, Hidden: true},

    {Name: "field", Typ: types.String},

    {Name: "description", Typ: types.String},

    {Name: "columns", Typ: types.String},

    {Name: "ordering", Typ: types.String},
}

ExplainPlanVerboseColumns are the result columns of an EXPLAIN (PLAN, ...) ... statement when a flag like VERBOSE or TYPES is passed.

var ExplainVecColumns = ResultColumns{
    {Name: "text", Typ: types.String},
}

ExplainVecColumns are the result columns of an EXPLAIN (VEC) statement.

var ExportColumns = ResultColumns{
    {Name: "filename", Typ: types.String},
    {Name: "rows", Typ: types.Int},
    {Name: "bytes", Typ: types.Int},
}

ExportColumns are the result columns of an EXPORT statement.

var ForeignKeyReferenceActionType = [...]tree.ReferenceAction{
    ForeignKeyReference_NO_ACTION:   tree.NoAction,
    ForeignKeyReference_RESTRICT:    tree.Restrict,
    ForeignKeyReference_SET_DEFAULT: tree.SetDefault,
    ForeignKeyReference_SET_NULL:    tree.SetNull,
    ForeignKeyReference_CASCADE:     tree.Cascade,
}

ForeignKeyReferenceActionType allows the conversion between a tree.ReferenceAction and a ForeignKeyReference_Action.

var ForeignKeyReferenceActionValue = [...]ForeignKeyReference_Action{
    tree.NoAction:   ForeignKeyReference_NO_ACTION,
    tree.Restrict:   ForeignKeyReference_RESTRICT,
    tree.SetDefault: ForeignKeyReference_SET_DEFAULT,
    tree.SetNull:    ForeignKeyReference_SET_NULL,
    tree.Cascade:    ForeignKeyReference_CASCADE,
}

ForeignKeyReferenceActionValue allows the conversion between a ForeignKeyReference_Action and a tree.ReferenceAction.

var ForeignKeyReferenceMatchValue = [...]tree.CompositeKeyMatchMethod{
    ForeignKeyReference_SIMPLE:  tree.MatchSimple,
    ForeignKeyReference_FULL:    tree.MatchFull,
    ForeignKeyReference_PARTIAL: tree.MatchPartial,
}

ForeignKeyReferenceMatchValue allows the conversion from a ForeignKeyReference_Match to a tree.ReferenceCompositeKeyMatchMethod. This should match CompositeKeyMatchMethodValue.

var ForeignKeyReference_Action_name = map[int32]string{
    0:  "NO_ACTION",
    1:  "RESTRICT",
    2:  "SET_NULL",
    3:  "SET_DEFAULT",
    4:  "CASCADE",
}
var ForeignKeyReference_Action_value = map[string]int32{
    "NO_ACTION":   0,
    "RESTRICT":    1,
    "SET_NULL":    2,
    "SET_DEFAULT": 3,
    "CASCADE":     4,
}
var ForeignKeyReference_Match_name = map[int32]string{
    0:  "SIMPLE",
    1:  "FULL",
    2:  "PARTIAL",
}
var ForeignKeyReference_Match_value = map[string]int32{
    "SIMPLE":  0,
    "FULL":    1,
    "PARTIAL": 2,
}
var IndexDescriptor_Direction_name = map[int32]string{
    0:  "ASC",
    1:  "DESC",
}
var IndexDescriptor_Direction_value = map[string]int32{
    "ASC":  0,
    "DESC": 1,
}
var IndexDescriptor_Type_name = map[int32]string{
    0:  "FORWARD",
    1:  "INVERTED",
}
var IndexDescriptor_Type_value = map[string]int32{
    "FORWARD":  0,
    "INVERTED": 1,
}
var JoinType_name = map[int32]string{
    0:  "INNER",
    1:  "LEFT_OUTER",
    2:  "RIGHT_OUTER",
    3:  "FULL_OUTER",
    4:  "LEFT_SEMI",
    5:  "LEFT_ANTI",
    6:  "INTERSECT_ALL",
    7:  "EXCEPT_ALL",
}
var JoinType_value = map[string]int32{
    "INNER":         0,
    "LEFT_OUTER":    1,
    "RIGHT_OUTER":   2,
    "FULL_OUTER":    3,
    "LEFT_SEMI":     4,
    "LEFT_ANTI":     5,
    "INTERSECT_ALL": 6,
    "EXCEPT_ALL":    7,
}
var MaxDefaultDescriptorID = keys.MaxReservedDescID + ID(len(DefaultUserDBs))

MaxDefaultDescriptorID is the maximum ID of a descriptor that exists in a new cluster.

var NoSessionDataOverride = InternalExecutorSessionDataOverride{}

NoSessionDataOverride is the empty InternalExecutorSessionDataOverride which does not override any session data.

var NodeUserSessionDataOverride = InternalExecutorSessionDataOverride{User: security.NodeUser}

NodeUserSessionDataOverride is an InternalExecutorSessionDataOverride which overrides the users to the NodeUser.

var PublicRole = "public"

PublicRole is the special "public" pseudo-role. All users are implicit members of "public". The role cannot be created, dropped, assigned to another role, and is generally not listed. It can be granted privileges, implicitly granting them to all users (current and future).

var QueryCanceledError = pgerror.New(
    pgcode.QueryCanceled, "query execution canceled")

QueryCanceledError is an error representing query cancellation.

var QueryTimeoutError = pgerror.New(
    pgcode.QueryCanceled, "query execution canceled due to statement timeout")

QueryTimeoutError is an error representing a query timeout.

var ScanLockingStrength_name = map[int32]string{
    0:  "FOR_NONE",
    1:  "FOR_KEY_SHARE",
    2:  "FOR_SHARE",
    3:  "FOR_NO_KEY_UPDATE",
    4:  "FOR_UPDATE",
}
var ScanLockingStrength_value = map[string]int32{
    "FOR_NONE":          0,
    "FOR_KEY_SHARE":     1,
    "FOR_SHARE":         2,
    "FOR_NO_KEY_UPDATE": 3,
    "FOR_UPDATE":        4,
}
var ScanLockingWaitPolicy_name = map[int32]string{
    0:  "BLOCK",
    1:  "SKIP",
    2:  "ERROR",
}
var ScanLockingWaitPolicy_value = map[string]int32{
    "BLOCK": 0,
    "SKIP":  1,
    "ERROR": 2,
}
var ScrubColumns = ResultColumns{
    {Name: "job_uuid", Typ: types.Uuid},
    {Name: "error_type", Typ: types.String},
    {Name: "database", Typ: types.String},
    {Name: "table", Typ: types.String},
    {Name: "primary_key", Typ: types.String},
    {Name: "timestamp", Typ: types.Timestamp},
    {Name: "repaired", Typ: types.Bool},
    {Name: "details", Typ: types.Jsonb},
}

ScrubColumns are the result columns of a SCRUB statement.

var (
    // SeedTypes includes the following types that form the basis of randomly
    // generated types:
    //   - All scalar types, except UNKNOWN and ANY
    //   - ARRAY of ANY, where the ANY will be replaced with one of the legal
    //     array element types in RandType
    //   - OIDVECTOR and INT2VECTOR types
    SeedTypes []*types.T
)
var SequenceSelectColumns = ResultColumns{
    {Name: `last_value`, Typ: types.Int},
    {Name: `log_cnt`, Typ: types.Int},
    {Name: `is_called`, Typ: types.Bool},
}

SequenceSelectColumns are the result columns of a sequence data source.

var ShowCompactTraceColumns = ResultColumns{
    {Name: "age", Typ: types.Interval},
    {Name: "message", Typ: types.String},
    {Name: "tag", Typ: types.String},
    {Name: "operation", Typ: types.String},
}

ShowCompactTraceColumns are the result columns of a SHOW COMPACT [KV] TRACE statement.

var ShowFingerprintsColumns = ResultColumns{
    {Name: "index_name", Typ: types.String},
    {Name: "fingerprint", Typ: types.String},
}

ShowFingerprintsColumns are the result columns of a SHOW EXPERIMENTAL_FINGERPRINTS statement.

var ShowLastQueryStatisticsColumns = ResultColumns{
    {Name: "parse_latency", Typ: types.Interval},
    {Name: "plan_latency", Typ: types.Interval},
    {Name: "exec_latency", Typ: types.Interval},
    {Name: "service_latency", Typ: types.Interval},
}

ShowLastQueryStatisticsColumns are the columns of a SHOW LAST QUERY STATISTICS statement.

var ShowReplicaTraceColumns = ResultColumns{
    {Name: "timestamp", Typ: types.TimestampTZ},
    {Name: "node_id", Typ: types.Int},
    {Name: "store_id", Typ: types.Int},
    {Name: "replica_id", Typ: types.Int},
}

ShowReplicaTraceColumns are the result columns of a SHOW EXPERIMENTAL_REPLICA TRACE statement.

var ShowSyntaxColumns = ResultColumns{
    {Name: "field", Typ: types.String},
    {Name: "message", Typ: types.String},
}

ShowSyntaxColumns are the columns of a SHOW SYNTAX statement.

var ShowTraceColumns = ResultColumns{
    {Name: "timestamp", Typ: types.TimestampTZ},
    {Name: "age", Typ: types.Interval},
    {Name: "message", Typ: types.String},
    {Name: "tag", Typ: types.String},
    {Name: "location", Typ: types.String},
    {Name: "operation", Typ: types.String},
    {Name: "span", Typ: types.Int},
}

ShowTraceColumns are the result columns of a SHOW [KV] TRACE statement.

var SystemAllowedPrivileges = map[ID]privilege.List{
    keys.SystemDatabaseID:           privilege.ReadData,
    keys.NamespaceTableID:           privilege.ReadData,
    keys.DeprecatedNamespaceTableID: privilege.ReadData,
    keys.DescriptorTableID:          privilege.ReadData,
    keys.UsersTableID:               privilege.ReadWriteData,
    keys.RoleOptionsTableID:         privilege.ReadWriteData,
    keys.ZonesTableID:               privilege.ReadWriteData,

    keys.SettingsTableID:   privilege.ReadWriteData,
    keys.DescIDSequenceID:  privilege.ReadData,
    keys.TenantsTableID:    privilege.ReadData,
    keys.LeaseTableID:      privilege.ReadWriteData,
    keys.EventLogTableID:   privilege.ReadWriteData,
    keys.RangeEventTableID: privilege.ReadWriteData,
    keys.UITableID:         privilege.ReadWriteData,

    keys.JobsTableID:                          privilege.ReadWriteData,
    keys.WebSessionsTableID:                   privilege.ReadWriteData,
    keys.TableStatisticsTableID:               privilege.ReadWriteData,
    keys.LocationsTableID:                     privilege.ReadWriteData,
    keys.RoleMembersTableID:                   privilege.ReadWriteData,
    keys.CommentsTableID:                      privilege.ReadWriteData,
    keys.ReplicationConstraintStatsTableID:    privilege.ReadWriteData,
    keys.ReplicationCriticalLocalitiesTableID: privilege.ReadWriteData,
    keys.ReplicationStatsTableID:              privilege.ReadWriteData,
    keys.ReportsMetaTableID:                   privilege.ReadWriteData,
    keys.ProtectedTimestampsMetaTableID:       privilege.ReadData,
    keys.ProtectedTimestampsRecordsTableID:    privilege.ReadData,
    keys.StatementBundleChunksTableID:         privilege.ReadWriteData,
    keys.StatementDiagnosticsRequestsTableID:  privilege.ReadWriteData,
    keys.StatementDiagnosticsTableID:          privilege.ReadWriteData,
    keys.ScheduledJobsTableID:                 privilege.ReadWriteData,
}

SystemAllowedPrivileges describes the allowable privilege list for each system object. Super users (root and admin) must have exactly the specified privileges, other users must not exceed the specified privileges.

var TableDescriptor_AuditMode_name = map[int32]string{
    0:  "DISABLED",
    1:  "READWRITE",
}
var TableDescriptor_AuditMode_value = map[string]int32{
    "DISABLED":  0,
    "READWRITE": 1,
}
var TableDescriptor_State_name = map[int32]string{
    0:  "PUBLIC",
    1:  "ADD",
    2:  "DROP",
    3:  "OFFLINE",
}
var TableDescriptor_State_value = map[string]int32{
    "PUBLIC":  0,
    "ADD":     1,
    "DROP":    2,
    "OFFLINE": 3,
}
var TypeDescriptor_Kind_name = map[int32]string{
    0:  "ENUM",
    1:  "ALIAS",
}
var TypeDescriptor_Kind_value = map[string]int32{
    "ENUM":  0,
    "ALIAS": 1,
}

func AdjustEndKeyForInterleave Uses

func AdjustEndKeyForInterleave(
    codec keys.SQLCodec,
    table *TableDescriptor,
    index *IndexDescriptor,
    end roachpb.Key,
    inclusive bool,
) (roachpb.Key, error)

AdjustEndKeyForInterleave returns an exclusive end key. It does two things:

- determines the end key based on the prior: inclusive vs exclusive
- adjusts the end key to skip unnecessary interleaved sections

For example, the parent span composed from the filter PK >= 1 and PK < 3 is

/1 - /3

This reads all keys up to the first parent key for PK = 3. If parent had interleaved tables and keys, it would unnecessarily scan over interleaved rows under PK2 (e.g. /2/#/5). We can instead "tighten" or adjust the end key from /3 to /2/#. DO NOT pass in any keys that have been invoked with PrefixEnd: this may cause issues when trying to decode the key tokens. AdjustEndKeyForInterleave is idempotent upon successive invocation(s).

func AdjustStartKeyForInterleave Uses

func AdjustStartKeyForInterleave(
    codec keys.SQLCodec, index *IndexDescriptor, start roachpb.Key,
) (roachpb.Key, error)

AdjustStartKeyForInterleave adjusts the start key to skip unnecessary interleaved sections.

For example, if child is interleaved into parent, a typical parent span might look like

/1 - /3

and a typical child span might look like

/1/#/2 - /2/#/5

Suppose the parent span is

/1/#/2 - /3

where the start key is a child's index key. Notice that the first parent key read actually starts at /2 since all the parent keys with the prefix /1 come before the child key /1/#/2 (and is not read in the span). We can thus push forward the start key from /1/#/2 to /2. If the start key was /1, we cannot push this forwards since that is the first key we want to read.

func AdjustValueToColumnType Uses

func AdjustValueToColumnType(
    typ *types.T, inVal tree.Datum, name *string,
) (outVal tree.Datum, err error)

AdjustValueToColumnType checks that the width (for strings, byte arrays, and bit strings), precision (time), shape/srid (for geospatial types) and scale (for decimals) of the value fits the specified column type.

In case of decimals, it can truncate fractional digits in the input value in order to fit the target column. If the input value fits the target column, it is returned unchanged. If the input value can be truncated to fit, then a truncated copy is returned. Otherwise, an error is returned.

In the case of time, it can truncate fractional digits of time datums to its relevant rounding for the given type definition.

In the case of geospatial types, it will check whether the SRID and Shape in the datum matches the type definition.

This method is used by INSERT and UPDATE.

func CannotWriteToComputedColError Uses

func CannotWriteToComputedColError(colName string) error

CannotWriteToComputedColError constructs a write error for a computed column.

func CheckDatumTypeFitsColumnType Uses

func CheckDatumTypeFitsColumnType(col *ColumnDescriptor, typ *types.T) error

CheckDatumTypeFitsColumnType verifies that a given scalar value type is valid to be stored in a column of the given column type.

For the purpose of this analysis, column type aliases are not considered to be different (eg. TEXT and VARCHAR will fit the same scalar type String).

This is used by the UPDATE, INSERT and UPSERT code.

func ColumnFamilyMutator Uses

func ColumnFamilyMutator(rng *rand.Rand, stmt tree.Statement) (changed bool)

ColumnFamilyMutator is mutations.StatementMutator, but lives here to prevent dependency cycles with RandCreateTable.

func ColumnNeedsBackfill Uses

func ColumnNeedsBackfill(desc *ColumnDescriptor) bool

ColumnNeedsBackfill returns true if adding the given column requires a backfill (dropping a column always requires a backfill).

func ColumnTypeIsIndexable Uses

func ColumnTypeIsIndexable(t *types.T) bool

ColumnTypeIsIndexable returns whether the type t is valid as an indexed column.

func ColumnTypeIsInvertedIndexable Uses

func ColumnTypeIsInvertedIndexable(t *types.T) bool

ColumnTypeIsInvertedIndexable returns whether the type t is valid to be indexed using an inverted index.

func ColumnsSelectors Uses

func ColumnsSelectors(cols []ColumnDescriptor) tree.SelectExprs

ColumnsSelectors generates Select expressions for cols.

func CompareDatums Uses

func CompareDatums(ordering ColumnOrdering, evalCtx *tree.EvalContext, lhs, rhs tree.Datums) int

CompareDatums compares two datum rows according to a column ordering. Returns:

- 0 if lhs and rhs are equal on the ordering columns;
- less than 0 if lhs comes first;
- greater than 0 if rhs comes first.

func ConditionalGetTableDescFromTxn Uses

func ConditionalGetTableDescFromTxn(
    ctx context.Context, txn *kv.Txn, codec keys.SQLCodec, expectation *TableDescriptor,
) ([]byte, error)

ConditionalGetTableDescFromTxn validates that the supplied TableDescriptor matches the one currently stored in kv. This simulates a CPut and returns a ConditionFailedError on mismatch. We don't directly use CPut with protos because the marshaling is not guaranteed to be stable and also because it's sensitive to things like missing vs default values of fields.

TODO(ajwerner): Make this take a TableDescriptorInterface and probably add an equality method on that interface or something like that.

func DecodeIndexKey Uses

func DecodeIndexKey(
    codec keys.SQLCodec,
    desc *TableDescriptor,
    index *IndexDescriptor,
    types []*types.T,
    vals []EncDatum,
    colDirs []IndexDescriptor_Direction,
    key []byte,
) (remainingKey []byte, matches bool, foundNull bool, _ error)

DecodeIndexKey decodes the values that are a part of the specified index key (setting vals).

The remaining bytes in the index key are returned which will either be an encoded column ID for the primary key index, the primary key suffix for non-unique secondary indexes or unique secondary indexes containing NULL or empty. If the given descriptor does not match the key, false is returned with no error.

func DecodeIndexKeyWithoutTableIDIndexIDPrefix Uses

func DecodeIndexKeyWithoutTableIDIndexIDPrefix(
    desc *TableDescriptor,
    index *IndexDescriptor,
    types []*types.T,
    vals []EncDatum,
    colDirs []IndexDescriptor_Direction,
    key []byte,
) (remainingKey []byte, matches bool, foundNull bool, _ error)

DecodeIndexKeyWithoutTableIDIndexIDPrefix is the same as DecodeIndexKey, except it expects its index key is missing in its tenant id and first table id / index id key prefix.

func DecodeKeyVals Uses

func DecodeKeyVals(
    types []*types.T, vals []EncDatum, directions []IndexDescriptor_Direction, key []byte,
) ([]byte, bool, error)

DecodeKeyVals decodes the values that are part of the key. The decoded values are stored in the vals. If this slice is nil, the direction used will default to encoding.Ascending. DecodeKeyVals returns whether or not NULL was encountered in the key.

func DecodeNameMetadataKey Uses

func DecodeNameMetadataKey(
    codec keys.SQLCodec, k roachpb.Key,
) (parentID ID, parentSchemaID ID, name string, err error)

DecodeNameMetadataKey returns the components that make up the NameMetadataKey for version >= 20.1.

func DecodePartialTableIDIndexID Uses

func DecodePartialTableIDIndexID(key []byte) ([]byte, ID, IndexID, error)

DecodePartialTableIDIndexID decodes a table id followed by an index id. The input key must already have its tenant id removed.

func DecodeTableKey Uses

func DecodeTableKey(
    a *DatumAlloc, valType *types.T, key []byte, dir encoding.Direction,
) (tree.Datum, []byte, error)

DecodeTableKey decodes a value encoded by EncodeTableKey.

func DecodeTableValue Uses

func DecodeTableValue(a *DatumAlloc, valType *types.T, b []byte) (tree.Datum, []byte, error)

DecodeTableValue decodes a value encoded by EncodeTableValue.

func DecodeUntaggedDatum Uses

func DecodeUntaggedDatum(a *DatumAlloc, t *types.T, buf []byte) (tree.Datum, []byte, error)

DecodeUntaggedDatum is used to decode a Datum whose type is known, and which doesn't have a value tag (either due to it having been consumed already or not having one in the first place).

This is used to decode datums encoded using value encoding.

If t is types.Bool, the value tag must be present, as its value is encoded in the tag directly.

func EncDatumRowToDatums Uses

func EncDatumRowToDatums(
    types []*types.T, datums tree.Datums, row EncDatumRow, da *DatumAlloc,
) error

EncDatumRowToDatums converts a given EncDatumRow to a Datums.

func EncodeColumns Uses

func EncodeColumns(
    columnIDs []ColumnID,
    directions directions,
    colMap map[ColumnID]int,
    values []tree.Datum,
    keyPrefix []byte,
) (key []byte, containsNull bool, err error)

EncodeColumns is a version of EncodePartialIndexKey that takes ColumnIDs and directions explicitly. WARNING: unlike EncodePartialIndexKey, EncodeColumns appends directly to keyPrefix.

func EncodeGeoInvertedIndexTableKeys Uses

func EncodeGeoInvertedIndexTableKeys(
    val tree.Datum, inKey []byte, index *IndexDescriptor,
) (key [][]byte, err error)

EncodeGeoInvertedIndexTableKeys is the equivalent of EncodeInvertedIndexTableKeys for Geography and Geometry.

func EncodeIndexKey Uses

func EncodeIndexKey(
    tableDesc *TableDescriptor,
    index *IndexDescriptor,
    colMap map[ColumnID]int,
    values []tree.Datum,
    keyPrefix []byte,
) (key []byte, containsNull bool, err error)

EncodeIndexKey creates a key by concatenating keyPrefix with the encodings of the columns in the index, and returns the key and whether any of the encoded values were NULLs.

If a table or index is interleaved, `encoding.interleavedSentinel` is used in place of the family id (a varint) to signal the next component of the key. An example of one level of interleaving (a parent): /<parent_table_id>/<parent_index_id>/<field_1>/<field_2>/NullDesc/<table_id>/<index_id>/<field_3>/<family>

Note that ExtraColumnIDs are not encoded, so the result isn't always a full index key.

func EncodeInvertedIndexKeys Uses

func EncodeInvertedIndexKeys(
    index *IndexDescriptor, colMap map[ColumnID]int, values []tree.Datum, keyPrefix []byte,
) (key [][]byte, err error)

EncodeInvertedIndexKeys creates a list of inverted index keys by concatenating keyPrefix with the encodings of the column in the index.

func EncodeInvertedIndexTableKeys Uses

func EncodeInvertedIndexTableKeys(val tree.Datum, inKey []byte) (key [][]byte, err error)

EncodeInvertedIndexTableKeys produces one inverted index key per element in the input datum, which should be a container (either JSON or Array). For JSON, "element" means unique path through the document. Each output key is prefixed by inKey, and is guaranteed to be lexicographically sortable, but not guaranteed to be round-trippable during decoding. If the input Datum is (SQL) NULL, no inverted index keys will be produced, because inverted indexes cannot and do not need to satisfy the predicate col IS NULL.

func EncodePartialIndexKey Uses

func EncodePartialIndexKey(
    tableDesc *TableDescriptor,
    index *IndexDescriptor,
    numCols int,
    colMap map[ColumnID]int,
    values []tree.Datum,
    keyPrefix []byte,
) (key []byte, containsNull bool, err error)

EncodePartialIndexKey encodes a partial index key; only the first numCols of the index key columns are encoded. The index key columns are

- index.ColumnIDs for unique indexes, and
- append(index.ColumnIDs, index.ExtraColumnIDs) for non-unique indexes.

func EncodePartialIndexSpan Uses

func EncodePartialIndexSpan(
    tableDesc *TableDescriptor,
    index *IndexDescriptor,
    numCols int,
    colMap map[ColumnID]int,
    values []tree.Datum,
    keyPrefix []byte,
) (span roachpb.Span, containsNull bool, err error)

EncodePartialIndexSpan creates the minimal key span for the key specified by the given table, index, and values, with the same method as EncodePartialIndexKey.

func EncodePartialTableIDIndexID Uses

func EncodePartialTableIDIndexID(key []byte, tableID ID, indexID IndexID) []byte

EncodePartialTableIDIndexID encodes a table id followed by an index id to an existing key. The key must already contain a tenant id.

func EncodeTableKey Uses

func EncodeTableKey(b []byte, val tree.Datum, dir encoding.Direction) ([]byte, error)

EncodeTableKey encodes `val` into `b` and returns the new buffer. This is suitable to generate index/lookup keys in KV.

The encoded value is guaranteed to be lexicographically sortable, but not guaranteed to be round-trippable during decoding: some values like decimals or collated strings have composite encoding where part of their value lies in the value part of the key/value pair.

See also: docs/tech-notes/encoding.md, EncodeTableValue().

func EncodeTableValue Uses

func EncodeTableValue(
    appendTo []byte, colID ColumnID, val tree.Datum, scratch []byte,
) ([]byte, error)

EncodeTableValue encodes `val` into `appendTo` using DatumEncoding_VALUE and returns the new buffer.

This is suitable for generating the value part of individual columns in a column family.

The encoded value is guaranteed to round trip and decode exactly to its input, but is not guaranteed to be lexicographically sortable.

See also: docs/tech-notes/encoding.md, EncodeTableKey().

func EvalShardBucketCount Uses

func EvalShardBucketCount(
    ctx context.Context, semaCtx *tree.SemaContext, evalCtx *tree.EvalContext, shardBuckets tree.Expr,
) (int32, error)

EvalShardBucketCount evaluates and checks the integer argument to a `USING HASH WITH BUCKET_COUNT` index creation query.

func ExtractIndexKey Uses

func ExtractIndexKey(
    a *DatumAlloc, codec keys.SQLCodec, tableDesc *TableDescriptor, entry kv.KeyValue,
) (roachpb.Key, error)

ExtractIndexKey constructs the index (primary) key for a row from any index key/value entry, including secondary indexes.

Don't use this function in the scan "hot path".

func FilterTableState Uses

func FilterTableState(tableDesc *TableDescriptor) error

FilterTableState inspects the state of a given table and returns an error if the state is anything but PUBLIC. The error describes the state of the table.

func ForEachExprStringInTableDesc Uses

func ForEachExprStringInTableDesc(desc *TableDescriptor, f func(expr *string) error) error

ForEachExprStringInTableDesc runs a closure for each expression string within a TableDescriptor. The closure takes in a string pointer so that it can mutate the TableDescriptor if desired.

func GenerateRandInterestingTable Uses

func GenerateRandInterestingTable(db *gosql.DB, dbName, tableName string) error

GenerateRandInterestingTable takes a gosql.DB connection and creates a table with all the types in randInterestingDatums and rows of the interesting datums.

func GenerateUniqueConstraintName Uses

func GenerateUniqueConstraintName(prefix string, nameExistsFunc func(name string) bool) string

GenerateUniqueConstraintName attempts to generate a unique constraint name with the given prefix. It will first try prefix by itself, then it will subsequently try adding numeric digits at the end, starting from 1.

func GetColumnFamilyForShard Uses

func GetColumnFamilyForShard(desc *MutableTableDescriptor, idxColumns []string) string

GetColumnFamilyForShard returns the column family that a newly added shard column should be assigned to, given the set of columns it's computed from.

This is currently the column family of the first column in the set of index columns.

func GetColumnTypes Uses

func GetColumnTypes(desc *TableDescriptor, columnIDs []ColumnID) ([]*types.T, error)

GetColumnTypes returns the types of the columns with the given IDs.

func GetShardColumnName Uses

func GetShardColumnName(colNames []string, buckets int32) string

GetShardColumnName generates a name for the hidden shard column to be used to create a hash sharded index.

func GetTraceAgeColumnIdx Uses

func GetTraceAgeColumnIdx(compact bool) int

GetTraceAgeColumnIdx retrieves the index of the age column depending on whether the compact format is used.

func GetTypeDescriptorClosure Uses

func GetTypeDescriptorClosure(typ *types.T) map[ID]struct{}

GetTypeDescriptorClosure returns all type descriptor IDs that are referenced by this input types.T.

func HasAddingTableError Uses

func HasAddingTableError(err error) bool

HasAddingTableError returns true if the error contains an addingTableError.

func HasCompositeKeyEncoding Uses

func HasCompositeKeyEncoding(typ *types.T) bool

HasCompositeKeyEncoding returns true if key columns of the given kind can have a composite encoding. For such types, it can be decided on a case-by-base basis whether a given Datum requires the composite encoding.

As an example of a composite encoding, collated string key columns are encoded partly as a key and partly as a value. The key part is the collation key, so that different strings that collate equal cannot both be used as keys. The value part is the usual UTF-8 encoding of the string, stored so that it can be recovered later for inspection/display.

func HasInactiveTableError Uses

func HasInactiveTableError(err error) bool

HasInactiveTableError returns true if the error contains an inactiveTableError.

func HydrateTypesInTableDescriptor Uses

func HydrateTypesInTableDescriptor(desc *TableDescriptor, typeLookup TypeLookupFunc) error

HydrateTypesInTableDescriptor uses typeLookup to install metadata in the types present in a table descriptor. typeLookup retrieves the fully qualified name and descriptor for a particular ID.

func IndexKeyEquivSignature Uses

func IndexKeyEquivSignature(
    key []byte, validEquivSignatures map[string]int, signatureBuf []byte, restBuf []byte,
) (tableIdx int, restResult []byte, success bool, err error)

IndexKeyEquivSignature parses an index key if and only if the index key belongs to a table where its equivalence signature and all its interleave ancestors' signatures can be found in validEquivSignatures.

Its validEquivSignatures argument is a map containing equivalence signatures of valid ancestors of the desired table and of the desired table itself.

IndexKeyEquivSignature returns whether or not the index key satisfies the above condition, the value mapped to by the desired table (could be a table index), and the rest of the key that's not part of the signature.

It also requires two []byte buffers: one for the signature (signatureBuf) and one for the rest of the key (keyRestBuf).

The equivalence signature defines the equivalence classes for the signature of potentially interleaved tables. For example, the equivalence signatures for the following interleaved indexes:

<parent@primary>
<child@secondary>

and index keys

<parent index key>:   /<parent table id>/<parent index id>/<val 1>/<val 2>
<child index key>:    /<parent table id>/<parent index id>/<val 1>/<val 2>/#/<child table id>/child index id>/<val 3>/<val 4>

correspond to the equivalence signatures

<parent@primary>:     /<parent table id>/<parent index id>
<child@secondary>:    /<parent table id>/<parent index id>/#/<child table id>/<child index id>

Equivalence signatures allow us to associate an index key with its table without having to invoke DecodeIndexKey multiple times.

IndexKeyEquivSignature will return false if the a table's ancestor's signature or the table's signature (table which the index key belongs to) is not mapped in validEquivSignatures.

For example, suppose the given key is

/<t2 table id>/<t2 index id>/<val t2>/#/<t3 table id>/<t3 table id>/<val t3>

and validEquivSignatures contains

/<t1 table id>/t1 index id>
/<t1 table id>/t1 index id>/#/<t4 table id>/<t4 index id>

IndexKeyEquivSignature will short-circuit and return false once

/<t2 table id>/<t2 index id>

is processed since t2's signature is not specified in validEquivSignatures.

func IndexKeyValDirs Uses

func IndexKeyValDirs(index *IndexDescriptor) []encoding.Direction

IndexKeyValDirs returns the corresponding encoding.Directions for all the encoded values in index's "fullest" possible index key, including directions for table/index IDs, the interleaved sentinel and the index column values. For example, given

CREATE INDEX foo ON bar (a, b DESC) INTERLEAVED IN PARENT bar (a)

a typical index key with all values specified could be

/51/1/42/#/51/2/1337

which would return the slice

{ASC, ASC, ASC, 0, ASC, ASC, DESC}

func IndexStoringMutator Uses

func IndexStoringMutator(rng *rand.Rand, stmts []tree.Statement) ([]tree.Statement, bool)

IndexStoringMutator is mutations.StatementMutator, but lives here to prevent dependency cycles with RandCreateTable.

func IsCCLRequiredError Uses

func IsCCLRequiredError(err error) bool

IsCCLRequiredError returns whether the error is a CCLRequired error.

func IsDefaultCreatedDescriptor Uses

func IsDefaultCreatedDescriptor(descID ID) bool

IsDefaultCreatedDescriptor returns whether or not a given descriptor ID is present at the time of starting a cluster.

func IsOutOfMemoryError Uses

func IsOutOfMemoryError(err error) bool

IsOutOfMemoryError checks whether this is an out of memory error.

func IsRelationAlreadyExistsError Uses

func IsRelationAlreadyExistsError(err error) bool

IsRelationAlreadyExistsError checks whether this is an error for a preexisting relation.

func IsReservedID Uses

func IsReservedID(id ID) bool

IsReservedID returns whether this ID is for any system object.

func IsSystemConfigID Uses

func IsSystemConfigID(id ID) bool

IsSystemConfigID returns whether this ID is for a system config object.

func IsUndefinedColumnError Uses

func IsUndefinedColumnError(err error) bool

IsUndefinedColumnError checks whether this is an undefined column error.

func IsUndefinedRelationError Uses

func IsUndefinedRelationError(err error) bool

IsUndefinedRelationError checks whether this is an undefined relation error.

func IsVirtualTable Uses

func IsVirtualTable(id ID) bool

IsVirtualTable returns true if the TableDescriptor describes a virtual Table (like the informationgi_schema tables) and thus doesn't need to be physically stored.

func MakeAllDescsMetadataKey Uses

func MakeAllDescsMetadataKey(codec keys.SQLCodec) roachpb.Key

MakeAllDescsMetadataKey returns the key for all descriptors.

func MakeColumnDefDescs Uses

func MakeColumnDefDescs(
    ctx context.Context, d *tree.ColumnTableDef, semaCtx *tree.SemaContext, evalCtx *tree.EvalContext,
) (*ColumnDescriptor, *IndexDescriptor, tree.TypedExpr, error)

MakeColumnDefDescs creates the column descriptor for a column, as well as the index descriptor if the column is a primary key or unique.

If the column type *may* be SERIAL (or SERIAL-like), it is the caller's responsibility to call sql.processSerialInColumnDef() and sql.doCreateSequence() before MakeColumnDefDescs() to remove the SERIAL type and replace it with a suitable integer type and default expression.

semaCtx can be nil if no default expression is used for the column or during cluster bootstrapping.

The DEFAULT expression is returned in TypedExpr form for analysis (e.g. recording sequence dependencies).

func MakeDefaultExprs Uses

func MakeDefaultExprs(
    ctx context.Context,
    cols []ColumnDescriptor,
    txCtx *transform.ExprTransformContext,
    evalCtx *tree.EvalContext,
    semaCtx *tree.SemaContext,
) ([]tree.TypedExpr, error)

MakeDefaultExprs returns a slice of the default expressions for the slice of input column descriptors, or nil if none of the input column descriptors have default expressions. The length of the result slice matches the length of the input column descriptors. For every column that has no default expression, a NULL expression is reported as default.

func MakeDeprecatedNameMetadataKey Uses

func MakeDeprecatedNameMetadataKey(codec keys.SQLCodec, parentID ID, name string) roachpb.Key

MakeDeprecatedNameMetadataKey returns the key for a name, as expected by versions < 20.1. Pass name == "" in order to generate the prefix key to use to scan over all of the names for the specified parentID.

func MakeDescMetadataKey Uses

func MakeDescMetadataKey(codec keys.SQLCodec, descID ID) roachpb.Key

MakeDescMetadataKey returns the key for the descriptor.

func MakeIndexKeyPrefix Uses

func MakeIndexKeyPrefix(codec keys.SQLCodec, desc *TableDescriptor, indexID IndexID) []byte

MakeIndexKeyPrefix returns the key prefix used for the index's data. If you need the corresponding Span, prefer desc.IndexSpan(indexID) or desc.PrimaryIndexSpan().

func MakeIntCols Uses

func MakeIntCols(numCols int) []*types.T

MakeIntCols makes a slice of numCols IntTypes.

func MakeNameMetadataKey Uses

func MakeNameMetadataKey(
    codec keys.SQLCodec, parentID ID, parentSchemaID ID, name string,
) roachpb.Key

MakeNameMetadataKey returns the key for the name, as expected by versions >= 20.1. Pass name == "" in order to generate the prefix key to use to scan over all of the names for the specified parentID.

func MakeObjectAlreadyExistsError Uses

func MakeObjectAlreadyExistsError(collidingObject *Descriptor, name string) error

MakeObjectAlreadyExistsError creates an error for a namespace collision with an arbitrary descriptor type.

func MakeSpanFromEncDatums Uses

func MakeSpanFromEncDatums(
    values EncDatumRow,
    types []*types.T,
    dirs []IndexDescriptor_Direction,
    tableDesc *TableDescriptor,
    index *IndexDescriptor,
    alloc *DatumAlloc,
    keyPrefix []byte,
) (_ roachpb.Span, containsNull bool, _ error)

MakeSpanFromEncDatums creates a minimal index key span on the input values. A minimal index key span is a span that includes the fewest possible keys after the start key generated by the input values.

The start key is generated by concatenating keyPrefix with the encodings of the given EncDatum values. The values, types, and dirs parameters should be specified in the same order as the index key columns and may be a prefix.

If a table or index is interleaved, `encoding.interleavedSentinel` is used in place of the family id (a varint) to signal the next component of the key. An example of one level of interleaving (a parent): /<parent_table_id>/<parent_index_id>/<field_1>/<field_2>/NullDesc/<table_id>/<index_id>/<field_3>/<family>

func MarshalColumnValue Uses

func MarshalColumnValue(col *ColumnDescriptor, val tree.Datum) (roachpb.Value, error)

MarshalColumnValue produces the value encoding of the given datum, constrained by the given column type, into a roachpb.Value.

This is used when when the table format does not use column families, such as pre-2.0 tables and some system tables.

If val's type is incompatible with col, or if col's type is not yet implemented by this function, an error is returned.

func MustBeValueEncoded Uses

func MustBeValueEncoded(semanticType *types.T) bool

MustBeValueEncoded returns true if columns of the given kind can only be value encoded.

func NewAggInAggError Uses

func NewAggInAggError() error

NewAggInAggError creates an error for the case when an aggregate function is contained within another aggregate function.

func NewCCLRequiredError Uses

func NewCCLRequiredError(err error) error

NewCCLRequiredError creates an error for when a CCL feature is used in an OSS binary.

func NewColumnAlreadyExistsError Uses

func NewColumnAlreadyExistsError(name, relation string) error

NewColumnAlreadyExistsError creates an error for a preexisting column.

func NewDatabaseAlreadyExistsError Uses

func NewDatabaseAlreadyExistsError(name string) error

NewDatabaseAlreadyExistsError creates an error for a preexisting database.

func NewDependentObjectErrorf Uses

func NewDependentObjectErrorf(format string, args ...interface{}) error

NewDependentObjectErrorf creates a dependent object error.

func NewInvalidSchemaDefinitionError Uses

func NewInvalidSchemaDefinitionError(err error) error

NewInvalidSchemaDefinitionError creates an error for an invalid schema definition such as a schema definition that doesn't parse.

func NewInvalidWildcardError Uses

func NewInvalidWildcardError(name string) error

NewInvalidWildcardError creates an error that represents the result of expanding a table wildcard over an invalid database or schema prefix.

func NewNonNullViolationError Uses

func NewNonNullViolationError(columnName string) error

NewNonNullViolationError creates an error for a violation of a non-NULL constraint.

func NewRangeUnavailableError Uses

func NewRangeUnavailableError(rangeID roachpb.RangeID, origErr error) error

NewRangeUnavailableError creates an unavailable range error.

func NewRelationAlreadyExistsError Uses

func NewRelationAlreadyExistsError(name string) error

NewRelationAlreadyExistsError creates an error for a preexisting relation.

func NewSyntaxErrorf Uses

func NewSyntaxErrorf(format string, args ...interface{}) error

NewSyntaxErrorf creates a syntax error.

func NewTransactionAbortedError Uses

func NewTransactionAbortedError(customMsg string) error

NewTransactionAbortedError creates an error for trying to run a command in the context of transaction that's in the aborted state. Any statement other than ROLLBACK TO SAVEPOINT will return this error.

func NewTransactionCommittedError Uses

func NewTransactionCommittedError() error

NewTransactionCommittedError creates an error that signals that the SQL txn is in the COMMIT_WAIT state and that only a COMMIT statement will be accepted.

func NewTypeAlreadyExistsError Uses

func NewTypeAlreadyExistsError(name string) error

NewTypeAlreadyExistsError creates an error for a preexisting type.

func NewUndefinedColumnError Uses

func NewUndefinedColumnError(name string) error

NewUndefinedColumnError creates an error that represents a missing database column.

func NewUndefinedDatabaseError Uses

func NewUndefinedDatabaseError(name string) error

NewUndefinedDatabaseError creates an error that represents a missing database.

func NewUndefinedObjectError Uses

func NewUndefinedObjectError(name tree.NodeFormatter, kind tree.DesiredObjectKind) error

NewUndefinedObjectError returns the correct undefined object error based on the kind of object that was requested.

func NewUndefinedRelationError Uses

func NewUndefinedRelationError(name tree.NodeFormatter) error

NewUndefinedRelationError creates an error that represents a missing database table or view.

func NewUndefinedTypeError Uses

func NewUndefinedTypeError(name tree.NodeFormatter) error

NewUndefinedTypeError creates an error that represents a missing type.

func NewUnsupportedSchemaUsageError Uses

func NewUnsupportedSchemaUsageError(name string) error

NewUnsupportedSchemaUsageError creates an error for an invalid schema use, e.g. mydb.someschema.tbl.

func NewWindowInAggError Uses

func NewWindowInAggError() error

NewWindowInAggError creates an error for the case when a window function is nested within an aggregate function.

func NewWrongObjectTypeError Uses

func NewWrongObjectTypeError(name tree.NodeFormatter, desiredObjType string) error

NewWrongObjectTypeError creates a wrong object type error.

func ParseDatumStringAs Uses

func ParseDatumStringAs(t *types.T, s string, evalCtx *tree.EvalContext) (tree.Datum, error)

ParseDatumStringAs parses s as type t. This function is guaranteed to round-trip when printing a Datum with FmtExport.

func ParseDatumStringAsWithRawBytes Uses

func ParseDatumStringAsWithRawBytes(
    t *types.T, s string, evalCtx *tree.EvalContext,
) (tree.Datum, error)

ParseDatumStringAsWithRawBytes parses s as type t. However, if the requested type is Bytes then the string is returned unchanged. This function is used when the input string might be unescaped raw bytes, so we don't want to run a bytes parsing routine on the input. Other than the bytes case, this function does the same as ParseDatumStringAs but is not guaranteed to round-trip.

func PrettyKey Uses

func PrettyKey(valDirs []encoding.Direction, key roachpb.Key, skip int) string

PrettyKey pretty-prints the specified key, skipping over the first `skip` fields. The pretty printed key looks like:

/Table/<tableID>/<indexID>/...

We always strip off the /Table prefix and then `skip` more fields. Note that this assumes that the fields themselves do not contain '/', but that is currently true for the fields we care about stripping (the table and index ID).

func PrettySpan Uses

func PrettySpan(valDirs []encoding.Direction, span roachpb.Span, skip int) string

PrettySpan returns a human-readable representation of a span.

func PrettySpans Uses

func PrettySpans(index *IndexDescriptor, spans []roachpb.Span, skip int) string

PrettySpans returns a human-readable description of the spans. If index is nil, then pretty print subroutines will use their default settings.

func RandArray Uses

func RandArray(rng *rand.Rand, typ *types.T, nullChance int) tree.Datum

RandArray generates a random DArray where the contents have nullChance of being null.

func RandArrayContentsType Uses

func RandArrayContentsType(rng *rand.Rand) *types.T

RandArrayContentsType returns a random type that's guaranteed to be valid to use as the contents of an array.

func RandArrayType Uses

func RandArrayType(rng *rand.Rand) *types.T

RandArrayType generates a random array type.

func RandCollationLocale Uses

func RandCollationLocale(rng *rand.Rand) *string

RandCollationLocale returns a random element of collationLocales.

func RandColumnType Uses

func RandColumnType(rng *rand.Rand) *types.T

RandColumnType returns a random type that is a legal column type (e.g. no nested arrays or tuples).

func RandColumnTypes Uses

func RandColumnTypes(rng *rand.Rand, numCols int) []*types.T

RandColumnTypes returns a slice of numCols random types. These types must be legal table column types.

func RandCreateTable Uses

func RandCreateTable(rng *rand.Rand, prefix string, tableIdx int) *tree.CreateTable

RandCreateTable creates a random CreateTable definition.

func RandCreateTableWithInterleave Uses

func RandCreateTableWithInterleave(
    rng *rand.Rand, prefix string, tableIdx int, interleaveInto *tree.CreateTable,
) *tree.CreateTable

RandCreateTableWithInterleave creates a random CreateTable definition, interleaved into the given other CreateTable definition.

func RandCreateTables Uses

func RandCreateTables(
    rng *rand.Rand, prefix string, num int, mutators ...Mutator,
) []tree.Statement

RandCreateTables creates random table definitions.

func RandCreateType Uses

func RandCreateType(rng *rand.Rand, name, alphabet string) tree.Statement

RandCreateType creates a random CREATE TYPE statement. The resulting type's name will be name, and if the type is an enum, the members will be random strings generated from alphabet.

func RandDatum Uses

func RandDatum(rng *rand.Rand, typ *types.T, nullOk bool) tree.Datum

RandDatum generates a random Datum of the given type. If nullOk is true, the datum can be DNull. Note that if typ.Family is UNKNOWN, the datum will always be DNull, regardless of the null flag.

func RandDatumSimple Uses

func RandDatumSimple(rng *rand.Rand, typ *types.T) tree.Datum

RandDatumSimple generates a random Datum of the given type. The generated datums will be simple (i.e., only one character or an integer between 0 and 9), such that repeated calls to this function will regularly return a previously generated datum.

func RandDatumWithNullChance Uses

func RandDatumWithNullChance(rng *rand.Rand, typ *types.T, nullChance int) tree.Datum

RandDatumWithNullChance generates a random Datum of the given type. nullChance is the chance of returning null, expressed as a fraction denominator. For example, a nullChance of 5 means that there's a 1/5 chance that DNull will be returned. A nullChance of 0 means that DNull will not be returned. Note that if typ.Family is UNKNOWN, the datum will always be DNull, regardless of the null flag.

func RandEncodableColumnTypes Uses

func RandEncodableColumnTypes(rng *rand.Rand, numCols int) []*types.T

RandEncodableColumnTypes works around #36736, which fails when name[] (or other type using DTypeWrapper) is encoded.

TODO(andyk): Remove this workaround once #36736 is resolved. Replace calls to it with calls to RandColumnTypes.

func RandEncodableType Uses

func RandEncodableType(rng *rand.Rand) *types.T

RandEncodableType wraps RandType in order to workaround #36736, which fails when name[] (or other type using DTypeWrapper) is encoded.

TODO(andyk): Remove this workaround once #36736 is resolved. Also, RandDatum really should be extended to create DTypeWrapper datums with alternate OIDs like oid.T_varchar for better testing.

func RandSortingEncDatumSlices Uses

func RandSortingEncDatumSlices(
    rng *rand.Rand, numSets, numValsPerSet int,
) ([][]EncDatum, []*types.T)

RandSortingEncDatumSlices generates EncDatum slices, each slice with values of the same random type which is key-encodable.

func RandSortingType Uses

func RandSortingType(rng *rand.Rand) *types.T

RandSortingType returns a column type which can be key-encoded.

func RandSortingTypes Uses

func RandSortingTypes(rng *rand.Rand, numCols int) []*types.T

RandSortingTypes returns a slice of numCols random ColumnType values which are key-encodable.

func RandString Uses

func RandString(rng *rand.Rand, length int, alphabet string) string

RandString generates a random string of the desired length from the input alphaget.

func RandType Uses

func RandType(rng *rand.Rand) *types.T

RandType returns a random type value.

func RandTypeFromSlice Uses

func RandTypeFromSlice(rng *rand.Rand, typs []*types.T) *types.T

RandTypeFromSlice returns a random type from the input slice of types.

func RemapIVarsInTypedExpr Uses

func RemapIVarsInTypedExpr(expr tree.TypedExpr, indexVarMap []int) tree.TypedExpr

RemapIVarsInTypedExpr remaps tree.IndexedVars in expr using indexVarMap. Note that a new expression is returned.

func RemoveDatabaseNamespaceEntry Uses

func RemoveDatabaseNamespaceEntry(
    ctx context.Context, txn *kv.Txn, codec keys.SQLCodec, name string, KVTrace bool,
) error

RemoveDatabaseNamespaceEntry is a wrapper around RemoveObjectNamespaceEntry for databases.

func RemoveObjectNamespaceEntry Uses

func RemoveObjectNamespaceEntry(
    ctx context.Context,
    txn *kv.Txn,
    codec keys.SQLCodec,
    parentID ID,
    parentSchemaID ID,
    name string,
    KVTrace bool,
) error

RemoveObjectNamespaceEntry removes entries from both the deprecated and new system.namespace table (if one exists).

func RemovePublicTableNamespaceEntry Uses

func RemovePublicTableNamespaceEntry(
    ctx context.Context, txn *kv.Txn, codec keys.SQLCodec, parentID ID, name string,
) error

RemovePublicTableNamespaceEntry is a wrapper around RemoveObjectNamespaceEntry for public tables.

func RemoveSchemaNamespaceEntry Uses

func RemoveSchemaNamespaceEntry(
    ctx context.Context, txn *kv.Txn, codec keys.SQLCodec, parentID ID, name string,
) error

RemoveSchemaNamespaceEntry is a wrapper around RemoveObjectNamespaceEntry for schemas.

func ResolveNames Uses

func ResolveNames(
    expr tree.Expr,
    source *DataSourceInfo,
    ivarHelper tree.IndexedVarHelper,
    searchPath sessiondata.SearchPath,
) (tree.Expr, error)

ResolveNames is a wrapper around ResolveNamesUsingVisitor.

func ResolveNamesUsingVisitor Uses

func ResolveNamesUsingVisitor(
    v *NameResolutionVisitor,
    expr tree.Expr,
    source *DataSourceInfo,
    ivarHelper tree.IndexedVarHelper,
    searchPath sessiondata.SearchPath,
) (tree.Expr, error)

ResolveNamesUsingVisitor resolves the names in the given expression.

func RunFilter Uses

func RunFilter(filter tree.TypedExpr, evalCtx *tree.EvalContext) (bool, error)

RunFilter runs a filter expression and returns whether the filter passes.

func SanitizeVarFreeExpr Uses

func SanitizeVarFreeExpr(
    ctx context.Context,
    expr tree.Expr,
    expectedType *types.T,
    context string,
    semaCtx *tree.SemaContext,
    maxVolatility tree.Volatility,
) (tree.TypedExpr, error)

SanitizeVarFreeExpr verifies that an expression is valid, has the correct type and contains no variable expressions. It returns the type-checked and constant-folded expression.

func ShouldSplitAtDesc Uses

func ShouldSplitAtDesc(rawDesc *roachpb.Value) bool

ShouldSplitAtDesc determines whether a specific descriptor should be considered for a split. Only plain tables are considered for split.

func SkipTableKey Uses

func SkipTableKey(key []byte) ([]byte, error)

SkipTableKey skips a value of type valType in key, returning the remainder of the key.

func Sort Uses

func Sort(data sort.Interface, cancelChecker *CancelChecker)

Sort sorts data. It makes one call to data.Len to determine n, and O(n*log(n)) calls to data.Less and data.Swap. The sort is not guaranteed to be stable.

func SplitSpanIntoSeparateFamilies Uses

func SplitSpanIntoSeparateFamilies(
    appendTo roachpb.Spans, span roachpb.Span, neededFamilies []FamilyID,
) roachpb.Spans

SplitSpanIntoSeparateFamilies splits a span representing a single row point lookup into separate disjoint spans that request only the particular column families from neededFamilies instead of requesting all the families. It is up to the client to ensure the requested span represents a single row lookup and that the span splitting is appropriate (see CanSplitSpanIntoSeparateFamilies).

The function accepts a slice of spans to append to.

func TableEquivSignatures Uses

func TableEquivSignatures(
    desc *TableDescriptor, index *IndexDescriptor,
) (signatures [][]byte, err error)

TableEquivSignatures returns the equivalence signatures for each interleave ancestor and itself. See IndexKeyEquivSignature for more info.

func TestingMakePrimaryIndexKey Uses

func TestingMakePrimaryIndexKey(desc *TableDescriptor, vals ...interface{}) (roachpb.Key, error)

TestingMakePrimaryIndexKey creates a key prefix that corresponds to a table row (in the primary index); it is intended for tests.

It is exported because it is used by tests outside of this package.

The value types must match the primary key columns (or a prefix of them); supported types are: - Datum

- bool (converts to DBool)
- int (converts to DInt)
- string (converts to DString)

func UnmarshalColumnValue Uses

func UnmarshalColumnValue(a *DatumAlloc, typ *types.T, value roachpb.Value) (tree.Datum, error)

UnmarshalColumnValue is the counterpart to MarshalColumnValues.

It decodes the value from a roachpb.Value using the type expected by the column. An error is returned if the value's type does not match the column's type.

func ValidateColumnDefType Uses

func ValidateColumnDefType(t *types.T) error

ValidateColumnDefType returns an error if the type of a column definition is not valid. It is checked when a column is created or altered.

func WrapErrorWhileConstructingObjectAlreadyExistsErr Uses

func WrapErrorWhileConstructingObjectAlreadyExistsErr(err error) error

WrapErrorWhileConstructingObjectAlreadyExistsErr is used to wrap an error when an error occurs while trying to get the colliding object for an ObjectAlreadyExistsErr.

type BaseDescriptorInterface Uses

type BaseDescriptorInterface interface {
    tree.NameResolutionResult

    GetID() ID
    GetName() string
    GetParentID() ID
    GetParentSchemaID() ID

    // Metadata for descriptor leasing.
    GetVersion() DescriptorVersion
    GetModificationTime() hlc.Timestamp
    GetDrainingNames() []NameInfo

    GetPrivileges() *PrivilegeDescriptor
    TypeName() string
    GetAuditMode() TableDescriptor_AuditMode

    // DescriptorProto prepares this descriptor for serialization.
    DescriptorProto() *Descriptor
}

BaseDescriptorInterface is an interface to be shared by individual descriptor types. Perhaps this should be the actual DescriptorInterface.

type BaseDescriptorInterfaces Uses

type BaseDescriptorInterfaces []BaseDescriptorInterface

BaseDescriptorInterfaces is a sortable list of BaseDescriptorInterfaces.

func (BaseDescriptorInterfaces) Len Uses

func (d BaseDescriptorInterfaces) Len() int

func (BaseDescriptorInterfaces) Less Uses

func (d BaseDescriptorInterfaces) Less(i, j int) bool

func (BaseDescriptorInterfaces) Swap Uses

func (d BaseDescriptorInterfaces) Swap(i, j int)

type CancelChecker Uses

type CancelChecker struct {
    // contains filtered or unexported fields
}

CancelChecker is a helper object for repeatedly checking whether the associated context has been canceled or not. Encapsulates all logic for waiting for cancelCheckInterval rows before actually checking for cancellation. The cancellation check has a significant time overhead, so it's not checked in every iteration.

func NewCancelChecker Uses

func NewCancelChecker(ctx context.Context) *CancelChecker

NewCancelChecker returns a new CancelChecker.

func (*CancelChecker) Check Uses

func (c *CancelChecker) Check() error

Check returns an error if the associated query has been canceled.

func (*CancelChecker) Reset Uses

func (c *CancelChecker) Reset(ctx context.Context)

Reset resets this cancel checker with a fresh context.

type ColTypeInfo Uses

type ColTypeInfo struct {
    // contains filtered or unexported fields
}

ColTypeInfo is a type that allows multiple representations of column type information (to avoid conversions and allocations).

func ColTypeInfoFromColDescs Uses

func ColTypeInfoFromColDescs(colDescs []ColumnDescriptor) ColTypeInfo

ColTypeInfoFromColDescs creates a ColTypeInfo from []ColumnDescriptor.

func ColTypeInfoFromColTypes Uses

func ColTypeInfoFromColTypes(colTypes []*types.T) ColTypeInfo

ColTypeInfoFromColTypes creates a ColTypeInfo from []ColumnType.

func ColTypeInfoFromResCols Uses

func ColTypeInfoFromResCols(resCols ResultColumns) ColTypeInfo

ColTypeInfoFromResCols creates a ColTypeInfo from ResultColumns.

func (ColTypeInfo) NumColumns Uses

func (ti ColTypeInfo) NumColumns() int

NumColumns returns the number of columns in the type.

func (ColTypeInfo) Type Uses

func (ti ColTypeInfo) Type(idx int) *types.T

Type returns the datum type of the i-th column.

type ColumnDescriptor Uses

type ColumnDescriptor struct {
    Name     string   `protobuf:"bytes,1,opt,name=name" json:"name"`
    ID       ColumnID `protobuf:"varint,2,opt,name=id,casttype=ColumnID" json:"id"`
    Type     *types.T `protobuf:"bytes,3,opt,name=type" json:"type,omitempty"`
    Nullable bool     `protobuf:"varint,4,opt,name=nullable" json:"nullable"`
    // Default expression to use to populate the column on insert if no
    // value is provided. Note that it is not correct to use DefaultExpr
    // as output to display to a user. User defined types within DefaultExpr
    // have been serialized in a internal format. Instead, format the result
    // of DeserializeTableDescExpr.
    DefaultExpr *string `protobuf:"bytes,5,opt,name=default_expr,json=defaultExpr" json:"default_expr,omitempty"`
    Hidden      bool    `protobuf:"varint,6,opt,name=hidden" json:"hidden"`
    // Ids of sequences used in this column's DEFAULT expression, in calls to nextval().
    UsesSequenceIds []ID `protobuf:"varint,10,rep,name=uses_sequence_ids,json=usesSequenceIds,casttype=ID" json:"uses_sequence_ids,omitempty"`
    // Ids of sequences that the column owns.
    OwnsSequenceIds []ID `protobuf:"varint,12,rep,name=owns_sequence_ids,json=ownsSequenceIds,casttype=ID" json:"owns_sequence_ids,omitempty"`
    // Expression to use to compute the value of this column if this is a
    // computed column. Note that it is not correct to use ComputeExpr
    // as output to display to a user. User defined types within ComputeExpr
    // have been serialized in a internal format. Instead, format the result
    // of DeserializeTableDescExpr.
    ComputeExpr *string `protobuf:"bytes,11,opt,name=compute_expr,json=computeExpr" json:"compute_expr,omitempty"`
    // LogicalColumnID must be accessed through the accessor, since it is set
    // lazily, it is incorrect to access it directly.
    // LogicalColumnID represents a column's number in catalog tables.
    // This only differs from ID when the Column order is swapped or
    // the ColumnDescriptor must be remade while remaining visual ordering.
    // This does not exist in TableDescriptors pre 20.2.
    LogicalColumnID ColumnID `protobuf:"varint,13,opt,name=logical_id,json=logicalId,casttype=ColumnID" json:"logical_id"`
    // Used to indicate column is used and dropped for ALTER COLUMN TYPE mutation.
    AlterColumnTypeInProgress bool `protobuf:"varint,14,opt,name=alter_column_type_in_progress,json=alterColumnTypeInProgress" json:"alter_column_type_in_progress"`
}

func ProcessDefaultColumns Uses

func ProcessDefaultColumns(
    ctx context.Context,
    cols []ColumnDescriptor,
    tableDesc *ImmutableTableDescriptor,
    txCtx *transform.ExprTransformContext,
    evalCtx *tree.EvalContext,
    semaCtx *tree.SemaContext,
) ([]ColumnDescriptor, []tree.TypedExpr, error)

ProcessDefaultColumns adds columns with DEFAULT to cols if not present and returns the defaultExprs for cols.

func ProcessTargetColumns Uses

func ProcessTargetColumns(
    tableDesc *ImmutableTableDescriptor, nameList tree.NameList, ensureColumns, allowMutations bool,
) ([]ColumnDescriptor, error)

ProcessTargetColumns returns the column descriptors identified by the given name list. It also checks that a given column name is only listed once. If no column names are given (special case for INSERT) and ensureColumns is set, the descriptors for all visible columns are returned. If allowMutations is set, even columns undergoing mutations are added.

func (*ColumnDescriptor) CheckCanBeFKRef Uses

func (desc *ColumnDescriptor) CheckCanBeFKRef() error

CheckCanBeFKRef returns whether the given column is computed.

func (*ColumnDescriptor) ColID Uses

func (desc *ColumnDescriptor) ColID() cat.StableID

ColID is part of the cat.Column interface.

func (*ColumnDescriptor) ColName Uses

func (desc *ColumnDescriptor) ColName() tree.Name

ColName is part of the cat.Column interface.

func (*ColumnDescriptor) ColTypePrecision Uses

func (desc *ColumnDescriptor) ColTypePrecision() int

ColTypePrecision is part of the cat.Column interface.

func (*ColumnDescriptor) ColTypeStr Uses

func (desc *ColumnDescriptor) ColTypeStr() string

ColTypeStr is part of the cat.Column interface.

func (*ColumnDescriptor) ColTypeWidth Uses

func (desc *ColumnDescriptor) ColTypeWidth() int

ColTypeWidth is part of the cat.Column interface.

func (*ColumnDescriptor) ComputedExprStr Uses

func (desc *ColumnDescriptor) ComputedExprStr() string

ComputedExprStr is part of the cat.Column interface.

func (*ColumnDescriptor) DatumType Uses

func (desc *ColumnDescriptor) DatumType() *types.T

DatumType is part of the cat.Column interface.

func (*ColumnDescriptor) DefaultExprStr Uses

func (desc *ColumnDescriptor) DefaultExprStr() string

DefaultExprStr is part of the cat.Column interface.

func (*ColumnDescriptor) Descriptor Uses

func (*ColumnDescriptor) Descriptor() ([]byte, []int)

func (*ColumnDescriptor) Equal Uses

func (this *ColumnDescriptor) Equal(that interface{}) bool

func (ColumnDescriptor) GetLogicalColumnID Uses

func (desc ColumnDescriptor) GetLogicalColumnID() ColumnID

GetLogicalColumnID returns the LogicalColumnID of the ColumnDescriptor if the LogicalColumnID is set (non-zero). Returns the ID of the ColumnDescriptor if the LogicalColumnID is not set.

func (*ColumnDescriptor) HasDefault Uses

func (desc *ColumnDescriptor) HasDefault() bool

HasDefault is part of the cat.Column interface.

func (*ColumnDescriptor) HasNullDefault Uses

func (desc *ColumnDescriptor) HasNullDefault() bool

HasNullDefault checks that the column descriptor has a default of NULL.

func (*ColumnDescriptor) IsComputed Uses

func (desc *ColumnDescriptor) IsComputed() bool

IsComputed is part of the cat.Column interface.

func (*ColumnDescriptor) IsHidden Uses

func (desc *ColumnDescriptor) IsHidden() bool

IsHidden is part of the cat.Column interface.

func (*ColumnDescriptor) IsNullable Uses

func (desc *ColumnDescriptor) IsNullable() bool

IsNullable is part of the cat.Column interface.

func (*ColumnDescriptor) Marshal Uses

func (m *ColumnDescriptor) Marshal() (dAtA []byte, err error)

func (*ColumnDescriptor) MarshalTo Uses

func (m *ColumnDescriptor) MarshalTo(dAtA []byte) (int, error)

func (*ColumnDescriptor) ProtoMessage Uses

func (*ColumnDescriptor) ProtoMessage()

func (*ColumnDescriptor) Reset Uses

func (m *ColumnDescriptor) Reset()

func (*ColumnDescriptor) SQLString Uses

func (desc *ColumnDescriptor) SQLString() string

SQLString returns the SQL statement describing the column.

func (*ColumnDescriptor) Size Uses

func (m *ColumnDescriptor) Size() (n int)

func (*ColumnDescriptor) String Uses

func (m *ColumnDescriptor) String() string

func (*ColumnDescriptor) Unmarshal Uses

func (m *ColumnDescriptor) Unmarshal(dAtA []byte) error

func (*ColumnDescriptor) XXX_DiscardUnknown Uses

func (m *ColumnDescriptor) XXX_DiscardUnknown()

func (*ColumnDescriptor) XXX_Marshal Uses

func (m *ColumnDescriptor) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ColumnDescriptor) XXX_Merge Uses

func (dst *ColumnDescriptor) XXX_Merge(src proto.Message)

func (*ColumnDescriptor) XXX_Size Uses

func (m *ColumnDescriptor) XXX_Size() int

func (*ColumnDescriptor) XXX_Unmarshal Uses

func (m *ColumnDescriptor) XXX_Unmarshal(b []byte) error

type ColumnFamilyDescriptor Uses

type ColumnFamilyDescriptor struct {
    Name string `protobuf:"bytes,1,opt,name=name" json:"name"`
    // Column family 0 is *always* included in k/v pairs for a row. This makes
    // sure that rows will all NULL values still have a k/v pair. When performing
    // optimizations involving column families, ensure that column family 0
    // is scanned if the row may have nulls.
    ID  FamilyID `protobuf:"varint,2,opt,name=id,casttype=FamilyID" json:"id"`
    // A list of column names of which the family is comprised. This list
    // parallels the column_ids list. If duplicating the storage of the column
    // names here proves to be prohibitive, we could clear this field before
    // saving and reconstruct it after loading.
    ColumnNames []string `protobuf:"bytes,3,rep,name=column_names,json=columnNames" json:"column_names,omitempty"`
    // A list of column ids of which the family is comprised. This list parallels
    // the column_names list.
    ColumnIDs []ColumnID `protobuf:"varint,4,rep,name=column_ids,json=columnIds,casttype=ColumnID" json:"column_ids,omitempty"`
    // If nonzero, the column involved in the single column optimization.
    //
    // Families store columns in a ValueType_TUPLE as repeated <columnID><data>
    // entries. As a space optimization and for backward compatibility, a single
    // column is written without the column id prefix. Because more columns could
    // be added, it would be ambiguous which column was stored when read back in,
    // so this field supplies it.
    DefaultColumnID ColumnID `protobuf:"varint,5,opt,name=default_column_id,json=defaultColumnId,casttype=ColumnID" json:"default_column_id"`
}

ColumnFamilyDescriptor is set of columns stored together in one kv entry. For more information, look at `docs/tech-notes/encoding.md#value-encoding`.

func (*ColumnFamilyDescriptor) Descriptor Uses

func (*ColumnFamilyDescriptor) Descriptor() ([]byte, []int)

func (*ColumnFamilyDescriptor) Equal Uses

func (this *ColumnFamilyDescriptor) Equal(that interface{}) bool

func (*ColumnFamilyDescriptor) Marshal Uses

func (m *ColumnFamilyDescriptor) Marshal() (dAtA []byte, err error)

func (*ColumnFamilyDescriptor) MarshalTo Uses

func (m *ColumnFamilyDescriptor) MarshalTo(dAtA []byte) (int, error)

func (*ColumnFamilyDescriptor) ProtoMessage Uses

func (*ColumnFamilyDescriptor) ProtoMessage()

func (*ColumnFamilyDescriptor) Reset Uses

func (m *ColumnFamilyDescriptor) Reset()

func (*ColumnFamilyDescriptor) Size Uses

func (m *ColumnFamilyDescriptor) Size() (n int)

func (*ColumnFamilyDescriptor) String Uses

func (m *ColumnFamilyDescriptor) String() string

func (*ColumnFamilyDescriptor) Unmarshal Uses

func (m *ColumnFamilyDescriptor) Unmarshal(dAtA []byte) error

func (*ColumnFamilyDescriptor) XXX_DiscardUnknown Uses

func (m *ColumnFamilyDescriptor) XXX_DiscardUnknown()

func (*ColumnFamilyDescriptor) XXX_Marshal Uses

func (m *ColumnFamilyDescriptor) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ColumnFamilyDescriptor) XXX_Merge Uses

func (dst *ColumnFamilyDescriptor) XXX_Merge(src proto.Message)

func (*ColumnFamilyDescriptor) XXX_Size Uses

func (m *ColumnFamilyDescriptor) XXX_Size() int

func (*ColumnFamilyDescriptor) XXX_Unmarshal Uses

func (m *ColumnFamilyDescriptor) XXX_Unmarshal(b []byte) error

type ColumnID Uses

type ColumnID tree.ColumnID

ColumnID is a custom type for ColumnDescriptor IDs.

type ColumnIDs Uses

type ColumnIDs []ColumnID

ColumnIDs is a slice of ColumnDescriptor IDs.

func (ColumnIDs) Contains Uses

func (c ColumnIDs) Contains(i ColumnID) bool

Contains returns whether this list contains the input ID.

func (ColumnIDs) Equals Uses

func (c ColumnIDs) Equals(input ColumnIDs) bool

Equals returns true if the input list is equal to this list.

func (ColumnIDs) HasPrefix Uses

func (c ColumnIDs) HasPrefix(input ColumnIDs) bool

HasPrefix returns true if the input list is a prefix of this list.

func (ColumnIDs) Len Uses

func (c ColumnIDs) Len() int

func (ColumnIDs) Less Uses

func (c ColumnIDs) Less(i, j int) bool

func (ColumnIDs) Swap Uses

func (c ColumnIDs) Swap(i, j int)

type ColumnOrderInfo Uses

type ColumnOrderInfo struct {
    ColIdx    int
    Direction encoding.Direction
}

ColumnOrderInfo describes a column (as an index) and a desired order direction.

type ColumnOrdering Uses

type ColumnOrdering []ColumnOrderInfo

ColumnOrdering is used to describe a desired column ordering. For example,

[]ColumnOrderInfo{ {3, encoding.Descending}, {1, encoding.Ascending} }

represents an ordering first by column 3 (descending), then by column 1 (ascending).

var NoOrdering ColumnOrdering

NoOrdering is used to indicate an empty ColumnOrdering.

type ColumnResolver Uses

type ColumnResolver struct {
    Source *DataSourceInfo

    // ResolverState is modified in-place by the implementation of the
    // tree.ColumnItemResolver interface in resolver.go.
    ResolverState struct {
        ColIdx int
    }
}

ColumnResolver is a utility struct to be used when resolving column names to point to one of the data sources and one of the column IDs in that data source.

func (*ColumnResolver) FindSourceMatchingName Uses

func (r *ColumnResolver) FindSourceMatchingName(
    ctx context.Context, tn tree.TableName,
) (
    res tree.NumResolutionResults,
    prefix *tree.TableName,
    srcMeta tree.ColumnSourceMeta,
    err error,
)

FindSourceMatchingName is part of the tree.ColumnItemResolver interface.

func (*ColumnResolver) FindSourceProvidingColumn Uses

func (r *ColumnResolver) FindSourceProvidingColumn(
    ctx context.Context, col tree.Name,
) (prefix *tree.TableName, srcMeta tree.ColumnSourceMeta, colHint int, err error)

FindSourceProvidingColumn is part of the tree.ColumnItemResolver interface.

func (*ColumnResolver) Resolve Uses

func (r *ColumnResolver) Resolve(
    ctx context.Context,
    prefix *tree.TableName,
    srcMeta tree.ColumnSourceMeta,
    colHint int,
    col tree.Name,
) (tree.ColumnResolutionResult, error)

Resolve is part of the tree.ColumnItemResolver interface.

type ComputedColumnSwap Uses

type ComputedColumnSwap struct {
    NewColumnId ColumnID `protobuf:"varint,1,opt,name=new_column_id,json=newColumnId,casttype=ColumnID" json:"new_column_id"`
    OldColumnId ColumnID `protobuf:"varint,2,opt,name=old_column_id,json=oldColumnId,casttype=ColumnID" json:"old_column_id"`
    // inverse_expr is the expression used to compute values for the old column
    // once it is swapped for the new column.
    InverseExpr string `protobuf:"bytes,3,opt,name=inverse_expr,json=inverseExpr" json:"inverse_expr"`
}

ComputedColumnSwap is a mutation corresponding to the atomic swap phase where Column a' that is computed using Column a is swapped to replace Column a while Column a becomes computed using a'.

func (*ComputedColumnSwap) Descriptor Uses

func (*ComputedColumnSwap) Descriptor() ([]byte, []int)

func (*ComputedColumnSwap) Equal Uses

func (this *ComputedColumnSwap) Equal(that interface{}) bool

func (*ComputedColumnSwap) Marshal Uses

func (m *ComputedColumnSwap) Marshal() (dAtA []byte, err error)

func (*ComputedColumnSwap) MarshalTo Uses

func (m *ComputedColumnSwap) MarshalTo(dAtA []byte) (int, error)

func (*ComputedColumnSwap) ProtoMessage Uses

func (*ComputedColumnSwap) ProtoMessage()

func (*ComputedColumnSwap) Reset Uses

func (m *ComputedColumnSwap) Reset()

func (*ComputedColumnSwap) Size Uses

func (m *ComputedColumnSwap) Size() (n int)

func (*ComputedColumnSwap) String Uses

func (m *ComputedColumnSwap) String() string

func (*ComputedColumnSwap) Unmarshal Uses

func (m *ComputedColumnSwap) Unmarshal(dAtA []byte) error

func (*ComputedColumnSwap) XXX_DiscardUnknown Uses

func (m *ComputedColumnSwap) XXX_DiscardUnknown()

func (*ComputedColumnSwap) XXX_Marshal Uses

func (m *ComputedColumnSwap) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ComputedColumnSwap) XXX_Merge Uses

func (dst *ComputedColumnSwap) XXX_Merge(src proto.Message)

func (*ComputedColumnSwap) XXX_Size Uses

func (m *ComputedColumnSwap) XXX_Size() int

func (*ComputedColumnSwap) XXX_Unmarshal Uses

func (m *ComputedColumnSwap) XXX_Unmarshal(b []byte) error

type ConstraintDetail Uses

type ConstraintDetail struct {
    Kind        ConstraintType
    Columns     []string
    Details     string
    Unvalidated bool

    // Only populated for PK and Unique Constraints.
    Index *IndexDescriptor

    // Only populated for FK Constraints.
    FK              *ForeignKeyConstraint
    ReferencedTable *TableDescriptor

    // Only populated for Check Constraints.
    CheckConstraint *TableDescriptor_CheckConstraint
}

ConstraintDetail describes a constraint.

type ConstraintToUpdate Uses

type ConstraintToUpdate struct {
    ConstraintType ConstraintToUpdate_ConstraintType `protobuf:"varint,1,req,name=constraint_type,json=constraintType,enum=cockroach.sql.sqlbase.ConstraintToUpdate_ConstraintType" json:"constraint_type"`
    Name           string                            `protobuf:"bytes,2,req,name=name" json:"name"`
    Check          TableDescriptor_CheckConstraint   `protobuf:"bytes,3,opt,name=check" json:"check"`
    // All fields past 3 haven't been persisted before 19.2.
    ForeignKey    ForeignKeyConstraint `protobuf:"bytes,4,opt,name=foreign_key,json=foreignKey" json:"foreign_key"`
    NotNullColumn ColumnID             `protobuf:"varint,6,opt,name=not_null_column,json=notNullColumn,casttype=ColumnID" json:"not_null_column"`
}

ConstraintToUpdate represents a constraint to be added to the table and validated for existing rows. More generally, in the future, when we support adding constraints that are unvalidated for existing rows and can be validated later using VALIDATE CONSTRAINT, this mutation will also represent either adding an unvalidated constraint or validating an existing constraint.

This mutation effects changes only in the backfill step of the schema changer: First, a new version of the table descriptor with the constraint added is published, after all columns being added have been backfilled. After waiting for the constraint to be enforced for writes on all nodes, the constraint is then validated for all existing rows. This ensures that constraints added to columns that are being added are correctly enforced before the column becomes public.

func (*ConstraintToUpdate) Descriptor Uses

func (*ConstraintToUpdate) Descriptor() ([]byte, []int)

func (*ConstraintToUpdate) Equal Uses

func (this *ConstraintToUpdate) Equal(that interface{}) bool

func (*ConstraintToUpdate) Marshal Uses

func (m *ConstraintToUpdate) Marshal() (dAtA []byte, err error)

func (*ConstraintToUpdate) MarshalTo Uses

func (m *ConstraintToUpdate) MarshalTo(dAtA []byte) (int, error)

func (*ConstraintToUpdate) ProtoMessage Uses

func (*ConstraintToUpdate) ProtoMessage()

func (*ConstraintToUpdate) Reset Uses

func (m *ConstraintToUpdate) Reset()

func (*ConstraintToUpdate) Size Uses

func (m *ConstraintToUpdate) Size() (n int)

func (*ConstraintToUpdate) String Uses

func (m *ConstraintToUpdate) String() string

func (*ConstraintToUpdate) Unmarshal Uses

func (m *ConstraintToUpdate) Unmarshal(dAtA []byte) error

func (*ConstraintToUpdate) XXX_DiscardUnknown Uses

func (m *ConstraintToUpdate) XXX_DiscardUnknown()

func (*ConstraintToUpdate) XXX_Marshal Uses

func (m *ConstraintToUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ConstraintToUpdate) XXX_Merge Uses

func (dst *ConstraintToUpdate) XXX_Merge(src proto.Message)

func (*ConstraintToUpdate) XXX_Size Uses

func (m *ConstraintToUpdate) XXX_Size() int

func (*ConstraintToUpdate) XXX_Unmarshal Uses

func (m *ConstraintToUpdate) XXX_Unmarshal(b []byte) error

type ConstraintToUpdate_ConstraintType Uses

type ConstraintToUpdate_ConstraintType int32
const (
    ConstraintToUpdate_CHECK       ConstraintToUpdate_ConstraintType = 0
    ConstraintToUpdate_FOREIGN_KEY ConstraintToUpdate_ConstraintType = 1
    // NOT NULL constraints being added are represented by a dummy check
    // constraint so that a multi-state schema change, including a bulk
    // validation step, can occur. The check field contains the dummy
    // constraint.
    ConstraintToUpdate_NOT_NULL ConstraintToUpdate_ConstraintType = 2
)

func (ConstraintToUpdate_ConstraintType) Enum Uses

func (x ConstraintToUpdate_ConstraintType) Enum() *ConstraintToUpdate_ConstraintType

func (ConstraintToUpdate_ConstraintType) EnumDescriptor Uses

func (ConstraintToUpdate_ConstraintType) EnumDescriptor() ([]byte, []int)

func (ConstraintToUpdate_ConstraintType) String Uses

func (x ConstraintToUpdate_ConstraintType) String() string

func (*ConstraintToUpdate_ConstraintType) UnmarshalJSON Uses

func (x *ConstraintToUpdate_ConstraintType) UnmarshalJSON(data []byte) error

type ConstraintType Uses

type ConstraintType string

ConstraintType is used to identify the type of a constraint.

const (
    // ConstraintTypePK identifies a PRIMARY KEY constraint.
    ConstraintTypePK ConstraintType = "PRIMARY KEY"
    // ConstraintTypeFK identifies a FOREIGN KEY constraint.
    ConstraintTypeFK ConstraintType = "FOREIGN KEY"
    // ConstraintTypeUnique identifies a FOREIGN constraint.
    ConstraintTypeUnique ConstraintType = "UNIQUE"
    // ConstraintTypeCheck identifies a CHECK constraint.
    ConstraintTypeCheck ConstraintType = "CHECK"
)

type ConstraintValidity Uses

type ConstraintValidity int32
const (
    // The constraint is valid for all rows.
    ConstraintValidity_Validated ConstraintValidity = 0
    // The constraint has not yet been validated for all rows (and will not be
    // validated until VALIDATE CONSTRAINT is used).
    ConstraintValidity_Unvalidated ConstraintValidity = 1
    // The constraint was just added, but the validation for existing rows is not
    // yet complete. If validation fails, the constraint will be dropped.
    ConstraintValidity_Validating ConstraintValidity = 2
    // The constraint is being dropped in the schema changer.
    ConstraintValidity_Dropping ConstraintValidity = 3
)

func (ConstraintValidity) Enum Uses

func (x ConstraintValidity) Enum() *ConstraintValidity

func (ConstraintValidity) EnumDescriptor Uses

func (ConstraintValidity) EnumDescriptor() ([]byte, []int)

func (ConstraintValidity) String Uses

func (x ConstraintValidity) String() string

func (*ConstraintValidity) UnmarshalJSON Uses

func (x *ConstraintValidity) UnmarshalJSON(data []byte) error

type DataSourceInfo Uses

type DataSourceInfo struct {
    // SourceColumns match the plan.Columns() 1-to-1. However the column
    // names might be different if the statement renames them using AS.
    SourceColumns ResultColumns

    // SourceAlias indicates to which table the source columns belong.
    // This often corresponds to the original table names for each column but
    // might be different if the statement renames them using AS.
    SourceAlias tree.TableName
}

DataSourceInfo provides column metadata for exactly one data source.

func NewSourceInfoForSingleTable Uses

func NewSourceInfoForSingleTable(tn tree.TableName, columns ResultColumns) *DataSourceInfo

NewSourceInfoForSingleTable creates a simple DataSourceInfo which maps the same tableAlias to all columns.

func (*DataSourceInfo) NodeFormatter Uses

func (src *DataSourceInfo) NodeFormatter(colIdx int) tree.NodeFormatter

NodeFormatter returns a tree.NodeFormatter that, when formatted, represents the object at the input column index.

func (*DataSourceInfo) String Uses

func (src *DataSourceInfo) String() string

type DatabaseDescriptor Uses

type DatabaseDescriptor struct {
    Name string `protobuf:"bytes,1,opt,name=name" json:"name"`
    ID   ID     `protobuf:"varint,2,opt,name=id,casttype=ID" json:"id"`
    // Last modification time of the descriptor.
    ModificationTime hlc.Timestamp        `protobuf:"bytes,4,opt,name=modification_time,json=modificationTime" json:"modification_time"`
    Version          DescriptorVersion    `protobuf:"varint,5,opt,name=version,casttype=DescriptorVersion" json:"version"`
    DrainingNames    []NameInfo           `protobuf:"bytes,6,rep,name=draining_names,json=drainingNames" json:"draining_names"`
    Privileges       *PrivilegeDescriptor `protobuf:"bytes,3,opt,name=privileges" json:"privileges,omitempty"`
}

DatabaseDescriptor represents a namespace (aka database) and is stored in a structured metadata key. The DatabaseDescriptor has a globally-unique ID shared with other Descriptors. Permissions are applied to all tables in the namespace.

func (*DatabaseDescriptor) DatabaseDesc Uses

func (desc *DatabaseDescriptor) DatabaseDesc() *DatabaseDescriptor

DatabaseDesc implements the ObjectDescriptor interface.

func (*DatabaseDescriptor) Descriptor Uses

func (*DatabaseDescriptor) Descriptor() ([]byte, []int)

func (*DatabaseDescriptor) Equal Uses

func (this *DatabaseDescriptor) Equal(that interface{}) bool

func (*DatabaseDescriptor) GetDrainingNames Uses

func (m *DatabaseDescriptor) GetDrainingNames() []NameInfo

func (*DatabaseDescriptor) GetID Uses

func (m *DatabaseDescriptor) GetID() ID

func (*DatabaseDescriptor) GetModificationTime Uses

func (m *DatabaseDescriptor) GetModificationTime() hlc.Timestamp

func (*DatabaseDescriptor) GetName Uses

func (m *DatabaseDescriptor) GetName() string

func (*DatabaseDescriptor) GetPrivileges Uses

func (m *DatabaseDescriptor) GetPrivileges() *PrivilegeDescriptor

func (*DatabaseDescriptor) GetVersion Uses

func (m *DatabaseDescriptor) GetVersion() DescriptorVersion

func (*DatabaseDescriptor) Marshal Uses

func (m *DatabaseDescriptor) Marshal() (dAtA []byte, err error)

func (*DatabaseDescriptor) MarshalTo Uses

func (m *DatabaseDescriptor) MarshalTo(dAtA []byte) (int, error)

func (*DatabaseDescriptor) ProtoMessage Uses

func (*DatabaseDescriptor) ProtoMessage()

func (*DatabaseDescriptor) Reset Uses

func (m *DatabaseDescriptor) Reset()

func (*DatabaseDescriptor) SchemaDesc Uses

func (desc *DatabaseDescriptor) SchemaDesc() *SchemaDescriptor

SchemaDesc implements the ObjectDescriptor interface.

func (*DatabaseDescriptor) SchemaMeta Uses

func (*DatabaseDescriptor) SchemaMeta()

SchemaMeta implements the tree.SchemaMeta interface.

func (*DatabaseDescriptor) Size Uses

func (m *DatabaseDescriptor) Size() (n int)

func (*DatabaseDescriptor) String Uses

func (m *DatabaseDescriptor) String() string

func (*DatabaseDescriptor) TableDesc Uses

func (desc *DatabaseDescriptor) TableDesc() *TableDescriptor

TableDesc implements the ObjectDescriptor interface.

func (*DatabaseDescriptor) TypeDesc Uses

func (desc *DatabaseDescriptor) TypeDesc() *TypeDescriptor

TypeDesc implements the ObjectDescriptor interface.

func (*DatabaseDescriptor) TypeName Uses

func (desc *DatabaseDescriptor) TypeName() string

TypeName returns the plain type of this descriptor.

func (*DatabaseDescriptor) Unmarshal Uses

func (m *DatabaseDescriptor) Unmarshal(dAtA []byte) error

func (*DatabaseDescriptor) XXX_DiscardUnknown Uses

func (m *DatabaseDescriptor) XXX_DiscardUnknown()

func (*DatabaseDescriptor) XXX_Marshal Uses

func (m *DatabaseDescriptor) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*DatabaseDescriptor) XXX_Merge Uses

func (dst *DatabaseDescriptor) XXX_Merge(src proto.Message)

func (*DatabaseDescriptor) XXX_Size Uses

func (m *DatabaseDescriptor) XXX_Size() int

func (*DatabaseDescriptor) XXX_Unmarshal Uses

func (m *DatabaseDescriptor) XXX_Unmarshal(b []byte) error

type DatabaseDescriptorInterface Uses

type DatabaseDescriptorInterface interface {
    BaseDescriptorInterface
    DatabaseDesc() *DatabaseDescriptor
}

DatabaseDescriptorInterface will eventually be called dbdesc.Descriptor. It is implemented by ImmutableDatabaseDescriptor.

type DatabaseKey Uses

type DatabaseKey struct {
    // contains filtered or unexported fields
}

DatabaseKey implements DescriptorKey.

func NewDatabaseKey Uses

func NewDatabaseKey(name string) DatabaseKey

NewDatabaseKey returns a new DatabaseKey.

func (DatabaseKey) Key Uses

func (dk DatabaseKey) Key(codec keys.SQLCodec) roachpb.Key

Key implements DescriptorKey interface.

func (DatabaseKey) Name Uses

func (dk DatabaseKey) Name() string

Name implements DescriptorKey interface.

type DatumAlloc Uses

type DatumAlloc struct {

    // AllocSize determines the number of objects allocated whenever we've used
    // up previously allocated ones. This field is exported so that the caller
    // could adjust it dynamically. If it is left unchanged by the caller, then
    // it will be set to defaultDatumAllocSize automatically.
    AllocSize int
    // contains filtered or unexported fields
}

DatumAlloc provides batch allocation of datum pointers, amortizing the cost of the allocations. NOTE: it *must* be passed in by a pointer.

func (*DatumAlloc) NewDBitArray Uses

func (a *DatumAlloc) NewDBitArray(v tree.DBitArray) *tree.DBitArray

NewDBitArray allocates a DBitArray.

func (*DatumAlloc) NewDBytes Uses

func (a *DatumAlloc) NewDBytes(v tree.DBytes) *tree.DBytes

NewDBytes allocates a DBytes.

func (*DatumAlloc) NewDDate Uses

func (a *DatumAlloc) NewDDate(v tree.DDate) *tree.DDate

NewDDate allocates a DDate.

func (*DatumAlloc) NewDDecimal Uses

func (a *DatumAlloc) NewDDecimal(v tree.DDecimal) *tree.DDecimal

NewDDecimal allocates a DDecimal.

func (*DatumAlloc) NewDEnum Uses

func (a *DatumAlloc) NewDEnum(v tree.DEnum) *tree.DEnum

NewDEnum allocates a DEnum.

func (*DatumAlloc) NewDFloat Uses

func (a *DatumAlloc) NewDFloat(v tree.DFloat) *tree.DFloat

NewDFloat allocates a DFloat.

func (*DatumAlloc) NewDGeography Uses

func (a *DatumAlloc) NewDGeography(v tree.DGeography) *tree.DGeography

NewDGeography allocates a DGeography.

func (*DatumAlloc) NewDGeometry Uses

func (a *DatumAlloc) NewDGeometry(v tree.DGeometry) *tree.DGeometry

NewDGeometry allocates a DGeometry.

func (*DatumAlloc) NewDIPAddr Uses

func (a *DatumAlloc) NewDIPAddr(v tree.DIPAddr) *tree.DIPAddr

NewDIPAddr allocates a DIPAddr.

func (*DatumAlloc) NewDInt Uses

func (a *DatumAlloc) NewDInt(v tree.DInt) *tree.DInt

NewDInt allocates a DInt.

func (*DatumAlloc) NewDInterval Uses

func (a *DatumAlloc) NewDInterval(v tree.DInterval) *tree.DInterval

NewDInterval allocates a DInterval.

func (*DatumAlloc) NewDJSON Uses

func (a *DatumAlloc) NewDJSON(v tree.DJSON) *tree.DJSON

NewDJSON allocates a DJSON.

func (*DatumAlloc) NewDName Uses

func (a *DatumAlloc) NewDName(v tree.DString) tree.Datum

NewDName allocates a DName.

func (*DatumAlloc) NewDOid Uses

func (a *DatumAlloc) NewDOid(v tree.DOid) tree.Datum

NewDOid allocates a DOid.

func (*DatumAlloc) NewDString Uses

func (a *DatumAlloc) NewDString(v tree.DString) *tree.DString

NewDString allocates a DString.

func (*DatumAlloc) NewDTime Uses

func (a *DatumAlloc) NewDTime(v tree.DTime) *tree.DTime

NewDTime allocates a DTime.

func (*DatumAlloc) NewDTimeTZ Uses

func (a *DatumAlloc) NewDTimeTZ(v tree.DTimeTZ) *tree.DTimeTZ

NewDTimeTZ allocates a DTimeTZ.

func (*DatumAlloc) NewDTimestamp Uses

func (a *DatumAlloc) NewDTimestamp(v tree.DTimestamp) *tree.DTimestamp

NewDTimestamp allocates a DTimestamp.

func (*DatumAlloc) NewDTimestampTZ Uses

func (a *DatumAlloc) NewDTimestampTZ(v tree.DTimestampTZ) *tree.DTimestampTZ

NewDTimestampTZ allocates a DTimestampTZ.

func (*DatumAlloc) NewDTuple Uses

func (a *DatumAlloc) NewDTuple(v tree.DTuple) *tree.DTuple

NewDTuple allocates a DTuple.

func (*DatumAlloc) NewDUuid Uses

func (a *DatumAlloc) NewDUuid(v tree.DUuid) *tree.DUuid

NewDUuid allocates a DUuid.

func (*DatumAlloc) NewDatums Uses

func (a *DatumAlloc) NewDatums(num int) tree.Datums

NewDatums allocates Datums of the specified size.

type DatumEncoding Uses

type DatumEncoding int32

DatumEncoding identifies the encoding used for an EncDatum.

const (
    // Indicates that the datum is encoded using the order-preserving encoding
    // used for keys (ascending order).
    DatumEncoding_ASCENDING_KEY DatumEncoding = 0
    // Indicates that the datum is encoded using the order-preserving encoding
    // used for keys (descending order).
    DatumEncoding_DESCENDING_KEY DatumEncoding = 1
    // Indicates that the datum is encoded using the encoding used for values.
    DatumEncoding_VALUE DatumEncoding = 2
)

func EncodingDirToDatumEncoding Uses

func EncodingDirToDatumEncoding(dir encoding.Direction) DatumEncoding

EncodingDirToDatumEncoding returns an equivalent DatumEncoding for the given encoding direction.

func RandDatumEncoding Uses

func RandDatumEncoding(rng *rand.Rand) DatumEncoding

RandDatumEncoding returns a random DatumEncoding value.

func (DatumEncoding) Enum Uses

func (x DatumEncoding) Enum() *DatumEncoding

func (DatumEncoding) EnumDescriptor Uses

func (DatumEncoding) EnumDescriptor() ([]byte, []int)

func (DatumEncoding) String Uses

func (x DatumEncoding) String() string

func (*DatumEncoding) UnmarshalJSON Uses

func (x *DatumEncoding) UnmarshalJSON(data []byte) error

type DeprecatedDatabaseKey Uses

type DeprecatedDatabaseKey struct {
    // contains filtered or unexported fields
}

DeprecatedDatabaseKey implements DescriptorKey interface.

func NewDeprecatedDatabaseKey Uses

func NewDeprecatedDatabaseKey(name string) DeprecatedDatabaseKey

NewDeprecatedDatabaseKey returns a new DeprecatedDatabaseKey

func (DeprecatedDatabaseKey) Key Uses

func (ddk DeprecatedDatabaseKey) Key(codec keys.SQLCodec) roachpb.Key

Key implements DescriptorKey interface.

func (DeprecatedDatabaseKey) Name Uses

func (ddk DeprecatedDatabaseKey) Name() string

Name implements DescriptorKey interface.

type DeprecatedTableKey Uses

type DeprecatedTableKey struct {
    // contains filtered or unexported fields
}

DeprecatedTableKey implements DescriptorKey interface.

func NewDeprecatedTableKey Uses

func NewDeprecatedTableKey(parentID ID, name string) DeprecatedTableKey

NewDeprecatedTableKey returns a new DeprecatedTableKey

func (DeprecatedTableKey) Key Uses

func (dtk DeprecatedTableKey) Key(codec keys.SQLCodec) roachpb.Key

Key implements DescriptorKey interface.

func (DeprecatedTableKey) Name Uses

func (dtk DeprecatedTableKey) Name() string

Name implements DescriptorKey interface.

type Descriptor Uses

type Descriptor struct {
    // Types that are valid to be assigned to Union:
    //	*Descriptor_Table
    //	*Descriptor_Database
    //	*Descriptor_Type
    //	*Descriptor_Schema
    Union isDescriptor_Union `protobuf_oneof:"union"`
}

Descriptor is a union type for descriptors for tables, schemas, databases, and types.

func (*Descriptor) Descriptor Uses

func (*Descriptor) Descriptor() ([]byte, []int)

func (*Descriptor) Equal Uses

func (this *Descriptor) Equal(that interface{}) bool

func (*Descriptor) GetDatabase Uses

func (m *Descriptor) GetDatabase() *DatabaseDescriptor

func (*Descriptor) GetID Uses

func (desc *Descriptor) GetID() ID

GetID returns the ID of the descriptor.

func (*Descriptor) GetModificationTime Uses

func (desc *Descriptor) GetModificationTime() hlc.Timestamp

GetModificationTime returns the ModificationTime of the descriptor.

func (*Descriptor) GetName Uses

func (desc *Descriptor) GetName() string

GetName returns the Name of the descriptor.

func (*Descriptor) GetSchema Uses

func (m *Descriptor) GetSchema() *SchemaDescriptor

func (*Descriptor) GetTable Uses

func (m *Descriptor) GetTable() *TableDescriptor

func (*Descriptor) GetType Uses

func (m *Descriptor) GetType() *TypeDescriptor

func (*Descriptor) GetUnion Uses

func (m *Descriptor) GetUnion() isDescriptor_Union

func (*Descriptor) GetVersion Uses

func (desc *Descriptor) GetVersion() DescriptorVersion

GetVersion returns the Version of the descriptor.

func (*Descriptor) Marshal Uses

func (m *Descriptor) Marshal() (dAtA []byte, err error)

func (*Descriptor) MarshalTo Uses

func (m *Descriptor) MarshalTo(dAtA []byte) (int, error)

func (*Descriptor) MaybeSetModificationTimeFromMVCCTimestamp Uses

func (desc *Descriptor) MaybeSetModificationTimeFromMVCCTimestamp(
    ctx context.Context, ts hlc.Timestamp,
)

MaybeSetModificationTimeFromMVCCTimestamp will update ModificationTime and possibly CreateAsOfTime on TableDescriptor with the provided timestamp. If ModificationTime is non-zero it must be the case that it is not after the provided timestamp.

When table descriptor versions are incremented they are written with a zero-valued ModificationTime. This is done to avoid the need to observe the commit timestamp for the writing transaction which would prevent pushes. This method is used in the read path to set the modification time based on the MVCC timestamp of row which contained this descriptor. If the ModificationTime is non-zero then we know that either this table descriptor was written by older version of cockroach which included the exact commit timestamp or it was re-written in which case it will include a timestamp which was set by this method.

It is vital that users which read table descriptor values from the KV store call this method.

func (Descriptor) NameResolutionResult Uses

func (Descriptor) NameResolutionResult()

NameResolutionResult implements the tree.NameResolutionResult interface.

func (*Descriptor) ProtoMessage Uses

func (*Descriptor) ProtoMessage()

func (*Descriptor) Reset Uses

func (m *Descriptor) Reset()

func (Descriptor) SchemaMeta Uses

func (Descriptor) SchemaMeta()

SchemaMeta implements the tree.SchemaMeta interface.

func (*Descriptor) Size Uses

func (m *Descriptor) Size() (n int)

func (*Descriptor) String Uses

func (m *Descriptor) String() string

func (*Descriptor) Table Uses

func (desc *Descriptor) Table(ts hlc.Timestamp) *TableDescriptor

Table is a replacement for GetTable() which seeks to ensure that clients which unmarshal Descriptor structs properly set the ModificationTime on tables based on the MVCC timestamp at which the descriptor was read.

A linter should ensure that GetTable() is not called.

func (*Descriptor) Unmarshal Uses

func (m *Descriptor) Unmarshal(dAtA []byte) error

func (*Descriptor) XXX_DiscardUnknown Uses

func (m *Descriptor) XXX_DiscardUnknown()

func (*Descriptor) XXX_Marshal Uses

func (m *Descriptor) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Descriptor) XXX_Merge Uses

func (dst *Descriptor) XXX_Merge(src proto.Message)

func (*Descriptor) XXX_OneofFuncs Uses

func (*Descriptor) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{})

XXX_OneofFuncs is for the internal use of the proto package.

func (*Descriptor) XXX_Size Uses

func (m *Descriptor) XXX_Size() int

func (*Descriptor) XXX_Unmarshal Uses

func (m *Descriptor) XXX_Unmarshal(b []byte) error

type DescriptorInterface Uses

type DescriptorInterface interface {
    BaseDescriptorInterface

    // DatabaseDesc returns the underlying database descriptor, or nil if the
    // descriptor is not a table backed object.
    DatabaseDesc() *DatabaseDescriptor

    // SchemaDesc returns the underlying schema descriptor, or nil if the
    // descriptor is not a table backed object.
    SchemaDesc() *SchemaDescriptor

    // TableDesc returns the underlying table descriptor, or nil if the
    // descriptor is not a table backed object.
    TableDesc() *TableDescriptor

    // TypeDesc returns the underlying type descriptor, or nil if the
    // descriptor is not a type backed object.
    TypeDesc() *TypeDescriptor
}

DescriptorInterface provides table information for results from a name lookup.

TODO(ajwerner): Move this back to catalog after sqlbase has been appropriately cleaned up. Furthermore, reconsider whether this interface actually makes much sense. It may make more sense to instead type assert into the individual descriptor type interfaces which we'll be introducing.

type DescriptorKey Uses

type DescriptorKey interface {
    Key(codec keys.SQLCodec) roachpb.Key
    Name() string
}

DescriptorKey is the interface implemented by both databaseKey and tableKey. It is used to easily get the descriptor key and plain name.

func MakeDatabaseNameKey Uses

func MakeDatabaseNameKey(
    ctx context.Context, settings *cluster.Settings, name string,
) DescriptorKey

MakeDatabaseNameKey is a wrapper around MakeObjectNameKey for databases.

func MakeObjectNameKey Uses

func MakeObjectNameKey(
    ctx context.Context, settings *cluster.Settings, parentID ID, parentSchemaID ID, name string,
) DescriptorKey

MakeObjectNameKey returns a key in the system.namespace table for a given parentID and name, based on the cluster version. - If cluster version >= 20.1, the key is in the new system.namespace table. - If cluster version < 20.1, the key is in the deprecated system.namespace table. - The parentSchemaID field is ignored in < 20.1 clusters.

func MakePublicTableNameKey Uses

func MakePublicTableNameKey(
    ctx context.Context, settings *cluster.Settings, parentID ID, name string,
) DescriptorKey

MakePublicTableNameKey is a wrapper around MakeObjectNameKey for public tables.

type DescriptorMutation Uses

type DescriptorMutation struct {
    // Types that are valid to be assigned to Descriptor_:
    //	*DescriptorMutation_Column
    //	*DescriptorMutation_Index
    //	*DescriptorMutation_Constraint
    //	*DescriptorMutation_PrimaryKeySwap
    //	*DescriptorMutation_ComputedColumnSwap
    Descriptor_ isDescriptorMutation_Descriptor_ `protobuf_oneof:"descriptor"`
    State       DescriptorMutation_State         `protobuf:"varint,3,opt,name=state,enum=cockroach.sql.sqlbase.DescriptorMutation_State" json:"state"`
    Direction   DescriptorMutation_Direction     `protobuf:"varint,4,opt,name=direction,enum=cockroach.sql.sqlbase.DescriptorMutation_Direction" json:"direction"`
    // The mutation id used to group mutations that should be applied together.
    // This is used for situations like creating a unique column, which
    // involve adding two mutations: one for the column, and another for the
    // unique constraint index.
    MutationID MutationID `protobuf:"varint,5,opt,name=mutation_id,json=mutationId,casttype=MutationID" json:"mutation_id"`
    // Indicates that this mutation is a rollback.
    Rollback bool `protobuf:"varint,7,opt,name=rollback" json:"rollback"`
}

A DescriptorMutation represents a column or an index that has either been added or dropped and hasn't yet transitioned into a stable state: completely backfilled and visible, or completely deleted. A table descriptor in the middle of a schema change will have a DescriptorMutation FIFO queue containing each column/index descriptor being added or dropped. Mutations for constraints work differently from columns and indexes; see the documentation for ConstraintToUpdate.

func (*DescriptorMutation) Descriptor Uses

func (*DescriptorMutation) Descriptor() ([]byte, []int)

func (*DescriptorMutation) Equal Uses

func (this *DescriptorMutation) Equal(that interface{}) bool

func (*DescriptorMutation) GetColumn Uses

func (m *DescriptorMutation) GetColumn() *ColumnDescriptor

func (*DescriptorMutation) GetComputedColumnSwap Uses

func (m *DescriptorMutation) GetComputedColumnSwap() *ComputedColumnSwap

func (*DescriptorMutation) GetConstraint Uses

func (m *DescriptorMutation) GetConstraint() *ConstraintToUpdate

func (*DescriptorMutation) GetDescriptor_ Uses

func (m *DescriptorMutation) GetDescriptor_() isDescriptorMutation_Descriptor_

func (*DescriptorMutation) GetIndex Uses

func (m *DescriptorMutation) GetIndex() *IndexDescriptor

func (*DescriptorMutation) GetPrimaryKeySwap Uses

func (m *DescriptorMutation) GetPrimaryKeySwap() *PrimaryKeySwap

func (*DescriptorMutation) Marshal Uses

func (m *DescriptorMutation) Marshal() (dAtA []byte, err error)

func (*DescriptorMutation) MarshalTo Uses

func (m *DescriptorMutation) MarshalTo(dAtA []byte) (int, error)

func (*DescriptorMutation) ProtoMessage Uses

func (*DescriptorMutation) ProtoMessage()

func (*DescriptorMutation) Reset Uses

func (m *DescriptorMutation) Reset()

func (*DescriptorMutation) Size Uses

func (m *DescriptorMutation) Size() (n int)

func (*DescriptorMutation) String Uses

func (m *DescriptorMutation) String() string

func (*DescriptorMutation) Unmarshal Uses

func (m *DescriptorMutation) Unmarshal(dAtA []byte) error

func (*DescriptorMutation) XXX_DiscardUnknown Uses

func (m *DescriptorMutation) XXX_DiscardUnknown()

func (*DescriptorMutation) XXX_Marshal Uses

func (m *DescriptorMutation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*DescriptorMutation) XXX_Merge Uses

func (dst *DescriptorMutation) XXX_Merge(src proto.Message)

func (*DescriptorMutation) XXX_OneofFuncs Uses

func (*DescriptorMutation) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{})

XXX_OneofFuncs is for the internal use of the proto package.

func (*DescriptorMutation) XXX_Size Uses

func (m *DescriptorMutation) XXX_Size() int

func (*DescriptorMutation) XXX_Unmarshal Uses

func (m *DescriptorMutation) XXX_Unmarshal(b []byte) error

type DescriptorMutation_Column Uses

type DescriptorMutation_Column struct {
    Column *ColumnDescriptor `protobuf:"bytes,1,opt,name=column,oneof"`
}

func (*DescriptorMutation_Column) Equal Uses

func (this *DescriptorMutation_Column) Equal(that interface{}) bool

func (*DescriptorMutation_Column) MarshalTo Uses

func (m *DescriptorMutation_Column) MarshalTo(dAtA []byte) (int, error)

func (*DescriptorMutation_Column) Size Uses

func (m *DescriptorMutation_Column) Size() (n int)

type DescriptorMutation_ComputedColumnSwap Uses

type DescriptorMutation_ComputedColumnSwap struct {
    ComputedColumnSwap *ComputedColumnSwap `protobuf:"bytes,10,opt,name=computedColumnSwap,oneof"`
}

func (*DescriptorMutation_ComputedColumnSwap) Equal Uses

func (this *DescriptorMutation_ComputedColumnSwap) Equal(that interface{}) bool

func (*DescriptorMutation_ComputedColumnSwap) MarshalTo Uses

func (m *DescriptorMutation_ComputedColumnSwap) MarshalTo(dAtA []byte) (int, error)

func (*DescriptorMutation_ComputedColumnSwap) Size Uses

func (m *DescriptorMutation_ComputedColumnSwap) Size() (n int)

type DescriptorMutation_Constraint Uses

type DescriptorMutation_Constraint struct {
    Constraint *ConstraintToUpdate `protobuf:"bytes,8,opt,name=constraint,oneof"`
}

func (*DescriptorMutation_Constraint) Equal Uses

func (this *DescriptorMutation_Constraint) Equal(that interface{}) bool

func (*DescriptorMutation_Constraint) MarshalTo Uses

func (m *DescriptorMutation_Constraint) MarshalTo(dAtA []byte) (int, error)

func (*DescriptorMutation_Constraint) Size Uses

func (m *DescriptorMutation_Constraint) Size() (n int)

type DescriptorMutation_Direction Uses

type DescriptorMutation_Direction int32

Direction of mutation.

const (
    // Not used.
    DescriptorMutation_NONE DescriptorMutation_Direction = 0
    // Descriptor is being added.
    DescriptorMutation_ADD DescriptorMutation_Direction = 1
    // Descriptor is being dropped.
    DescriptorMutation_DROP DescriptorMutation_Direction = 2
)

func (DescriptorMutation_Direction) Enum Uses

func (x DescriptorMutation_Direction) Enum() *DescriptorMutation_Direction

func (DescriptorMutation_Direction) EnumDescriptor Uses

func (DescriptorMutation_Direction) EnumDescriptor() ([]byte, []int)

func (DescriptorMutation_Direction) String Uses

func (x DescriptorMutation_Direction) String() string

func (*DescriptorMutation_Direction) UnmarshalJSON Uses

func (x *DescriptorMutation_Direction) UnmarshalJSON(data []byte) error

type DescriptorMutation_Index Uses

type DescriptorMutation_Index struct {
    Index *IndexDescriptor `protobuf:"bytes,2,opt,name=index,oneof"`
}

func (*DescriptorMutation_Index) Equal Uses

func (this *DescriptorMutation_Index) Equal(that interface{}) bool

func (*DescriptorMutation_Index) MarshalTo Uses

func (m *DescriptorMutation_Index) MarshalTo(dAtA []byte) (int, error)

func (*DescriptorMutation_Index) Size Uses

func (m *DescriptorMutation_Index) Size() (n int)

type DescriptorMutation_PrimaryKeySwap Uses

type DescriptorMutation_PrimaryKeySwap struct {
    PrimaryKeySwap *PrimaryKeySwap `protobuf:"bytes,9,opt,name=primaryKeySwap,oneof"`
}

func (*DescriptorMutation_PrimaryKeySwap) Equal Uses

func (this *DescriptorMutation_PrimaryKeySwap) Equal(that interface{}) bool

func (*DescriptorMutation_PrimaryKeySwap) MarshalTo Uses

func (m *DescriptorMutation_PrimaryKeySwap) MarshalTo(dAtA []byte) (int, error)

func (*DescriptorMutation_PrimaryKeySwap) Size Uses

func (m *DescriptorMutation_PrimaryKeySwap) Size() (n int)

type DescriptorMutation_State Uses

type DescriptorMutation_State int32

A descriptor within a mutation is unavailable for reads, writes and deletes. It is only available for implicit (internal to the database) writes and deletes depending on the state of the mutation.

const (
    // Not used.
    DescriptorMutation_UNKNOWN DescriptorMutation_State = 0
    // Operations can use this invisible descriptor to implicitly
    // delete entries.
    // Column: A descriptor in this state is invisible to
    // INSERT and UPDATE. DELETE must delete a column in this state.
    // Index: A descriptor in this state is invisible to an INSERT.
    // UPDATE must delete the old value of the index but doesn't write
    // the new value. DELETE must delete the index.
    //
    // When deleting a descriptor, all descriptor related data
    // (column or index data) can only be mass deleted once
    // all the nodes have transitioned to the DELETE_ONLY state.
    DescriptorMutation_DELETE_ONLY DescriptorMutation_State = 1
    // Operations can use this invisible descriptor to implicitly
    // write and delete entries.
    // Column: INSERT will populate this column with the default
    // value. UPDATE ignores this descriptor. DELETE must delete
    // the column.
    // Index: INSERT, UPDATE and DELETE treat this index like any
    // other index.
    //
    // When adding a descriptor, all descriptor related data
    // (column default or index data) can only be backfilled once
    // all nodes have transitioned into the DELETE_AND_WRITE_ONLY state.
    DescriptorMutation_DELETE_AND_WRITE_ONLY DescriptorMutation_State = 2
)

func (DescriptorMutation_State) Enum Uses

func (x DescriptorMutation_State) Enum() *DescriptorMutation_State

func (DescriptorMutation_State) EnumDescriptor Uses

func (DescriptorMutation_State) EnumDescriptor() ([]byte, []int)

func (DescriptorMutation_State) String Uses

func (x DescriptorMutation_State) String() string

func (*DescriptorMutation_State) UnmarshalJSON Uses

func (x *DescriptorMutation_State) UnmarshalJSON(data []byte) error

type DescriptorVersion Uses

type DescriptorVersion uint32

DescriptorVersion is a custom type for TableDescriptor Versions.

type Descriptor_Database Uses

type Descriptor_Database struct {
    Database *DatabaseDescriptor `protobuf:"bytes,2,opt,name=database,oneof"`
}

func (*Descriptor_Database) Equal Uses

func (this *Descriptor_Database) Equal(that interface{}) bool

func (*Descriptor_Database) MarshalTo Uses

func (m *Descriptor_Database) MarshalTo(dAtA []byte) (int, error)

func (*Descriptor_Database) Size Uses

func (m *Descriptor_Database) Size() (n int)

type Descriptor_Schema Uses

type Descriptor_Schema struct {
    Schema *SchemaDescriptor `protobuf:"bytes,4,opt,name=schema,oneof"`
}

func (*Descriptor_Schema) Equal Uses

func (this *Descriptor_Schema) Equal(that interface{}) bool

func (*Descriptor_Schema) MarshalTo Uses

func (m *Descriptor_Schema) MarshalTo(dAtA []byte) (int, error)

func (*Descriptor_Schema) Size Uses

func (m *Descriptor_Schema) Size() (n int)

type Descriptor_Table Uses

type Descriptor_Table struct {
    Table *TableDescriptor `protobuf:"bytes,1,opt,name=table,oneof"`
}

func (*Descriptor_Table) Equal Uses

func (this *Descriptor_Table) Equal(that interface{}) bool

func (*Descriptor_Table) MarshalTo Uses

func (m *Descriptor_Table) MarshalTo(dAtA []byte) (int, error)

func (*Descriptor_Table) Size Uses

func (m *Descriptor_Table) Size() (n int)

type Descriptor_Type Uses

type Descriptor_Type struct {
    Type *TypeDescriptor `protobuf:"bytes,3,opt,name=type,oneof"`
}

func (*Descriptor_Type) Equal Uses

func (this *Descriptor_Type) Equal(that interface{}) bool

func (*Descriptor_Type) MarshalTo Uses

func (m *Descriptor_Type) MarshalTo(dAtA []byte) (int, error)

func (*Descriptor_Type) Size Uses

func (m *Descriptor_Type) Size() (n int)

type DummyClientNoticeSender Uses

type DummyClientNoticeSender struct{}

DummyClientNoticeSender implements the tree.ClientNoticeSender interface.

func (*DummyClientNoticeSender) SendClientNotice Uses

func (c *DummyClientNoticeSender) SendClientNotice(context.Context, error)

SendClientNotice is part of the tree.ClientNoticeSender interface.

type DummyEvalPlanner Uses

type DummyEvalPlanner struct{}

DummyEvalPlanner implements the tree.EvalPlanner interface by returning errors.

func (*DummyEvalPlanner) EvalSubquery Uses

func (ep *DummyEvalPlanner) EvalSubquery(expr *tree.Subquery) (tree.Datum, error)

EvalSubquery is part of the tree.EvalPlanner interface.

func (*DummyEvalPlanner) LookupSchema Uses

func (ep *DummyEvalPlanner) LookupSchema(
    ctx context.Context, dbName, scName string,
) (bool, tree.SchemaMeta, error)

LookupSchema is part of the tree.EvalDatabase interface.

func (*DummyEvalPlanner) ParseQualifiedTableName Uses

func (ep *DummyEvalPlanner) ParseQualifiedTableName(sql string) (*tree.TableName, error)

ParseQualifiedTableName is part of the tree.EvalDatabase interface.

func (*DummyEvalPlanner) ParseType Uses

func (ep *DummyEvalPlanner) ParseType(sql string) (*types.T, error)

ParseType is part of the tree.EvalPlanner interface.

func (*DummyEvalPlanner) ResolveTableName Uses

func (ep *DummyEvalPlanner) ResolveTableName(
    ctx context.Context, tn *tree.TableName,
) (tree.ID, error)

ResolveTableName is part of the tree.EvalDatabase interface.

type DummyPrivilegedAccessor Uses

type DummyPrivilegedAccessor struct{}

DummyPrivilegedAccessor implements the tree.PrivilegedAccessor interface by returning errors.

func (*DummyPrivilegedAccessor) LookupNamespaceID Uses

func (ep *DummyPrivilegedAccessor) LookupNamespaceID(
    ctx context.Context, parentID int64, name string,
) (tree.DInt, bool, error)

LookupNamespaceID is part of the tree.PrivilegedAccessor interface.

func (*DummyPrivilegedAccessor) LookupZoneConfigByNamespaceID Uses

func (ep *DummyPrivilegedAccessor) LookupZoneConfigByNamespaceID(
    ctx context.Context, id int64,
) (tree.DBytes, bool, error)

LookupZoneConfigByNamespaceID is part of the tree.PrivilegedAccessor interface.

type DummySequenceOperators Uses

type DummySequenceOperators struct{}

DummySequenceOperators implements the tree.SequenceOperators interface by returning errors.

func (*DummySequenceOperators) GetLatestValueInSessionForSequence Uses

func (so *DummySequenceOperators) GetLatestValueInSessionForSequence(
    ctx context.Context, seqName *tree.TableName,
) (int64, error)

GetLatestValueInSessionForSequence implements the tree.SequenceOperators interface.

func (*DummySequenceOperators) IncrementSequence Uses

func (so *DummySequenceOperators) IncrementSequence(
    ctx context.Context, seqName *tree.TableName,
) (int64, error)

IncrementSequence is part of the tree.SequenceOperators interface.

func (*DummySequenceOperators) LookupSchema Uses

func (so *DummySequenceOperators) LookupSchema(
    ctx context.Context, dbName, scName string,
) (bool, tree.SchemaMeta, error)

LookupSchema is part of the tree.EvalDatabase interface.

func (*DummySequenceOperators) ParseQualifiedTableName Uses

func (so *DummySequenceOperators) ParseQualifiedTableName(sql string) (*tree.TableName, error)

ParseQualifiedTableName is part of the tree.EvalDatabase interface.

func (*DummySequenceOperators) ResolveTableName Uses

func (so *DummySequenceOperators) ResolveTableName(
    ctx context.Context, tn *tree.TableName,
) (tree.ID, error)

ResolveTableName is part of the tree.EvalDatabase interface.

func (*DummySequenceOperators) SetSequenceValue Uses

func (so *DummySequenceOperators) SetSequenceValue(
    ctx context.Context, seqName *tree.TableName, newVal int64, isCalled bool,
) error

SetSequenceValue implements the tree.SequenceOperators interface.

type DummySessionAccessor Uses

type DummySessionAccessor struct{}

DummySessionAccessor implements the tree.EvalSessionAccessor interface by returning errors.

func (*DummySessionAccessor) GetSessionVar Uses

func (ep *DummySessionAccessor) GetSessionVar(
    _ context.Context, _ string, _ bool,
) (bool, string, error)

GetSessionVar is part of the tree.EvalSessionAccessor interface.

func (*DummySessionAccessor) HasAdminRole Uses

func (ep *DummySessionAccessor) HasAdminRole(_ context.Context) (bool, error)

HasAdminRole is part of the tree.EvalSessionAccessor interface.

func (*DummySessionAccessor) SetSessionVar Uses

func (ep *DummySessionAccessor) SetSessionVar(_ context.Context, _, _ string) error

SetSessionVar is part of the tree.EvalSessionAccessor interface.

type DummyTenantOperator Uses

type DummyTenantOperator struct{}

DummyTenantOperator implements the tree.TenantOperator interface.

func (*DummyTenantOperator) CreateTenant Uses

func (c *DummyTenantOperator) CreateTenant(_ context.Context, _ uint64, _ []byte) error

CreateTenant is part of the tree.TenantOperator interface.

func (*DummyTenantOperator) DestroyTenant Uses

func (c *DummyTenantOperator) DestroyTenant(_ context.Context, _ uint64) error

DestroyTenant is part of the tree.TenantOperator interface.

type EncDatum Uses

type EncDatum struct {

    // Decoded datum.
    Datum tree.Datum
    // contains filtered or unexported fields
}

EncDatum represents a datum that is "backed" by an encoding and/or by a tree.Datum. It allows "passing through" a Datum without decoding and reencoding.

func DatumToEncDatum Uses

func DatumToEncDatum(ctyp *types.T, d tree.Datum) EncDatum

DatumToEncDatum initializes an EncDatum with the given Datum.

func EncDatumFromBuffer Uses

func EncDatumFromBuffer(typ *types.T, enc DatumEncoding, buf []byte) (EncDatum, []byte, error)

EncDatumFromBuffer initializes an EncDatum with an encoding that is possibly followed by other data. Similar to EncDatumFromEncoded, except that this function figures out where the encoding stops and returns a slice for the rest of the buffer.

func EncDatumFromEncoded Uses

func EncDatumFromEncoded(enc DatumEncoding, encoded []byte) EncDatum

EncDatumFromEncoded initializes an EncDatum with the given encoded value. The encoded value is stored as a shallow copy, so the caller must make sure the slice is not modified for the lifetime of the EncDatum. The underlying Datum is nil.

func EncDatumValueFromBufferWithOffsetsAndType Uses

func EncDatumValueFromBufferWithOffsetsAndType(
    buf []byte, typeOffset int, dataOffset int, typ encoding.Type,
) (EncDatum, []byte, error)

EncDatumValueFromBufferWithOffsetsAndType is just like calling EncDatumFromBuffer with DatumEncoding_VALUE, except it expects that you pass in the result of calling DecodeValueTag on the input buf. Use this if you've already called DecodeValueTag on buf already, to avoid it getting called more than necessary.

func IntEncDatum Uses

func IntEncDatum(i int) EncDatum

IntEncDatum returns an EncDatum representation of DInt(i).

func NullEncDatum Uses

func NullEncDatum() EncDatum

NullEncDatum returns and EncDatum representation of tree.DNull.

func RandEncDatum Uses

func RandEncDatum(rng *rand.Rand) (EncDatum, *types.T)

RandEncDatum generates a random EncDatum (of a random type).

func RandSortingEncDatumSlice Uses

func RandSortingEncDatumSlice(rng *rand.Rand, numVals int) ([]EncDatum, *types.T)

RandSortingEncDatumSlice generates a slice of random EncDatum values of the same random type which is key-encodable.

func StrEncDatum Uses

func StrEncDatum(s string) EncDatum

StrEncDatum returns an EncDatum representation of DString(s).

func (*EncDatum) BytesEqual Uses

func (ed *EncDatum) BytesEqual(b []byte) bool

BytesEqual is true if the EncDatum's encoded field is equal to the input.

func (*EncDatum) Compare Uses

func (ed *EncDatum) Compare(
    typ *types.T, a *DatumAlloc, evalCtx *tree.EvalContext, rhs *EncDatum,
) (int, error)

Compare returns:

-1 if the receiver is less than rhs,
0  if the receiver is equal to rhs,
+1 if the receiver is greater than rhs.

func (*EncDatum) Encode Uses

func (ed *EncDatum) Encode(
    typ *types.T, a *DatumAlloc, enc DatumEncoding, appendTo []byte,
) ([]byte, error)

Encode appends the encoded datum to the given slice using the requested encoding. Note: DatumEncoding_VALUE encodings are not unique because they can contain a column ID so they should not be used to test for equality.

func (*EncDatum) EncodedBytes Uses

func (ed *EncDatum) EncodedBytes() []byte

EncodedBytes returns this EncDatum's encoded field. This should be rarely used, and the caller must not modify the returned slice.

func (*EncDatum) EncodedString Uses

func (ed *EncDatum) EncodedString() string

EncodedString returns an immutable copy of this EncDatum's encoded field.

func (*EncDatum) Encoding Uses

func (ed *EncDatum) Encoding() (DatumEncoding, bool)

Encoding returns the encoding that is already available (the latter indicated by the bool return value).

func (*EncDatum) EnsureDecoded Uses

func (ed *EncDatum) EnsureDecoded(typ *types.T, a *DatumAlloc) error

EnsureDecoded ensures that the Datum field is set (decoding if it is not).

func (*EncDatum) Fingerprint Uses

func (ed *EncDatum) Fingerprint(typ *types.T, a *DatumAlloc, appendTo []byte) ([]byte, error)

Fingerprint appends a unique hash of ed to the given slice. If datums are intended to be deduplicated or grouped with hashes, this function should be used instead of encode. Additionally, Fingerprint has the property that if the fingerprints of a set of datums are appended together, the resulting fingerprint will uniquely identify the set.

func (*EncDatum) GetInt Uses

func (ed *EncDatum) GetInt() (int64, error)

GetInt decodes an EncDatum that is known to be of integer type and returns the integer value. It is a more convenient and more efficient alternative to calling EnsureDecoded and casting the Datum.

func (*EncDatum) IsNull Uses

func (ed *EncDatum) IsNull() bool

IsNull returns true if the EncDatum value is NULL. Equivalent to checking if ed.Datum is DNull after calling EnsureDecoded.

func (*EncDatum) IsUnset Uses

func (ed *EncDatum) IsUnset() bool

IsUnset returns true if EncDatumFromEncoded or DatumToEncDatum were not called.

func (EncDatum) Size Uses

func (ed EncDatum) Size() uintptr

Size returns a lower bound on the total size of the receiver in bytes, including memory referenced by the receiver.

func (*EncDatum) String Uses

func (ed *EncDatum) String(typ *types.T) string

func (*EncDatum) UnsetDatum Uses

func (ed *EncDatum) UnsetDatum()

UnsetDatum ensures subsequent IsUnset() calls return false.

type EncDatumRow Uses

type EncDatumRow []EncDatum

EncDatumRow is a row of EncDatums.

func RandEncDatumRowOfTypes Uses

func RandEncDatumRowOfTypes(rng *rand.Rand, types []*types.T) EncDatumRow

RandEncDatumRowOfTypes generates a slice of random EncDatum values for the corresponding type in types.

func (EncDatumRow) Compare Uses

func (r EncDatumRow) Compare(
    types []*types.T,
    a *DatumAlloc,
    ordering ColumnOrdering,
    evalCtx *tree.EvalContext,
    rhs EncDatumRow,
) (int, error)

Compare returns the relative ordering of two EncDatumRows according to a ColumnOrdering:

-1 if the receiver comes before the rhs in the ordering,
+1 if the receiver comes after the rhs in the ordering,
0 if the relative order does not matter (i.e. the two rows have the same
  values for the columns in the ordering).

Note that a return value of 0 does not (in general) imply that the rows are equal; for example, rows [1 1 5] and [1 1 6] when compared against ordering {{0, asc}, {1, asc}} (i.e. ordered by first column and then by second column).

func (EncDatumRow) CompareToDatums Uses

func (r EncDatumRow) CompareToDatums(
    types []*types.T,
    a *DatumAlloc,
    ordering ColumnOrdering,
    evalCtx *tree.EvalContext,
    rhs tree.Datums,
) (int, error)

CompareToDatums is a version of Compare which compares against decoded Datums.

func (EncDatumRow) Copy Uses

func (r EncDatumRow) Copy() EncDatumRow

Copy makes a copy of this EncDatumRow. Convenient for tests. Use an EncDatumRowAlloc in non-test code.

func (EncDatumRow) Size Uses

func (r EncDatumRow) Size() uintptr

Size returns a lower bound on the total size all EncDatum's in the receiver, including memory referenced by all EncDatum's.

func (EncDatumRow) String Uses

func (r EncDatumRow) String(types []*types.T) string

type EncDatumRowAlloc Uses

type EncDatumRowAlloc struct {
    // contains filtered or unexported fields
}

EncDatumRowAlloc is a helper that speeds up allocation of EncDatumRows (preferably of the same length).

func (*EncDatumRowAlloc) AllocRow Uses

func (a *EncDatumRowAlloc) AllocRow(cols int) EncDatumRow

AllocRow allocates an EncDatumRow with the given number of columns.

func (*EncDatumRowAlloc) CopyRow Uses

func (a *EncDatumRowAlloc) CopyRow(row EncDatumRow) EncDatumRow

CopyRow allocates an EncDatumRow and copies the given row to it.

type EncDatumRowContainer Uses

type EncDatumRowContainer struct {
    // contains filtered or unexported fields
}

EncDatumRowContainer holds rows and can cycle through them. Must be Reset upon initialization.

func (*EncDatumRowContainer) IsEmpty Uses

func (c *EncDatumRowContainer) IsEmpty() bool

IsEmpty returns whether the container is "empty", which means that it's about to cycle through its rows again on the next Pop.

func (*EncDatumRowContainer) Peek Uses

func (c *EncDatumRowContainer) Peek() EncDatumRow

Peek returns the current element at the top of the container.

func (*EncDatumRowContainer) Pop Uses

func (c *EncDatumRowContainer) Pop() EncDatumRow

Pop returns the next row from the container. Will cycle through the rows again if we reach the end.

func (*EncDatumRowContainer) Push Uses

func (c *EncDatumRowContainer) Push(row EncDatumRow)

Push adds a row to the container.

func (*EncDatumRowContainer) Reset Uses

func (c *EncDatumRowContainer) Reset()

Reset clears the container and resets the indexes. Must be called upon creating a container.

type EncDatumRows Uses

type EncDatumRows []EncDatumRow

EncDatumRows is a slice of EncDatumRows having the same schema.

func GenEncDatumRowsInt Uses

func GenEncDatumRowsInt(inputRows [][]int) EncDatumRows

GenEncDatumRowsInt converts rows of ints to rows of EncDatum DInts. If an int is negative, the corresponding value is NULL.

func MakeIntRows Uses

func MakeIntRows(numRows, numCols int) EncDatumRows

MakeIntRows constructs a numRows x numCols table where rows[i][j] = i + j.

func MakeRandIntRows Uses

func MakeRandIntRows(rng *rand.Rand, numRows int, numCols int) EncDatumRows

MakeRandIntRows constructs a numRows x numCols table where the values are random.

func MakeRandIntRowsInRange Uses

func MakeRandIntRowsInRange(
    rng *rand.Rand, numRows int, numCols int, maxNum int, nullProbability float64,
) EncDatumRows

MakeRandIntRowsInRange constructs a numRows * numCols table where the values are random integers in the range [0, maxNum).

func MakeRepeatedIntRows Uses

func MakeRepeatedIntRows(n int, numRows int, numCols int) EncDatumRows

MakeRepeatedIntRows constructs a numRows x numCols table where blocks of n consecutive rows have the same value.

func RandEncDatumRows Uses

func RandEncDatumRows(rng *rand.Rand, numRows, numCols int) (EncDatumRows, []*types.T)

RandEncDatumRows generates EncDatumRows where all rows follow the same random []ColumnType structure.

func RandEncDatumRowsOfTypes Uses

func RandEncDatumRowsOfTypes(rng *rand.Rand, numRows int, types []*types.T) EncDatumRows

RandEncDatumRowsOfTypes generates EncDatumRows, each row with values of the corresponding type in types.

func (EncDatumRows) String Uses

func (r EncDatumRows) String(types []*types.T) string

type FamilyID Uses

type FamilyID uint32

FamilyID is a custom type for ColumnFamilyDescriptor IDs.

func NeededColumnFamilyIDs Uses

func NeededColumnFamilyIDs(
    neededCols util.FastIntSet, table *TableDescriptor, index *IndexDescriptor,
) []FamilyID

NeededColumnFamilyIDs returns the minimal set of column families required to retrieve neededCols for the specified table and index. The returned FamilyIDs are in sorted order.

type ForeignKeyConstraint Uses

type ForeignKeyConstraint struct {
    OriginTableID       ID                         `protobuf:"varint,1,opt,name=origin_table_id,json=originTableId,casttype=ID" json:"origin_table_id"`
    OriginColumnIDs     []ColumnID                 `protobuf:"varint,2,rep,name=origin_column_ids,json=originColumnIds,casttype=ColumnID" json:"origin_column_ids,omitempty"`
    ReferencedColumnIDs []ColumnID                 `protobuf:"varint,3,rep,name=referenced_column_ids,json=referencedColumnIds,casttype=ColumnID" json:"referenced_column_ids,omitempty"`
    ReferencedTableID   ID                         `protobuf:"varint,4,opt,name=referenced_table_id,json=referencedTableId,casttype=ID" json:"referenced_table_id"`
    Name                string                     `protobuf:"bytes,5,opt,name=name" json:"name"`
    Validity            ConstraintValidity         `protobuf:"varint,6,opt,name=validity,enum=cockroach.sql.sqlbase.ConstraintValidity" json:"validity"`
    OnDelete            ForeignKeyReference_Action `protobuf:"varint,7,opt,name=on_delete,json=onDelete,enum=cockroach.sql.sqlbase.ForeignKeyReference_Action" json:"on_delete"`
    OnUpdate            ForeignKeyReference_Action `protobuf:"varint,8,opt,name=on_update,json=onUpdate,enum=cockroach.sql.sqlbase.ForeignKeyReference_Action" json:"on_update"`
    // This is only important for composite keys. For all prior matches before
    // the addition of this value, MATCH SIMPLE will be used.
    Match ForeignKeyReference_Match `protobuf:"varint,9,opt,name=match,enum=cockroach.sql.sqlbase.ForeignKeyReference_Match" json:"match"`
}

ForeignKeyConstraint is the new (as of 19.2 and VersionTopLevelForeignKeys) representation for foreign keys. It's stored on the TableDescriptor and is designed to be agnostic to which indexes are available on both the origin and referenced tables, so that the optimizer can have full freedom to choose the best possible index to satisfy constraint checks at runtime.

func (*ForeignKeyConstraint) Descriptor Uses

func (*ForeignKeyConstraint) Descriptor() ([]byte, []int)

func (*ForeignKeyConstraint) Equal Uses

func (this *ForeignKeyConstraint) Equal(that interface{}) bool

func (*ForeignKeyConstraint) Marshal Uses

func (m *ForeignKeyConstraint) Marshal() (dAtA []byte, err error)

func (*ForeignKeyConstraint) MarshalTo Uses

func (m *ForeignKeyConstraint) MarshalTo(dAtA []byte) (int, error)

func (*ForeignKeyConstraint) ProtoMessage Uses

func (*ForeignKeyConstraint) ProtoMessage()

func (*ForeignKeyConstraint) Reset Uses

func (m *ForeignKeyConstraint) Reset()

func (*ForeignKeyConstraint) Size Uses

func (m *ForeignKeyConstraint) Size() (n int)

func (*ForeignKeyConstraint) String Uses

func (m *ForeignKeyConstraint) String() string

func (*ForeignKeyConstraint) Unmarshal Uses

func (m *ForeignKeyConstraint) Unmarshal(dAtA []byte) error

func (*ForeignKeyConstraint) XXX_DiscardUnknown Uses

func (m *ForeignKeyConstraint) XXX_DiscardUnknown()

func (*ForeignKeyConstraint) XXX_Marshal Uses

func (m *ForeignKeyConstraint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ForeignKeyConstraint) XXX_Merge Uses

func (dst *ForeignKeyConstraint) XXX_Merge(src proto.Message)

func (*ForeignKeyConstraint) XXX_Size Uses

func (m *ForeignKeyConstraint) XXX_Size() int

func (*ForeignKeyConstraint) XXX_Unmarshal Uses

func (m *ForeignKeyConstraint) XXX_Unmarshal(b []byte) error

type ForeignKeyReference Uses

type ForeignKeyReference struct {
    Table    ID                 `protobuf:"varint,1,opt,name=table,casttype=ID" json:"table"`
    Index    IndexID            `protobuf:"varint,2,opt,name=index,casttype=IndexID" json:"index"`
    Name     string             `protobuf:"bytes,3,opt,name=name" json:"name"`
    Validity ConstraintValidity `protobuf:"varint,4,opt,name=validity,enum=cockroach.sql.sqlbase.ConstraintValidity" json:"validity"`
    // If this FK only uses a prefix of the columns in its index, we record how
    // many to avoid spuriously counting the additional cols as used by this FK.
    SharedPrefixLen int32                      `protobuf:"varint,5,opt,name=shared_prefix_len,json=sharedPrefixLen" json:"shared_prefix_len"`
    OnDelete        ForeignKeyReference_Action `protobuf:"varint,6,opt,name=on_delete,json=onDelete,enum=cockroach.sql.sqlbase.ForeignKeyReference_Action" json:"on_delete"`
    OnUpdate        ForeignKeyReference_Action `protobuf:"varint,7,opt,name=on_update,json=onUpdate,enum=cockroach.sql.sqlbase.ForeignKeyReference_Action" json:"on_update"`
    // This is only important for composite keys. For all prior matches before
    // the addition of this value, MATCH SIMPLE will be used.
    Match ForeignKeyReference_Match `protobuf:"varint,8,opt,name=match,enum=cockroach.sql.sqlbase.ForeignKeyReference_Match" json:"match"`
}

ForeignKeyReference is deprecated, replaced by ForeignKeyConstraint in v19.2 (though it is still possible for table descriptors on disk to have ForeignKeyReferences).

It is still used to describe interleavings (see IndexDescriptor.InterleavedBy), for which it is a poor choice: only the Table and Index fields are used, and the interleaving has nothing to do with traditional foreign key references.

func (*ForeignKeyReference) Descriptor Uses

func (*ForeignKeyReference) Descriptor() ([]byte, []int)

func (*ForeignKeyReference) Equal Uses

func (this *ForeignKeyReference) Equal(that interface{}) bool

func (ForeignKeyReference) IsSet Uses

func (f ForeignKeyReference) IsSet() bool

IsSet returns whether or not the foreign key actually references a table.

func (*ForeignKeyReference) Marshal Uses

func (m *ForeignKeyReference) Marshal() (dAtA []byte, err error)

func (*ForeignKeyReference) MarshalTo Uses

func (m *ForeignKeyReference) MarshalTo(dAtA []byte) (int, error)

func (*ForeignKeyReference) ProtoMessage Uses

func (*ForeignKeyReference) ProtoMessage()

func (*ForeignKeyReference) Reset Uses

func (m *ForeignKeyReference) Reset()

func (*ForeignKeyReference) Size Uses

func (m *ForeignKeyReference) Size() (n int)

func (*ForeignKeyReference) String Uses

func (m *ForeignKeyReference) String() string

func (*ForeignKeyReference) Unmarshal Uses

func (m *ForeignKeyReference) Unmarshal(dAtA []byte) error

func (*ForeignKeyReference) XXX_DiscardUnknown Uses

func (m *ForeignKeyReference) XXX_DiscardUnknown()

func (*ForeignKeyReference) XXX_Marshal Uses

func (m *ForeignKeyReference) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ForeignKeyReference) XXX_Merge Uses

func (dst *ForeignKeyReference) XXX_Merge(src proto.Message)

func (*ForeignKeyReference) XXX_Size Uses

func (m *ForeignKeyReference) XXX_Size() int

func (*ForeignKeyReference) XXX_Unmarshal Uses

func (m *ForeignKeyReference) XXX_Unmarshal(b []byte) error

type ForeignKeyReference_Action Uses

type ForeignKeyReference_Action int32
const (
    ForeignKeyReference_NO_ACTION   ForeignKeyReference_Action = 0
    ForeignKeyReference_RESTRICT    ForeignKeyReference_Action = 1
    ForeignKeyReference_SET_NULL    ForeignKeyReference_Action = 2
    ForeignKeyReference_SET_DEFAULT ForeignKeyReference_Action = 3
    ForeignKeyReference_CASCADE     ForeignKeyReference_Action = 4
)

func (ForeignKeyReference_Action) Enum Uses

func (x ForeignKeyReference_Action) Enum() *ForeignKeyReference_Action

func (ForeignKeyReference_Action) EnumDescriptor Uses

func (ForeignKeyReference_Action) EnumDescriptor() ([]byte, []int)

func (ForeignKeyReference_Action) MarshalJSON Uses

func (x ForeignKeyReference_Action) MarshalJSON() ([]byte, error)

func (ForeignKeyReference_Action) String Uses

func (x ForeignKeyReference_Action) String() string

String implements the fmt.Stringer interface.

func (*ForeignKeyReference_Action) UnmarshalJSON Uses

func (x *ForeignKeyReference_Action) UnmarshalJSON(data []byte) error

type ForeignKeyReference_Match Uses

type ForeignKeyReference_Match int32

Match is the algorithm used to compare composite keys.

const (
    ForeignKeyReference_SIMPLE  ForeignKeyReference_Match = 0
    ForeignKeyReference_FULL    ForeignKeyReference_Match = 1
    ForeignKeyReference_PARTIAL ForeignKeyReference_Match = 2
)

func (ForeignKeyReference_Match) Enum Uses

func (x ForeignKeyReference_Match) Enum() *ForeignKeyReference_Match

func (ForeignKeyReference_Match) EnumDescriptor Uses

func (ForeignKeyReference_Match) EnumDescriptor() ([]byte, []int)

func (ForeignKeyReference_Match) MarshalJSON Uses

func (x ForeignKeyReference_Match) MarshalJSON() ([]byte, error)

func (ForeignKeyReference_Match) String Uses

func (x ForeignKeyReference_Match) String() string

String implements the fmt.Stringer interface.

func (*ForeignKeyReference_Match) UnmarshalJSON Uses

func (x *ForeignKeyReference_Match) UnmarshalJSON(data []byte) error

type FormatVersion Uses

type FormatVersion uint32

FormatVersion is a custom type for TableDescriptor versions of the sql to key:value mapping. go:generate stringer -type=FormatVersion

const (

    // BaseFormatVersion corresponds to the encoding described in
    // https://www.cockroachlabs.com/blog/sql-in-cockroachdb-mapping-table-data-to-key-value-storage/.
    BaseFormatVersion FormatVersion
    // FamilyFormatVersion corresponds to the encoding described in
    // https://github.com/cockroachdb/cockroach/blob/master/docs/RFCS/20151214_sql_column_families.md
    FamilyFormatVersion
    // InterleavedFormatVersion corresponds to the encoding described in
    // https://github.com/cockroachdb/cockroach/blob/master/docs/RFCS/20160624_sql_interleaved_tables.md
    InterleavedFormatVersion
)

func (FormatVersion) String Uses

func (i FormatVersion) String() string

type ID Uses

type ID tree.ID

ID is a custom type for {Database,Table}Descriptor IDs.

const InvalidID ID = 0

InvalidID is the uninitialised descriptor id.

func LookupDatabaseID Uses

func LookupDatabaseID(
    ctx context.Context, txn *kv.Txn, codec keys.SQLCodec, name string,
) (bool, ID, error)

LookupDatabaseID is a wrapper around LookupObjectID for databases.

func LookupObjectID Uses

func LookupObjectID(
    ctx context.Context,
    txn *kv.Txn,
    codec keys.SQLCodec,
    parentID ID,
    parentSchemaID ID,
    name string,
) (bool, ID, error)

LookupObjectID returns the ObjectID for the given (parentID, parentSchemaID, name) supplied. If cluster version < 20.1, the parentSchemaID is ignored.

func LookupPublicTableID Uses

func LookupPublicTableID(
    ctx context.Context, txn *kv.Txn, codec keys.SQLCodec, parentID ID, name string,
) (bool, ID, error)

LookupPublicTableID is a wrapper around LookupObjectID for public tables.

func LookupSystemTableDescriptorID Uses

func LookupSystemTableDescriptorID(
    ctx context.Context, settings *cluster.Settings, codec keys.SQLCodec, dbID ID, tableName string,
) ID

LookupSystemTableDescriptorID uses the lookup cache above to bypass a KV lookup when resolving the name of system tables.

type IDs Uses

type IDs []ID

IDs is a sortable list of IDs.

func (IDs) Len Uses

func (ids IDs) Len() int

func (IDs) Less Uses

func (ids IDs) Less(i, j int) bool

func (IDs) Swap Uses

func (ids IDs) Swap(i, j int)

type ImmutableDatabaseDescriptor Uses

type ImmutableDatabaseDescriptor struct {
    DatabaseDescriptor
}

ImmutableDatabaseDescriptor wraps a database descriptor and provides methods on it.

func GetDatabaseDescFromID Uses

func GetDatabaseDescFromID(
    ctx context.Context, protoGetter protoGetter, codec keys.SQLCodec, id ID,
) (*ImmutableDatabaseDescriptor, error)

GetDatabaseDescFromID retrieves the database descriptor for the database ID passed in using an existing proto getter. Returns an error if the descriptor doesn't exist or if it exists and is not a database.

func MakeSystemDatabaseDesc Uses

func MakeSystemDatabaseDesc() *ImmutableDatabaseDescriptor

MakeSystemDatabaseDesc constructs a copy of the system database descriptor.

func NewImmutableDatabaseDescriptor Uses

func NewImmutableDatabaseDescriptor(desc DatabaseDescriptor) *ImmutableDatabaseDescriptor

NewImmutableDatabaseDescriptor makes a new database descriptor.

func NewInitialDatabaseDescriptor Uses

func NewInitialDatabaseDescriptor(id ID, name string) *ImmutableDatabaseDescriptor

NewInitialDatabaseDescriptor constructs a new DatabaseDescriptor for an initial version from an id and name.

func NewInitialDatabaseDescriptorWithPrivileges Uses

func NewInitialDatabaseDescriptorWithPrivileges(
    id ID, name string, privileges *PrivilegeDescriptor,
) *ImmutableDatabaseDescriptor

NewInitialDatabaseDescriptorWithPrivileges constructs a new DatabaseDescriptor for an initial version from an id and name.

func (*ImmutableDatabaseDescriptor) DescriptorProto Uses

func (desc *ImmutableDatabaseDescriptor) DescriptorProto() *Descriptor

DescriptorProto wraps a DatabaseDescriptor in a Descriptor.

func (*ImmutableDatabaseDescriptor) GetAuditMode Uses

func (desc *ImmutableDatabaseDescriptor) GetAuditMode() TableDescriptor_AuditMode

GetAuditMode is part of the DescriptorProto interface. This is a stub until per-database auditing is enabled.

func (*ImmutableDatabaseDescriptor) GetParentID Uses

func (desc *ImmutableDatabaseDescriptor) GetParentID() ID

GetParentID implements the BaseDescriptorInterface interface.

func (*ImmutableDatabaseDescriptor) GetParentSchemaID Uses

func (desc *ImmutableDatabaseDescriptor) GetParentSchemaID() ID

GetParentSchemaID implements the BaseDescriptorInterface interface.

func (*ImmutableDatabaseDescriptor) NameResolutionResult Uses

func (desc *ImmutableDatabaseDescriptor) NameResolutionResult()

NameResolutionResult implements the ObjectDescriptor interface.

func (*ImmutableDatabaseDescriptor) Validate Uses

func (desc *ImmutableDatabaseDescriptor) Validate() error

Validate validates that the database descriptor is well formed. Checks include validate the database name, and verifying that there is at least one read and write user.

type ImmutableSchemaDescriptor Uses

type ImmutableSchemaDescriptor struct {
    SchemaDescriptor
}

ImmutableSchemaDescriptor wraps a Schema descriptor and provides methods on it.

func NewImmutableSchemaDescriptor Uses

func NewImmutableSchemaDescriptor(desc SchemaDescriptor) *ImmutableSchemaDescriptor

NewImmutableSchemaDescriptor makes a new Schema descriptor.

func (*ImmutableSchemaDescriptor) DatabaseDesc Uses

func (desc *ImmutableSchemaDescriptor) DatabaseDesc() *DatabaseDescriptor

DatabaseDesc implements the ObjectDescriptor interface.

func (*ImmutableSchemaDescriptor) DescriptorProto Uses

func (desc *ImmutableSchemaDescriptor) DescriptorProto() *Descriptor

DescriptorProto wraps a SchemaDescriptor in a Descriptor.

func (*ImmutableSchemaDescriptor) GetAuditMode Uses

func (desc *ImmutableSchemaDescriptor) GetAuditMode() TableDescriptor_AuditMode

GetAuditMode implements the DescriptorProto interface.

func (*ImmutableSchemaDescriptor) GetParentSchemaID Uses

func (desc *ImmutableSchemaDescriptor) GetParentSchemaID() ID

GetParentSchemaID implements the BaseDescriptorInterface interface.

func (*ImmutableSchemaDescriptor) NameResolutionResult Uses

func (desc *ImmutableSchemaDescriptor) NameResolutionResult()

NameResolutionResult implements the ObjectDescriptor interface.

func (*ImmutableSchemaDescriptor) SchemaDesc Uses

func (desc *ImmutableSchemaDescriptor) SchemaDesc() *SchemaDescriptor

SchemaDesc implements the ObjectDescriptor interface.

func (*ImmutableSchemaDescriptor) TableDesc Uses

func (desc *ImmutableSchemaDescriptor) TableDesc() *TableDescriptor

TableDesc implements the ObjectDescriptor interface.

func (*ImmutableSchemaDescriptor) TypeDesc Uses

func (desc *ImmutableSchemaDescriptor) TypeDesc() *TypeDescriptor

TypeDesc implements the ObjectDescriptor interface.

func (*ImmutableSchemaDescriptor) TypeName Uses

func (desc *ImmutableSchemaDescriptor) TypeName() string

TypeName implements the DescriptorProto interface.

type ImmutableTableDescriptor Uses

type ImmutableTableDescriptor struct {
    TableDescriptor

    // ReadableColumns is a list of columns (including those undergoing a schema change)
    // which can be scanned. Columns in the process of a schema change
    // are all set to nullable while column backfilling is still in
    // progress, as mutation columns may have NULL values.
    ReadableColumns []ColumnDescriptor
    // contains filtered or unexported fields
}

ImmutableTableDescriptor is a custom type for TableDescriptors It holds precomputed values and the underlying TableDescriptor should be const.

func NewImmutableTableDescriptor Uses

func NewImmutableTableDescriptor(tbl TableDescriptor) *ImmutableTableDescriptor

NewImmutableTableDescriptor returns a ImmutableTableDescriptor from the given TableDescriptor.

func TestingGetImmutableTableDescriptor Uses

func TestingGetImmutableTableDescriptor(
    kvDB *kv.DB, codec keys.SQLCodec, database string, table string,
) *ImmutableTableDescriptor

TestingGetImmutableTableDescriptor retrieves an immutable table descriptor directly from the KV layer.

func (*ImmutableTableDescriptor) ActiveChecks Uses

func (desc *ImmutableTableDescriptor) ActiveChecks() []TableDescriptor_CheckConstraint

ActiveChecks returns a list of all check constraints that should be enforced on writes (including constraints being added/validated). The columns referenced by the returned checks are writable, but not necessarily public.

func (*ImmutableTableDescriptor) ContainsUserDefinedTypes Uses

func (desc *ImmutableTableDescriptor) ContainsUserDefinedTypes() bool

ContainsUserDefinedTypes returns whether or not this table descriptor has any columns of user defined types.

func (*ImmutableTableDescriptor) DatabaseDesc Uses

func (desc *ImmutableTableDescriptor) DatabaseDesc() *DatabaseDescriptor

DatabaseDesc implements the ObjectDescriptor interface.

func (*ImmutableTableDescriptor) DeletableColumns Uses

func (desc *ImmutableTableDescriptor) DeletableColumns() []ColumnDescriptor

DeletableColumns returns a list of public and non-public columns.

func (*ImmutableTableDescriptor) DeletableIndexes Uses

func (desc *ImmutableTableDescriptor) DeletableIndexes() []IndexDescriptor

DeletableIndexes returns a list of public and non-public indexes.

func (*ImmutableTableDescriptor) DeleteOnlyIndexes Uses

func (desc *ImmutableTableDescriptor) DeleteOnlyIndexes() []IndexDescriptor

DeleteOnlyIndexes returns a list of delete-only mutation indexes.

func (*ImmutableTableDescriptor) FindReadableColumnByID Uses

func (desc *ImmutableTableDescriptor) FindReadableColumnByID(
    id ColumnID,
) (*ColumnDescriptor, bool, error)

FindReadableColumnByID finds the readable column with specified ID. The column may be undergoing a schema change and is marked nullable regardless of its configuration. It returns true if the column is undergoing a schema change.

func (*ImmutableTableDescriptor) MakeFirstMutationPublic Uses

func (desc *ImmutableTableDescriptor) MakeFirstMutationPublic(
    includeConstraints bool,
) (*MutableTableDescriptor, error)

MakeFirstMutationPublic creates a MutableTableDescriptor from the ImmutableTableDescriptor by making the first mutation public. This is super valuable when trying to run SQL over data associated with a schema mutation that is still not yet public: Data validation, error reporting.

func (*ImmutableTableDescriptor) MutationColumns Uses

func (desc *ImmutableTableDescriptor) MutationColumns() []ColumnDescriptor

MutationColumns returns a list of mutation columns.

func (*ImmutableTableDescriptor) SchemaDesc Uses

func (desc *ImmutableTableDescriptor) SchemaDesc() *SchemaDescriptor

SchemaDesc implements the ObjectDescriptor interface.

func (*ImmutableTableDescriptor) TableDesc Uses

func (desc *ImmutableTableDescriptor) TableDesc() *TableDescriptor

TableDesc implements the ObjectDescriptor interface.

func (*ImmutableTableDescriptor) TypeDesc Uses

func (desc *ImmutableTableDescriptor) TypeDesc() *TypeDescriptor

TypeDesc implements the ObjectDescriptor interface.

func (*ImmutableTableDescriptor) WritableColumns Uses

func (desc *ImmutableTableDescriptor) WritableColumns() []ColumnDescriptor

WritableColumns returns a list of public and write-only mutation columns.

func (*ImmutableTableDescriptor) WritableIndexes Uses

func (desc *ImmutableTableDescriptor) WritableIndexes() []IndexDescriptor

WritableIndexes returns a list of public and write-only mutation indexes.

type ImmutableTypeDescriptor Uses

type ImmutableTypeDescriptor struct {
    TypeDescriptor
}

ImmutableTypeDescriptor is a custom type for wrapping TypeDescriptors when used in a read only way.

func GetTypeDescFromID Uses

func GetTypeDescFromID(
    ctx context.Context, protoGetter protoGetter, codec keys.SQLCodec, id ID,
) (*ImmutableTypeDescriptor, error)

GetTypeDescFromID retrieves the type descriptor for the type ID passed in using an existing proto getter. It returns an error if the descriptor doesn't exist or if it exists and is not a type descriptor.

TODO(ajwerner): Move this to catalogkv or something like it.

func MakeSimpleAliasTypeDescriptor Uses

func MakeSimpleAliasTypeDescriptor(typ *types.T) *ImmutableTypeDescriptor

MakeSimpleAliasTypeDescriptor creates a type descriptor that is an alias for the input type. It is intended to be used as an intermediate for name resolution, and should not be serialized and stored on disk.

func NewImmutableTypeDescriptor Uses

func NewImmutableTypeDescriptor(desc TypeDescriptor) *ImmutableTypeDescriptor

NewImmutableTypeDescriptor returns an ImmutableTypeDescriptor from the given TypeDescriptor.

func (*ImmutableTypeDescriptor) DatabaseDesc Uses

func (desc *ImmutableTypeDescriptor) DatabaseDesc() *DatabaseDescriptor

DatabaseDesc implements the ObjectDescriptor interface.

func (*ImmutableTypeDescriptor) HydrateTypeInfoWithName Uses

func (desc *ImmutableTypeDescriptor) HydrateTypeInfoWithName(
    typ *types.T, name *tree.TypeName, typeLookup TypeLookupFunc,
) error

HydrateTypeInfoWithName fills in user defined type metadata for a type and also sets the name in the metadata to the passed in name. This is used when hydrating a type with a known qualified name.

func (*ImmutableTypeDescriptor) MakeTypesT Uses

func (desc *ImmutableTypeDescriptor) MakeTypesT(
    name *tree.TypeName, typeLookup TypeLookupFunc,
) (*types.T, error)

MakeTypesT creates a types.T from the input type descriptor.

func (*ImmutableTypeDescriptor) SchemaDesc Uses

func (desc *ImmutableTypeDescriptor) SchemaDesc() *SchemaDescriptor

SchemaDesc implements the ObjectDescriptor interface.

func (*ImmutableTypeDescriptor) TableDesc Uses

func (desc *ImmutableTypeDescriptor) TableDesc() *TableDescriptor

TableDesc implements the ObjectDescriptor interface.

func (*ImmutableTypeDescriptor) TypeDesc Uses

func (desc *ImmutableTypeDescriptor) TypeDesc() *TypeDescriptor

TypeDesc implements the ObjectDescriptor interface.

type IndexDescriptor Uses

type IndexDescriptor struct {
    Name    string                 `protobuf:"bytes,1,opt,name=name" json:"name"`
    ID      IndexID                `protobuf:"varint,2,opt,name=id,casttype=IndexID" json:"id"`
    Unique  bool                   `protobuf:"varint,3,opt,name=unique" json:"unique"`
    Version IndexDescriptorVersion `protobuf:"varint,18,opt,name=version,casttype=IndexDescriptorVersion" json:"version"`
    // An ordered list of column names of which the index is comprised; these
    // columns do not include any additional stored columns (which are in
    // stored_column_names). This list parallels the column_ids list.
    //
    // Note: if duplicating the storage of the column names here proves to be
    // prohibitive, we could clear this field before saving and reconstruct it
    // after loading.
    ColumnNames []string `protobuf:"bytes,4,rep,name=column_names,json=columnNames" json:"column_names,omitempty"`
    // The sort direction of each column in column_names.
    ColumnDirections []IndexDescriptor_Direction `protobuf:"varint,8,rep,name=column_directions,json=columnDirections,enum=cockroach.sql.sqlbase.IndexDescriptor_Direction" json:"column_directions,omitempty"`
    // An ordered list of column names which the index stores in addition to the
    // columns which are explicitly part of the index (STORING clause). Only used
    // for secondary indexes.
    StoreColumnNames []string `protobuf:"bytes,5,rep,name=store_column_names,json=storeColumnNames" json:"store_column_names,omitempty"`
    // An ordered list of column IDs of which the index is comprised. This list
    // parallels the column_names list and does not include any additional stored
    // columns.
    ColumnIDs []ColumnID `protobuf:"varint,6,rep,name=column_ids,json=columnIds,casttype=ColumnID" json:"column_ids,omitempty"`
    // An ordered list of IDs for the additional columns associated with the
    // index:
    //  - implicit columns, which are all the primary key columns that are not
    //    already part of the index (i.e. PrimaryIndex.column_ids - column_ids).
    //  - stored columns (the columns in store_column_names) if this index uses the
    //    old STORING encoding (key-encoded data).
    //
    // Only used for secondary indexes.
    // For non-unique indexes, these columns are appended to the key.
    // For unique indexes, these columns are stored in the value (unless the key
    // contains a NULL value: then the extra columns are appended to the key to
    // unique-ify it).
    // This distinction exists because we want to be able to insert an entry using
    // a single conditional put on the key.
    ExtraColumnIDs []ColumnID `protobuf:"varint,7,rep,name=extra_column_ids,json=extraColumnIds,casttype=ColumnID" json:"extra_column_ids,omitempty"`
    // An ordered list of column IDs that parallels store_column_names if this
    // index uses the new STORING encoding (value-encoded data, always in the KV
    // value).
    StoreColumnIDs []ColumnID `protobuf:"varint,14,rep,name=store_column_ids,json=storeColumnIds,casttype=ColumnID" json:"store_column_ids,omitempty"`
    // CompositeColumnIDs contains an ordered list of IDs of columns that appear
    // in the index and have a composite encoding. Includes IDs from both
    // column_ids and extra_column_ids.
    CompositeColumnIDs []ColumnID `protobuf:"varint,13,rep,name=composite_column_ids,json=compositeColumnIds,casttype=ColumnID" json:"composite_column_ids,omitempty"`
    // ForeignKey and ReferencedBy are deprecated and not stored from 19.2 onward.
    ForeignKey   ForeignKeyReference   `protobuf:"bytes,9,opt,name=foreign_key,json=foreignKey" json:"foreign_key"`        // Deprecated: Do not use.
    ReferencedBy []ForeignKeyReference `protobuf:"bytes,10,rep,name=referenced_by,json=referencedBy" json:"referenced_by"` // Deprecated: Do not use.
    // Interleave, if it's not the zero value, describes how this index's data is
    // interleaved into another index's data.
    Interleave InterleaveDescriptor `protobuf:"bytes,11,opt,name=interleave" json:"interleave"`
    // InterleavedBy contains a reference to every table/index that is interleaved
    // into this one.
    //
    // Note that any of these indexes can themselves be interleaved by other
    // tables but this list contains only those for which this index is a direct
    // interleave parent.
    //
    // Only the Table and Index fields of the ForeignKeyReference are used. And
    // despite the message used here, interleaving