cockroach: github.com/cockroachdb/cockroach/pkg/sql/opt/testutils/testcat Index | Files

package testcat

import "github.com/cockroachdb/cockroach/pkg/sql/opt/testutils/testcat"

Index

Package Files

alter_table.go create_sequence.go create_table.go create_view.go drop_table.go set_zone_config.go test_catalog.go vtable.go

type Catalog Uses

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

Catalog implements the cat.Catalog interface for testing purposes.

func New Uses

func New() *Catalog

New creates a new empty instance of the test catalog.

func (*Catalog) AddSequence Uses

func (tc *Catalog) AddSequence(seq *Sequence)

AddSequence adds the given test sequence to the catalog.

func (*Catalog) AddTable Uses

func (tc *Catalog) AddTable(tab *Table)

AddTable adds the given test table to the catalog.

func (*Catalog) AddView Uses

func (tc *Catalog) AddView(view *View)

AddView adds the given test view to the catalog.

func (*Catalog) AlterTable Uses

func (tc *Catalog) AlterTable(stmt *tree.AlterTable)

AlterTable is a partial implementation of the ALTER TABLE statement.

Supported commands:

- INJECT STATISTICS: imports table statistics from a JSON object.

func (*Catalog) CheckAnyPrivilege Uses

func (tc *Catalog) CheckAnyPrivilege(ctx context.Context, o cat.Object) error

CheckAnyPrivilege is part of the cat.Catalog interface.

func (*Catalog) CheckPrivilege Uses

func (tc *Catalog) CheckPrivilege(ctx context.Context, o cat.Object, priv privilege.Kind) error

CheckPrivilege is part of the cat.Catalog interface.

func (*Catalog) CreateSequence Uses

func (tc *Catalog) CreateSequence(stmt *tree.CreateSequence) *Sequence

CreateSequence creates a test sequence from a parsed DDL statement and adds it the catalog. This is intended for testing, and is not a complete (and probably not fully correct) implementation. It just has to be "good enough".

func (*Catalog) CreateTable Uses

func (tc *Catalog) CreateTable(stmt *tree.CreateTable) *Table

CreateTable creates a test table from a parsed DDL statement and adds it to the catalog. This is intended for testing, and is not a complete (and probably not fully correct) implementation. It just has to be "good enough".

func (*Catalog) CreateTableAs Uses

func (tc *Catalog) CreateTableAs(name tree.TableName, columns []*Column) *Table

CreateTableAs creates a table in the catalog with the given name and columns. It should be used for creating a table from the CREATE TABLE <name> AS <query> syntax. In addition to the provided columns, CreateTableAs adds a unique rowid column as the primary key. It returns a pointer to the new table.

func (*Catalog) CreateView Uses

func (tc *Catalog) CreateView(stmt *tree.CreateView) *View

CreateView creates a test view from a parsed DDL statement and adds it to the catalog.

func (*Catalog) DropTable Uses

func (tc *Catalog) DropTable(stmt *tree.DropTable)

DropTable is a partial implementation of the DROP TABLE statement.

func (*Catalog) ExecuteDDL Uses

func (tc *Catalog) ExecuteDDL(sql string) (string, error)

ExecuteDDL parses the given DDL SQL statement and creates objects in the test catalog. This is used to test without spinning up a cluster.

func (*Catalog) ExecuteMultipleDDL Uses

func (tc *Catalog) ExecuteMultipleDDL(sql string) error

ExecuteMultipleDDL parses the given semicolon-separated DDL SQL statements and applies each of them to the test catalog.

func (*Catalog) FullyQualifiedName Uses

func (tc *Catalog) FullyQualifiedName(
    ctx context.Context, ds cat.DataSource,
) (cat.DataSourceName, error)

FullyQualifiedName is part of the cat.Catalog interface.

func (*Catalog) HasAdminRole Uses

func (tc *Catalog) HasAdminRole(ctx context.Context) (bool, error)

HasAdminRole is part of the cat.Catalog interface.

func (*Catalog) RequireAdminRole Uses

func (tc *Catalog) RequireAdminRole(ctx context.Context, action string) error

RequireAdminRole is part of the cat.Catalog interface.

func (*Catalog) ResolveDataSource Uses

func (tc *Catalog) ResolveDataSource(
    _ context.Context, _ cat.Flags, name *cat.DataSourceName,
) (cat.DataSource, cat.DataSourceName, error)

ResolveDataSource is part of the cat.Catalog interface.

func (*Catalog) ResolveDataSourceByID Uses

func (tc *Catalog) ResolveDataSourceByID(
    ctx context.Context, flags cat.Flags, id cat.StableID,
) (_ cat.DataSource, isAdding bool, _ error)

ResolveDataSourceByID is part of the cat.Catalog interface.

func (*Catalog) ResolveSchema Uses

func (tc *Catalog) ResolveSchema(
    _ context.Context, _ cat.Flags, name *cat.SchemaName,
) (cat.Schema, cat.SchemaName, error)

ResolveSchema is part of the cat.Catalog interface.

func (*Catalog) Schema Uses

func (tc *Catalog) Schema() *Schema

Schema returns the singleton test schema.

func (*Catalog) SetZoneConfig Uses

func (tc *Catalog) SetZoneConfig(stmt *tree.SetZoneConfig) *config.ZoneConfig

SetZoneConfig is a partial implementation of the ALTER TABLE ... CONFIGURE ZONE USING statement.

func (*Catalog) Table Uses

func (tc *Catalog) Table(name *tree.TableName) *Table

Table returns the test table that was previously added with the given name.

func (*Catalog) View Uses

func (tc *Catalog) View(name *cat.DataSourceName) *View

View returns the test view that was previously added with the given name.

type Column Uses

type Column struct {
    Ordinal      int
    Hidden       bool
    Nullable     bool
    Name         string
    Type         *types.T
    ColType      types.T
    DefaultExpr  *string
    ComputedExpr *string
}

Column implements the cat.Column interface for testing purposes.

func (*Column) ColID Uses

func (tc *Column) ColID() cat.StableID

ColID is part of the cat.Index interface.

func (*Column) ColName Uses

func (tc *Column) ColName() tree.Name

ColName is part of the cat.Column interface.

func (*Column) ColTypePrecision Uses

func (tc *Column) ColTypePrecision() int

ColTypePrecision is part of the cat.Column interface.

func (*Column) ColTypeStr Uses

func (tc *Column) ColTypeStr() string

ColTypeStr is part of the cat.Column interface.

func (*Column) ColTypeWidth Uses

func (tc *Column) ColTypeWidth() int

ColTypeWidth is part of the cat.Column interface.

func (*Column) ComputedExprStr Uses

func (tc *Column) ComputedExprStr() string

ComputedExprStr is part of the cat.Column interface.

func (*Column) DatumType Uses

func (tc *Column) DatumType() *types.T

DatumType is part of the cat.Column interface.

func (*Column) DefaultExprStr Uses

func (tc *Column) DefaultExprStr() string

DefaultExprStr is part of the cat.Column interface.

func (*Column) HasDefault Uses

func (tc *Column) HasDefault() bool

HasDefault is part of the cat.Column interface.

func (*Column) IsComputed Uses

func (tc *Column) IsComputed() bool

IsComputed is part of the cat.Column interface.

func (*Column) IsHidden Uses

func (tc *Column) IsHidden() bool

IsHidden is part of the cat.Column interface.

func (*Column) IsNullable Uses

func (tc *Column) IsNullable() bool

IsNullable is part of the cat.Column interface.

type Family Uses

type Family struct {
    FamName string

    // Ordinal is the ordinal of this family in the table.
    Ordinal int

    Columns []cat.FamilyColumn
    // contains filtered or unexported fields
}

Family implements the cat.Family interface for testing purposes.

func (*Family) Column Uses

func (tf *Family) Column(i int) cat.FamilyColumn

Column is part of the cat.Family interface.

func (*Family) ColumnCount Uses

func (tf *Family) ColumnCount() int

ColumnCount is part of the cat.Family interface.

func (*Family) ID Uses

func (tf *Family) ID() cat.StableID

ID is part of the cat.Family interface.

func (*Family) Name Uses

func (tf *Family) Name() tree.Name

Name is part of the cat.Family interface.

func (*Family) Table Uses

func (tf *Family) Table() cat.Table

Table is part of the cat.Family interface.

type ForeignKeyConstraint Uses

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

ForeignKeyConstraint implements cat.ForeignKeyConstraint. See that interface for more information on the fields.

func (*ForeignKeyConstraint) ColumnCount Uses

func (fk *ForeignKeyConstraint) ColumnCount() int

ColumnCount is part of the cat.ForeignKeyConstraint interface.

func (*ForeignKeyConstraint) DeleteReferenceAction Uses

func (fk *ForeignKeyConstraint) DeleteReferenceAction() tree.ReferenceAction

DeleteReferenceAction is part of the cat.ForeignKeyConstraint interface.

func (*ForeignKeyConstraint) MatchMethod Uses

func (fk *ForeignKeyConstraint) MatchMethod() tree.CompositeKeyMatchMethod

MatchMethod is part of the cat.ForeignKeyConstraint interface.

func (*ForeignKeyConstraint) Name Uses

func (fk *ForeignKeyConstraint) Name() string

Name is part of the cat.ForeignKeyConstraint interface.

func (*ForeignKeyConstraint) OriginColumnOrdinal Uses

func (fk *ForeignKeyConstraint) OriginColumnOrdinal(originTable cat.Table, i int) int

OriginColumnOrdinal is part of the cat.ForeignKeyConstraint interface.

func (*ForeignKeyConstraint) OriginTableID Uses

func (fk *ForeignKeyConstraint) OriginTableID() cat.StableID

OriginTableID is part of the cat.ForeignKeyConstraint interface.

func (*ForeignKeyConstraint) ReferencedColumnOrdinal Uses

func (fk *ForeignKeyConstraint) ReferencedColumnOrdinal(referencedTable cat.Table, i int) int

ReferencedColumnOrdinal is part of the cat.ForeignKeyConstraint interface.

func (*ForeignKeyConstraint) ReferencedTableID Uses

func (fk *ForeignKeyConstraint) ReferencedTableID() cat.StableID

ReferencedTableID is part of the cat.ForeignKeyConstraint interface.

func (*ForeignKeyConstraint) UpdateReferenceAction Uses

func (fk *ForeignKeyConstraint) UpdateReferenceAction() tree.ReferenceAction

UpdateReferenceAction is part of the cat.ForeignKeyConstraint interface.

func (*ForeignKeyConstraint) Validated Uses

func (fk *ForeignKeyConstraint) Validated() bool

Validated is part of the cat.ForeignKeyConstraint interface.

type Index Uses

type Index struct {
    IdxName string

    // KeyCount is the number of columns that make up the unique key for the
    // index. See the cat.Index.KeyColumnCount for more details.
    KeyCount int

    // LaxKeyCount is the number of columns that make up a lax key for the
    // index, which allows duplicate rows when at least one of the values is
    // NULL. See the cat.Index.LaxKeyColumnCount for more details.
    LaxKeyCount int

    // Unique is true if this index is declared as UNIQUE in the schema.
    Unique bool

    // Inverted is true when this index is an inverted index.
    Inverted bool

    Columns []cat.IndexColumn

    // IdxZone is the zone associated with the index. This may be inherited from
    // the parent table, database, or even the default zone.
    IdxZone *config.ZoneConfig
    // contains filtered or unexported fields
}

Index implements the cat.Index interface for testing purposes.

func (*Index) Column Uses

func (ti *Index) Column(i int) cat.IndexColumn

Column is part of the cat.Index interface.

func (*Index) ColumnCount Uses

func (ti *Index) ColumnCount() int

ColumnCount is part of the cat.Index interface.

func (*Index) ID Uses

func (ti *Index) ID() cat.StableID

ID is part of the cat.Index interface.

func (*Index) IsInverted Uses

func (ti *Index) IsInverted() bool

IsInverted is part of the cat.Index interface.

func (*Index) IsUnique Uses

func (ti *Index) IsUnique() bool

IsUnique is part of the cat.Index interface.

func (*Index) KeyColumnCount Uses

func (ti *Index) KeyColumnCount() int

KeyColumnCount is part of the cat.Index interface.

func (*Index) LaxKeyColumnCount Uses

func (ti *Index) LaxKeyColumnCount() int

LaxKeyColumnCount is part of the cat.Index interface.

func (*Index) Name Uses

func (ti *Index) Name() tree.Name

Name is part of the cat.Index interface.

func (*Index) Ordinal Uses

func (ti *Index) Ordinal() int

Ordinal is part of the cat.Index interface.

func (*Index) PartitionByListPrefixes Uses

func (ti *Index) PartitionByListPrefixes() []tree.Datums

PartitionByListPrefixes is part of the cat.Index interface.

func (*Index) Span Uses

func (ti *Index) Span() roachpb.Span

Span is part of the cat.Index interface.

func (*Index) Table Uses

func (ti *Index) Table() cat.Table

Table is part of the cat.Index interface.

func (*Index) Zone Uses

func (ti *Index) Zone() cat.Zone

Zone is part of the cat.Index interface.

type Schema Uses

type Schema struct {
    SchemaID   cat.StableID
    SchemaName cat.SchemaName

    // If Revoked is true, then the user has had privileges on the schema revoked.
    Revoked bool
    // contains filtered or unexported fields
}

Schema implements the cat.Schema interface for testing purposes.

func (*Schema) Equals Uses

func (s *Schema) Equals(other cat.Object) bool

Equals is part of the cat.Object interface.

func (*Schema) GetDataSourceNames Uses

func (s *Schema) GetDataSourceNames(ctx context.Context) ([]cat.DataSourceName, error)

GetDataSourceNames is part of the cat.Schema interface.

func (*Schema) ID Uses

func (s *Schema) ID() cat.StableID

ID is part of the cat.Object interface.

func (*Schema) Name Uses

func (s *Schema) Name() *cat.SchemaName

Name is part of the cat.Schema interface.

type Sequence Uses

type Sequence struct {
    SeqID      cat.StableID
    SeqVersion int
    SeqName    tree.TableName
    Catalog    cat.Catalog

    // If Revoked is true, then the user has had privileges on the sequence revoked.
    Revoked bool
}

Sequence implements the cat.Sequence interface for testing purposes.

func (*Sequence) Equals Uses

func (ts *Sequence) Equals(other cat.Object) bool

Equals is part of the cat.Object interface.

func (*Sequence) ID Uses

func (ts *Sequence) ID() cat.StableID

ID is part of the cat.DataSource interface.

func (*Sequence) Name Uses

func (ts *Sequence) Name() tree.Name

Name is part of the cat.DataSource interface.

func (*Sequence) SequenceMarker Uses

func (ts *Sequence) SequenceMarker()

SequenceMarker is part of the cat.Sequence interface.

func (*Sequence) String Uses

func (ts *Sequence) String() string

type Table Uses

type Table struct {
    TabID      cat.StableID
    TabVersion int
    TabName    tree.TableName
    Columns    []*Column
    Indexes    []*Index
    Stats      TableStats
    Checks     []cat.CheckConstraint
    Families   []*Family
    IsVirtual  bool
    Catalog    cat.Catalog

    // If Revoked is true, then the user has had privileges on the table revoked.
    Revoked bool
    // contains filtered or unexported fields
}

Table implements the cat.Table interface for testing purposes.

func (*Table) Check Uses

func (tt *Table) Check(i int) cat.CheckConstraint

Check is part of the cat.Table interface.

func (*Table) CheckCount Uses

func (tt *Table) CheckCount() int

CheckCount is part of the cat.Table interface.

func (*Table) Column Uses

func (tt *Table) Column(i int) cat.Column

Column is part of the cat.Table interface.

func (*Table) ColumnCount Uses

func (tt *Table) ColumnCount() int

ColumnCount is part of the cat.Table interface.

func (*Table) DeletableColumnCount Uses

func (tt *Table) DeletableColumnCount() int

DeletableColumnCount is part of the cat.Table interface.

func (*Table) DeletableIndexCount Uses

func (tt *Table) DeletableIndexCount() int

DeletableIndexCount is part of the cat.Table interface.

func (*Table) Equals Uses

func (tt *Table) Equals(other cat.Object) bool

Equals is part of the cat.Object interface.

func (*Table) Family Uses

func (tt *Table) Family(i int) cat.Family

Family is part of the cat.Table interface.

func (*Table) FamilyCount Uses

func (tt *Table) FamilyCount() int

FamilyCount is part of the cat.Table interface.

func (*Table) FindOrdinal Uses

func (tt *Table) FindOrdinal(name string) int

FindOrdinal returns the ordinal of the column with the given name.

func (*Table) ID Uses

func (tt *Table) ID() cat.StableID

ID is part of the cat.DataSource interface.

func (*Table) InboundForeignKey Uses

func (tt *Table) InboundForeignKey(i int) cat.ForeignKeyConstraint

InboundForeignKey is part of the cat.Table interface.

func (*Table) InboundForeignKeyCount Uses

func (tt *Table) InboundForeignKeyCount() int

InboundForeignKeyCount is part of the cat.Table interface.

func (*Table) Index Uses

func (tt *Table) Index(i cat.IndexOrdinal) cat.Index

Index is part of the cat.Table interface.

func (*Table) IndexCount Uses

func (tt *Table) IndexCount() int

IndexCount is part of the cat.Table interface.

func (*Table) IsInterleaved Uses

func (tt *Table) IsInterleaved() bool

IsInterleaved is part of the cat.Table interface.

func (*Table) IsVirtualTable Uses

func (tt *Table) IsVirtualTable() bool

IsVirtualTable is part of the cat.Table interface.

func (*Table) Name Uses

func (tt *Table) Name() tree.Name

Name is part of the cat.DataSource interface.

func (*Table) OutboundForeignKey Uses

func (tt *Table) OutboundForeignKey(i int) cat.ForeignKeyConstraint

OutboundForeignKey is part of the cat.Table interface.

func (*Table) OutboundForeignKeyCount Uses

func (tt *Table) OutboundForeignKeyCount() int

OutboundForeignKeyCount is part of the cat.Table interface.

func (*Table) Statistic Uses

func (tt *Table) Statistic(i int) cat.TableStatistic

Statistic is part of the cat.Table interface.

func (*Table) StatisticCount Uses

func (tt *Table) StatisticCount() int

StatisticCount is part of the cat.Table interface.

func (*Table) String Uses

func (tt *Table) String() string

func (*Table) WritableColumnCount Uses

func (tt *Table) WritableColumnCount() int

WritableColumnCount is part of the cat.Table interface.

func (*Table) WritableIndexCount Uses

func (tt *Table) WritableIndexCount() int

WritableIndexCount is part of the cat.Table interface.

type TableStat Uses

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

TableStat implements the cat.TableStatistic interface for testing purposes.

func (*TableStat) ColumnCount Uses

func (ts *TableStat) ColumnCount() int

ColumnCount is part of the cat.TableStatistic interface.

func (*TableStat) ColumnOrdinal Uses

func (ts *TableStat) ColumnOrdinal(i int) int

ColumnOrdinal is part of the cat.TableStatistic interface.

func (*TableStat) CreatedAt Uses

func (ts *TableStat) CreatedAt() time.Time

CreatedAt is part of the cat.TableStatistic interface.

func (*TableStat) DistinctCount Uses

func (ts *TableStat) DistinctCount() uint64

DistinctCount is part of the cat.TableStatistic interface.

func (*TableStat) Histogram Uses

func (ts *TableStat) Histogram() []cat.HistogramBucket

Histogram is part of the cat.TableStatistic interface.

func (*TableStat) NullCount Uses

func (ts *TableStat) NullCount() uint64

NullCount is part of the cat.TableStatistic interface.

func (*TableStat) RowCount Uses

func (ts *TableStat) RowCount() uint64

RowCount is part of the cat.TableStatistic interface.

type TableStats Uses

type TableStats []*TableStat

TableStats is a slice of TableStat pointers.

func (TableStats) Len Uses

func (ts TableStats) Len() int

Len is part of the Sorter interface.

func (TableStats) Less Uses

func (ts TableStats) Less(i, j int) bool

Less is part of the Sorter interface.

func (TableStats) Swap Uses

func (ts TableStats) Swap(i, j int)

Swap is part of the Sorter interface.

type View Uses

type View struct {
    ViewID      cat.StableID
    ViewVersion int
    ViewName    cat.DataSourceName
    QueryText   string
    ColumnNames tree.NameList

    // If Revoked is true, then the user has had privileges on the view revoked.
    Revoked bool
}

View implements the cat.View interface for testing purposes.

func (*View) ColumnName Uses

func (tv *View) ColumnName(i int) tree.Name

ColumnName is part of the cat.View interface.

func (*View) ColumnNameCount Uses

func (tv *View) ColumnNameCount() int

ColumnNameCount is part of the cat.View interface.

func (*View) Equals Uses

func (tv *View) Equals(other cat.Object) bool

Equals is part of the cat.Object interface.

func (*View) ID Uses

func (tv *View) ID() cat.StableID

ID is part of the cat.DataSource interface.

func (*View) IsSystemView Uses

func (tv *View) IsSystemView() bool

IsSystemView is part of the cat.View interface.

func (*View) Name Uses

func (tv *View) Name() tree.Name

Name is part of the cat.DataSource interface.

func (*View) Query Uses

func (tv *View) Query() string

Query is part of the cat.View interface.

func (*View) String Uses

func (tv *View) String() string

Package testcat imports 22 packages (graph) and is imported by 4 packages. Updated 2019-09-19. Refresh now. Tools for package owners.