Documentation
¶
Index ¶
- Variables
- func Drivers() []string
- func Register(name string, driver driver.Driver)
- func RegisterByOctillery(name string, driver driver.Driver)
- func SetAfterCommitCallback(successCallback func(*Tx) error, ...)
- func SetBeforeCommitCallback(callback func(tx *Tx, writeQueries []*QueryLog) error)
- type ColumnType
- func (ci *ColumnType) DatabaseTypeName() string
- func (ci *ColumnType) DecimalSize() (precision, scale int64, ok bool)
- func (ci *ColumnType) Length() (length int64, ok bool)
- func (ci *ColumnType) Name() string
- func (ci *ColumnType) Nullable() (nullable, ok bool)
- func (ci *ColumnType) ScanType() reflect.Type
- type DB
- func (db *DB) Begin() (*Tx, error)
- func (db *DB) BeginTx(ctx context.Context, opts *TxOptions) (*Tx, error)
- func (db *DB) Close() error
- func (db *DB) ConnectionManager() *connection.DBConnectionManager
- func (db *DB) Driver() coredriver.Driver
- func (db *DB) Exec(query string, args ...interface{}) (Result, error)
- func (db *DB) ExecContext(ctx context.Context, query string, args ...interface{}) (Result, error)
- func (db *DB) Ping() error
- func (db *DB) PingContext(ctx context.Context) error
- func (db *DB) Prepare(query string) (*Stmt, error)
- func (db *DB) PrepareContext(ctx context.Context, query string) (*Stmt, error)
- func (db *DB) Query(query string, args ...interface{}) (*Rows, error)
- func (db *DB) QueryContext(ctx context.Context, query string, args ...interface{}) (*Rows, error)
- func (db *DB) QueryRow(query string, args ...interface{}) *Row
- func (db *DB) QueryRowContext(ctx context.Context, query string, args ...interface{}) *Row
- func (db *DB) SetConnMaxLifetime(d time.Duration)
- func (db *DB) SetMaxIdleConns(n int)
- func (db *DB) SetMaxOpenConns(n int)
- func (db *DB) Stats() DBStats
- type DBStats
- type IsolationLevel
- type NamedArg
- type NullBool
- type NullFloat64
- type NullInt32
- type NullInt64
- type NullString
- type NullTime
- type QueryLog
- type RawBytes
- type Result
- type Row
- type Rows
- type Scanner
- type Stmt
- func (s *Stmt) Close() error
- func (s *Stmt) Exec(args ...interface{}) (core.Result, error)
- func (s *Stmt) ExecContext(ctx context.Context, args ...interface{}) (core.Result, error)
- func (s *Stmt) Query(args ...interface{}) (*Rows, error)
- func (s *Stmt) QueryContext(ctx context.Context, args ...interface{}) (*Rows, error)
- func (s *Stmt) QueryRow(args ...interface{}) *Row
- func (s *Stmt) QueryRowContext(ctx context.Context, args ...interface{}) *Row
- type Tx
- func (proxy *Tx) AfterCommitCallback(success func() error, failure func(bool, []*QueryLog) error)
- func (proxy *Tx) BeforeCommitCallback(callback func([]*QueryLog) error)
- func (proxy *Tx) Commit() error
- func (t *Tx) ConvertWriteQueryIntoCountQuery(query sqlparser.Query) (sqlparser.Query, error)
- func (proxy *Tx) Exec(query string, args ...interface{}) (Result, error)
- func (proxy *Tx) ExecContext(ctx context.Context, query string, args ...interface{}) (Result, error)
- func (t *Tx) ExecWithQueryLog(log *QueryLog) (Result, error)
- func (t *Tx) GetParsedQueryByQueryLog(log *QueryLog) (sqlparser.Query, error)
- func (t *Tx) IsAlreadyCommittedQueryLog(log *QueryLog) (bool, error)
- func (proxy *Tx) Prepare(query string) (*Stmt, error)
- func (proxy *Tx) PrepareContext(ctx context.Context, query string) (*Stmt, error)
- func (proxy *Tx) Query(query string, args ...interface{}) (*Rows, error)
- func (proxy *Tx) QueryContext(ctx context.Context, query string, args ...interface{}) (*Rows, error)
- func (proxy *Tx) QueryRow(query string, args ...interface{}) *Row
- func (proxy *Tx) QueryRowContext(ctx context.Context, query string, args ...interface{}) *Row
- func (proxy *Tx) ReadQueries() []*connection.QueryLog
- func (proxy *Tx) Rollback() error
- func (proxy *Tx) Stmt(stmt *Stmt) *Stmt
- func (proxy *Tx) StmtContext(ctx context.Context, stmt *Stmt) *Stmt
- func (proxy *Tx) WriteQueries() []*connection.QueryLog
- type TxOptions
Constants ¶
This section is empty.
Variables ¶
var ErrNoRows = errors.New("sql: no rows in result set")
ErrNoRows the compatible value of ErrNoRows in 'database/sql' package.
var ErrTxDone = errors.New("sql: Transaction has already been committed or rolled back")
ErrTxDone the compatible value of ErrTxDone in 'database/sql' package.
Functions ¶
func Drivers ¶
func Drivers() []string
Drivers the compatible method of Drivers in 'database/sql' package.
func Register ¶
Register the compatible method of Register in 'database/sql' package. If this called by application, ignore register driver. Octillery register driver by RegisterByOctillery instead.
func RegisterByOctillery ¶
RegisterByOctillery register driver by Octillery
func SetAfterCommitCallback ¶
func SetAfterCommitCallback( successCallback func(*Tx) error, failureCallback func(*Tx, bool, []*QueryLog) error)
SetAfterCommitCallback set function for it is callbacked after commit. Function is set as internal global variable, so must be care possible about it is called by multiple threads.
func SetBeforeCommitCallback ¶
SetBeforeCommitCallback set function for it is callbacked before commit. Function is set as internal global variable, so must be care possible about it is called by multiple threads.
Types ¶
type ColumnType ¶
type ColumnType struct {
// contains filtered or unexported fields
}
ColumnType the compatible structure of ColumnType in 'database/sql' package.
func (*ColumnType) DatabaseTypeName ¶
func (ci *ColumnType) DatabaseTypeName() string
DatabaseTypeName the compatible method of DatabaseTypeName in 'database/sql' package.
func (*ColumnType) DecimalSize ¶
func (ci *ColumnType) DecimalSize() (precision, scale int64, ok bool)
DecimalSize the compatible method of DecimalSize in 'database/sql' package.
func (*ColumnType) Length ¶
func (ci *ColumnType) Length() (length int64, ok bool)
Length the compatible method of Length in 'database/sql' package.
func (*ColumnType) Name ¶
func (ci *ColumnType) Name() string
Name the compatible method of Name in 'database/sql' package.
func (*ColumnType) Nullable ¶
func (ci *ColumnType) Nullable() (nullable, ok bool)
Nullable the compatible method of Nullable in 'database/sql' package.
func (*ColumnType) ScanType ¶
func (ci *ColumnType) ScanType() reflect.Type
ScanType the compatible method of ScanType in 'database/sql' package.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB the compatible structure of DB in 'database/sql' package.
func (*DB) ConnectionManager ¶
func (db *DB) ConnectionManager() *connection.DBConnectionManager
ConnectionManager returns instance that manage all database connections.
func (*DB) Driver ¶
func (db *DB) Driver() coredriver.Driver
Driver the compatible method of Driver in 'database/sql' package.
func (*DB) ExecContext ¶
ExecContext the compatible method of ExecContext in 'database/sql' package.
func (*DB) Ping ¶
Ping the compatible method of Ping in 'database/sql' package. Currently, Ping is ignored.
func (*DB) PingContext ¶
PingContext the compatible method of PingContext in 'database/sql' package. Currently, PingContext is ignored.
func (*DB) PrepareContext ¶
PrepareContext the compatible method of PrepareContext in 'database/sql' package.
func (*DB) QueryContext ¶
QueryContext the compatible method of QueryContext in 'database/sql' package.
func (*DB) QueryRowContext ¶
QueryRowContext the compatible method of QueryRowContext in 'database/sql' package.
func (*DB) SetConnMaxLifetime ¶
SetConnMaxLifetime the compatible method of SetConnMaxLifetime in 'database/sql' package, call SetConnMaxLifetime for all opened connections.
func (*DB) SetMaxIdleConns ¶
SetMaxIdleConns the compatible method of SetMaxIdleConns in 'database/sql' package, call SetMaxIdleConns for all opened connections.
func (*DB) SetMaxOpenConns ¶
SetMaxOpenConns the compatible method of SetMaxOpenConns in 'database/sql' package, call SetMaxOpenConns for all opened connections.
type DBStats ¶
type DBStats struct {
// contains filtered or unexported fields
}
DBStats the compatible structure of DBStats in 'database/sql' package.
type IsolationLevel ¶
type IsolationLevel int
IsolationLevel the compatible type of IsolationLevel in 'database/sql' package.
const ( // LevelDefault the compatible of LevelDefault in 'database/sql' package. LevelDefault IsolationLevel = iota // LevelReadUncommitted the compatible of LevelReadUncommitted in 'database/sql' package. LevelReadUncommitted // LevelReadCommitted the compatible of LevelReadCommitted in 'database/sql' package. LevelReadCommitted // LevelWriteCommitted the compatible of LevelWriteCommitted in 'database/sql' package. LevelWriteCommitted // LevelRepeatableRead the compatible of LevelRepeatableRead in 'database/sql' package. LevelRepeatableRead // LevelSnapshot the compatible of LevelSnapshot in 'database/sql' package. LevelSnapshot // LevelSerializable the compatible of LevelSerializable in 'database/sql' package. LevelSerializable // LevelLinearizable the compatible of LevelLinearizable in 'database/sql' package. LevelLinearizable )
type NamedArg ¶
type NamedArg struct { Name string Value interface{} }
NamedArg the compatible structure of NamedArg in 'database/sql' package.
type NullBool ¶
NullBool is the compatible structure of NullBool in 'database/sql' package.
type NullFloat64 ¶
NullFloat64 the compatible structure of NullFloat64 in 'database/sql' package.
func (*NullFloat64) Scan ¶
func (n *NullFloat64) Scan(value interface{}) error
Scan the compatible method of Scan in 'database/sql' package.
type NullInt32 ¶
NullInt32 the compatible structure of NullInt32 in 'database/sql' package.
type NullInt64 ¶
NullInt64 the compatible structure of NullInt64 in 'database/sql' package.
type NullString ¶
NullString the compatible structure of NullString in 'database/sql' package.
func (*NullString) Scan ¶
func (ns *NullString) Scan(value interface{}) error
Scan the compatible method of Scan in 'database/sql' package.
type NullTime ¶
NullTime the compatible structure of NullTime in 'database/sql' package.
type QueryLog ¶
type QueryLog struct { Query string `json:"query"` Args []interface{} `json:"args"` LastInsertID int64 `json:"lastInsertId"` }
QueryLog type for storing information of executed query
type RawBytes ¶
type RawBytes []byte
RawBytes the compatible type of RawBytes in 'database/sql' package.
type Row ¶
type Row struct {
// contains filtered or unexported fields
}
Row the compatible structure of Row in 'database/sql' package.
type Rows ¶
type Rows struct {
// contains filtered or unexported fields
}
Rows the compatible structure of Rows in 'database/sql' package.
func (*Rows) ColumnTypes ¶
func (rs *Rows) ColumnTypes() ([]*ColumnType, error)
ColumnTypes the compatible method of ColumnTypes in 'database/sql' package.
func (*Rows) NextResultSet ¶
NextResultSet the compatible method of NextResultSet in 'database/sql' package.
type Scanner ¶
type Scanner interface {
Scan(src interface{}) error
}
Scanner the compatible interface of Scanner in 'database/sql' package.
type Stmt ¶
type Stmt struct {
// contains filtered or unexported fields
}
Stmt the compatible structure of Stmt in 'database/sql' package.
func (*Stmt) ExecContext ¶
ExecContext the compatible method of ExecContext in 'database/sql' package.
func (*Stmt) QueryContext ¶
QueryContext the compatible method of QueryContext in 'database/sql' package.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx the compatible type of Tx in 'database/sql' package.
func (*Tx) AfterCommitCallback ¶
AfterCommitCallback set callback function for after commit
func (*Tx) BeforeCommitCallback ¶
BeforeCommitCallback set callback function for before commit
func (*Tx) ConvertWriteQueryIntoCountQuery ¶
ConvertWriteQueryIntoCountQuery convert INSERT/UPDATE/DELETE query to `SELECT COUNT(*)`
func (*Tx) ExecContext ¶
func (proxy *Tx) ExecContext(ctx context.Context, query string, args ...interface{}) (Result, error)
ExecContext the compatible method of ExecContext in 'database/sql' package.
func (*Tx) ExecWithQueryLog ¶
ExecWithQueryLog exec query by *connection.QueryLog. This is able to use for recovery from distributed transaction error.
func (*Tx) GetParsedQueryByQueryLog ¶
GetParsedQueryByQueryLog get instance of `sqlparser.Query` by QueryLog. If QueryLog has LastInsertID value, add to query it
func (*Tx) IsAlreadyCommittedQueryLog ¶
IsAlreadyCommittedQueryLog returns whether write query gave by QueryLog is committed or not.
func (*Tx) PrepareContext ¶
PrepareContext the compatible method of PrepareContext in 'database/sql' package.
func (*Tx) QueryContext ¶
func (proxy *Tx) QueryContext(ctx context.Context, query string, args ...interface{}) (*Rows, error)
QueryContext the compatible method of QueryContext in 'database/sql' package.
func (*Tx) QueryRowContext ¶
QueryRowContext the compatible method of QueryRowContext in 'database/sql' package.
func (*Tx) ReadQueries ¶
func (proxy *Tx) ReadQueries() []*connection.QueryLog
ReadQueries informations of executed SELECT query
func (*Tx) StmtContext ¶
StmtContext the compatible method of StmtContext in 'database/sql' package.
func (*Tx) WriteQueries ¶
func (proxy *Tx) WriteQueries() []*connection.QueryLog
WriteQueries informations of executed INSERT/UPDATE/DELETE query
type TxOptions ¶
type TxOptions struct { Isolation IsolationLevel ReadOnly bool }
TxOptions the compatible structure of TxOptions in 'database/sql' package.