sql

package
v1.1.11 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoRows = errors.New("sql: no rows in result set")

ErrNoRows the compatible value of ErrNoRows in 'database/sql' package.

View Source
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

func Register(name string, driver driver.Driver)

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

func RegisterByOctillery(name string, driver driver.Driver)

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

func SetBeforeCommitCallback(callback func(tx *Tx, writeQueries []*QueryLog) error)

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 Open

func Open(driverName, dataSourceName string) (*DB, error)

Open the compatible method of Open in 'database/sql' package.

func (*DB) Begin

func (db *DB) Begin() (*Tx, error)

Begin the compatible method of Begin in 'database/sql' package.

func (*DB) BeginTx

func (db *DB) BeginTx(ctx context.Context, opts *TxOptions) (*Tx, error)

BeginTx the compatible method of BeginTx in 'database/sql' package.

func (*DB) Close

func (db *DB) Close() error

Close the compatible method of Close 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) Exec

func (db *DB) Exec(query string, args ...interface{}) (Result, error)

Exec the compatible method of Exec in 'database/sql' package.

func (*DB) ExecContext

func (db *DB) ExecContext(ctx context.Context, query string, args ...interface{}) (Result, error)

ExecContext the compatible method of ExecContext in 'database/sql' package.

func (*DB) Ping

func (db *DB) Ping() error

Ping the compatible method of Ping in 'database/sql' package. Currently, Ping is ignored.

func (*DB) PingContext

func (db *DB) PingContext(ctx context.Context) error

PingContext the compatible method of PingContext in 'database/sql' package. Currently, PingContext is ignored.

func (*DB) Prepare

func (db *DB) Prepare(query string) (*Stmt, error)

Prepare the compatible method of Prepare in 'database/sql' package.

func (*DB) PrepareContext

func (db *DB) PrepareContext(ctx context.Context, query string) (*Stmt, error)

PrepareContext the compatible method of PrepareContext in 'database/sql' package.

func (*DB) Query

func (db *DB) Query(query string, args ...interface{}) (*Rows, error)

Query the compatible method of Query in 'database/sql' package.

func (*DB) QueryContext

func (db *DB) QueryContext(ctx context.Context, query string, args ...interface{}) (*Rows, error)

QueryContext the compatible method of QueryContext in 'database/sql' package.

func (*DB) QueryRow

func (db *DB) QueryRow(query string, args ...interface{}) *Row

QueryRow the compatible method of QueryRow in 'database/sql' package.

func (*DB) QueryRowContext

func (db *DB) QueryRowContext(ctx context.Context, query string, args ...interface{}) *Row

QueryRowContext the compatible method of QueryRowContext in 'database/sql' package.

func (*DB) SetConnMaxLifetime

func (db *DB) SetConnMaxLifetime(d time.Duration)

SetConnMaxLifetime the compatible method of SetConnMaxLifetime in 'database/sql' package, call SetConnMaxLifetime for all opened connections.

func (*DB) SetMaxIdleConns

func (db *DB) SetMaxIdleConns(n int)

SetMaxIdleConns the compatible method of SetMaxIdleConns in 'database/sql' package, call SetMaxIdleConns for all opened connections.

func (*DB) SetMaxOpenConns

func (db *DB) SetMaxOpenConns(n int)

SetMaxOpenConns the compatible method of SetMaxOpenConns in 'database/sql' package, call SetMaxOpenConns for all opened connections.

func (*DB) Stats

func (db *DB) Stats() DBStats

Stats the compatible method of Stats in 'database/sql' package.

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.

func Named

func Named(name string, value interface{}) NamedArg

Named the compatible method of Named in 'database/sql' package.

type NullBool

type NullBool struct {
	Bool  bool
	Valid bool
	// contains filtered or unexported fields
}

NullBool is the compatible structure of NullBool in 'database/sql' package.

func (*NullBool) Scan

func (n *NullBool) Scan(value interface{}) error

Scan the compatible method of Scan in 'database/sql' package.

func (NullBool) Value

func (n NullBool) Value() (driver.Value, error)

Value the compatible method of Value in 'database/sql' package.

type NullFloat64

type NullFloat64 struct {
	Float64 float64
	Valid   bool
	// contains filtered or unexported fields
}

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.

func (NullFloat64) Value

func (n NullFloat64) Value() (driver.Value, error)

Value the compatible method of Value in 'database/sql' package.

type NullInt32 added in v1.1.8

type NullInt32 struct {
	Int32 int32
	Valid bool
	// contains filtered or unexported fields
}

NullInt32 the compatible structure of NullInt32 in 'database/sql' package.

func (*NullInt32) Scan added in v1.1.8

func (n *NullInt32) Scan(value interface{}) error

Scan the compatible method of Scan in 'database/sql' package.

func (NullInt32) Value added in v1.1.8

func (n NullInt32) Value() (driver.Value, error)

Value the compatible method of Value in 'database/sql' package.

type NullInt64

type NullInt64 struct {
	Int64 int64
	Valid bool
	// contains filtered or unexported fields
}

NullInt64 the compatible structure of NullInt64 in 'database/sql' package.

func (*NullInt64) Scan

func (n *NullInt64) Scan(value interface{}) error

Scan the compatible method of Scan in 'database/sql' package.

func (NullInt64) Value

func (n NullInt64) Value() (driver.Value, error)

Value the compatible method of Value in 'database/sql' package.

type NullString

type NullString struct {
	String string
	Valid  bool
	// contains filtered or unexported fields
}

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.

func (NullString) Value

func (ns NullString) Value() (driver.Value, error)

Value the compatible method of Value in 'database/sql' package.

type NullTime added in v1.1.8

type NullTime struct {
	Time  time.Time
	Valid bool
	// contains filtered or unexported fields
}

NullTime the compatible structure of NullTime in 'database/sql' package.

func (*NullTime) Scan added in v1.1.8

func (n *NullTime) Scan(value interface{}) error

Scan the compatible method of Scan in 'database/sql' package.

func (NullTime) Value added in v1.1.8

func (n NullTime) Value() (driver.Value, error)

Value the compatible method of Value 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 Result

type Result interface {
	LastInsertId() (int64, error)
	RowsAffected() (int64, error)
}

Result the compatible interface of Result in 'database/sql' package.

type Row

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

Row the compatible structure of Row in 'database/sql' package.

func (*Row) Scan

func (r *Row) Scan(dest ...interface{}) error

Scan the compatible method of Scan 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) Close

func (rs *Rows) Close() error

Close the compatible method of Close 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) Columns

func (rs *Rows) Columns() ([]string, error)

Columns the compatible method of Columns in 'database/sql' package.

func (*Rows) Err

func (rs *Rows) Err() error

Err the compatible method of Err in 'database/sql' package.

func (*Rows) Next

func (rs *Rows) Next() bool

Next the compatible method of Next in 'database/sql' package.

func (*Rows) NextResultSet

func (rs *Rows) NextResultSet() bool

NextResultSet the compatible method of NextResultSet in 'database/sql' package.

func (*Rows) Scan

func (rs *Rows) Scan(dest ...interface{}) error

Scan the compatible method of Scan 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) Close

func (s *Stmt) Close() error

Close the compatible method of Close in 'database/sql' package.

func (*Stmt) Exec

func (s *Stmt) Exec(args ...interface{}) (core.Result, error)

Exec the compatible method of Exec in 'database/sql' package.

func (*Stmt) ExecContext

func (s *Stmt) ExecContext(ctx context.Context, args ...interface{}) (core.Result, error)

ExecContext the compatible method of ExecContext in 'database/sql' package.

func (*Stmt) Query

func (s *Stmt) Query(args ...interface{}) (*Rows, error)

Query the compatible method of Query in 'database/sql' package.

func (*Stmt) QueryContext

func (s *Stmt) QueryContext(ctx context.Context, args ...interface{}) (*Rows, error)

QueryContext the compatible method of QueryContext in 'database/sql' package.

func (*Stmt) QueryRow

func (s *Stmt) QueryRow(args ...interface{}) *Row

QueryRow the compatible method of QueryRow in 'database/sql' package.

func (*Stmt) QueryRowContext

func (s *Stmt) QueryRowContext(ctx context.Context, args ...interface{}) *Row

QueryRowContext the compatible method of QueryRowContext 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

func (proxy *Tx) AfterCommitCallback(success func() error, failure func(bool, []*QueryLog) error)

AfterCommitCallback set callback function for after commit

func (*Tx) BeforeCommitCallback

func (proxy *Tx) BeforeCommitCallback(callback func([]*QueryLog) error)

BeforeCommitCallback set callback function for before commit

func (*Tx) Commit

func (proxy *Tx) Commit() error

Commit the compatible method of Commit in 'database/sql' package.

func (*Tx) ConvertWriteQueryIntoCountQuery

func (t *Tx) ConvertWriteQueryIntoCountQuery(query sqlparser.Query) (sqlparser.Query, error)

ConvertWriteQueryIntoCountQuery convert INSERT/UPDATE/DELETE query to `SELECT COUNT(*)`

func (*Tx) Exec

func (proxy *Tx) Exec(query string, args ...interface{}) (Result, error)

Exec the compatible method of Exec in 'database/sql' package.

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

func (t *Tx) ExecWithQueryLog(log *QueryLog) (Result, error)

ExecWithQueryLog exec query by *connection.QueryLog. This is able to use for recovery from distributed transaction error.

func (*Tx) GetParsedQueryByQueryLog

func (t *Tx) GetParsedQueryByQueryLog(log *QueryLog) (sqlparser.Query, error)

GetParsedQueryByQueryLog get instance of `sqlparser.Query` by QueryLog. If QueryLog has LastInsertID value, add to query it

func (*Tx) IsAlreadyCommittedQueryLog

func (t *Tx) IsAlreadyCommittedQueryLog(log *QueryLog) (bool, error)

IsAlreadyCommittedQueryLog returns whether write query gave by QueryLog is committed or not.

func (*Tx) Prepare

func (proxy *Tx) Prepare(query string) (*Stmt, error)

Prepare the compatible method of Prepare in 'database/sql' package.

func (*Tx) PrepareContext

func (proxy *Tx) PrepareContext(ctx context.Context, query string) (*Stmt, error)

PrepareContext the compatible method of PrepareContext in 'database/sql' package.

func (*Tx) Query

func (proxy *Tx) Query(query string, args ...interface{}) (*Rows, error)

Query the compatible method of Query 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) QueryRow

func (proxy *Tx) QueryRow(query string, args ...interface{}) *Row

QueryRow the compatible method of QueryRow in 'database/sql' package.

func (*Tx) QueryRowContext

func (proxy *Tx) QueryRowContext(ctx context.Context, query string, args ...interface{}) *Row

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) Rollback

func (proxy *Tx) Rollback() error

Rollback the compatible method of Rollback in 'database/sql' package.

func (*Tx) Stmt

func (proxy *Tx) Stmt(stmt *Stmt) *Stmt

Stmt the compatible method of Stmt in 'database/sql' package.

func (*Tx) StmtContext

func (proxy *Tx) StmtContext(ctx context.Context, stmt *Stmt) *Stmt

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL