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

package mutations

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

Index

Package Files

mutations.go

Variables

var (
    // StatisticsMutator adds ALTER TABLE INJECT STATISTICS statements.
    StatisticsMutator MultiStatementMutation = statisticsMutator

    // ForeignKeyMutator adds ALTER TABLE ADD FOREIGN KEY statements.
    ForeignKeyMutator MultiStatementMutation = foreignKeyMutator

    // ColumnFamilyMutator modifies a CREATE TABLE statement without any FAMILY
    // definitions to have random FAMILY definitions.
    ColumnFamilyMutator StatementMutator = sqlbase.ColumnFamilyMutator

    // IndexStoringMutator modifies the STORING clause of CREATE INDEX and
    // indexes in CREATE TABLE.
    IndexStoringMutator MultiStatementMutation = sqlbase.IndexStoringMutator

    // PartialIndexMutator adds random partial index predicate expressions to
    // indexes.
    PartialIndexMutator MultiStatementMutation = sqlbase.PartialIndexMutator

    // PostgresMutator modifies strings such that they execute identically
    // in both Postgres and Cockroach (however this mutator does not remove
    // features not supported by Postgres; use PostgresCreateTableMutator
    // for those).
    PostgresMutator StatementStringMutator = postgresMutator

    // PostgresCreateTableMutator modifies CREATE TABLE statements to
    // remove any features not supported by Postgres that would change
    // results (like descending primary keys). This should be used on the
    // output of sqlbase.RandCreateTable.
    PostgresCreateTableMutator MultiStatementMutation = postgresCreateTableMutator
)

func Apply Uses

func Apply(
    rng *rand.Rand, stmts []tree.Statement, mutators ...sqlbase.Mutator,
) (mutated []tree.Statement, changed bool)

Apply executes all mutators on stmts. It returns the (possibly mutated and changed in place) statements and a boolean indicating whether any changes were made.

func ApplyString Uses

func ApplyString(
    rng *rand.Rand, input string, mutators ...sqlbase.Mutator,
) (output string, changed bool)

ApplyString executes all mutators on input. A mutator can also be a StringMutator which will operate after all other mutators.

type MultiStatementMutation Uses

type MultiStatementMutation func(rng *rand.Rand, stmts []tree.Statement) (mutated []tree.Statement, changed bool)

MultiStatementMutation defines a func that can return a list of new and/or mutated statements.

func (MultiStatementMutation) Mutate Uses

func (msm MultiStatementMutation) Mutate(
    rng *rand.Rand, stmts []tree.Statement,
) (mutated []tree.Statement, changed bool)

Mutate implements the Mutator interface.

type StatementMutator Uses

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

StatementMutator defines a func that can change a statement.

func (StatementMutator) Mutate Uses

func (sm StatementMutator) Mutate(
    rng *rand.Rand, stmts []tree.Statement,
) (mutated []tree.Statement, changed bool)

Mutate implements the Mutator interface.

type StatementStringMutator Uses

type StatementStringMutator func(*rand.Rand, string) string

StatementStringMutator defines a func that mutates a string.

func (StatementStringMutator) Mutate Uses

func (sm StatementStringMutator) Mutate(
    rng *rand.Rand, stmts []tree.Statement,
) (mutated []tree.Statement, changed bool)

Mutate implements the Mutator interface.

func (StatementStringMutator) MutateString Uses

func (sm StatementStringMutator) MutateString(
    rng *rand.Rand, q string,
) (mutated string, changed bool)

MutateString implements the StringMutator interface.

type StringMutator Uses

type StringMutator interface {
    MutateString(*rand.Rand, string) (mutated string, changed bool)
}

StringMutator defines a mutator that works on strings.

Package mutations imports 11 packages (graph) and is imported by 6 packages. Updated 2020-08-12. Refresh now. Tools for package owners.