{"modulePath":"github.com/matrixorigin/matrixone","version":"v1.2.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package executor\n\n## Functions\n\n```go\nfunc AppendBytesRows(m *MemResult, col int, values [][]byte) error\n```\n\n```go\nfunc AppendFixedRows[T any](m *MemResult, col int, values []T) error\n```\n\n```go\nfunc AppendStringRows(m *MemResult, col int, values []string) error\n```\n\n```go\nfunc GetBytesRows(vec *vector.Vector) [][]byte\n```\nGetBytesRows get bytes rows, varchar, varbinary, text, json, etc.\n\n```go\nfunc GetFixedRows[T any](vec *vector.Vector) []T\n```\nGetFixedRows get fixed rows, int, float, etc.\n\n```go\nfunc GetStringRows(vec *vector.Vector) []string\n```\nGetStringRows get bytes rows, varchar, varbinary, text, json, etc.\n\n## Types\n\n```go\ntype MemResult struct {\n\t// contains filtered or unexported fields\n}\n```\nMemResult used to test. Construct a Result from memory.\n\n```go\nfunc NewMemResult(\n\ttypes []types.Type,\n\tmp *mpool.MPool) *MemResult\n```\n\n```go\nfunc (m *MemResult) GetResult() Result\n```\n\n```go\nfunc (m *MemResult) NewBatch()\n```\n\n```go\ntype Options struct {\n\t// contains filtered or unexported fields\n}\n```\nOptions execute options.\n\n```go\nfunc (opts Options) AccountID() uint32\n```\nAccountID returns account id\n\n```go\nfunc (opts Options) Database() string\n```\nDatabase returns default database\n\n```go\nfunc (opts Options) DisableIncrStatement() bool\n```\nDisableIncrStatement returns the txn operator need incr a new input statement\n\n```go\nfunc (opts Options) EnableTrace() bool\n```\n\n```go\nfunc (opts Options) ExistsTxn() bool\n```\nExistsTxn return true if the txn is a exists txn which is not create by executor\n\n```go\nfunc (opts Options) ExtraTxnOptions() []client.TxnOption\n```\n\n```go\nfunc (opts Options) GetTimeZone() *time.Location\n```\nGetTimeZone return the time zone of original session\n\n```go\nfunc (opts Options) HasAccountID() bool\n```\nHasAccountID returns true if account is set\n\n```go\nfunc (opts Options) HasExistsTxn() bool\n```\nHasExistsTxn return true if a exists txn is set\n\n```go\nfunc (opts Options) LowerCaseTableNames() int64\n```\n\n```go\nfunc (opts Options) MinCommittedTS() timestamp.Timestamp\n```\nMinCommittedTS returns min committed ts\n\n```go\nfunc (opts Options) SetupNewTxn(txnOp client.TxnOperator) Options\n```\nSetupNewTxn setup new txn\n\n```go\nfunc (opts Options) StatementOption() StatementOption\n```\nStatementOption returns statement options\n\n```go\nfunc (opts Options) Txn() client.TxnOperator\n```\nTxn returns the txn operator\n\n```go\nfunc (opts Options) WaitCommittedLogApplied() bool\n```\nWaitCommittedLogApplied return true means need wait committed log applied in current cn.\n\n```go\nfunc (opts Options) WithAccountID(accountID uint32) Options\n```\nWithAccountID execute sql in account\n\n```go\nfunc (opts Options) WithDatabase(database string) Options\n```\nWithDatabase exec sql in database\n\n```go\nfunc (opts Options) WithDisableIncrStatement() Options\n```\nWithDisableIncrStatement disable incr statement\n\n```go\nfunc (opts Options) WithDisableTrace() Options\n```\n\n```go\nfunc (opts Options) WithEnableTrace() Options\n```\n\n```go\nfunc (opts Options) WithLowerCaseTableNames(lower *int64) Options\n```\n\n```go\nfunc (opts Options) WithMinCommittedTS(ts timestamp.Timestamp) Options\n```\nWithMinCommittedTS 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.\n\n```go\nfunc (opts Options) WithStatementOption(statementOption StatementOption) Options\n```\nWithStatementOption set statement option\n\n```go\nfunc (opts Options) WithTimeZone(timeZone *time.Location) Options\n```\n\n```go\nfunc (opts Options) WithTxn(txnOp client.TxnOperator) Options\n```\nWithTxn exec sql in a exists txn\n\n```go\nfunc (opts Options) WithWaitCommittedLogApplied() Options\n```\nWithWaitCommittedLogApplied if set, the executor will wait all committed log applied for the txn.\n\n```go\ntype Result struct {\n\tLastInsertID uint64\n\tAffectedRows uint64\n\tBatches      []*batch.Batch\n\t// contains filtered or unexported fields\n}\n```\nResult exec sql result\n\n```go\nfunc NewResult(mp *mpool.MPool) Result\n```\nNewResult create result\n\n```go\nfunc (res Result) Close()\n```\n\n```go\nfunc (res Result) ReadRows(apply func(rows int, cols []*vector.Vector) bool)\n```\nReadRows 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.\n\n```go\ntype SQLExecutor interface {\n\t// Exec exec a sql in a exists txn.\n\tExec(ctx context.Context, sql string, opts Options) (Result, error)\n\t// ExecTxn executor sql in a txn. execFunc can use TxnExecutor to exec multiple sql\n\t// in a transaction.\n\t// NOTE: Pass SQL stmts one by one to TxnExecutor.Exec(). If you pass multiple SQL stmts to\n\t// TxnExecutor.Exec() as `\\n` seperated string, it will only execute the first SQL statement causing Bug.\n\tExecTxn(ctx context.Context, execFunc func(txn TxnExecutor) error, opts Options) error\n}\n```\nSQLExecutor 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.\n\n```go\nfunc NewMemExecutor(mocker func(sql string) (Result, error)) SQLExecutor\n```\nNewMemExecutor used to testing\n\n```go\ntype StatementOption struct {\n\t// contains filtered or unexported fields\n}\n```\nStatementOption statement execute option.\n\n```go\nfunc (opts StatementOption) AccountID() uint32\n```\n\n```go\nfunc (opts StatementOption) HasAccountID() bool\n```\n\n```go\nfunc (opts StatementOption) WaitPolicy() lock.WaitPolicy\n```\nWaitPolicy returns the wait policy for current statement\n\n```go\nfunc (opts StatementOption) WithAccountID(accountID uint32) StatementOption\n```\nWithAccountID execute sql in account\n\n```go\nfunc (opts StatementOption) WithWaitPolicy(waitPolicy lock.WaitPolicy) StatementOption\n```\nWithWaitPolicy set wait policy for current statement\n\n```go\ntype TxnExecutor interface {\n\tUse(db string)\n\tLockTable(table string) error\n\t// NOTE: If you specify `AccoundId` in `StatementOption`, sql will be executed under that tenant.\n\t// If not specified, it will be executed under the system tenant by default.\n\tExec(sql string, options StatementOption) (Result, error)\n\tTxn() client.TxnOperator\n}\n```\nTxnExecutor exec all sql in a transaction.\n\n","path":"github.com/matrixorigin/matrixone/pkg/util/executor","name":"executor","synopsis":"","isRedistributable":true}
