cockroach: github.com/cockroachdb/cockroach/pkg/cmd/cmpconn Index | Files

package cmpconn

import "github.com/cockroachdb/cockroach/pkg/cmd/cmpconn"

Package cmpconn assists in comparing results from DB connections.

Index

Package Files

compare.go conn.go

func CompareConns Uses

func CompareConns(
    ctx context.Context,
    timeout time.Duration,
    conns map[string]Conn,
    prep, exec string,
    ignoreSQLErrors bool,
) (err error)

CompareConns executes prep and exec on all connections in conns. If any differ, an error is returned. ignoreSQLErrors determines whether SQL errors are ignored. NOTE: exec will be mutated for each connection of type connWithMutators.

func CompareVals Uses

func CompareVals(a, b []interface{}) error

CompareVals returns an error if a and b differ, specifying what the difference is. It is designed to compare SQL results from a query executed on two different servers or configurations (i.e., cockroach and postgres). Postgres and Cockroach have subtle differences in their result types and OIDs. This function is aware of those and is able to correctly compare those values.

type Conn Uses

type Conn interface {
    // DB returns gosql connection.
    DB() *gosql.DB
    // PGX returns pgx connection.
    PGX() *pgx.Conn
    // Values executes prep and exec and returns the results of exec.
    Values(ctx context.Context, prep, exec string) (rows *pgx.Rows, err error)
    // Exec executes s.
    Exec(ctx context.Context, s string) error
    // Ping pings a connection.
    Ping() error
    // Close closes the connections.
    Close()
}

Conn holds gosql and pgx connections and provides some utility methods.

func NewConn Uses

func NewConn(uri string, initSQL ...string) (Conn, error)

NewConn returns a new Conn on the given uri and executes initSQL on it.

func NewConnWithMutators Uses

func NewConnWithMutators(
    uri string, rng *rand.Rand, sqlMutators []sqlbase.Mutator, initSQL ...string,
) (Conn, error)

NewConnWithMutators returns a new Conn on the given uri and executes initSQL on it. The mutators are applied to initSQL and will be applied to all queries to be executed in CompareConns.

Package cmpconn imports 18 packages (graph) and is imported by 2 packages. Updated 2020-08-11. Refresh now. Tools for package owners.