sql

package
v0.0.0-...-6fba4f8 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// MaxDMLRetryCount defines maximum number of times of DML retrying.
	MaxDMLRetryCount = 100
	// MaxDDLRetryCount defines maximum number of times of DDL retrying.
	MaxDDLRetryCount = 5
	// RetryWaitTime defines wait time when retrying.
	RetryWaitTime = 3 * time.Second

	// SlowWarnLog defines the duration to log warn log of sql when exec time greater than
	SlowWarnLog = 100 * time.Millisecond
)

Functions

func ExecuteSQLs

func ExecuteSQLs(db *sql.DB, sqls []string, args [][]interface{}, isDDL bool) error

ExecuteSQLs execute sqls in a transaction with retry.

func ExecuteSQLsWithHistogram

func ExecuteSQLsWithHistogram(db *sql.DB, sqls []string, args [][]interface{}, isDDL bool, hist *prometheus.HistogramVec) error

ExecuteSQLsWithHistogram execute sqls in a transaction with retry.

func ExecuteTxn

func ExecuteTxn(db *sql.DB, sqls []string, args [][]interface{}) error

ExecuteTxn executes transaction

func ExecuteTxnWithHistogram

func ExecuteTxnWithHistogram(db *sql.DB, sqls []string, args [][]interface{}, hist *prometheus.HistogramVec) error

ExecuteTxnWithHistogram executes transaction

func GetOraclePosition

func GetOraclePosition(db *sql.DB) (int64, error)

GetOraclePosition return oracle scn

func GetSQLErrCode

func GetSQLErrCode(err error) (errors.ErrCode, bool)

GetSQLErrCode returns error code if err is a mysql error

func GetTidbPosition

func GetTidbPosition(db *sql.DB) (int64, error)

GetTidbPosition gets tidb's position.

func IgnoreDDLError

func IgnoreDDLError(err error) bool

IgnoreDDLError checks the error can be ignored or not.

func OpenCH

func OpenCH(host string, port int, username string, password string, dbName string, blockSize int) (*sql.DB, error)

OpenCH opens a connection to CH and returns the standard SQL driver's DB interface.

func OpenDB

func OpenDB(proto string, host string, port int, username string, password string) (*sql.DB, error)

OpenDB creates an instance of sql.DB.

func OpenDBWithSQLMode

func OpenDBWithSQLMode(proto string, host string, port int, username string, password string, sqlMode *string) (*sql.DB, error)

OpenDBWithSQLMode creates an instance of sql.DB.

func QuoteName

func QuoteName(name string) string

QuoteName quote name like `name`

func QuoteSchema

func QuoteSchema(schema string, table string) string

QuoteSchema quote like `dbname`.`table` name

func ScanRow

func ScanRow(rows *sql.Rows) (map[string][]byte, error)

ScanRow scans rows into a map.

Types

type CHHostAndPort

type CHHostAndPort struct {
	Host string
	Port int
}

CHHostAndPort is a CH host:port pair.

func ParseCHAddr

func ParseCHAddr(addr string) ([]CHHostAndPort, error)

ParseCHAddr parses an address config string to CHHostAndPort pairs.

Jump to

Keyboard shortcuts

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