executor

package
v1.0.0-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendBytesRows

func AppendBytesRows(m *MemResult, col int, values [][]byte) error

func AppendFixedRows

func AppendFixedRows[T any](m *MemResult, col int, values []T) error

func AppendStringRows

func AppendStringRows(m *MemResult, col int, values []string) error

func GetBytesRows

func GetBytesRows(vec *vector.Vector) [][]byte

GetBytesRows get bytes rows, varchar, varbinary, text, json, etc.

func GetFixedRows

func GetFixedRows[T any](vec *vector.Vector) []T

GetFixedRows get fixed rows, int, float, etc.

func GetStringRows

func GetStringRows(vec *vector.Vector) []string

GetStringRows get bytes rows, varchar, varbinary, text, json, etc.

Types

type MemResult

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

MemResult used to test. Construct a Result from memory.

func NewMemResult

func NewMemResult(
	types []types.Type,
	mp *mpool.MPool) *MemResult

func (*MemResult) GetResult

func (m *MemResult) GetResult() Result

func (*MemResult) NewBatch

func (m *MemResult) NewBatch()

type Options

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

Options execute options.

func (Options) AccountID

func (opts Options) AccountID() uint32

AccountID returns account id

func (Options) Database

func (opts Options) Database() string

Database returns default database

func (Options) DisableIncrStatement added in v1.0.0

func (opts Options) DisableIncrStatement() bool

DisableIncrStatement returns the txn operator need incr a new input statement

func (Options) ExistsTxn

func (opts Options) ExistsTxn() bool

ExistsTxn return true if the txn is a exists txn which is not create by executor

func (Options) GetTimeZone added in v1.0.0

func (opts Options) GetTimeZone() *time.Location

GetTimeZone return the time zone of original session

func (Options) HasAccountID

func (opts Options) HasAccountID() bool

HasAccountID returns true if account is set

func (Options) HasExistsTxn

func (opts Options) HasExistsTxn() bool

HasExistsTxn return true if a exists txn is set

func (Options) MinCommittedTS

func (opts Options) MinCommittedTS() timestamp.Timestamp

MinCommittedTS returns min committed ts

func (Options) SetupNewTxn

func (opts Options) SetupNewTxn(txnOp client.TxnOperator) Options

SetupNewTxn setup new txn

func (Options) Txn

func (opts Options) Txn() client.TxnOperator

Txn returns the txn operator

func (Options) WaitCommittedLogApplied

func (opts Options) WaitCommittedLogApplied() bool

WaitCommittedLogApplied return true means need wait committed log applied in current cn.

func (Options) WithAccountID

func (opts Options) WithAccountID(accountID uint32) Options

WithAccountID execute sql in account

func (Options) WithDatabase

func (opts Options) WithDatabase(database string) Options

WithDatabase exec sql in database

func (Options) WithDisableIncrStatement added in v1.0.0

func (opts Options) WithDisableIncrStatement() Options

WithDisableIncrStatement disable incr statement

func (Options) WithMinCommittedTS

func (opts Options) WithMinCommittedTS(ts timestamp.Timestamp) Options

WithMinCommittedTS use minCommittedTS to exec sql. It will set txn's snapshot to minCommittedTS+1, so the txn can see the data which committed at minCommittedTS. It's not work if txn operator is set.

func (Options) WithTimeZone added in v1.0.0

func (opts Options) WithTimeZone(timeZone *time.Location) Options

func (Options) WithTxn

func (opts Options) WithTxn(txnOp client.TxnOperator) Options

WithTxn exec sql in a exists txn

func (Options) WithWaitCommittedLogApplied

func (opts Options) WithWaitCommittedLogApplied() Options

WithWaitCommittedLogApplied if set, the executor will wait all committed log applied for the txn.

type Result

type Result struct {
	AffectedRows uint64
	Batches      []*batch.Batch
	// contains filtered or unexported fields
}

Result exec sql result

func NewResult

func NewResult(mp *mpool.MPool) Result

NewResult create result

func (Result) Close

func (res Result) Close()

func (Result) ReadRows

func (res Result) ReadRows(apply func(cols []*vector.Vector) bool)

ReadRows read all rows, apply is used to read cols data in a row. If apply return false, stop reading. If the query has a lot of data, apply will be called multiple times, giving a batch of rows for each call.

type SQLExecutor

type SQLExecutor interface {
	// Exec exec a sql in a exists txn.
	Exec(ctx context.Context, sql string, opts Options) (Result, error)
	// ExecTxn executor sql in a txn. execFunc can use TxnExecutor to exec multiple sql
	// in a transaction.
	ExecTxn(ctx context.Context, execFunc func(TxnExecutor) error, opts Options) error
}

SQLExecutor is used to execute internal sql. All internal requirements for writing data should be done using the internal sql executor, otherwise pessimistic transactions may not work.

func NewMemExecutor

func NewMemExecutor(mocker func(sql string) (Result, error)) SQLExecutor

NewMemExecutor used to testing

type TxnExecutor

type TxnExecutor interface {
	Exec(sql string) (Result, error)
}

TxnExecutor exec all sql in a transaction.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL