executor

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: Apache-2.0 Imports: 9 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) EnableTrace added in v1.2.0

func (opts Options) EnableTrace() bool

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) ExtraTxnOptions added in v1.2.0

func (opts Options) ExtraTxnOptions() []client.TxnOption

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) StatementOption added in v1.2.0

func (opts Options) StatementOption() StatementOption

StatementOption returns statement options

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) WithDisableTrace added in v1.2.0

func (opts Options) WithDisableTrace() Options

func (Options) WithEnableTrace added in v1.2.0

func (opts Options) WithEnableTrace() Options

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) WithStatementOption added in v1.2.0

func (opts Options) WithStatementOption(statementOption StatementOption) Options

WithStatementOption set statement option

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 {
	LastInsertID uint64
	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(rows int, 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 new a txn operator, used for debug.
	NewTxnOperator(ctx context.Context) client.TxnOperator
	// 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.
	// NOTE: Pass SQL stmts one by one to TxnExecutor.Exec(). If you pass multiple SQL stmts to
	// TxnExecutor.Exec() as `\n` seperated string, it will only execute the first SQL statement causing Bug.
	ExecTxn(ctx context.Context, execFunc func(txn 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 StatementOption added in v1.2.0

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

StatementOption statement execute option.

func (StatementOption) AccountID added in v1.2.0

func (opts StatementOption) AccountID() uint32

func (StatementOption) HasAccountID added in v1.2.0

func (opts StatementOption) HasAccountID() bool

func (StatementOption) WaitPolicy added in v1.2.0

func (opts StatementOption) WaitPolicy() lock.WaitPolicy

WaitPolicy returns the wait policy for current statement

func (StatementOption) WithAccountID added in v1.2.0

func (opts StatementOption) WithAccountID(accountID uint32) StatementOption

WithAccountID execute sql in account

func (StatementOption) WithWaitPolicy added in v1.2.0

func (opts StatementOption) WithWaitPolicy(waitPolicy lock.WaitPolicy) StatementOption

WithWaitPolicy set wait policy for current statement

type TxnExecutor

type TxnExecutor interface {
	Use(db string)
	LockTable(table string) error
	// NOTE: If you specify `AccoundId` in `StatementOption`, sql will be executed under that tenant.
	// If not specified, it will be executed under the system tenant by default.
	Exec(sql string, options StatementOption) (Result, error)
	Txn() client.TxnOperator
}

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