cockroach: github.com/cockroachdb/cockroach/pkg/keys Index | Files

package keys

import "github.com/cockroachdb/cockroach/pkg/keys"

Package keys manages the construction of keys for CockroachDB's key-value layer.

The keys package is necessarily tightly coupled to the storage package. In theory, it is oblivious to higher levels of the stack. In practice, it exposes several functions that blur abstraction boundaries to break dependency cycles. For example, EnsureSafeSplitKey knows far too much about how to decode SQL keys.

1. Overview

This is the ten-thousand foot view of the keyspace:

+------------------+
| (empty)          | /Min
| \x01...          | /Local            ---------------------+
|                  |                                        |
| ...              |                                        | local keys
|                  |                                        |
|                  |                   ---------------------+
|                  |                   ---------------------+
| \x02...          | /Meta1            ----+                |
| \x03...          | /Meta2                |                |
| \x04...          | /System               |                |
|                  |                       | system keys    |
| ...              |                       |                |
|                  |                   ----+                |
| \x89...          | /Table/1          ----+                |
| \x8a...          | /Table/2              |                |
|                  |                       | system tenant  |
| ...              |                       |                | global keys
|                  |                   ----+                |
| \xfe\x8a\x89...  | /Tenant/2/Table/1 ----+                |
| \xfe\x8a\x8a...  | /Tenant/2/Table/2     |                |
|                  |                       | tenant 2       |
| ...              |                       |                |
|                  |                   ----+                |
| \xfe...          | /Tenant/...       ----+                |
| \xfe...          |                       |                |
|                  |                       | tenant ...     |
| ...              |                       |                |
|                  |                   ----+                |
| \xff\xff         | /Max              ---------------------+
+------------------+

When keys are pretty printed, the logical name to the right of the table is shown instead of the raw byte sequence.

1. Key Ranges

The keyspace is divided into contiguous, non-overlapping chunks called "ranges." A range is defined by its start and end keys. For example, a range might span from [/Table/1, /Table/2), where the lower bound is inclusive and the upper bound is exclusive. Any key that begins with /Table/1, like /Table/1/SomePrimaryKeyValue..., would belong to this range. Key ranges exist over the "resolved" keyspace, refer to the "Key Addressing" section below for more details.

2. Local vs. Global Keys

There are broadly two types of keys, "local" and "global":

(i) Local keys, such as store- and range-specific metadata, are keys that
must be physically collocated with the store and/or ranges they refer to but
also logically separated so that they do not pollute the user key space.
This is further elaborated on in the "Key Addressing" section below. Local
data also includes data "local" to a node, such as the store metadata and
the raft log, which is where the name originated.

(ii) Non-local keys (for e.g. meta1, meta2, system, and SQL keys) are
collectively referred to as "global" keys.

NB: The empty key (/Min) is a special case. No data is stored there, but it is used as the start key of the first range descriptor and as the starting point for some scans, in which case it acts like a global key.

(Check `keymap` below for a more precise breakdown of the local and global keyspace.)

2. Key Addressing

We also have this concept of the "address" for a key. Keys get "resolved" using `keys.Addr`, through which we're able to lookup the range "containing" the key. For global keys, the resolved key is the key itself.

Local keys are special. For certain kinds of local keys (namely, addressable ones), the resolved key is obtained by stripping out the local key prefix, suffix, and optional details (refer to `keymap` below to understand how local keys are constructed). This level of indirection was introduced so that we could logically sort these local keys into a range other than what a strictly physical key based sort would entail. For example, the key /Local/Range/Table/1 would naturally sort into the range [/Min, /System), but its "address" is /Table/1, so it actually belongs to a range like [/Table1, /Table/2).

Consider the motivating example: we want to store a copy of the range descriptor in a key that's both (a) a part of the range, and (b) does not require us to remove a portion of the keyspace from the user (say by reserving some key suffix). Storing this information in the global keyspace would place the data on an arbitrary set of stores, with no guarantee of collocation. By being able to logically sort the range descriptor key next to the range itself, we're able to collocate the two.

3. (replicated) Range-ID local keys vs. Range local keys

Deciding between replicated range-ID local keys and range local keys is not entirely straightforward, as the two key types serve similar purposes. Range-ID keys, as the name suggests, use the range-ID in the key. Range local keys instead use a key within the range bounds. Range-ID keys are not addressable whereas range-local keys are. Note that only addressable keys can be the target of KV operations, unaddressable keys can only be written as a side-effect of other KV operations. This can often makes the choice between the two clear (range descriptor keys needing to be addressable, and therefore being a range local key is one example of this).

The "behavioral" difference between range local keys and range-id local keys is that range local keys split and merge along range boundaries while range-id local keys don't. We want to move as little data as possible during splits and merges (in fact, we don't re-write any data during splits), and that generally determines which data sits where. If we want the split point of a range to dictate where certain keys end up, then they're likely meant to be range local keys. If not, they're meant to be range-ID local keys. Any key we need to re-write during splits/merges will needs to go through Raft. We have limits set on the size of Raft proposals so we generally don’t want to be re-writing lots of data.

This naturally leads to range-id local keys being used to store metadata about a specific Range and range local keys being used to store metadata about specific "global" keys. Let us consider transaction record keys for example (ignoring for a second we also need them to be addressable). Hot ranges could potentially have lots of transaction keys. Keys destined for the RHS of the split need to be collocated with the RHS range. By categorizing them as as range local keys, we avoid needing to re-write them during splits as they automatically sort into the new range boundaries. If they were range-ID local keys, we'd have to update each transaction key with the new range ID.

Index

Package Files

constants.go doc.go errors.go keys.go printer.go spans.go sql.go

Constants

const (
    // MaxSystemConfigDescID is the maximum system descriptor ID that will be
    // gossiped as part of the SystemConfig. Be careful adding new descriptors to
    // this ID range.
    MaxSystemConfigDescID = 10

    // MaxReservedDescID is the maximum value of reserved descriptor
    // IDs. Reserved IDs are used by namespaces and tables used internally by
    // cockroach.
    MaxReservedDescID = 49

    // MinUserDescID is the first descriptor ID available for user
    // structured data.
    MinUserDescID = MaxReservedDescID + 1

    // MinNonPredefinedUserDescID is the first descriptor ID used by
    // user-level objects that are not created automatically on empty
    // clusters (default databases).
    MinNonPredefinedUserDescID = MinUserDescID + 2

    // RootNamespaceID is the ID of the root namespace.
    RootNamespaceID = 0

    // SystemDatabaseID and following are the database/table IDs for objects
    // in the system span.
    // NOTE: IDs must be <= MaxSystemConfigDescID.
    SystemDatabaseID = 1
    // DeprecatedNamespaceTableID was the tableID for the system.namespace table
    // for pre-20.1 clusters.
    DeprecatedNamespaceTableID = 2
    DescriptorTableID          = 3
    UsersTableID               = 4
    ZonesTableID               = 5
    SettingsTableID            = 6
    DescIDSequenceID           = 7
    TenantsTableID             = 8

    // IDs for the important columns and indexes in the zones table live here to
    // avoid introducing a dependency on sql/sqlbase throughout the codebase.
    ZonesTablePrimaryIndexID = 1
    ZonesTableConfigColumnID = 2
    ZonesTableConfigColFamID = 2

    DescriptorTablePrimaryKeyIndexID  = 1
    DescriptorTableDescriptorColID    = 2
    DescriptorTableDescriptorColFamID = 2
    TenantsTablePrimaryKeyIndexID     = 1

    // Reserved IDs for other system tables. Note that some of these IDs refer
    // to "Ranges" instead of a Table - these IDs are needed to store custom
    // configuration for non-table ranges (e.g. Zone Configs).
    // NOTE: IDs must be <= MaxReservedDescID.
    LeaseTableID                         = 11
    EventLogTableID                      = 12
    RangeEventTableID                    = 13
    UITableID                            = 14
    JobsTableID                          = 15
    MetaRangesID                         = 16 // pseudo
    SystemRangesID                       = 17 // pseudo
    TimeseriesRangesID                   = 18 // pseudo
    WebSessionsTableID                   = 19
    TableStatisticsTableID               = 20
    LocationsTableID                     = 21
    LivenessRangesID                     = 22 // pseudo
    RoleMembersTableID                   = 23
    CommentsTableID                      = 24
    ReplicationConstraintStatsTableID    = 25
    ReplicationCriticalLocalitiesTableID = 26
    ReplicationStatsTableID              = 27
    ReportsMetaTableID                   = 28
    PublicSchemaID                       = 29 // pseudo
    // New NamespaceTableID for cluster version >= 20.1
    // Ensures that NamespaceTable does not get gossiped again
    NamespaceTableID                    = 30
    ProtectedTimestampsMetaTableID      = 31
    ProtectedTimestampsRecordsTableID   = 32
    RoleOptionsTableID                  = 33
    StatementBundleChunksTableID        = 34
    StatementDiagnosticsRequestsTableID = 35
    StatementDiagnosticsTableID         = 36
    ScheduledJobsTableID                = 37
    TenantsRangesID                     = 38 // pseudo
    SqllivenessID                       = 39

    // CommentType is type for system.comments
    DatabaseCommentType = 0
    TableCommentType    = 1
    ColumnCommentType   = 2
    IndexCommentType    = 3
)

Various IDs used by the structured data layer. NOTE: these must not change during the lifetime of a cluster.

const (
    // SequenceIndexID is the ID of the single index on each special single-column,
    // single-row sequence table.
    SequenceIndexID = 1
    // SequenceColumnFamilyID is the ID of the column family on each special single-column,
    // single-row sequence table.
    SequenceColumnFamilyID = 0
)

Variables

var (
    // MinKey is a minimum key value which sorts before all other keys.
    MinKey = roachpb.KeyMin
    // MaxKey is the infinity marker which is larger than any other key.
    MaxKey = roachpb.KeyMax

    // LocalMax is the end of the local key range. It is itself a global
    // key.
    LocalMax = roachpb.Key{localMaxByte}

    // 1. Replicated Range-ID keys
    //
    // LocalRangeIDPrefix is the prefix identifying per-range data
    // indexed by Range ID. The Range ID is appended to this prefix,
    // encoded using EncodeUvarint. The specific sort of per-range
    // metadata is identified by one of the suffixes listed below, along
    // with potentially additional encoded key info, for instance in the
    // case of AbortSpan entry.
    //
    // NOTE: LocalRangeIDPrefix must be kept in sync with the value
    // in storage/engine/rocksdb/db.cc.
    LocalRangeIDPrefix = roachpb.RKey(makeKey(localPrefix, roachpb.Key("i")))
    // LocalRangeIDReplicatedInfix is the post-Range ID specifier for all Raft
    // replicated per-range data. By appending this after the Range ID, these
    // keys will be sorted directly before the local unreplicated keys for the
    // same Range ID, so they can be manipulated either together or individually
    // in a single scan.
    LocalRangeIDReplicatedInfix = []byte("r")
    // LocalAbortSpanSuffix is the suffix for AbortSpan entries. The
    // AbortSpan protects a transaction from re-reading its own intents
    // after it's been aborted.
    LocalAbortSpanSuffix = []byte("abc-")

    // LocalRangeLastGCSuffix is the suffix for the last GC.
    LocalRangeLastGCSuffix = []byte("lgc-")
    // LocalRangeAppliedStateSuffix is the suffix for the range applied state
    // key.
    LocalRangeAppliedStateSuffix = []byte("rask")
    // LocalRaftAppliedIndexLegacySuffix is the suffix for the raft applied index.
    LocalRaftAppliedIndexLegacySuffix = []byte("rfta")
    // LocalRaftTruncatedStateLegacySuffix is the suffix for the legacy
    // RaftTruncatedState. See VersionUnreplicatedRaftTruncatedState.
    // Note: This suffix is also used for unreplicated Range-ID keys.
    LocalRaftTruncatedStateLegacySuffix = []byte("rftt")
    // LocalRangeLeaseSuffix is the suffix for a range lease.
    LocalRangeLeaseSuffix = []byte("rll-")
    // LocalLeaseAppliedIndexLegacySuffix is the suffix for the applied lease
    // index.
    LocalLeaseAppliedIndexLegacySuffix = []byte("rlla")
    // LocalRangeStatsLegacySuffix is the suffix for range statistics.
    LocalRangeStatsLegacySuffix = []byte("stat")

    // LocalRangeTombstoneSuffix is the suffix for the range tombstone.
    //
    // NB: This suffix was originally named LocalRaftTombstoneSuffix, which is
    // why it starts off with "rft" as opposed to "rl".
    LocalRangeTombstoneSuffix = []byte("rftb")
    // LocalRaftHardStateSuffix is the Suffix for the raft HardState.
    LocalRaftHardStateSuffix = []byte("rfth")

    // LocalRaftLogSuffix is the suffix for the raft log.
    LocalRaftLogSuffix = []byte("rftl")
    // LocalRangeLastReplicaGCTimestampSuffix is the suffix for a range's last
    // replica GC timestamp (for GC of old replicas).
    LocalRangeLastReplicaGCTimestampSuffix = []byte("rlrt")

    // 3. Range local keys
    //
    // LocalRangePrefix is the prefix identifying per-range data indexed
    // by range key (either start key, or some key in the range). The
    // key is appended to this prefix, encoded using EncodeBytes. The
    // specific sort of per-range metadata is identified by one of the
    // suffixes listed below, along with potentially additional encoded
    // key info, such as the txn ID in the case of a transaction record.
    //
    // NOTE: LocalRangePrefix must be kept in sync with the value in
    // storage/engine/rocksdb/db.cc.
    LocalRangePrefix = roachpb.Key(makeKey(localPrefix, roachpb.RKey("k")))
    LocalRangeMax    = LocalRangePrefix.PrefixEnd()
    // LocalQueueLastProcessedSuffix is the suffix for replica queue state keys.
    LocalQueueLastProcessedSuffix = roachpb.RKey("qlpt")
    // LocalRangeDescriptorJointSuffix is the suffix for keys storing
    // range descriptors. The value is a struct of type RangeDescriptor.
    //
    // TODO(tbg): decide what to actually store here. This is still unused.
    LocalRangeDescriptorJointSuffix = roachpb.RKey("rdjt")
    // LocalRangeDescriptorSuffix is the suffix for keys storing
    // range descriptors. The value is a struct of type RangeDescriptor.
    LocalRangeDescriptorSuffix = roachpb.RKey("rdsc")
    // LocalTransactionSuffix specifies the key suffix for
    // transaction records. The additional detail is the transaction id.
    // NOTE: if this value changes, it must be updated in C++
    // (storage/engine/rocksdb/db.cc).
    LocalTransactionSuffix = roachpb.RKey("txn-")

    // LocalStoreSuggestedCompactionsMin is the start of the span of
    // possible suggested compaction keys for a store.
    LocalStoreSuggestedCompactionsMin = MakeStoreKey(localStoreSuggestedCompactionSuffix, nil)
    // LocalStoreSuggestedCompactionsMax is the end of the span of
    // possible suggested compaction keys for a store.
    LocalStoreSuggestedCompactionsMax = LocalStoreSuggestedCompactionsMin.PrefixEnd()

    // 1. Meta keys
    //
    // MetaMin is the start of the range of addressing keys.
    MetaMin = Meta1Prefix
    // MetaMax is the end of the range of addressing keys.
    MetaMax = roachpb.Key{metaMaxByte}
    // Meta1Prefix is the first level of key addressing. It is selected such that
    // all range addressing records sort before any system tables which they
    // might describe. The value is a RangeDescriptor struct.
    Meta1Prefix = roachpb.Key{meta1PrefixByte}
    // Meta1KeyMax is the end of the range of the first level of key addressing.
    // The value is a RangeDescriptor struct.
    Meta1KeyMax = roachpb.Key(makeKey(Meta1Prefix, roachpb.RKeyMax))
    // Meta2Prefix is the second level of key addressing. The value is a
    // RangeDescriptor struct.
    Meta2Prefix = roachpb.Key{meta2PrefixByte}
    // Meta2KeyMax is the end of the range of the second level of key addressing.
    // The value is a RangeDescriptor struct.
    Meta2KeyMax = roachpb.Key(makeKey(Meta2Prefix, roachpb.RKeyMax))

    // 2. System keys
    //
    // SystemPrefix indicates the beginning of the key range for
    // global, system data which are replicated across the cluster.
    SystemPrefix = roachpb.Key{systemPrefixByte}
    SystemMax    = roachpb.Key{systemMaxByte}
    // NodeLivenessPrefix specifies the key prefix for the node liveness
    // table.  Note that this should sort before the rest of the system
    // keyspace in order to limit the number of ranges which must use
    // expiration-based range leases instead of the more efficient
    // node-liveness epoch-based range leases (see
    // https://github.com/cockroachdb/cockroach/blob/master/docs/RFCS/20160210_range_leases.md)
    NodeLivenessPrefix = roachpb.Key(makeKey(SystemPrefix, roachpb.RKey("\x00liveness-")))
    // NodeLivenessKeyMax is the maximum value for any node liveness key.
    NodeLivenessKeyMax = NodeLivenessPrefix.PrefixEnd()
    //
    // BootstrapVersion is the key at which clusters bootstrapped with a version
    // > 1.0 persist the version at which they were bootstrapped.
    BootstrapVersionKey = roachpb.Key(makeKey(SystemPrefix, roachpb.RKey("bootstrap-version")))

    // NodeIDGenerator is the global node ID generator sequence.
    NodeIDGenerator = roachpb.Key(makeKey(SystemPrefix, roachpb.RKey("node-idgen")))
    // RangeIDGenerator is the global range ID generator sequence.
    RangeIDGenerator = roachpb.Key(makeKey(SystemPrefix, roachpb.RKey("range-idgen")))
    // StoreIDGenerator is the global store ID generator sequence.
    StoreIDGenerator = roachpb.Key(makeKey(SystemPrefix, roachpb.RKey("store-idgen")))
    //
    // StatusPrefix specifies the key prefix to store all status details.
    StatusPrefix = roachpb.Key(makeKey(SystemPrefix, roachpb.RKey("status-")))
    // StatusNodePrefix stores all status info for nodes.
    StatusNodePrefix = roachpb.Key(makeKey(StatusPrefix, roachpb.RKey("node-")))
    //
    // MigrationPrefix specifies the key prefix to store all migration details.
    MigrationPrefix = roachpb.Key(makeKey(SystemPrefix, roachpb.RKey("system-version/")))
    // MigrationLease is the key that nodes must take a lease on in order to run
    // system migrations on the cluster.
    MigrationLease = roachpb.Key(makeKey(MigrationPrefix, roachpb.RKey("lease")))
    //
    // TimeseriesPrefix is the key prefix for all timeseries data.
    TimeseriesPrefix = roachpb.Key(makeKey(SystemPrefix, roachpb.RKey("tsd")))
    // TimeseriesKeyMax is the maximum value for any timeseries data.
    TimeseriesKeyMax = TimeseriesPrefix.PrefixEnd()

    // 3. System tenant SQL keys
    //
    // TODO(nvanbenschoten): Figure out what to do with all of these. At a
    // minimum, prefix them all with "System".
    //
    // TableDataMin is the start of the range of table data keys.
    TableDataMin = SystemSQLCodec.TablePrefix(0)
    // TableDataMin is the end of the range of table data keys.
    TableDataMax = SystemSQLCodec.TablePrefix(math.MaxUint32).PrefixEnd()
    //
    // SystemConfigSplitKey is the key to split at immediately prior to the
    // system config span. NB: Split keys need to be valid column keys.
    // TODO(bdarnell): this should be either roachpb.Key or RKey, not []byte.
    SystemConfigSplitKey = []byte(TableDataMin)
    // SystemConfigTableDataMax is the end key of system config span.
    SystemConfigTableDataMax = SystemSQLCodec.TablePrefix(MaxSystemConfigDescID + 1)
    //
    // NamespaceTableMin is the start key of system.namespace, which is a system
    // table that does not reside in the same range as other system tables.
    NamespaceTableMin = SystemSQLCodec.TablePrefix(NamespaceTableID)
    // NamespaceTableMax is the end key of system.namespace.
    NamespaceTableMax = SystemSQLCodec.TablePrefix(NamespaceTableID + 1)
    //
    // UserTableDataMin is the start key of user structured data.
    UserTableDataMin = SystemSQLCodec.TablePrefix(MinUserDescID)

    // 4. Non-system tenant SQL keys
    //
    // TenantPrefix is the prefix for all non-system tenant keys.
    TenantPrefix       = roachpb.Key{tenantPrefixByte}
    TenantTableDataMin = MakeTenantPrefix(roachpb.MinTenantID)
    TenantTableDataMax = MakeTenantPrefix(roachpb.MaxTenantID).PrefixEnd()
)

Constants for system-reserved keys in the KV map.

Note: Preserve group-wise ordering when adding new constants. Note: Update `keymap` in doc.go when adding new constants.

var (
    // ConstKeyDict translates some pretty-printed keys.
    ConstKeyDict = []struct {
        Name  string
        Value roachpb.Key
    }{
        {"/Max", MaxKey},
        {"/Min", MinKey},
        {"/Meta1/Max", Meta1KeyMax},
        {"/Meta2/Max", Meta2KeyMax},
    }

    // KeyDict drives the pretty-printing and pretty-scanning of the key space.
    KeyDict = KeyComprehensionTable{
        {Name: "/Local", Entries: []DictEntry{
            {Name: "/Store",
                PSFunc: localStoreKeyParse,
                // contains filtered or unexported fields
            },
            {Name: "/RangeID",
                PSFunc: localRangeIDKeyParse,
                // contains filtered or unexported fields
            },
            {Name: "/Range",
                PSFunc: parseUnsupported,
                // contains filtered or unexported fields
            },
        },
        // contains filtered or unexported fields
        },
        {Name: "/Meta1", Entries: []DictEntry{
            {Name: "",
                PSFunc: func(input string) (string, roachpb.Key) {
                    input = mustShiftSlash(input)
                    unq, err := strconv.Unquote(input)
                    if err != nil {
                        panic(err)
                    }
                    if len(unq) == 0 {
                        return "", Meta1Prefix
                    }
                    return "", RangeMetaKey(RangeMetaKey(MustAddr(
                        roachpb.Key(unq)))).AsRawKey()
                },
                // contains filtered or unexported fields
            }},
        // contains filtered or unexported fields
        },
        {Name: "/Meta2", Entries: []DictEntry{
            {Name: "",
                PSFunc: func(input string) (string, roachpb.Key) {
                    input = mustShiftSlash(input)
                    unq, err := strconv.Unquote(input)
                    if err != nil {
                        panic(&ErrUglifyUnsupported{err})
                    }
                    if len(unq) == 0 {
                        return "", Meta2Prefix
                    }
                    return "", RangeMetaKey(MustAddr(roachpb.Key(unq))).AsRawKey()
                },
                // contains filtered or unexported fields
            }},
        // contains filtered or unexported fields
        },
        {Name: "/System", Entries: []DictEntry{
            {Name: "/NodeLiveness",

                PSFunc: parseUnsupported,
                // contains filtered or unexported fields
            },
            {Name: "/NodeLivenessMax",

                PSFunc: parseUnsupported,
                // contains filtered or unexported fields
            },
            {Name: "/StatusNode",

                PSFunc: parseUnsupported,
                // contains filtered or unexported fields
            },
            {Name: "/tsd",

                PSFunc: parseUnsupported,
                // contains filtered or unexported fields
            },
        },
        // contains filtered or unexported fields
        },
        {Name: "/NamespaceTable", Entries: []DictEntry{
            {Name: "", PSFunc: parseUnsupported, /* contains filtered or unexported fields */},
        },
        // contains filtered or unexported fields
        },
        {Name: "/Table", Entries: []DictEntry{
            {Name: "", PSFunc: tableKeyParse, /* contains filtered or unexported fields */},
        },
        // contains filtered or unexported fields
        },
        {Name: "/Tenant", Entries: []DictEntry{
            {Name: "", PSFunc: tenantKeyParse, /* contains filtered or unexported fields */},
        },
        // contains filtered or unexported fields
        },
    }
)
var (
    // Meta1Span holds all first level addressing records.
    Meta1Span = roachpb.Span{Key: roachpb.KeyMin, EndKey: Meta2Prefix}

    // Meta2MaxSpan begins at key Meta2KeyMax with the last entry in the second
    // level addressing keyspace. The rest of the span is always empty. We cannot
    // split at this starting key or between it and MetaMax.
    // - The first condition is explained and enforced in libroach/mvcc.cc.
    // - The second condition is necessary because a split between Meta2KeyMax
    //   and MetaMax would conflict with the use of Meta1KeyMax to hold the
    //   descriptor for the range that spans the meta2/userspace boundary (see
    //   case 3a in rangeAddressing). If splits were allowed in this span then
    //   the descriptor for the ranges ending in this span would be stored AFTER
    //   Meta1KeyMax, which would allow meta1 to get out of order.
    Meta2MaxSpan = roachpb.Span{Key: Meta2KeyMax, EndKey: MetaMax}

    // NodeLivenessSpan holds the liveness records for nodes in the cluster.
    NodeLivenessSpan = roachpb.Span{Key: NodeLivenessPrefix, EndKey: NodeLivenessKeyMax}

    // SystemConfigSpan is the range of system objects which will be gossiped.
    SystemConfigSpan = roachpb.Span{Key: SystemConfigSplitKey, EndKey: SystemConfigTableDataMax}

    // NoSplitSpans describes the ranges that should never be split.
    // Meta1Span: needed to find other ranges.
    // Meta2MaxSpan: between meta and system ranges.
    // NodeLivenessSpan: liveness information on nodes in the cluster.
    // SystemConfigSpan: system objects which will be gossiped.
    NoSplitSpans = []roachpb.Span{Meta1Span, Meta2MaxSpan, NodeLivenessSpan, SystemConfigSpan}
)
var MaxPseudoTableID = func() uint32 {
    var max uint32
    for _, id := range PseudoTableIDs {
        if max < id {
            max = id
        }
    }
    return max
}()

MaxPseudoTableID is the largest ID in PseudoTableIDs.

var PrettyPrintTimeseriesKey func(key roachpb.Key) string

PrettyPrintTimeseriesKey is a hook for pretty printing a timeseries key. The timeseries key prefix will already have been stripped off.

var PseudoTableIDs = []uint32{
    MetaRangesID,
    SystemRangesID,
    TimeseriesRangesID,
    LivenessRangesID,
    PublicSchemaID,
    TenantsRangesID,
}

PseudoTableIDs is the list of ids from above that are not real tables (i.e. there's no table descriptor). They're grouped here because the cluster bootstrap process needs to create splits for them; splits for the tables happen separately.

var SystemSQLCodec = MakeSQLCodec(roachpb.SystemTenantID)

SystemSQLCodec is a SQL key codec for the system tenant.

var TODOSQLCodec = MakeSQLCodec(roachpb.SystemTenantID)

TODOSQLCodec is a SQL key codec. It is equivalent to SystemSQLCodec, but should be used when it is unclear which tenant should be referenced by the surrounding context.

func AbortSpanKey Uses

func AbortSpanKey(rangeID roachpb.RangeID, txnID uuid.UUID) roachpb.Key

AbortSpanKey returns a range-local key by Range ID for an AbortSpan entry, with detail specified by encoding the supplied transaction ID.

func Addr Uses

func Addr(k roachpb.Key) (roachpb.RKey, error)

Addr returns the address for the key, used to lookup the range containing the key. In the normal case, this is simply the key's value. However, for local keys, such as transaction records, the address is the inner encoded key, with the local key prefix and the suffix and optional detail removed. This address unwrapping is performed repeatedly in the case of doubly-local keys. In this way, local keys address to the same range as non-local keys, but are stored separately so that they don't collide with user-space or global system keys.

Logically, the keys are arranged as follows:

k1 /local/k1/KeyMin ... /local/k1/KeyMax k1\x00 /local/k1/x00/KeyMin ...

However, not all local keys are addressable in the global map. Only range local keys incorporating a range key (start key or transaction key) are addressable (e.g. range metadata and txn records). Range local keys incorporating the Range ID are not (e.g. AbortSpan Entries, and range stats).

See AddrUpperBound which is to be used when `k` is the EndKey of an interval.

func AddrUpperBound Uses

func AddrUpperBound(k roachpb.Key) (roachpb.RKey, error)

AddrUpperBound returns the address of an (exclusive) EndKey, used to lookup ranges containing the keys strictly smaller than that key. However, unlike Addr, it will return the following key that local range keys address to. This is necessary because range-local keys exist conceptually in the space between regular keys. Addr() returns the regular key that is just to the left of a range-local key, which is guaranteed to be located on the same range. AddrUpperBound() returns the regular key that is just to the right, which may not be on the same range but is suitable for use as the EndKey of a span involving a range-local key.

Logically, the keys are arranged as follows:

k1 /local/k1/KeyMin ... /local/k1/KeyMax k1\x00 /local/k1/x00/KeyMin ...

and so any end key /local/k1/x corresponds to an address-resolved end key of k1\x00.

func DecodeAbortSpanKey Uses

func DecodeAbortSpanKey(key roachpb.Key, dest []byte) (uuid.UUID, error)

DecodeAbortSpanKey decodes the provided AbortSpan entry, returning the transaction ID.

func DecodeRangeIDKey Uses

func DecodeRangeIDKey(
    key roachpb.Key,
) (rangeID roachpb.RangeID, infix, suffix, detail roachpb.Key, err error)

DecodeRangeIDKey parses a local range ID key into range ID, infix, suffix, and detail.

func DecodeRangeKey Uses

func DecodeRangeKey(key roachpb.Key) (startKey, suffix, detail roachpb.Key, err error)

DecodeRangeKey decodes the range key into range start key, suffix and optional detail (may be nil).

func DecodeStoreKey Uses

func DecodeStoreKey(key roachpb.Key) (suffix, detail roachpb.RKey, err error)

DecodeStoreKey returns the suffix and detail portions of a local store key.

func DecodeStoreSuggestedCompactionKey Uses

func DecodeStoreSuggestedCompactionKey(key roachpb.Key) (start, end roachpb.Key, err error)

DecodeStoreSuggestedCompactionKey returns the start and end keys of the suggested compaction's span.

func DecodeTableIDIndexID Uses

func DecodeTableIDIndexID(key []byte) ([]byte, uint32, uint32, error)

DecodeTableIDIndexID decodes a table id followed by an index id from the provided key. The input key must already have its tenant id removed.

func DecodeTenantPrefix Uses

func DecodeTenantPrefix(key roachpb.Key) ([]byte, roachpb.TenantID, error)

DecodeTenantPrefix determines the tenant ID from the key prefix, returning the remainder of the key (with the prefix removed) and the decoded tenant ID.

func EnsureSafeSplitKey Uses

func EnsureSafeSplitKey(key roachpb.Key) (roachpb.Key, error)

EnsureSafeSplitKey transforms an SQL table key such that it is a valid split key (i.e. does not occur in the middle of a row).

func GetRowPrefixLength Uses

func GetRowPrefixLength(key roachpb.Key) (int, error)

GetRowPrefixLength returns the length of the row prefix of the key. A table key's row prefix is defined as the maximal prefix of the key that is also a prefix of every key for the same row. (Any key with this maximal prefix is also guaranteed to be part of the input key's row.) For secondary index keys, the row prefix is defined as the entire key.

func IsLocal Uses

func IsLocal(k roachpb.Key) bool

IsLocal performs a cheap check that returns true iff a range-local key is passed, that is, a key for which `Addr` would return a non-identical RKey (or a decoding error).

TODO(tschottdorf): we need a better name for these keys as only some of them are local and it's been identified as an area that is not understood by many of the team's developers. An obvious suggestion is "system" (as opposed to "user") keys, but unfortunately that name has already been claimed by a related (but not identical) concept.

func LeaseAppliedIndexLegacyKey Uses

func LeaseAppliedIndexLegacyKey(rangeID roachpb.RangeID) roachpb.Key

LeaseAppliedIndexLegacyKey returns a system-local key for a lease applied index. The key is no longer written to. Its responsibility has been subsumed by the RangeAppliedStateKey.

func MakeFamilyKey Uses

func MakeFamilyKey(key []byte, famID uint32) []byte

MakeFamilyKey returns the key for the family in the given row by appending to the passed key.

func MakeRangeIDPrefix Uses

func MakeRangeIDPrefix(rangeID roachpb.RangeID) roachpb.Key

MakeRangeIDPrefix creates a range-local key prefix from rangeID for both replicated and unreplicated data.

func MakeRangeIDReplicatedPrefix Uses

func MakeRangeIDReplicatedPrefix(rangeID roachpb.RangeID) roachpb.Key

MakeRangeIDReplicatedPrefix creates a range-local key prefix from rangeID for all Raft replicated data.

func MakeRangeIDUnreplicatedPrefix Uses

func MakeRangeIDUnreplicatedPrefix(rangeID roachpb.RangeID) roachpb.Key

MakeRangeIDUnreplicatedPrefix creates a range-local key prefix from rangeID for all unreplicated data.

func MakeRangeKey Uses

func MakeRangeKey(key, suffix, detail roachpb.RKey) roachpb.Key

MakeRangeKey creates a range-local key based on the range start key, metadata key suffix, and optional detail (e.g. the transaction ID for a txn record, etc.).

func MakeRangeKeyPrefix Uses

func MakeRangeKeyPrefix(key roachpb.RKey) roachpb.Key

MakeRangeKeyPrefix creates a key prefix under which all range-local keys can be found.

func MakeStoreKey Uses

func MakeStoreKey(suffix, detail roachpb.RKey) roachpb.Key

MakeStoreKey creates a store-local key based on the metadata key suffix, and optional detail.

func MakeTableIDIndexID Uses

func MakeTableIDIndexID(key []byte, tableID uint32, indexID uint32) []byte

MakeTableIDIndexID returns the key for the table id and index id by appending to the passed key. The key must already contain a tenant id.

func MakeTenantPrefix Uses

func MakeTenantPrefix(tenID roachpb.TenantID) roachpb.Key

MakeTenantPrefix creates the key prefix associated with the specified tenant.

func MassagePrettyPrintedSpanForTest Uses

func MassagePrettyPrintedSpanForTest(span string, dirs []encoding.Direction) string

MassagePrettyPrintedSpanForTest does some transformations on pretty-printed spans and keys: - if dirs is not nil, replace all ints with their ones' complement for descendingly-encoded columns. - strips line numbers from error messages.

func MetaReverseScanBounds Uses

func MetaReverseScanBounds(key roachpb.RKey) (roachpb.RSpan, error)

MetaReverseScanBounds returns the range [start,end) within which the desired meta record can be found by means of a reverse engine scan. The given key must be a valid RangeMetaKey as defined by validateRangeMetaKey.

func MetaScanBounds Uses

func MetaScanBounds(key roachpb.RKey) (roachpb.RSpan, error)

MetaScanBounds returns the range [start,end) within which the desired meta record can be found by means of an engine scan. The given key must be a valid RangeMetaKey as defined by validateRangeMetaKey. TODO(tschottdorf): a lot of casting going on inside.

func MustAddr Uses

func MustAddr(k roachpb.Key) roachpb.RKey

MustAddr calls Addr and panics on errors.

func NodeLivenessKey Uses

func NodeLivenessKey(nodeID roachpb.NodeID) roachpb.Key

NodeLivenessKey returns the key for the node liveness record.

func NodeStatusKey Uses

func NodeStatusKey(nodeID roachpb.NodeID) roachpb.Key

NodeStatusKey returns the key for accessing the node status for the specified node ID.

func PrettyPrint Uses

func PrettyPrint(valDirs []encoding.Direction, key roachpb.Key) string

PrettyPrint prints the key in a human readable format, see TestPrettyPrint. The output does not indicate whether a key is part of the replicated or un- replicated keyspace.

valDirs correspond to the encoding direction of each encoded value in key. For example, table keys could have column values encoded in ascending or descending directions. If valDirs is unspecified, the default encoding direction for each value type is used (see encoding.go:prettyPrintFirstValue).

See keysutil.UglyPrint() for an inverse.

func PrettyPrintRange Uses

func PrettyPrintRange(start, end roachpb.Key, maxChars int) string

PrettyPrintRange pretty prints a compact representation of a key range. The output is of the form:

commonPrefix{remainingStart-remainingEnd}

If the end key is empty, the outut is of the form:

start

It prints at most maxChars, truncating components as needed. See TestPrettyPrintRange for some examples.

func QueueLastProcessedKey Uses

func QueueLastProcessedKey(key roachpb.RKey, queue string) roachpb.Key

QueueLastProcessedKey returns a range-local key for last processed timestamps for the named queue. These keys represent per-range last processed times.

func RaftAppliedIndexLegacyKey Uses

func RaftAppliedIndexLegacyKey(rangeID roachpb.RangeID) roachpb.Key

RaftAppliedIndexLegacyKey returns a system-local key for a raft applied index. The key is no longer written to. Its responsibility has been subsumed by the RangeAppliedStateKey.

func RaftHardStateKey Uses

func RaftHardStateKey(rangeID roachpb.RangeID) roachpb.Key

RaftHardStateKey returns a system-local key for a Raft HardState.

func RaftLogKey Uses

func RaftLogKey(rangeID roachpb.RangeID, logIndex uint64) roachpb.Key

RaftLogKey returns a system-local key for a Raft log entry.

func RaftLogPrefix Uses

func RaftLogPrefix(rangeID roachpb.RangeID) roachpb.Key

RaftLogPrefix returns the system-local prefix shared by all Entries in a Raft log.

func RaftTruncatedStateKey Uses

func RaftTruncatedStateKey(rangeID roachpb.RangeID) roachpb.Key

RaftTruncatedStateKey returns a system-local key for a RaftTruncatedState.

func RaftTruncatedStateLegacyKey Uses

func RaftTruncatedStateLegacyKey(rangeID roachpb.RangeID) roachpb.Key

RaftTruncatedStateLegacyKey returns a system-local key for a RaftTruncatedState. See VersionUnreplicatedRaftTruncatedState.

func Range Uses

func Range(reqs []roachpb.RequestUnion) (roachpb.RSpan, error)

Range returns a key range encompassing the key ranges of all requests.

func RangeAppliedStateKey Uses

func RangeAppliedStateKey(rangeID roachpb.RangeID) roachpb.Key

RangeAppliedStateKey returns a system-local key for the range applied state key. This key has subsumed the responsibility of the following three keys: - RaftAppliedIndexLegacyKey - LeaseAppliedIndexLegacyKey - RangeStatsLegacyKey

func RangeDescriptorJointKey Uses

func RangeDescriptorJointKey(key roachpb.RKey) roachpb.Key

RangeDescriptorJointKey returns a range-local key for the "joint descriptor" for the range with specified key. This key is not versioned and it is set if and only if the range is in a joint configuration that it yet has to transition out of.

func RangeDescriptorKey Uses

func RangeDescriptorKey(key roachpb.RKey) roachpb.Key

RangeDescriptorKey returns a range-local key for the descriptor for the range with specified key.

func RangeLastGCKey Uses

func RangeLastGCKey(rangeID roachpb.RangeID) roachpb.Key

RangeLastGCKey returns a system-local key for last used GC threshold on the user keyspace. Reads and writes <= this timestamp will not be served.

TODO(tschottdorf): should be renamed to RangeGCThresholdKey.

func RangeLastReplicaGCTimestampKey Uses

func RangeLastReplicaGCTimestampKey(rangeID roachpb.RangeID) roachpb.Key

RangeLastReplicaGCTimestampKey returns a range-local key for the range's last replica GC timestamp.

func RangeLeaseKey Uses

func RangeLeaseKey(rangeID roachpb.RangeID) roachpb.Key

RangeLeaseKey returns a system-local key for a range lease.

func RangeMetaKey Uses

func RangeMetaKey(key roachpb.RKey) roachpb.RKey

RangeMetaKey returns a range metadata (meta1, meta2) indexing key for the given key.

- For RKeyMin, KeyMin is returned. - For a meta1 key, KeyMin is returned. - For a meta2 key, a meta1 key is returned. - For an ordinary key, a meta2 key is returned.

func RangeStatsLegacyKey Uses

func RangeStatsLegacyKey(rangeID roachpb.RangeID) roachpb.Key

RangeStatsLegacyKey returns the key for accessing the MVCCStats struct for the specified Range ID. The key is no longer written to. Its responsibility has been subsumed by the RangeAppliedStateKey.

func RangeTombstoneKey Uses

func RangeTombstoneKey(rangeID roachpb.RangeID) roachpb.Key

RangeTombstoneKey returns a system-local key for a range tombstone.

func SpanAddr Uses

func SpanAddr(span roachpb.Span) (roachpb.RSpan, error)

SpanAddr is like Addr, but it takes a Span instead of a single key and applies the key transformation to the start and end keys in the span, returning an RSpan.

func StoreClusterVersionKey Uses

func StoreClusterVersionKey() roachpb.Key

StoreClusterVersionKey returns a store-local key for the cluster version.

func StoreGossipKey Uses

func StoreGossipKey() roachpb.Key

StoreGossipKey returns a store-local key for the gossip bootstrap metadata.

func StoreHLCUpperBoundKey Uses

func StoreHLCUpperBoundKey() roachpb.Key

StoreHLCUpperBoundKey returns the store-local key for storing an upper bound to the wall time used by HLC.

func StoreIdentKey Uses

func StoreIdentKey() roachpb.Key

StoreIdentKey returns a store-local key for the store metadata.

func StoreLastUpKey Uses

func StoreLastUpKey() roachpb.Key

StoreLastUpKey returns the key for the store's "last up" timestamp.

func StoreSuggestedCompactionKey Uses

func StoreSuggestedCompactionKey(start, end roachpb.Key) roachpb.Key

StoreSuggestedCompactionKey returns a store-local key for a suggested compaction. It combines the specified start and end keys.

func TransactionKey Uses

func TransactionKey(key roachpb.Key, txnID uuid.UUID) roachpb.Key

TransactionKey returns a transaction key based on the provided transaction key and ID. The base key is encoded in order to guarantee that all transaction records for a range sort together.

func UserKey Uses

func UserKey(key roachpb.RKey) roachpb.RKey

UserKey returns an ordinary key for the given range metadata (meta1, meta2) indexing key.

- For RKeyMin, Meta1Prefix is returned. - For a meta1 key, a meta2 key is returned. - For a meta2 key, an ordinary key is returned. - For an ordinary key, the input key is returned.

type DictEntry Uses

type DictEntry struct {
    Name string

    // PSFunc parses the relevant prefix of the input into a roachpb.Key,
    // returning the remainder and the key corresponding to the consumed prefix of
    // 'input'. Allowed to panic on errors.
    PSFunc KeyParserFunc
    // contains filtered or unexported fields
}

DictEntry contains info on pretty-printing and pretty-scanning keys in a region of the key space.

type ErrUglifyUnsupported Uses

type ErrUglifyUnsupported struct {
    Wrapped error
}

ErrUglifyUnsupported is returned when UglyPrint doesn't know how to process a key.

func (*ErrUglifyUnsupported) Error Uses

func (euu *ErrUglifyUnsupported) Error() string

type InvalidRangeMetaKeyError Uses

type InvalidRangeMetaKeyError struct {
    Msg string
    Key roachpb.Key
}

InvalidRangeMetaKeyError indicates that a Range Metadata key is somehow invalid.

func NewInvalidRangeMetaKeyError Uses

func NewInvalidRangeMetaKeyError(msg string, k []byte) *InvalidRangeMetaKeyError

NewInvalidRangeMetaKeyError returns a new InvalidRangeMetaKeyError

func (*InvalidRangeMetaKeyError) Error Uses

func (i *InvalidRangeMetaKeyError) Error() string

Error formats error string.

type KeyComprehensionTable Uses

type KeyComprehensionTable []struct {
    Name string

    Entries []DictEntry
    // contains filtered or unexported fields
}

KeyComprehensionTable contains information about how to decode pretty-printed keys, split by key spans.

type KeyParserFunc Uses

type KeyParserFunc func(input string) (string, roachpb.Key)

KeyParserFunc is a function able to reverse pretty-printed keys.

type RangeIDPrefixBuf Uses

type RangeIDPrefixBuf roachpb.Key

RangeIDPrefixBuf provides methods for generating range ID local keys while avoiding an allocation on every key generated. The generated keys are only valid until the next call to one of the key generation methods.

func MakeRangeIDPrefixBuf Uses

func MakeRangeIDPrefixBuf(rangeID roachpb.RangeID) RangeIDPrefixBuf

MakeRangeIDPrefixBuf creates a new range ID prefix buf suitable for generating the various range ID local keys.

func (RangeIDPrefixBuf) AbortSpanKey Uses

func (b RangeIDPrefixBuf) AbortSpanKey(txnID uuid.UUID) roachpb.Key

AbortSpanKey returns a range-local key by Range ID for an AbortSpan entry, with detail specified by encoding the supplied transaction ID.

func (RangeIDPrefixBuf) LeaseAppliedIndexLegacyKey Uses

func (b RangeIDPrefixBuf) LeaseAppliedIndexLegacyKey() roachpb.Key

LeaseAppliedIndexLegacyKey returns a system-local key for a lease applied index. See comment on LeaseAppliedIndexLegacyKey function.

func (RangeIDPrefixBuf) RaftAppliedIndexLegacyKey Uses

func (b RangeIDPrefixBuf) RaftAppliedIndexLegacyKey() roachpb.Key

RaftAppliedIndexLegacyKey returns a system-local key for a raft applied index. See comment on RaftAppliedIndexLegacyKey function.

func (RangeIDPrefixBuf) RaftHardStateKey Uses

func (b RangeIDPrefixBuf) RaftHardStateKey() roachpb.Key

RaftHardStateKey returns a system-local key for a Raft HardState.

func (RangeIDPrefixBuf) RaftLogKey Uses

func (b RangeIDPrefixBuf) RaftLogKey(logIndex uint64) roachpb.Key

RaftLogKey returns a system-local key for a Raft log entry.

func (RangeIDPrefixBuf) RaftLogPrefix Uses

func (b RangeIDPrefixBuf) RaftLogPrefix() roachpb.Key

RaftLogPrefix returns the system-local prefix shared by all Entries in a Raft log.

func (RangeIDPrefixBuf) RaftTruncatedStateKey Uses

func (b RangeIDPrefixBuf) RaftTruncatedStateKey() roachpb.Key

RaftTruncatedStateKey returns a system-local key for a RaftTruncatedState.

func (RangeIDPrefixBuf) RaftTruncatedStateLegacyKey Uses

func (b RangeIDPrefixBuf) RaftTruncatedStateLegacyKey() roachpb.Key

RaftTruncatedStateLegacyKey returns a system-local key for a RaftTruncatedState.

func (RangeIDPrefixBuf) RangeAppliedStateKey Uses

func (b RangeIDPrefixBuf) RangeAppliedStateKey() roachpb.Key

RangeAppliedStateKey returns a system-local key for the range applied state key. See comment on RangeAppliedStateKey function.

func (RangeIDPrefixBuf) RangeLastGCKey Uses

func (b RangeIDPrefixBuf) RangeLastGCKey() roachpb.Key

RangeLastGCKey returns a system-local key for the last GC.

func (RangeIDPrefixBuf) RangeLastReplicaGCTimestampKey Uses

func (b RangeIDPrefixBuf) RangeLastReplicaGCTimestampKey() roachpb.Key

RangeLastReplicaGCTimestampKey returns a range-local key for the range's last replica GC timestamp.

func (RangeIDPrefixBuf) RangeLeaseKey Uses

func (b RangeIDPrefixBuf) RangeLeaseKey() roachpb.Key

RangeLeaseKey returns a system-local key for a range lease.

func (RangeIDPrefixBuf) RangeStatsLegacyKey Uses

func (b RangeIDPrefixBuf) RangeStatsLegacyKey() roachpb.Key

RangeStatsLegacyKey returns the key for accessing the MVCCStats struct for the specified Range ID. See comment on RangeStatsLegacyKey function.

func (RangeIDPrefixBuf) RangeTombstoneKey Uses

func (b RangeIDPrefixBuf) RangeTombstoneKey() roachpb.Key

RangeTombstoneKey returns a system-local key for a range tombstone.

type SQLCodec Uses

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

SQLCodec provides methods for encoding SQL table keys bound to a given tenant. The generator also provides methods for efficiently decoding keys previously generated by it. The generated keys are safe to use indefinitely and the generator is safe to use concurrently.

func MakeSQLCodec Uses

func MakeSQLCodec(tenID roachpb.TenantID) SQLCodec

MakeSQLCodec creates a new SQLCodec suitable for manipulating SQL keys.

func (SQLCodec) DecodeDescMetadataID Uses

func (d SQLCodec) DecodeDescMetadataID(key roachpb.Key) (uint32, error)

DecodeDescMetadataID decodes a descriptor ID from a descriptor metadata key.

func (SQLCodec) DecodeIndexPrefix Uses

func (d SQLCodec) DecodeIndexPrefix(key roachpb.Key) ([]byte, uint32, uint32, error)

DecodeIndexPrefix validates that the given key has a table ID followed by an index ID, returning the remainder of the key (with the table and index prefix removed) and the decoded IDs of the table and index, respectively.

func (SQLCodec) DecodeTablePrefix Uses

func (d SQLCodec) DecodeTablePrefix(key roachpb.Key) ([]byte, uint32, error)

DecodeTablePrefix validates that the given key has a table prefix, returning the remainder of the key (with the prefix removed) and the decoded descriptor ID of the table.

func (SQLCodec) DecodeTenantMetadataID Uses

func (d SQLCodec) DecodeTenantMetadataID(key roachpb.Key) (roachpb.TenantID, error)

DecodeTenantMetadataID decodes a tenant ID from a tenant metadata key.

func (SQLCodec) DescIDSequenceKey Uses

func (e SQLCodec) DescIDSequenceKey() roachpb.Key

DescIDSequenceKey returns the key used for the descriptor ID sequence.

func (SQLCodec) DescMetadataKey Uses

func (e SQLCodec) DescMetadataKey(descID uint32) roachpb.Key

DescMetadataKey returns the key for the descriptor in the system.descriptor table.

func (SQLCodec) DescMetadataPrefix Uses

func (e SQLCodec) DescMetadataPrefix() roachpb.Key

DescMetadataPrefix returns the key prefix for all descriptors in the system.descriptor table.

func (SQLCodec) ForSystemTenant Uses

func (e SQLCodec) ForSystemTenant() bool

ForSystemTenant returns whether the encoder is bound to the system tenant.

func (SQLCodec) IndexPrefix Uses

func (e SQLCodec) IndexPrefix(tableID, indexID uint32) roachpb.Key

IndexPrefix returns the key prefix used for the index's data.

func (SQLCodec) MigrationKeyPrefix Uses

func (e SQLCodec) MigrationKeyPrefix() roachpb.Key

MigrationKeyPrefix returns the key prefix to store all migration details.

func (SQLCodec) MigrationLeaseKey Uses

func (e SQLCodec) MigrationLeaseKey() roachpb.Key

MigrationLeaseKey returns the key that nodes must take a lease on in order to run system migrations on the cluster.

func (SQLCodec) SequenceKey Uses

func (e SQLCodec) SequenceKey(tableID uint32) roachpb.Key

SequenceKey returns the key used to store the value of a sequence.

func (SQLCodec) StripTenantPrefix Uses

func (d SQLCodec) StripTenantPrefix(key roachpb.Key) ([]byte, error)

StripTenantPrefix validates that the given key has the proper tenant ID prefix, returning the remainder of the key with the prefix removed. The method returns an error if the key has a different tenant ID prefix than would be generated by the generator.

func (SQLCodec) TablePrefix Uses

func (e SQLCodec) TablePrefix(tableID uint32) roachpb.Key

TablePrefix returns the key prefix used for the table's data.

func (SQLCodec) TenantMetadataKey Uses

func (e SQLCodec) TenantMetadataKey(tenID roachpb.TenantID) roachpb.Key

TenantMetadataKey returns the key for the tenant metadata in the system.tenants table.

func (SQLCodec) TenantPrefix Uses

func (e SQLCodec) TenantPrefix() roachpb.Key

TenantPrefix returns the key prefix used for the tenants's data.

func (SQLCodec) ZoneKey Uses

func (e SQLCodec) ZoneKey(id uint32) roachpb.Key

ZoneKey returns the key for id's entry in the system.zones table.

func (SQLCodec) ZoneKeyPrefix Uses

func (e SQLCodec) ZoneKeyPrefix(id uint32) roachpb.Key

ZoneKeyPrefix returns the key prefix for id's row in the system.zones table.

Package keys imports 9 packages (graph) and is imported by 861 packages. Updated 2020-08-13. Refresh now. Tools for package owners.