cockroach: github.com/abhinavdahiya/cockroach/sql/sqlbase Index | Files

package sqlbase

import "github.com/abhinavdahiya/cockroach/sql/sqlbase"

Package sqlbase is a generated protocol buffer package.

It is generated from these files:

cockroach/sql/sqlbase/encoded_datum.proto
cockroach/sql/sqlbase/privilege.proto
cockroach/sql/sqlbase/structured.proto

It has these top-level messages:

UserPrivileges
PrivilegeDescriptor
ColumnType
ForeignKeyReference
ColumnDescriptor
ColumnFamilyDescriptor
InterleaveDescriptor
IndexDescriptor
DescriptorMutation
TableDescriptor
DatabaseDescriptor
Descriptor

Index

Package Files

encoded_datum.go encoded_datum.pb.go errors.go expr_filter.go formatversion_string.go keys.go kvfetcher.go metadata.go ordering.go privilege.go privilege.pb.go rowfetcher.go structured.go structured.pb.go system.go table.go testutils.go

Constants

const FamilyHeuristicTargetBytes = 256

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

const (
    // PrimaryKeyIndexName is the name of the index for the primary key.
    PrimaryKeyIndexName = "primary"
)

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 = DatabaseDescriptor{
        Name: "system",
        ID:   keys.SystemDatabaseID,

        Privileges: NewPrivilegeDescriptor(security.RootUser,
            systemConfigAllowedPrivileges[keys.SystemDatabaseID]),
    }

    // DescriptorTable is the descriptor for the descriptor table.
    DescriptorTable = createSystemConfigTable(keys.DescriptorTableID, descriptorTableSchema)

    // NumSystemDescriptors should be set to the number of system descriptors
    // above (SystemDB and each system table). This is used by tests which need
    // to know the number of system descriptors intended for installation; it starts at
    // 1 for the SystemDB descriptor created above, and is incremented by every
    // call to createSystemTable().
    NumSystemDescriptors = 1
)
var ColumnType_Kind_name = map[int32]string{
    0:  "BOOL",
    1:  "INT",
    2:  "FLOAT",
    3:  "DECIMAL",
    4:  "DATE",
    5:  "TIMESTAMP",
    6:  "INTERVAL",
    7:  "STRING",
    8:  "BYTES",
    9:  "TIMESTAMPTZ",
}
var ColumnType_Kind_value = map[string]int32{
    "BOOL":        0,
    "INT":         1,
    "FLOAT":       2,
    "DECIMAL":     3,
    "DATE":        4,
    "TIMESTAMP":   5,
    "INTERVAL":    6,
    "STRING":      7,
    "BYTES":       8,
    "TIMESTAMPTZ": 9,
}
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 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:  "WRITE_ONLY",
}
var DescriptorMutation_State_value = map[string]int32{
    "UNKNOWN":     0,
    "DELETE_ONLY": 1,
    "WRITE_ONLY":  2,
}
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 IndexDescriptor_Direction_name = map[int32]string{
    0:  "ASC",
    1:  "DESC",
}
var IndexDescriptor_Direction_value = map[string]int32{
    "ASC":  0,
    "DESC": 1,
}
var TableDescriptor_State_name = map[int32]string{
    0:  "PUBLIC",
    1:  "ADD",
    2:  "DROP",
}
var TableDescriptor_State_value = map[string]int32{
    "PUBLIC": 0,
    "ADD":    1,
    "DROP":   2,
}

func CheckColumnType Uses

func CheckColumnType(col ColumnDescriptor, val parser.Datum, pmap *parser.PlaceholderInfo) error

CheckColumnType verifies that a given value is compatible with the type requested by the column. If the value is a placeholder, the type of the placeholder gets populated.

func CheckValueWidth Uses

func CheckValueWidth(col ColumnDescriptor, val parser.Datum) error

CheckValueWidth checks that the width (for strings/byte arrays) and scale (for decimals) of the value fits the specified column type. Used by INSERT and UPDATE.

func ColumnsSelectors Uses

func ColumnsSelectors(cols []ColumnDescriptor) parser.SelectExprs

ColumnsSelectors generates Select expressions for cols.

func DecodeIndexKey Uses

func DecodeIndexKey(
    a *DatumAlloc,
    desc *TableDescriptor,
    indexID IndexID,
    valTypes, vals []parser.Datum,
    colDirs []encoding.Direction,
    key []byte,
) ([]byte, bool, error)

DecodeIndexKey decodes the values that are a part of the specified index key. ValTypes is a slice returned from makeKeyVals. 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 DecodeKeyVals Uses

func DecodeKeyVals(a *DatumAlloc, valTypes, vals []parser.Datum,
    directions []encoding.Direction, key []byte) ([]byte, error)

DecodeKeyVals decodes the values that are part of the key. ValTypes is a slice returned from makeKeyVals. The decoded values are stored in the vals parameter while the valTypes parameter is unmodified. Note that len(vals) >= len(valTypes). The types of the decoded values will match the corresponding entry in the valTypes parameter with the exception that a value might also be parser.DNull. The remaining bytes in the key after decoding the values are returned. A slice of directions can be provided to enforce encoding direction on each value in valTypes. If this slice is nil, the direction used will default to encoding.Ascending.

func DecodeTableIDIndexID Uses

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

DecodeTableIDIndexID decodes a table id followed by an index id.

func DecodeTableKey Uses

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

DecodeTableKey decodes a table key/value.

func DecodeTableValue Uses

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

DecodeTableValue decodes a value encoded by EncodeTableValue.

func EncodeColumns Uses

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

EncodeColumns is a version of EncodeIndexKey that takes ColumnIDs and directions explicitly.

func EncodeDTuple Uses

func EncodeDTuple(b []byte, d parser.DTuple) ([]byte, error)

EncodeDTuple encodes a DTuple (order-preserving).

func EncodeDatum Uses

func EncodeDatum(b []byte, d parser.Datum) ([]byte, error)

EncodeDatum encodes a datum (order-preserving encoding, suitable for keys).

func EncodeIndexKey Uses

func EncodeIndexKey(
    tableDesc *TableDescriptor,
    index *IndexDescriptor,
    colMap map[ColumnID]int,
    values []parser.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.

If a table or index is interleaved, `encoding.encodedNullDesc` 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>

Returns the key and whether any of the encoded values were NULLs.

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

func EncodeSecondaryIndexes Uses

func EncodeSecondaryIndexes(
    tableDesc *TableDescriptor,
    indexes []IndexDescriptor,
    colMap map[ColumnID]int,
    values []parser.Datum,
    secondaryIndexEntries []IndexEntry,
) error

EncodeSecondaryIndexes encodes key/values for the secondary indexes. colMap maps ColumnIDs to indices in `values`. secondaryIndexEntries is the return value (passed as a parameter so the caller can reuse between rows) and is expected to be the same length as indexes.

func EncodeTableKey Uses

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

EncodeTableKey encodes `val` into `b` and returns the new buffer.

func EncodeTableValue Uses

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

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

func EqualName Uses

func EqualName(a, b string) bool

EqualName returns true iff the normalizations of a and b are equal.

func ExtractIndexKey Uses

func ExtractIndexKey(
    a *DatumAlloc,
    tableDesc *TableDescriptor,
    entry client.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 IsIntegrityConstraintError Uses

func IsIntegrityConstraintError(err error) bool

IsIntegrityConstraintError returns true if the error is some kind of SQL constraint violation.

func IsSystemConfigID Uses

func IsSystemConfigID(id ID) bool

IsSystemConfigID returns true if this ID is for a system config object.

func MakeDescMetadataKey Uses

func MakeDescMetadataKey(descID ID) roachpb.Key

MakeDescMetadataKey returns the key for the descriptor.

func MakeIndexKeyPrefix Uses

func MakeIndexKeyPrefix(desc *TableDescriptor, indexID IndexID) []byte

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

func MakeKeyFromEncDatums Uses

func MakeKeyFromEncDatums(
    values EncDatumRow,
    directions []IndexDescriptor_Direction,
    keyPrefix []byte,
    alloc *DatumAlloc,
) (key roachpb.Key, err error)

MakeKeyFromEncDatums creates a key by concatenating keyPrefix with the encodings of the given EncDatum values.

func MakeKeyVals Uses

func MakeKeyVals(
    desc *TableDescriptor, columnIDs []ColumnID,
) ([]parser.Datum, error)

MakeKeyVals returns a slice of Datums with the correct types for the given columns.

func MakeNameMetadataKey Uses

func MakeNameMetadataKey(parentID ID, name string) roachpb.Key

MakeNameMetadataKey returns the key for the name. Pass name == "" in order to generate the prefix key to use to scan over all of the names for the specified parentID.

func MakeZoneKey Uses

func MakeZoneKey(id ID) roachpb.Key

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

func MarshalColumnValue Uses

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

MarshalColumnValue returns a Go primitive value equivalent of val, of the type expected by col. If val's type is incompatible with col, or if col's type is not yet implemented, an error is returned.

func NewNonNullViolationError Uses

func NewNonNullViolationError(columnName string) error

NewNonNullViolationError creates a new ErrNonNullViolation.

func NewRetryError Uses

func NewRetryError(cause error) error

NewRetryError creates a ErrRetry.

func NewTransactionAbortedError Uses

func NewTransactionAbortedError(customMsg string) error

NewTransactionAbortedError creates a new ErrTransactionAborted.

func NewTransactionCommittedError Uses

func NewTransactionCommittedError() error

NewTransactionCommittedError creates a new ErrTransactionCommitted.

func NewUndefinedDatabaseError Uses

func NewUndefinedDatabaseError(name string) error

NewUndefinedDatabaseError creates a new ErrUndefinedDatabase.

func NewUndefinedTableError Uses

func NewUndefinedTableError(name string) error

NewUndefinedTableError creates a new ErrUndefinedTable.

func NewUniquenessConstraintViolationError Uses

func NewUniquenessConstraintViolationError(
    index *IndexDescriptor, vals []parser.Datum,
) error

NewUniquenessConstraintViolationError creates a new ErrUniquenessConstrainViolation.

func NormalizeName Uses

func NormalizeName(name string) string

NormalizeName normalizes to lowercase and Unicode Normalization Form C (NFC).

func PrettySpan Uses

func PrettySpan(span Span, skip int) string

PrettySpan returns a human-readable representation of a span.

func PrettySpans Uses

func PrettySpans(spans []Span, skip int) string

PrettySpans returns a human-readable description of the spans.

func RandDatum Uses

func RandDatum(rng *rand.Rand, typ ColumnType_Kind, null bool) parser.Datum

RandDatum generates a random Datum of the given type. If null is true, the datum can be DNull.

func RunFilter Uses

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

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

func SanitizeVarFreeExpr Uses

func SanitizeVarFreeExpr(expr parser.Expr, expectedType parser.Datum, context string) error

SanitizeVarFreeExpr verifies a default expression is valid, has the correct type and contains no variable expressions.

func SetKVBatchSize Uses

func SetKVBatchSize(val int64) func()

SetKVBatchSize changes the kvFetcher batch size, and returns a function that restores it.

func UnmarshalColumnValue Uses

func UnmarshalColumnValue(
    a *DatumAlloc, kind ColumnType_Kind, value *roachpb.Value,
) (parser.Datum, error)

UnmarshalColumnValue decodes the value from a key-value pair using the type expected by the column. An error is returned if the value's type does not match the column's type.

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                   ColumnType `protobuf:"bytes,3,opt,name=type" json:"type"`
    Nullable               bool       `protobuf:"varint,4,opt,name=nullable" json:"nullable"`
    NullableConstraintName string     `protobuf:"bytes,8,opt,name=nullable_constraint_name,json=nullableConstraintName" json:"nullable_constraint_name"`
    // Default expression to use to populate the column on insert if no
    // value is provided.
    DefaultExpr               *string `protobuf:"bytes,5,opt,name=default_expr,json=defaultExpr" json:"default_expr,omitempty"`
    DefaultExprConstraintName string  `protobuf:"bytes,9,opt,name=default_expr_constraint_name,json=defaultExprConstraintName" json:"default_expr_constraint_name"`
    Hidden                    bool    `protobuf:"varint,6,opt,name=hidden" json:"hidden"`
}

func MakeColumnDefDescs Uses

func MakeColumnDefDescs(d *parser.ColumnTableDef) (*ColumnDescriptor, *IndexDescriptor, error)

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

func (*ColumnDescriptor) Descriptor Uses

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

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) 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

type ColumnFamilyDescriptor Uses

type ColumnFamilyDescriptor struct {
    Name string   `protobuf:"bytes,1,opt,name=name" json:"name"`
    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 colums in a ValueType_TUPLE as repeated <colid><data>
    // entries. As a space optimization and for backward compatibility, a single
    // column is written without the columnid 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.

func (*ColumnFamilyDescriptor) Descriptor Uses

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

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

type ColumnID Uses

type ColumnID uint32

ColumnID is a custom type for ColumnDescriptor IDs.

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, true}, {1, false} }

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

type ColumnType Uses

type ColumnType struct {
    Kind ColumnType_Kind `protobuf:"varint,1,opt,name=kind,enum=cockroach.sql.sqlbase.ColumnType_Kind" json:"kind"`
    // BIT, INT, FLOAT, DECIMAL, CHAR and BINARY
    Width int32 `protobuf:"varint,2,opt,name=width" json:"width"`
    // FLOAT and DECIMAL.
    Precision int32 `protobuf:"varint,3,opt,name=precision" json:"precision"`
}

func (*ColumnType) Descriptor Uses

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

func (*ColumnType) Marshal Uses

func (m *ColumnType) Marshal() (data []byte, err error)

func (*ColumnType) MarshalTo Uses

func (m *ColumnType) MarshalTo(data []byte) (int, error)

func (*ColumnType) ProtoMessage Uses

func (*ColumnType) ProtoMessage()

func (*ColumnType) Reset Uses

func (m *ColumnType) Reset()

func (*ColumnType) SQLString Uses

func (c *ColumnType) SQLString() string

SQLString returns the SQL string corresponding to the type.

func (*ColumnType) Size Uses

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

func (*ColumnType) String Uses

func (m *ColumnType) String() string

func (*ColumnType) ToDatumType Uses

func (c *ColumnType) ToDatumType() parser.Datum

ToDatumType converts the ColumnType to the correct type Datum, or nil if there is no correspondence.

func (*ColumnType) Unmarshal Uses

func (m *ColumnType) Unmarshal(data []byte) error

type ColumnType_Kind Uses

type ColumnType_Kind int32

These mirror the types supported by the sql/parser. See sql/parser/types.go.

const (
    ColumnType_BOOL        ColumnType_Kind = 0
    ColumnType_INT         ColumnType_Kind = 1
    ColumnType_FLOAT       ColumnType_Kind = 2
    ColumnType_DECIMAL     ColumnType_Kind = 3
    ColumnType_DATE        ColumnType_Kind = 4
    ColumnType_TIMESTAMP   ColumnType_Kind = 5
    ColumnType_INTERVAL    ColumnType_Kind = 6
    ColumnType_STRING      ColumnType_Kind = 7
    ColumnType_BYTES       ColumnType_Kind = 8
    ColumnType_TIMESTAMPTZ ColumnType_Kind = 9
)

func RandColumnType Uses

func RandColumnType(rng *rand.Rand) ColumnType_Kind

RandColumnType returns a random ColumnType_Kind value.

func (ColumnType_Kind) Enum Uses

func (x ColumnType_Kind) Enum() *ColumnType_Kind

func (ColumnType_Kind) EnumDescriptor Uses

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

func (ColumnType_Kind) String Uses

func (x ColumnType_Kind) String() string

func (ColumnType_Kind) ToDatumType Uses

func (k ColumnType_Kind) ToDatumType() parser.Datum

ToDatumType converts the ColumnType_Kind to the correct type Datum, or nil if there is no correspondence.

func (*ColumnType_Kind) UnmarshalJSON Uses

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

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"`
    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 the TableDescriptor ID. Permissions are applied to all tables in the namespace.

func (*DatabaseDescriptor) Descriptor Uses

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

func (*DatabaseDescriptor) GetID Uses

func (m *DatabaseDescriptor) GetID() ID

func (*DatabaseDescriptor) GetName Uses

func (m *DatabaseDescriptor) GetName() string

func (*DatabaseDescriptor) GetPrivileges Uses

func (m *DatabaseDescriptor) GetPrivileges() *PrivilegeDescriptor

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) SetID Uses

func (desc *DatabaseDescriptor) SetID(id ID)

SetID implements the DescriptorProto interface.

func (*DatabaseDescriptor) SetName Uses

func (desc *DatabaseDescriptor) SetName(name string)

SetName implements the DescriptorProto interface.

func (*DatabaseDescriptor) Size Uses

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

func (*DatabaseDescriptor) String Uses

func (m *DatabaseDescriptor) String() string

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) Validate Uses

func (desc *DatabaseDescriptor) 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 DatumAlloc Uses

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

DatumAlloc provides batch allocation of datum pointers, amortizing the cost of the allocations.

func (*DatumAlloc) NewDBytes Uses

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

NewDBytes allocates a DBytes.

func (*DatumAlloc) NewDDate Uses

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

NewDDate allocates a DDate.

func (*DatumAlloc) NewDDecimal Uses

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

NewDDecimal allocates a DDecimal.

func (*DatumAlloc) NewDFloat Uses

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

NewDFloat allocates a DFloat.

func (*DatumAlloc) NewDInt Uses

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

NewDInt allocates a DInt.

func (*DatumAlloc) NewDInterval Uses

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

NewDInterval allocates a DInterval.

func (*DatumAlloc) NewDString Uses

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

NewDString allocates a DString.

func (*DatumAlloc) NewDTimestamp Uses

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

NewDTimestamp allocates a DTimestamp.

func (*DatumAlloc) NewDTimestampTZ Uses

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

NewDTimestampTZ allocates a DTimestampTZ.

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 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 Descriptor Uses

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

Descriptor is a union type holding either a table or database descriptor.

func WrapDescriptor Uses

func WrapDescriptor(descriptor DescriptorProto) *Descriptor

WrapDescriptor fills in a Descriptor.

func (*Descriptor) Descriptor Uses

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

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) GetName Uses

func (desc *Descriptor) GetName() string

GetName returns the Name of the descriptor.

func (*Descriptor) GetTable Uses

func (m *Descriptor) GetTable() *TableDescriptor

func (*Descriptor) GetUnion Uses

func (m *Descriptor) GetUnion() isDescriptor_Union

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) ProtoMessage Uses

func (*Descriptor) ProtoMessage()

func (*Descriptor) Reset Uses

func (m *Descriptor) Reset()

func (*Descriptor) Size Uses

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

func (*Descriptor) String Uses

func (m *Descriptor) String() string

func (*Descriptor) Unmarshal Uses

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

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.

type DescriptorKey Uses

type DescriptorKey interface {
    Key() 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.

type DescriptorMutation Uses

type DescriptorMutation struct {
    // Types that are valid to be assigned to Descriptor_:
    //	*DescriptorMutation_Column
    //	*DescriptorMutation_Index
    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"`
}

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.

func (*DescriptorMutation) Descriptor Uses

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

func (*DescriptorMutation) GetColumn Uses

func (m *DescriptorMutation) GetColumn() *ColumnDescriptor

func (*DescriptorMutation) GetDescriptor_ Uses

func (m *DescriptorMutation) GetDescriptor_() isDescriptorMutation_Descriptor_

func (*DescriptorMutation) GetIndex Uses

func (m *DescriptorMutation) GetIndex() *IndexDescriptor

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_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.

type DescriptorMutation_Column Uses

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

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_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) 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_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 WRITE_ONLY state.
    DescriptorMutation_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 DescriptorProto Uses

type DescriptorProto interface {
    proto.Message
    GetPrivileges() *PrivilegeDescriptor
    GetID() ID
    SetID(ID)
    TypeName() string
    GetName() string
    SetName(string)
    Validate() error
}

DescriptorProto is the interface implemented by both DatabaseDescriptor and TableDescriptor. TODO(marc): this is getting rather large.

type DescriptorStatus Uses

type DescriptorStatus int

DescriptorStatus is the status for a descriptor.

const (

    // DescriptorAbsent for a descriptor that doesn't exist.
    DescriptorAbsent DescriptorStatus
    // DescriptorIncomplete for a descriptor that is a part of a
    // schema change, and is still being processed.
    DescriptorIncomplete
    // DescriptorActive for a descriptor that is completely active
    // for read/write and delete operations.
    DescriptorActive
)

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) 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_Table Uses

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

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 EncDatum Uses

type EncDatum struct {
    Type ColumnType_Kind

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

EncDatum represents a datum that is "backed" by an encoding and/or by a parser.Datum. It allows "passing through" a Datum without decoding and reencoding. TODO(radu): It will also allow comparing encoded datums directly (for certain encodings).

func RandEncDatum Uses

func RandEncDatum(rng *rand.Rand) EncDatum

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

func (*EncDatum) Compare Uses

func (ed *EncDatum) Compare(a *DatumAlloc, 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) Decode Uses

func (ed *EncDatum) Decode(a *DatumAlloc) error

Decode ensures that Datum is set (decoding if necessary).

func (*EncDatum) Encode Uses

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

Encode appends the encoded datum to the given slice using the requested encoding.

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) IsUnset Uses

func (ed *EncDatum) IsUnset() bool

IsUnset returns true if SetEncoded or SetDatum were not called.

func (*EncDatum) SetDatum Uses

func (ed *EncDatum) SetDatum(typ ColumnType_Kind, d parser.Datum)

SetDatum initializes the EncDatum with the given Datum.

func (*EncDatum) SetEncoded Uses

func (ed *EncDatum) SetEncoded(typ ColumnType_Kind, enc DatumEncoding, val []byte)

SetEncoded initializes the 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.

func (*EncDatum) SetFromBuffer Uses

func (ed *EncDatum) SetFromBuffer(
    typ ColumnType_Kind, enc DatumEncoding, buf []byte,
) (remaining []byte, err error)

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

func (*EncDatum) String Uses

func (ed *EncDatum) String() string

type EncDatumRow Uses

type EncDatumRow []EncDatum

EncDatumRow is a row of EncDatums.

func (EncDatumRow) Compare Uses

func (r EncDatumRow) Compare(a *DatumAlloc, ordering ColumnOrdering, 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) String Uses

func (r EncDatumRow) String() 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 EncDatumRows Uses

type EncDatumRows []EncDatumRow

EncDatumRows is a slice of EncDatumRows.

func (EncDatumRows) String Uses

func (r EncDatumRows) String() string

type ErrNonNullViolation Uses

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

ErrNonNullViolation represents a violation of a non-NULL constraint.

func (*ErrNonNullViolation) Code Uses

func (*ErrNonNullViolation) Code() string

Code implements the ErrorWithPGCode interface.

func (*ErrNonNullViolation) Error Uses

func (e *ErrNonNullViolation) Error() string

func (*ErrNonNullViolation) SrcContext Uses

func (e *ErrNonNullViolation) SrcContext() SrcCtx

SrcContext implements the ErrorWithPGCode interface.

type ErrRetry Uses

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

ErrRetry means that the transaction can be retried. It signals to the user that the SQL txn entered the RESTART_WAIT state after a serialization error, and that a ROLLBACK TO SAVEPOINT COCKROACH_RESTART statement should be issued.

func (*ErrRetry) Code Uses

func (*ErrRetry) Code() string

Code implements the ErrorWithPGCode interface.

func (*ErrRetry) Error Uses

func (e *ErrRetry) Error() string

func (*ErrRetry) SrcContext Uses

func (e *ErrRetry) SrcContext() SrcCtx

SrcContext implements the ErrorWithPGCode interface.

type ErrTransactionAborted Uses

type ErrTransactionAborted struct {
    CustomMsg string
    // contains filtered or unexported fields
}

ErrTransactionAborted represents an error for trying to run a command in the context of transaction that's already aborted.

func (*ErrTransactionAborted) Code Uses

func (*ErrTransactionAborted) Code() string

Code implements the ErrorWithPGCode interface.

func (*ErrTransactionAborted) Error Uses

func (e *ErrTransactionAborted) Error() string

func (*ErrTransactionAborted) SrcContext Uses

func (e *ErrTransactionAborted) SrcContext() SrcCtx

SrcContext implements the ErrorWithPGCode interface.

type ErrTransactionCommitted Uses

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

ErrTransactionCommitted signals that the SQL txn is in the COMMIT_WAIT state and that only a COMMIT statement will be accepted.

func (*ErrTransactionCommitted) Code Uses

func (*ErrTransactionCommitted) Code() string

Code implements the ErrorWithPGCode interface.

func (*ErrTransactionCommitted) Error Uses

func (*ErrTransactionCommitted) Error() string

func (*ErrTransactionCommitted) SrcContext Uses

func (e *ErrTransactionCommitted) SrcContext() SrcCtx

SrcContext implements the ErrorWithPGCode interface.

type ErrUndefinedDatabase Uses

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

ErrUndefinedDatabase represents a missing database error.

func (*ErrUndefinedDatabase) Code Uses

func (*ErrUndefinedDatabase) Code() string

Code implements the ErrorWithPGCode interface.

func (*ErrUndefinedDatabase) Error Uses

func (e *ErrUndefinedDatabase) Error() string

func (*ErrUndefinedDatabase) SrcContext Uses

func (e *ErrUndefinedDatabase) SrcContext() SrcCtx

SrcContext implements the ErrorWithPGCode interface.

type ErrUndefinedTable Uses

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

ErrUndefinedTable represents a missing database table.

func (*ErrUndefinedTable) Code Uses

func (*ErrUndefinedTable) Code() string

Code implements the ErrorWithPGCode interface.

func (*ErrUndefinedTable) Error Uses

func (e *ErrUndefinedTable) Error() string

func (*ErrUndefinedTable) SrcContext Uses

func (e *ErrUndefinedTable) SrcContext() SrcCtx

SrcContext implements the ErrorWithPGCode interface.

type ErrUniquenessConstraintViolation Uses

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

ErrUniquenessConstraintViolation represents a violation of a UNIQUE constraint.

func (*ErrUniquenessConstraintViolation) Code Uses

func (*ErrUniquenessConstraintViolation) Code() string

Code implements the ErrorWithPGCode interface.

func (*ErrUniquenessConstraintViolation) Error Uses

func (e *ErrUniquenessConstraintViolation) Error() string

func (*ErrUniquenessConstraintViolation) SrcContext Uses

func (e *ErrUniquenessConstraintViolation) SrcContext() SrcCtx

SrcContext implements the ErrorWithPGCode interface.

type ErrorWithPGCode Uses

type ErrorWithPGCode interface {
    error
    Code() string
    SrcContext() SrcCtx
}

ErrorWithPGCode represents errors that carries an error code to the user. pgwire recognizes this interfaces and extracts the code.

type FamilyID Uses

type FamilyID uint32

FamilyID is a custom type for ColumnFamilyDescriptor IDs.

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"`
}

func (*ForeignKeyReference) Descriptor Uses

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

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

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/sql_column_families.md
    FamilyFormatVersion
    // InterleavedFormatVersion corresponds to the encoding described in
    // https://github.com/cockroachdb/cockroach/blob/master/docs/RFCS/sql_interleaved_tables.md
    InterleavedFormatVersion
)

func (FormatVersion) String Uses

func (i FormatVersion) String() string

type ID Uses

type ID uint32

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

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"`
    // An ordered list of column names of which the index 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,4,rep,name=column_names,json=columnNames" json:"column_names,omitempty"`
    // Parallel with column_names - the sort direction of each column.
    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.
    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.
    ColumnIDs []ColumnID `protobuf:"varint,6,rep,name=column_ids,json=columnIds,casttype=ColumnID" json:"column_ids,omitempty"`
    // An ordered list of implicit column ids associated with the index. For
    // non-unique indexes, these columns will be appended to the key. For unique
    // indexes these columns will be stored in the value. The extra column IDs is
    // computed as PrimaryIndex.column_ids - column_ids. For the primary index
    // the list will be empty.
    // The distinction about whether the columns are written in the key or the value
    // comes because we want to always do writes using a single operation - this
    // way for unique indexes we can do a conditional put on the key.
    ImplicitColumnIDs []ColumnID             `protobuf:"varint,7,rep,name=implicit_column_ids,json=implicitColumnIds,casttype=ColumnID" json:"implicit_column_ids,omitempty"`
    ForeignKey        *ForeignKeyReference   `protobuf:"bytes,9,opt,name=foreign_key,json=foreignKey" json:"foreign_key,omitempty"`
    ReferencedBy      []*ForeignKeyReference `protobuf:"bytes,10,rep,name=referenced_by,json=referencedBy" json:"referenced_by,omitempty"`
    // 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.
    InterleavedBy []ForeignKeyReference `protobuf:"bytes,12,rep,name=interleaved_by,json=interleavedBy" json:"interleaved_by"`
}

func (*IndexDescriptor) ContainsColumnID Uses

func (desc *IndexDescriptor) ContainsColumnID(colID ColumnID) bool

ContainsColumnID returns true if the index descriptor contains the specified column ID either in its explicit column IDs or the implicit "extra" column IDs.

func (*IndexDescriptor) Descriptor Uses

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

func (*IndexDescriptor) FillColumns Uses

func (desc *IndexDescriptor) FillColumns(elems parser.IndexElemList) error

FillColumns sets the column names and directions in desc.

func (*IndexDescriptor) FullColumnIDs Uses

func (desc *IndexDescriptor) FullColumnIDs() ([]ColumnID, []encoding.Direction)

FullColumnIDs returns the index column IDs including any implicit column IDs for non-unique indexes. It also returns the direction with which each column was encoded.

func (*IndexDescriptor) Marshal Uses

func (m *IndexDescriptor) Marshal() (data []byte, err error)

func (*IndexDescriptor) MarshalTo Uses

func (m *IndexDescriptor) MarshalTo(data []byte) (int, error)

func (*IndexDescriptor) ProtoMessage Uses

func (*IndexDescriptor) ProtoMessage()

func (*IndexDescriptor) Reset Uses

func (m *IndexDescriptor) Reset()

func (*IndexDescriptor) Size Uses

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

func (*IndexDescriptor) String Uses

func (m *IndexDescriptor) String() string

func (*IndexDescriptor) Unmarshal Uses

func (m *IndexDescriptor) Unmarshal(data []byte) error

type IndexDescriptor_Direction Uses

type IndexDescriptor_Direction int32

The direction of a column in the index.

const (
    IndexDescriptor_ASC  IndexDescriptor_Direction = 0
    IndexDescriptor_DESC IndexDescriptor_Direction = 1
)

func (IndexDescriptor_Direction) Enum Uses

func (x IndexDescriptor_Direction) Enum() *IndexDescriptor_Direction

func (IndexDescriptor_Direction) EnumDescriptor Uses

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

func (IndexDescriptor_Direction) String Uses

func (x IndexDescriptor_Direction) String() string

func (IndexDescriptor_Direction) ToEncodingDirection Uses

func (dir IndexDescriptor_Direction) ToEncodingDirection() (encoding.Direction, error)

ToEncodingDirection converts a direction from the proto to an encoding.Direction.

func (*IndexDescriptor_Direction) UnmarshalJSON Uses

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

type IndexEntry Uses

type IndexEntry struct {
    Key   roachpb.Key
    Value roachpb.Value
}

IndexEntry represents an encoded key/value for an index entry.

func EncodeSecondaryIndex Uses

func EncodeSecondaryIndex(
    tableDesc *TableDescriptor,
    secondaryIndex *IndexDescriptor,
    colMap map[ColumnID]int,
    values []parser.Datum,
) (IndexEntry, error)

EncodeSecondaryIndex encodes key/values for a secondary index. colMap maps ColumnIDs to indices in `values`.

type IndexID Uses

type IndexID uint32

IndexID is a custom type for IndexDescriptor IDs.

func DecodeIndexKeyPrefix Uses

func DecodeIndexKeyPrefix(a *DatumAlloc, desc *TableDescriptor, key []byte) (
    indexID IndexID, remaining []byte, err error,
)

DecodeIndexKeyPrefix decodes the prefix of an index key and returns the index id and a slice for the rest of the key.

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

type InterleaveDescriptor Uses

type InterleaveDescriptor struct {
    // Ancestors contains the nesting of interleaves in the order they appear in
    // an encoded key. This means they are always in the far-to-near ancestor
    // order (e.g. grand-grand-parent, grand-parent, parent).
    Ancestors []InterleaveDescriptor_Ancestor `protobuf:"bytes,1,rep,name=ancestors" json:"ancestors"`
}

InterleaveDescriptor represents an index (either primary or secondary) that is interleaved into another table's data.

Example: Table 1 -> /a/b Table 2 -> /a/b/c Table 3 -> /a/b/c/d

There are two components (table 2 is the parent and table 1 is the grandparent) with shared lengths 2 and 1.

func (*InterleaveDescriptor) Descriptor Uses

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

func (*InterleaveDescriptor) Marshal Uses

func (m *InterleaveDescriptor) Marshal() (data []byte, err error)

func (*InterleaveDescriptor) MarshalTo Uses

func (m *InterleaveDescriptor) MarshalTo(data []byte) (int, error)

func (*InterleaveDescriptor) ProtoMessage Uses

func (*InterleaveDescriptor) ProtoMessage()

func (*InterleaveDescriptor) Reset Uses

func (m *InterleaveDescriptor) Reset()

func (*InterleaveDescriptor) Size Uses

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

func (*InterleaveDescriptor) String Uses

func (m *InterleaveDescriptor) String() string

func (*InterleaveDescriptor) Unmarshal Uses

func (m *InterleaveDescriptor) Unmarshal(data []byte) error

type InterleaveDescriptor_Ancestor Uses

type InterleaveDescriptor_Ancestor struct {
    // TableID the ID of the table being interleaved into.
    TableID ID  `protobuf:"varint,1,opt,name=table_id,json=tableId,casttype=ID" json:"table_id"`
    // IndexID is the ID of the parent index being interleaved into.
    IndexID IndexID `protobuf:"varint,2,opt,name=index_id,json=indexId,casttype=IndexID" json:"index_id"`
    // SharedPrefixLen is how many fields are shared between a parent and child
    // being interleaved, excluding any fields shared between parent and
    // grandparent. Thus, the sum of SharedPrefixLens in the components of an
    // InterleaveDescriptor is always strictly less than the number of fields
    // in the index being interleaved.
    SharedPrefixLen uint32 `protobuf:"varint,3,opt,name=shared_prefix_len,json=sharedPrefixLen" json:"shared_prefix_len"`
}

func (*InterleaveDescriptor_Ancestor) Descriptor Uses

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

func (*InterleaveDescriptor_Ancestor) Marshal Uses

func (m *InterleaveDescriptor_Ancestor) Marshal() (data []byte, err error)

func (*InterleaveDescriptor_Ancestor) MarshalTo Uses

func (m *InterleaveDescriptor_Ancestor) MarshalTo(data []byte) (int, error)

func (*InterleaveDescriptor_Ancestor) ProtoMessage Uses

func (*InterleaveDescriptor_Ancestor) ProtoMessage()

func (*InterleaveDescriptor_Ancestor) Reset Uses

func (m *InterleaveDescriptor_Ancestor) Reset()

func (*InterleaveDescriptor_Ancestor) Size Uses

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

func (*InterleaveDescriptor_Ancestor) String Uses

func (m *InterleaveDescriptor_Ancestor) String() string

func (*InterleaveDescriptor_Ancestor) Unmarshal Uses

func (m *InterleaveDescriptor_Ancestor) Unmarshal(data []byte) error

type MetadataSchema Uses

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

MetadataSchema is used to construct the initial sql schema for a new CockroachDB cluster being bootstrapped. Tables and databases must be installed on the underlying persistent storage before a cockroach store can start running correctly, thus requiring this special initialization.

func MakeMetadataSchema Uses

func MakeMetadataSchema() MetadataSchema

MakeMetadataSchema constructs a new MetadataSchema value which constructs the "system" database.

func (*MetadataSchema) AddDescriptor Uses

func (ms *MetadataSchema) AddDescriptor(parentID ID, desc DescriptorProto)

AddDescriptor adds a new descriptor to the system schema. Used only for SystemConfig tables and databases. Prefer AddTable for most uses.

func (*MetadataSchema) AddTable Uses

func (ms *MetadataSchema) AddTable(id ID, definition string)

AddTable adds a new table to the system database.

func (MetadataSchema) DescriptorCount Uses

func (ms MetadataSchema) DescriptorCount() int

DescriptorCount returns the number of descriptors that will be created by this schema. This value is needed to automate certain tests.

func (MetadataSchema) GetInitialValues Uses

func (ms MetadataSchema) GetInitialValues() []roachpb.KeyValue

GetInitialValues returns the set of initial K/V values which should be added to a bootstrapping CockroachDB cluster in order to create the tables contained in the schema.

func (MetadataSchema) MaxTableID Uses

func (ms MetadataSchema) MaxTableID() ID

MaxTableID returns the highest table ID of any system table. This value is needed to automate certain tests.

func (MetadataSchema) TableCount Uses

func (ms MetadataSchema) TableCount() int

TableCount returns the number of non-system config tables in the system database. This value is needed to automate certain tests.

type MutationID Uses

type MutationID uint32

MutationID is custom type for TableDescriptor mutations.

const InvalidMutationID MutationID = 0

InvalidMutationID is the uninitialised mutation id.

type PrivilegeDescriptor Uses

type PrivilegeDescriptor struct {
    Users []UserPrivileges `protobuf:"bytes,1,rep,name=users" json:"users"`
}

PrivilegeDescriptor describes a list of users and attached privileges. The list should be sorted by user for fast access.

func NewDefaultPrivilegeDescriptor Uses

func NewDefaultPrivilegeDescriptor() *PrivilegeDescriptor

NewDefaultPrivilegeDescriptor returns a privilege descriptor with ALL privileges for the root user.

func NewPrivilegeDescriptor Uses

func NewPrivilegeDescriptor(user string, priv privilege.List) *PrivilegeDescriptor

NewPrivilegeDescriptor returns a privilege descriptor for the given user with the specified list of privileges.

func (PrivilegeDescriptor) CheckPrivilege Uses

func (p PrivilegeDescriptor) CheckPrivilege(user string, priv privilege.Kind) bool

CheckPrivilege returns true if 'user' has 'privilege' on this descriptor.

func (*PrivilegeDescriptor) Descriptor Uses

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

func (*PrivilegeDescriptor) Grant Uses

func (p *PrivilegeDescriptor) Grant(user string, privList privilege.List)

Grant adds new privileges to this descriptor for a given list of users. TODO(marc): if all privileges other than ALL are set, should we collapse them into ALL?

func (*PrivilegeDescriptor) Marshal Uses

func (m *PrivilegeDescriptor) Marshal() (data []byte, err error)

func (*PrivilegeDescriptor) MarshalTo Uses

func (m *PrivilegeDescriptor) MarshalTo(data []byte) (int, error)

func (*PrivilegeDescriptor) ProtoMessage Uses

func (*PrivilegeDescriptor) ProtoMessage()

func (*PrivilegeDescriptor) Reset Uses

func (m *PrivilegeDescriptor) Reset()

func (*PrivilegeDescriptor) Revoke Uses

func (p *PrivilegeDescriptor) Revoke(user string, privList privilege.List)

Revoke removes privileges from this descriptor for a given list of users.

func (PrivilegeDescriptor) Show Uses

func (p PrivilegeDescriptor) Show() []UserPrivilegeString

Show returns the list of {username, privileges} sorted by username. 'privileges' is a string of comma-separated sorted privilege names.

func (*PrivilegeDescriptor) Size Uses

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

func (*PrivilegeDescriptor) String Uses

func (m *PrivilegeDescriptor) String() string

func (*PrivilegeDescriptor) Unmarshal Uses

func (m *PrivilegeDescriptor) Unmarshal(data []byte) error

func (PrivilegeDescriptor) Validate Uses

func (p PrivilegeDescriptor) Validate(id ID) error

Validate is called when writing a database or table descriptor. It takes the descriptor ID which is used to determine if it belongs to a system descriptor, in which case the maximum set of allowed privileges is looked up and applied.

type RowFetcher Uses

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

RowFetcher handles fetching kvs and forming table rows. Usage:

var rf RowFetcher
err := rf.Init(..)
// Handle err
err := rf.StartScan(..)
// Handle err
for {
   row, err := rf.NextRow()
   // Handle err
   if row == nil {
      // Done
      break
   }
   // Process row
}

func (*RowFetcher) Init Uses

func (rf *RowFetcher) Init(
    desc *TableDescriptor,
    colIdxMap map[ColumnID]int,
    index *IndexDescriptor,
    reverse, isSecondaryIndex bool,
    cols []ColumnDescriptor,
    valNeededForCol []bool,
) error

Init sets up a RowFetcher for a given table and index. If we are using a non-primary index, valNeededForCol can only be true for the columns in the index.

func (*RowFetcher) Key Uses

func (rf *RowFetcher) Key() roachpb.Key

Key returns the next key (the key that follows the last returned row).

func (*RowFetcher) NextKey Uses

func (rf *RowFetcher) NextKey() (rowDone bool, err error)

NextKey retrieves the next key/value and sets kv/kvEnd. Returns whether a row has been completed. TODO(andrei): change to return error

func (*RowFetcher) NextKeyDebug Uses

func (rf *RowFetcher) NextKeyDebug() (
    prettyKey string, prettyValue string, row parser.DTuple, err error,
)

NextKeyDebug processes one key at a time and returns a pretty printed key and value. If we completed a row, the row is returned as well (see nextRow). If there are no more keys, prettyKey is "".

func (*RowFetcher) NextRow Uses

func (rf *RowFetcher) NextRow() (parser.DTuple, error)

NextRow processes keys until we complete one row, which is returned as a DTuple. The row contains one value per table column, regardless of the index used; values that are not needed (as per valNeededForCol) are nil.

The DTuple should not be modified and is only valid until the next call. When there are no more rows, the DTuple is nil.

func (*RowFetcher) ProcessKV Uses

func (rf *RowFetcher) ProcessKV(kv client.KeyValue, debugStrings bool) (
    prettyKey string, prettyValue string, err error,
)

ProcessKV processes the given key/value, setting values in the row accordingly. If debugStrings is true, returns pretty printed key and value information in prettyKey/prettyValue (otherwise they are empty strings).

func (*RowFetcher) ReadIndexKey Uses

func (rf *RowFetcher) ReadIndexKey(k roachpb.Key) (remaining []byte, ok bool, err error)

ReadIndexKey decodes an index key for the fetcher's table.

func (*RowFetcher) StartScan Uses

func (rf *RowFetcher) StartScan(txn *client.Txn, spans Spans, limitHint int64) error

StartScan initializes and starts the key-value scan. Can be used multiple times.

type Span Uses

type Span struct {
    Start roachpb.Key // inclusive key
    End   roachpb.Key // exclusive key
    Count int64       // max # of keys for this span
}

Span represents a span that is part of a scan.

type Spans Uses

type Spans []Span

Spans is a slice of spans.

func (Spans) Len Uses

func (a Spans) Len() int

implement Sort.Interface

func (Spans) Less Uses

func (a Spans) Less(i, j int) bool

func (Spans) Swap Uses

func (a Spans) Swap(i, j int)

type SrcCtx Uses

type SrcCtx struct {
    File     string
    Line     int
    Function string
}

SrcCtx contains contextual information about the source of an error.

func MakeSrcCtx Uses

func MakeSrcCtx(depth int) SrcCtx

MakeSrcCtx creates a SrcCtx value with contextual information about the caller at the requested depth.

type TableDescriptor Uses

type TableDescriptor struct {
    // The table name. It should be normalized using sqlbase.NormalizeName()
    // before comparing it.
    Name string `protobuf:"bytes,1,opt,name=name" json:"name"`
    ID   ID     `protobuf:"varint,3,opt,name=id,casttype=ID" json:"id"`
    // ID of the parent database.
    ParentID ID  `protobuf:"varint,4,opt,name=parent_id,json=parentId,casttype=ID" json:"parent_id"`
    // Monotonically increasing version of the table descriptor.
    //
    // Invariants:
    // 1. not more than two subsequent versions of the table
    // descriptor can be leased. This is to make the system
    // easy to reason about, by permiting mutation state
    // changes (reflected in the next version), only when the existing
    // state (reflected in the current version) is present on all
    // outstanding unexpired leases.
    // 2. A schema change command (ALTER, RENAME, etc) never directly
    // increments the version. This allows the command to execute without
    // waiting for the entire cluster to converge to a single version
    // preventing weird deadlock situations. For instance, a transaction
    // with a schema change command might use a descriptor lease that is
    // at version: v - 1, and therefore deadlock when it tries to wait
    // for version: v, in the process of incrementing it to v + 1.
    // Therefore, a schema change command never increments the version,
    // and instead, sets the up_version boolean to notify the schema
    // changer execution engine that runs a future transaction to
    // increment the version.
    //
    // The schema change commands must therefore make *safe* modifications
    // to the table descriptor, such as scheduling long running schema
    // changes through mutations for future execution, or making simple
    // schema changes like RENAME that only modify the table descriptor in a
    // single transaction.
    //
    // Multiple schema changes in the same transaction set up_version.
    // The actual schema change execution that follows a schema change
    // command sees the up_version boolean set, and increments the
    // table version after ensuring that there are no unexpired leases
    // for version - 1. The schema change execution must increment
    // the version before executing future state changes, to ensure
    // that the scheduled mutations made by the original commands are
    // visible on all leases. Multiple schema change mutations can be
    // grouped together on a particular version increment.
    //
    // If schema change commands are safe to run without incrementing
    // the version, why do it later on? We increment the version
    // to ensure that all the nodes renew their leases with the new version
    // and get to see what the schema change command has done quickly.
    Version DescriptorVersion `protobuf:"varint,5,opt,name=version,casttype=DescriptorVersion" json:"version"`
    // See comment above.
    UpVersion bool `protobuf:"varint,6,opt,name=up_version,json=upVersion" json:"up_version"`
    // Last modification time of the table descriptor.
    ModificationTime cockroach_util_hlc.Timestamp `protobuf:"bytes,7,opt,name=modification_time,json=modificationTime" json:"modification_time"`
    Columns          []ColumnDescriptor           `protobuf:"bytes,8,rep,name=columns" json:"columns"`
    // next_column_id is used to ensure that deleted column ids are not reused.
    NextColumnID ColumnID                 `protobuf:"varint,9,opt,name=next_column_id,json=nextColumnId,casttype=ColumnID" json:"next_column_id"`
    Families     []ColumnFamilyDescriptor `protobuf:"bytes,22,rep,name=families" json:"families"`
    // next_family_id is used to ensure that deleted family ids are not reused.
    NextFamilyID FamilyID        `protobuf:"varint,23,opt,name=next_family_id,json=nextFamilyId,casttype=FamilyID" json:"next_family_id"`
    PrimaryIndex IndexDescriptor `protobuf:"bytes,10,opt,name=primary_index,json=primaryIndex" json:"primary_index"`
    // indexes are all the secondary indexes.
    Indexes []IndexDescriptor `protobuf:"bytes,11,rep,name=indexes" json:"indexes"`
    // next_index_id is used to ensure that deleted index ids are not reused.
    NextIndexID IndexID              `protobuf:"varint,12,opt,name=next_index_id,json=nextIndexId,casttype=IndexID" json:"next_index_id"`
    Privileges  *PrivilegeDescriptor `protobuf:"bytes,13,opt,name=privileges" json:"privileges,omitempty"`
    // Columns or indexes being added or deleted in a FIFO order.
    Mutations []DescriptorMutation               `protobuf:"bytes,14,rep,name=mutations" json:"mutations"`
    Lease     *TableDescriptor_SchemaChangeLease `protobuf:"bytes,15,opt,name=lease" json:"lease,omitempty"`
    // An id for the next group of mutations to be applied together.
    NextMutationID MutationID `protobuf:"varint,16,opt,name=next_mutation_id,json=nextMutationId,casttype=MutationID" json:"next_mutation_id"`
    // format_version declares which sql to key:value mapping is being used to
    // represent the data in this table.
    FormatVersion FormatVersion                      `protobuf:"varint,17,opt,name=format_version,json=formatVersion,casttype=FormatVersion" json:"format_version"`
    State         TableDescriptor_State              `protobuf:"varint,19,opt,name=state,enum=cockroach.sql.sqlbase.TableDescriptor_State" json:"state"`
    Checks        []*TableDescriptor_CheckConstraint `protobuf:"bytes,20,rep,name=checks" json:"checks,omitempty"`
    // This array is populated if the descriptor was renamed. If the descriptor is
    // renamed multiple times before the schema chage is processed, there will be
    // one element for each rename.
    // When this is detected in a schema change, the records for the old names are
    // deleted and this field is cleared.
    Renames []TableDescriptor_RenameInfo `protobuf:"bytes,21,rep,name=renames" json:"renames"`
}

A TableDescriptor represents a table and is stored in a structured metadata key. The TableDescriptor has a globally-unique ID, while its member {Column,Index}Descriptors have locally-unique IDs.

func GetTableDescriptor Uses

func GetTableDescriptor(kvDB *client.DB, database string, table string) *TableDescriptor

GetTableDescriptor retrieves a table descriptor directly from the KV layer.

func MakeTableDesc Uses

func MakeTableDesc(p *parser.CreateTable, parentID ID) (TableDescriptor, error)

MakeTableDesc creates a table descriptor from a CreateTable statement.

func (*TableDescriptor) AddColumn Uses

func (desc *TableDescriptor) AddColumn(col ColumnDescriptor)

AddColumn adds a column to the table.

func (*TableDescriptor) AddColumnMutation Uses

func (desc *TableDescriptor) AddColumnMutation(c ColumnDescriptor, direction DescriptorMutation_Direction)

AddColumnMutation adds a column mutation to desc.Mutations.

func (*TableDescriptor) AddColumnToFamilyMaybeCreate Uses

func (desc *TableDescriptor) AddColumnToFamilyMaybeCreate(
    col string, family string, create bool, ifNotExists bool,
) error

AddColumnToFamilyMaybeCreate adds the specified column to the specified family. If it doesn't exist and create is true, creates it. If it does exist adds it unless "strict" create (`true` for create but `false` for ifNotExists) is specified.

AllocateIDs must be called before the TableDesciptor will be valid.

func (*TableDescriptor) AddFamily Uses

func (desc *TableDescriptor) AddFamily(fam ColumnFamilyDescriptor)

AddFamily adds a family to the table.

func (*TableDescriptor) AddIndex Uses

func (desc *TableDescriptor) AddIndex(idx IndexDescriptor, primary bool) error

AddIndex adds an index to the table.

func (*TableDescriptor) AddIndexMutation Uses

func (desc *TableDescriptor) AddIndexMutation(idx IndexDescriptor, direction DescriptorMutation_Direction)

AddIndexMutation adds an index mutation to desc.Mutations.

func (*TableDescriptor) AllNonDropIndexes Uses

func (desc *TableDescriptor) AllNonDropIndexes() []IndexDescriptor

AllNonDropIndexes returns all the indexes, including those being added in the mutations.

func (*TableDescriptor) AllocateIDs Uses

func (desc *TableDescriptor) AllocateIDs() error

AllocateIDs allocates column, family, and index ids for any column, family, or index which has an ID of 0.

func (*TableDescriptor) Deleted Uses

func (desc *TableDescriptor) Deleted() bool

Deleted returns true if the table is being deleted.

func (*TableDescriptor) Descriptor Uses

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

func (*TableDescriptor) FinalizeMutation Uses

func (desc *TableDescriptor) FinalizeMutation() (MutationID, error)

FinalizeMutation returns the id that has been used by mutations appended with addMutation() since the last time this function was called. Future mutations will use a new ID.

func (*TableDescriptor) FindActiveColumnByID Uses

func (desc *TableDescriptor) FindActiveColumnByID(id ColumnID) (*ColumnDescriptor, error)

FindActiveColumnByID finds the active column with specified ID.

func (*TableDescriptor) FindActiveColumnByName Uses

func (desc *TableDescriptor) FindActiveColumnByName(name string) (ColumnDescriptor, error)

FindActiveColumnByName finds an active column with the specified name.

func (*TableDescriptor) FindColumnByID Uses

func (desc *TableDescriptor) FindColumnByID(id ColumnID) (*ColumnDescriptor, error)

FindColumnByID finds the column with specified ID.

func (*TableDescriptor) FindColumnByName Uses

func (desc *TableDescriptor) FindColumnByName(name string) (DescriptorStatus, int, error)

FindColumnByName finds the column with the specified name. It returns DescriptorStatus for the column, and an index into either the columns (status == DescriptorActive) or mutations (status == DescriptorIncomplete).

func (*TableDescriptor) FindFamilyByID Uses

func (desc *TableDescriptor) FindFamilyByID(id FamilyID) (*ColumnFamilyDescriptor, error)

FindFamilyByID finds the family with specified ID.

func (*TableDescriptor) FindIndexByID Uses

func (desc *TableDescriptor) FindIndexByID(id IndexID) (*IndexDescriptor, error)

FindIndexByID finds an index (active or inactive) with the specified ID. Must return a pointer to the IndexDescriptor in the TableDescriptor, so that callers can use returned values to modify the TableDesc.

func (*TableDescriptor) FindIndexByName Uses

func (desc *TableDescriptor) FindIndexByName(name string) (DescriptorStatus, int, error)

FindIndexByName finds the index with the specified name. It returns DescriptorStatus for the index, and an index into either the indexes (status == DescriptorActive) or mutations (status == DescriptorIncomplete).

func (*TableDescriptor) GetChecks Uses

func (m *TableDescriptor) GetChecks() []*TableDescriptor_CheckConstraint

func (*TableDescriptor) GetColumns Uses

func (m *TableDescriptor) GetColumns() []ColumnDescriptor

func (*TableDescriptor) GetFamilies Uses

func (m *TableDescriptor) GetFamilies() []ColumnFamilyDescriptor

func (*TableDescriptor) GetFormatVersion Uses

func (m *TableDescriptor) GetFormatVersion() FormatVersion

func (*TableDescriptor) GetID Uses

func (m *TableDescriptor) GetID() ID

func (*TableDescriptor) GetIndexes Uses

func (m *TableDescriptor) GetIndexes() []IndexDescriptor

func (*TableDescriptor) GetLease Uses

func (m *TableDescriptor) GetLease() *TableDescriptor_SchemaChangeLease

func (*TableDescriptor) GetModificationTime Uses

func (m *TableDescriptor) GetModificationTime() cockroach_util_hlc.Timestamp

func (*TableDescriptor) GetMutations Uses

func (m *TableDescriptor) GetMutations() []DescriptorMutation

func (*TableDescriptor) GetName Uses

func (m *TableDescriptor) GetName() string

func (*TableDescriptor) GetNextColumnID Uses

func (m *TableDescriptor) GetNextColumnID() ColumnID

func (*TableDescriptor) GetNextFamilyID Uses

func (m *TableDescriptor) GetNextFamilyID() FamilyID

func (*TableDescriptor) GetNextIndexID Uses

func (m *TableDescriptor) GetNextIndexID() IndexID

func (*TableDescriptor) GetNextMutationID Uses

func (m *TableDescriptor) GetNextMutationID() MutationID

func (*TableDescriptor) GetParentID Uses

func (m *TableDescriptor) GetParentID() ID

func (*TableDescriptor) GetPrimaryIndex Uses

func (m *TableDescriptor) GetPrimaryIndex() IndexDescriptor

func (*TableDescriptor) GetPrivileges Uses

func (m *TableDescriptor) GetPrivileges() *PrivilegeDescriptor

func (*TableDescriptor) GetRenames Uses

func (m *TableDescriptor) GetRenames() []TableDescriptor_RenameInfo

func (*TableDescriptor) GetState Uses

func (m *TableDescriptor) GetState() TableDescriptor_State

func (*TableDescriptor) GetUpVersion Uses

func (m *TableDescriptor) GetUpVersion() bool

func (*TableDescriptor) GetVersion Uses

func (m *TableDescriptor) GetVersion() DescriptorVersion

func (*TableDescriptor) IsEmpty Uses

func (desc *TableDescriptor) IsEmpty() bool

IsEmpty checks if the descriptor is uninitialized.

func (*TableDescriptor) IsInterleaved Uses

func (desc *TableDescriptor) IsInterleaved() bool

IsInterleaved returns true if any part of this this table is interleaved with another table's data.

func (*TableDescriptor) MakeMutationComplete Uses

func (desc *TableDescriptor) MakeMutationComplete(m DescriptorMutation)

MakeMutationComplete updates the descriptor upon completion of a mutation.

func (*TableDescriptor) Marshal Uses

func (m *TableDescriptor) Marshal() (data []byte, err error)

func (*TableDescriptor) MarshalTo Uses

func (m *TableDescriptor) MarshalTo(data []byte) (int, error)

func (*TableDescriptor) MaybeUpgradeFormatVersion Uses

func (desc *TableDescriptor) MaybeUpgradeFormatVersion() bool

MaybeUpgradeFormatVersion transforms the TableDescriptor to the latest FormatVersion (if it's not already there) and returns true if any changes were made.

func (*TableDescriptor) ProtoMessage Uses

func (*TableDescriptor) ProtoMessage()

func (*TableDescriptor) RemoveColumnFromFamily Uses

func (desc *TableDescriptor) RemoveColumnFromFamily(colID ColumnID)

RemoveColumnFromFamily removes a colID from the family it's assigned to.

func (*TableDescriptor) RenameColumn Uses

func (desc *TableDescriptor) RenameColumn(colID ColumnID, newColName string)

RenameColumn updates all references to a column name in indexes and families.

func (*TableDescriptor) Renamed Uses

func (desc *TableDescriptor) Renamed() bool

Renamed returns true if the table is being renamed.

func (*TableDescriptor) Reset Uses

func (m *TableDescriptor) Reset()

func (*TableDescriptor) SetID Uses

func (desc *TableDescriptor) SetID(id ID)

SetID implements the DescriptorProto interface.

func (*TableDescriptor) SetName Uses

func (desc *TableDescriptor) SetName(name string)

SetName implements the DescriptorProto interface.

func (*TableDescriptor) SetUpVersion Uses

func (desc *TableDescriptor) SetUpVersion() error

SetUpVersion sets the up_version marker on the table descriptor (see the proto

func (*TableDescriptor) Size Uses

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

func (*TableDescriptor) String Uses

func (m *TableDescriptor) String() string

func (*TableDescriptor) TypeName Uses

func (desc *TableDescriptor) TypeName() string

TypeName returns the plain type of this descriptor.

func (*TableDescriptor) Unmarshal Uses

func (m *TableDescriptor) Unmarshal(data []byte) error

func (*TableDescriptor) Validate Uses

func (desc *TableDescriptor) Validate() error

Validate validates that the table descriptor is well formed. Checks include validating the table, column and index names, verifying that column names and index names are unique and verifying that column IDs and index IDs are consistent.

func (*TableDescriptor) VisibleColumns Uses

func (desc *TableDescriptor) VisibleColumns() []ColumnDescriptor

VisibleColumns returns all non hidden columns.

type TableDescriptor_CheckConstraint Uses

type TableDescriptor_CheckConstraint struct {
    Expr string `protobuf:"bytes,1,opt,name=expr" json:"expr"`
    Name string `protobuf:"bytes,2,opt,name=name" json:"name"`
}

func (*TableDescriptor_CheckConstraint) Descriptor Uses

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

func (*TableDescriptor_CheckConstraint) Marshal Uses

func (m *TableDescriptor_CheckConstraint) Marshal() (data []byte, err error)

func (*TableDescriptor_CheckConstraint) MarshalTo Uses

func (m *TableDescriptor_CheckConstraint) MarshalTo(data []byte) (int, error)

func (*TableDescriptor_CheckConstraint) ProtoMessage Uses

func (*TableDescriptor_CheckConstraint) ProtoMessage()

func (*TableDescriptor_CheckConstraint) Reset Uses

func (m *TableDescriptor_CheckConstraint) Reset()

func (*TableDescriptor_CheckConstraint) Size Uses

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

func (*TableDescriptor_CheckConstraint) String Uses

func (m *TableDescriptor_CheckConstraint) String() string

func (*TableDescriptor_CheckConstraint) Unmarshal Uses

func (m *TableDescriptor_CheckConstraint) Unmarshal(data []byte) error

type TableDescriptor_RenameInfo Uses

type TableDescriptor_RenameInfo struct {
    // The database that the table belonged to before the rename (tables can be
    // renamed from one db to another).
    OldParentID uint32 `protobuf:"varint,1,opt,name=old_parent_id,json=oldParentId" json:"old_parent_id"`
    OldName     string `protobuf:"bytes,2,opt,name=old_name,json=oldName" json:"old_name"`
}

func (*TableDescriptor_RenameInfo) Descriptor Uses

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

func (*TableDescriptor_RenameInfo) Marshal Uses

func (m *TableDescriptor_RenameInfo) Marshal() (data []byte, err error)

func (*TableDescriptor_RenameInfo) MarshalTo Uses

func (m *TableDescriptor_RenameInfo) MarshalTo(data []byte) (int, error)

func (*TableDescriptor_RenameInfo) ProtoMessage Uses

func (*TableDescriptor_RenameInfo) ProtoMessage()

func (*TableDescriptor_RenameInfo) Reset Uses

func (m *TableDescriptor_RenameInfo) Reset()

func (*TableDescriptor_RenameInfo) Size Uses

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

func (*TableDescriptor_RenameInfo) String Uses

func (m *TableDescriptor_RenameInfo) String() string

func (*TableDescriptor_RenameInfo) Unmarshal Uses

func (m *TableDescriptor_RenameInfo) Unmarshal(data []byte) error

type TableDescriptor_SchemaChangeLease Uses

type TableDescriptor_SchemaChangeLease struct {
    NodeID github_com_cockroachdb_cockroach_roachpb.NodeID `protobuf:"varint,1,opt,name=node_id,json=nodeId,casttype=github.com/cockroachdb/cockroach/roachpb.NodeID" json:"node_id"`
    // Nanoseconds since the Unix epoch.
    ExpirationTime int64 `protobuf:"varint,2,opt,name=expiration_time,json=expirationTime" json:"expiration_time"`
}

The schema update lease. A single goroutine across a cockroach cluster can own it, and will execute pending schema changes for this table. Since the execution of a pending schema change is through transactions, it is legal for more than one goroutine to attempt to execute it. This lease reduces write contention on the schema change.

func (*TableDescriptor_SchemaChangeLease) Descriptor Uses

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

func (*TableDescriptor_SchemaChangeLease) Marshal Uses

func (m *TableDescriptor_SchemaChangeLease) Marshal() (data []byte, err error)

func (*TableDescriptor_SchemaChangeLease) MarshalTo Uses

func (m *TableDescriptor_SchemaChangeLease) MarshalTo(data []byte) (int, error)

func (*TableDescriptor_SchemaChangeLease) ProtoMessage Uses

func (*TableDescriptor_SchemaChangeLease) ProtoMessage()

func (*TableDescriptor_SchemaChangeLease) Reset Uses

func (m *TableDescriptor_SchemaChangeLease) Reset()

func (*TableDescriptor_SchemaChangeLease) Size Uses

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

func (*TableDescriptor_SchemaChangeLease) String Uses

func (m *TableDescriptor_SchemaChangeLease) String() string

func (*TableDescriptor_SchemaChangeLease) Unmarshal Uses

func (m *TableDescriptor_SchemaChangeLease) Unmarshal(data []byte) error

type TableDescriptor_State Uses

type TableDescriptor_State int32

State is set if this TableDescriptor is in the process of being added or deleted. A non-public table descriptor cannot be leased. A schema changer observing DROP set will truncate the table and delete the descriptor. It is illegal to transition DROP to any other state.

const (
    // Not used.
    TableDescriptor_PUBLIC TableDescriptor_State = 0
    // Descriptor is being added.
    TableDescriptor_ADD TableDescriptor_State = 1
    // Descriptor is being dropped.
    TableDescriptor_DROP TableDescriptor_State = 2
)

func (TableDescriptor_State) Enum Uses

func (x TableDescriptor_State) Enum() *TableDescriptor_State

func (TableDescriptor_State) EnumDescriptor Uses

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

func (TableDescriptor_State) String Uses

func (x TableDescriptor_State) String() string

func (*TableDescriptor_State) UnmarshalJSON Uses

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

type UserPrivilegeString Uses

type UserPrivilegeString struct {
    User       string
    Privileges string
}

UserPrivilegeString is a pair of strings describing the privileges for a given user.

type UserPrivileges Uses

type UserPrivileges struct {
    User string `protobuf:"bytes,1,opt,name=user" json:"user"`
    // privileges is a bitfield of 1<<Privilege values.
    Privileges uint32 `protobuf:"varint,2,opt,name=privileges" json:"privileges"`
}

UserPrivileges describes the list of privileges available for a given user.

func (*UserPrivileges) Descriptor Uses

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

func (*UserPrivileges) Marshal Uses

func (m *UserPrivileges) Marshal() (data []byte, err error)

func (*UserPrivileges) MarshalTo Uses

func (m *UserPrivileges) MarshalTo(data []byte) (int, error)

func (*UserPrivileges) ProtoMessage Uses

func (*UserPrivileges) ProtoMessage()

func (*UserPrivileges) Reset Uses

func (m *UserPrivileges) Reset()

func (*UserPrivileges) Size Uses

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

func (*UserPrivileges) String Uses

func (m *UserPrivileges) String() string

func (*UserPrivileges) Unmarshal Uses

func (m *UserPrivileges) Unmarshal(data []byte) error

Package sqlbase imports 29 packages (graph). Updated 2017-03-13. Refresh now. Tools for package owners. This is a dead-end fork (no commits since the fork).