Documentation
¶
Index ¶
- Variables
- func AppendBytesRows(m *MemResult, col int, values [][]byte) error
- func AppendFixedRows[T any](m *MemResult, col int, values []T) error
- func AppendStringRows(m *MemResult, col int, values []string) error
- func GetBytesRows(vec *vector.Vector) [][]byte
- func GetFixedRows[T any](vec *vector.Vector) []T
- func GetStringRows(vec *vector.Vector) []string
- type MemResult
- type Options
- func (opts Options) AccountID() uint32
- func (opts Options) AdjustTableExtraFunc() func(*api.SchemaExtra) error
- func (opts Options) Database() string
- func (opts Options) DisableIncrStatement() bool
- func (opts Options) EnableTrace() bool
- func (opts Options) ExistsTxn() bool
- func (opts Options) ExtraTxnOptions() []client.TxnOption
- func (opts Options) ForceRebuildPlan() bool
- func (opts Options) GetTimeZone() *time.Location
- func (opts Options) HasAccountID() bool
- func (opts Options) HasExistsTxn() bool
- func (opts Options) IsFrontend() bool
- func (opts Options) KeepTxnAlive() bool
- func (opts Options) LowerCaseTableNames() int64
- func (opts Options) MinCommittedTS() timestamp.Timestamp
- func (opts Options) ResolveVariableFunc() func(varName string, isSystemVar, isGlobalVar bool) (interface{}, error)
- func (opts Options) SQL() string
- func (opts Options) SetupNewTxn(txnOp client.TxnOperator) Options
- func (opts Options) StatementOption() StatementOption
- func (opts Options) Streaming() (chan Result, chan error, bool)
- func (opts Options) Txn() client.TxnOperator
- func (opts Options) WaitCommittedLogApplied() bool
- func (opts Options) WithAccountID(accountID uint32) Options
- func (opts Options) WithAdjustTableExtraFunc(fn func(*api.SchemaExtra) error) Options
- func (opts Options) WithDatabase(database string) Options
- func (opts Options) WithDisableIncrStatement() Options
- func (opts Options) WithDisableTrace() Options
- func (opts Options) WithDisableWaitPaused() Options
- func (opts Options) WithEnableTrace() Options
- func (opts Options) WithForceRebuildPlan() Options
- func (opts Options) WithFrontend(b bool) Options
- func (opts Options) WithKeepTxnAlive() Options
- func (opts Options) WithLowerCaseTableNames(lower *int64) Options
- func (opts Options) WithMinCommittedTS(ts timestamp.Timestamp) Options
- func (opts Options) WithResolveVariableFunc(fn func(varName string, isSystemVar, isGlobalVar bool) (interface{}, error)) Options
- func (opts Options) WithSQL(sql string) Options
- func (opts Options) WithStatementOption(statementOption StatementOption) Options
- func (opts Options) WithStreaming(stream_chan chan Result, error_chan chan error) Options
- func (opts Options) WithTimeZone(timeZone *time.Location) Options
- func (opts Options) WithTxn(txnOp client.TxnOperator) Options
- func (opts Options) WithUserTxn() Options
- func (opts Options) WithWaitCommittedLogApplied() Options
- type Result
- type SQLExecutor
- type StatementOption
- func (opts StatementOption) AccountID() uint32
- func (opts StatementOption) AlterCopyDedupOpt() *plan.AlterCopyOpt
- func (opts StatementOption) DisableDropIncrStatement() bool
- func (opts StatementOption) DisableLock() bool
- func (opts StatementOption) DisableLog() bool
- func (opts StatementOption) HasAccountID() bool
- func (opts StatementOption) HasParams() bool
- func (opts StatementOption) HasRoleID() bool
- func (opts StatementOption) HasUserID() bool
- func (opts StatementOption) IgnoreCheckExperimental() bool
- func (opts StatementOption) IgnoreForeignKey() bool
- func (opts StatementOption) IgnorePublish() bool
- func (opts StatementOption) KeepAutoIncrement() uint64
- func (opts StatementOption) KeepLogicalId() uint64
- func (opts StatementOption) Params(mp *mpool.MPool) *vector.Vector
- func (opts StatementOption) RoleID() uint32
- func (opts StatementOption) UserID() uint32
- func (opts StatementOption) WaitPolicy() lock.WaitPolicy
- func (opts StatementOption) WithAccountID(accountID uint32) StatementOption
- func (opts StatementOption) WithAlterCopyOpt(opt *plan.AlterCopyOpt) StatementOption
- func (opts StatementOption) WithDisableDropIncrStatement() StatementOption
- func (opts StatementOption) WithDisableLock() StatementOption
- func (opts StatementOption) WithDisableLog() StatementOption
- func (opts StatementOption) WithIgnoreCheckExperimental() StatementOption
- func (opts StatementOption) WithIgnoreForeignKey() StatementOption
- func (opts StatementOption) WithIgnorePublish() StatementOption
- func (opts StatementOption) WithKeepAutoIncrement(keep uint64) StatementOption
- func (opts StatementOption) WithKeepLogicalId(keep uint64) StatementOption
- func (opts StatementOption) WithParams(values []string) StatementOption
- func (opts StatementOption) WithRoleID(roleID uint32) StatementOption
- func (opts StatementOption) WithUserID(userID uint32) StatementOption
- func (opts StatementOption) WithWaitPolicy(waitPolicy lock.WaitPolicy) StatementOption
- type TxnExecutor
Constants ¶
This section is empty.
Variables ¶
var DefaultResolveVariable func( varName string, isSystemVar, isGlobalVar bool, ) (any, error)
DefaultResolveVariable is a process-wide fallback system-variable resolver, installed once at startup by pkg/frontend's init() from gSysVarsDefs. It is consulted whenever code needs to resolve a system variable from a *process.Process that has no session-bound resolver attached — typically background flows (idxcron ALTER REINDEX, ProcessInitSQL, bootstrap, cron tasks).
Lives here in pkg/util/executor because:
- pkg/iscp, pkg/sql/compile, and pkg/frontend already import this package, so it's the lowest common ancestor.
- Conceptually paired with Options.WithResolveVariableFunc and proc.Base.IsFrontend — all three turn on the same axis ("does this proc have a session?").
Nil-safe by design: tests that don't blank-import pkg/frontend see this as nil; callers must nil-check before invocation. See pkg/iscp/iteration.go::ProcessInitSQL and pkg/sql/compile/util.go::resolveVariableOrDefault for the canonical nil-checked consumers.
Defaults-only — SET GLOBAL overrides are NOT honoured. Per-index admin-tuned values are expected to ride along in the captured-vars sqlexec.Metadata that the idxcron task carries.
Functions ¶
func GetBytesRows ¶
GetBytesRows get bytes rows, varchar, varbinary, text, json, etc.
func GetFixedRows ¶
GetFixedRows get fixed rows, int, float, etc.
func GetStringRows ¶
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 (*MemResult) NewBatchWithRowCount ¶
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options execute options.
func (Options) AdjustTableExtraFunc ¶
func (opts Options) AdjustTableExtraFunc() func(*api.SchemaExtra) error
func (Options) DisableIncrStatement ¶ added in v1.0.0
DisableIncrStatement returns the txn operator need incr a new input statement
func (Options) EnableTrace ¶ added in v1.2.0
func (Options) ExistsTxn ¶
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 (Options) ForceRebuildPlan ¶
func (Options) GetTimeZone ¶ added in v1.0.0
GetTimeZone return the time zone of original session
func (Options) HasAccountID ¶
HasAccountID returns true if account is set
func (Options) HasExistsTxn ¶
HasExistsTxn return true if a exists txn is set
func (Options) IsFrontend ¶
func (Options) KeepTxnAlive ¶
func (Options) LowerCaseTableNames ¶ added in v1.2.2
func (Options) MinCommittedTS ¶
MinCommittedTS returns min committed ts
func (Options) ResolveVariableFunc ¶
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) WaitCommittedLogApplied ¶
WaitCommittedLogApplied return true means need wait committed log applied in current cn.
func (Options) WithAccountID ¶
WithAccountID execute sql in account
func (Options) WithAdjustTableExtraFunc ¶
func (opts Options) WithAdjustTableExtraFunc( fn func(*api.SchemaExtra) error, ) Options
func (Options) WithDatabase ¶
WithDatabase exec sql in database
func (Options) WithDisableIncrStatement ¶ added in v1.0.0
WithDisableIncrStatement disable incr statement
func (Options) WithDisableTrace ¶ added in v1.2.0
func (Options) WithDisableWaitPaused ¶
func (Options) WithEnableTrace ¶ added in v1.2.0
func (Options) WithForceRebuildPlan ¶
func (Options) WithFrontend ¶
WithFrontend marks the SQL execution as a frontend session-bound invocation (b=true) versus a background / internal one (b=false). Consumed by pkg/sql/compile/sql_executor.go's NewTopProcess which sets proc.Base.IsFrontend = opts.IsFrontend().
The default — `executor.Options{}` with no setter — is background (IsFrontend()=false). Frontend code that uses the internal SQL executor for session-bound queries opts in by calling WithFrontend(true). Background callers (idxcron, ProcessInitSQL, bootstrap, cron tasks, task service, …) don't need to call this — they inherit the default.
Takes a bool (rather than a no-arg setter) so callers that wrap an existing proc and re-invoke the executor can carry the flag forward via opts.WithFrontend(proc.Base.IsFrontend) — same shape as WithResolveVariableFunc(proc.GetResolveVariableFunc()).
func (Options) WithKeepTxnAlive ¶
func (Options) WithLowerCaseTableNames ¶ added in v1.2.2
func (Options) WithMinCommittedTS ¶
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) WithResolveVariableFunc ¶
func (Options) WithStatementOption ¶ added in v1.2.0
func (opts Options) WithStatementOption(statementOption StatementOption) Options
WithStatementOption set statement option
func (Options) WithStreaming ¶
func (Options) WithTimeZone ¶ added in v1.0.0
func (Options) WithTxn ¶
func (opts Options) WithTxn(txnOp client.TxnOperator) Options
WithTxn exec sql in a exists txn
func (Options) WithUserTxn ¶
func (Options) WithWaitCommittedLogApplied ¶
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
Mp *mpool.MPool
LogicalPlan *plan.Query
}
Result exec sql result
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(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
func NewMemExecutor2 ¶
func NewMemExecutor2(mocker func(sql string) (Result, error), txnOp client.TxnOperator) SQLExecutor
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) AlterCopyDedupOpt ¶
func (opts StatementOption) AlterCopyDedupOpt() *plan.AlterCopyOpt
func (StatementOption) DisableDropIncrStatement ¶
func (opts StatementOption) DisableDropIncrStatement() bool
func (StatementOption) DisableLock ¶
func (opts StatementOption) DisableLock() bool
func (StatementOption) DisableLog ¶
func (opts StatementOption) DisableLog() bool
func (StatementOption) HasAccountID ¶ added in v1.2.0
func (opts StatementOption) HasAccountID() bool
func (StatementOption) HasParams ¶
func (opts StatementOption) HasParams() bool
func (StatementOption) HasRoleID ¶
func (opts StatementOption) HasRoleID() bool
func (StatementOption) HasUserID ¶
func (opts StatementOption) HasUserID() bool
func (StatementOption) IgnoreCheckExperimental ¶
func (opts StatementOption) IgnoreCheckExperimental() bool
func (StatementOption) IgnoreForeignKey ¶
func (opts StatementOption) IgnoreForeignKey() bool
func (StatementOption) IgnorePublish ¶
func (opts StatementOption) IgnorePublish() bool
func (StatementOption) KeepAutoIncrement ¶
func (opts StatementOption) KeepAutoIncrement() uint64
func (StatementOption) KeepLogicalId ¶
func (opts StatementOption) KeepLogicalId() uint64
func (StatementOption) Params ¶
func (opts StatementOption) Params( mp *mpool.MPool, ) *vector.Vector
func (StatementOption) RoleID ¶
func (opts StatementOption) RoleID() uint32
func (StatementOption) UserID ¶
func (opts StatementOption) UserID() uint32
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) WithAlterCopyOpt ¶
func (opts StatementOption) WithAlterCopyOpt(opt *plan.AlterCopyOpt) StatementOption
func (StatementOption) WithDisableDropIncrStatement ¶
func (opts StatementOption) WithDisableDropIncrStatement() StatementOption
func (StatementOption) WithDisableLock ¶
func (opts StatementOption) WithDisableLock() StatementOption
func (StatementOption) WithDisableLog ¶
func (opts StatementOption) WithDisableLog() StatementOption
func (StatementOption) WithIgnoreCheckExperimental ¶
func (opts StatementOption) WithIgnoreCheckExperimental() StatementOption
func (StatementOption) WithIgnoreForeignKey ¶
func (opts StatementOption) WithIgnoreForeignKey() StatementOption
WithDisableIncrStatement disable incr statement
func (StatementOption) WithIgnorePublish ¶
func (opts StatementOption) WithIgnorePublish() StatementOption
func (StatementOption) WithKeepAutoIncrement ¶
func (opts StatementOption) WithKeepAutoIncrement(keep uint64) StatementOption
func (StatementOption) WithKeepLogicalId ¶
func (opts StatementOption) WithKeepLogicalId(keep uint64) StatementOption
func (StatementOption) WithParams ¶
func (opts StatementOption) WithParams( values []string, ) StatementOption
func (StatementOption) WithRoleID ¶
func (opts StatementOption) WithRoleID(roleID uint32) StatementOption
func (StatementOption) WithUserID ¶
func (opts StatementOption) WithUserID(userID uint32) StatementOption
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.
func NewMemTxnExecutor ¶
func NewMemTxnExecutor(mocker func(sql string) (Result, error), txnOperator client.TxnOperator) TxnExecutor
NewMemTxnExecutor used to testing