Documentation ¶
Index ¶
- func CommandType(ctx context.Context) byte
- func ConnectionID(ctx context.Context) uint32
- func IsMaster(ctx context.Context) bool
- func IsSlave(ctx context.Context) bool
- func QueryStmt(ctx context.Context) ast.StmtNode
- func RemoteAddr(ctx context.Context) string
- func Schema(ctx context.Context) string
- func SqlText(ctx context.Context) string
- func UserName(ctx context.Context) string
- func Variable(ctx context.Context, key string) interface{}
- func WithCommandType(ctx context.Context, commandType byte) context.Context
- func WithConnectionID(ctx context.Context, connectionID uint32) context.Context
- func WithDBGroupTx(ctx context.Context, tx DBGroupTx) context.Context
- func WithMaster(ctx context.Context) context.Context
- func WithPrepareStmt(ctx context.Context, stmt *Stmt) context.Context
- func WithQueryStmt(ctx context.Context, stmt ast.StmtNode) context.Context
- func WithRemoteAddr(ctx context.Context, remoteAddr string) context.Context
- func WithSchema(ctx context.Context, schema string) context.Context
- func WithSlave(ctx context.Context) context.Context
- func WithSqlText(ctx context.Context, sqlText string) context.Context
- func WithUserName(ctx context.Context, userName string) context.Context
- func WithVariable(ctx context.Context, key string, value interface{}) bool
- func WithVariableMap(ctx context.Context) context.Context
- type Connection
- type DB
- type DBConnectionPostFilter
- type DBConnectionPreFilter
- type DBGroupExecutor
- type DBGroupTx
- type DBListener
- type DBManager
- type DBPostFilter
- type DBPreFilter
- type DBStatus
- type DistributedTransactionManager
- type Executor
- type Field
- type Filter
- type FilterFactory
- type HttpPostFilter
- type HttpPreFilter
- type Listener
- type Optimizer
- type Plan
- type Result
- type Row
- type SequenceGenerator
- type Stmt
- type Tx
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectionID ¶
ConnectionID extracts connection id
func RemoteAddr ¶ added in v0.2.0
RemoteAddr extracts remote addr
func WithCommandType ¶
WithCommandType binds command type
func WithConnectionID ¶
WithConnectionID binds connection id
func WithDBGroupTx ¶ added in v0.5.0
WithDBGroupTx .
func WithMaster ¶
WithMaster uses master datasource.
func WithPrepareStmt ¶
WithPrepareStmt binds prepare stmt
func WithQueryStmt ¶
WithQueryStmt binds query stmt
func WithRemoteAddr ¶ added in v0.2.0
WithRemoteAddr binds remote address
func WithSchema ¶
WithSchema binds schema
func WithSqlText ¶ added in v0.2.0
WithSqlText binds sql text
func WithUserName ¶ added in v0.2.0
WithUserName binds user name
func WithVariable ¶
WithVariable binds a key value pair
Types ¶
type Connection ¶
type DB ¶
type DB interface { Name() string Status() DBStatus SetCapacity(capacity int) error SetIdleTimeout(idleTimeout time.Duration) Capacity() int64 Available() int64 Active() int64 InUse() int64 MaxCap() int64 WaitCount() int64 WaitTime() time.Duration IdleTimeout() time.Duration IdleClosed() int64 Exhausted() int64 StatsJSON() string Ping() error Close() IsClosed() bool IsMaster() bool MasterName() string SetWriteWeight(int) SetReadWeight(int) WriteWeight() int ReadWeight() int SetConnectionPreFilters(filters []DBConnectionPreFilter) SetConnectionPostFilters(filters []DBConnectionPostFilter) UseDB(ctx context.Context, schema string) error ExecuteFieldList(ctx context.Context, table, wildcard string) ([]Field, error) Query(ctx context.Context, query string) (Result, uint16, error) QueryDirectly(query string) (Result, uint16, error) ExecuteStmt(ctx context.Context, stmt *Stmt) (Result, uint16, error) ExecuteSql(ctx context.Context, sql string, args ...interface{}) (Result, uint16, error) ExecuteSqlDirectly(sql string, args ...interface{}) (Result, uint16, error) Begin(ctx context.Context) (Tx, Result, error) XAStart(ctx context.Context, sql string) (Tx, Result, error) }
type DBConnectionPostFilter ¶
type DBConnectionPreFilter ¶
type DBConnectionPreFilter interface { Filter PreHandle(ctx context.Context, conn Connection) error }
type DBGroupExecutor ¶
type DBGroupExecutor interface { GroupName() string Begin(ctx context.Context) (Tx, Result, error) Query(ctx context.Context, query string) (Result, uint16, error) QueryAll(ctx context.Context, query string) (Result, uint16, error) Execute(ctx context.Context, query string) (Result, uint16, error) PrepareQuery(ctx context.Context, query string, args ...interface{}) (Result, uint16, error) PrepareExecute(ctx context.Context, query string, args ...interface{}) (Result, uint16, error) PrepareExecuteStmt(ctx context.Context, stmt *Stmt) (Result, uint16, error) XAStart(ctx context.Context, sql string) (Tx, Result, error) }
DBGroupExecutor prepare a query, execute the statement, and then close the statement.
type DBGroupTx ¶ added in v0.5.0
type DBGroupTx interface { Begin(ctx context.Context, executor DBGroupExecutor) (Tx, error) Query(ctx context.Context, query string) (Result, uint16, error) Execute(ctx context.Context, stmt ast.StmtNode, args ...interface{}) (Result, uint16, error) Commit(ctx context.Context) (result Result, err error) Rollback(ctx context.Context) (result Result, err error) }
func ExtractDBGroupTx ¶ added in v0.5.0
ExtractDBGroupTx .
type DBListener ¶
type DBPostFilter ¶
type DBPostFilter interface { Filter PostHandle(ctx context.Context, result Result, err error) error }
DBPostFilter ...
type DBPreFilter ¶
DBPreFilter ...
type DistributedTransactionManager ¶ added in v0.4.0
type DistributedTransactionManager interface { Begin(ctx context.Context, transactionName string, timeout int32) (string, error) Commit(ctx context.Context, xid string) (api.GlobalSession_GlobalStatus, error) Rollback(ctx context.Context, xid string) (api.GlobalSession_GlobalStatus, error) BranchRegister(ctx context.Context, in *api.BranchRegisterRequest) (string, int64, error) BranchReport(ctx context.Context, branchID string, status api.BranchSession_BranchStatus) error ReleaseLockKeys(ctx context.Context, resourceID string, lockKeys []string) (bool, error) IsLockable(ctx context.Context, resourceID, lockKey string) (bool, error) IsLockableWithXID(ctx context.Context, resourceID, lockKey, xid string) (bool, error) ListDeadBranchSessions(ctx context.Context) ([]*api.BranchSession, error) IsMaster() bool }
type Executor ¶
type Executor interface { GetPreFilters() []DBPreFilter GetPostFilters() []DBPostFilter ExecuteMode() config.ExecuteMode ProcessDistributedTransaction() bool InLocalTransaction(ctx context.Context) bool InGlobalTransaction(ctx context.Context) bool ExecuteUseDB(ctx context.Context, db string) error ExecuteFieldList(ctx context.Context, table, wildcard string) ([]Field, error) ExecutorComQuery(ctx context.Context, sql string) (Result, uint16, error) ExecutorComStmtExecute(ctx context.Context, stmt *Stmt) (Result, uint16, error) ConnectionClose(ctx context.Context) }
Executor ...
type FilterFactory ¶
type HttpPostFilter ¶
type HttpPreFilter ¶
type Optimizer ¶
type Optimizer interface { // Optimize optimizes the sql with arguments then returns a Plan. Optimize(ctx context.Context, stmt ast.StmtNode, args ...interface{}) (Plan, error) }
Optimizer represents a sql statement optimizer which can be used to create QueryPlan or ExecPlan.
type Plan ¶
type Plan interface { // Execute executes the current Plan. Execute(ctx context.Context, hints ...*ast.TableOptimizerHint) (Result, uint16, error) }
Plan represents a plan for query/execute command.
type Result ¶
type Result interface { // LastInsertId returns the database's auto-generated ID // after, for example, an INSERT into a table with primary // key. LastInsertId() (uint64, error) // RowsAffected returns the number of rows affected by the // query. RowsAffected() (uint64, error) }
Result is the result of a query execution.
type Row ¶
type Row interface { // Columns returns the names of the columns. The number of // columns of the result is inferred from the length of the // slice. If a particular column name isn't known, an empty // string should be returned for that entry. Columns() []string Fields() []Field // Data Data() []byte Decode() ([]*Value, error) }
Rows is an iterator over an executed query's results.
type SequenceGenerator ¶ added in v0.5.0
type Stmt ¶
type Stmt struct { StatementID uint32 HasLongDataParam bool SqlText string ParamsCount uint16 ParamData []byte ParamsType []int32 ColumnNames []string BindVars map[string]interface{} StmtNode ast.StmtNode }
Stmt is a buffer used for store prepare statement meta data
type Tx ¶
type Tx interface { Query(ctx context.Context, query string) (Result, uint16, error) QueryDirectly(query string) (Result, uint16, error) ExecuteStmt(ctx context.Context, stmt *Stmt) (Result, uint16, error) ExecuteSql(ctx context.Context, sql string, args ...interface{}) (Result, uint16, error) ExecuteSqlDirectly(sql string, args ...interface{}) (Result, uint16, error) Commit(ctx context.Context) (Result, error) Rollback(ctx context.Context, stmt *ast.RollbackStmt) (Result, error) ReleaseSavepoint(ctx context.Context, savepoint string) (result Result, err error) XAPrepare(ctx context.Context, sql string) (Result, error) }