Documentation ¶
Overview ¶
Package mysql provides a MySQL driver for Go's database/sql package.
The driver should be used via the database/sql package:
import "database/sql" import _ "github.com/go-sql-driver/mysql" db, err := sql.Open("mysql", "user:password@/dbname")
See https://github.com/go-sql-driver/mysql#usage for details
Index ¶
- Constants
- Variables
- func DeleteBuildUndoSql(undoLog sqlUndoLog) string
- func DeregisterLocalFile(filePath string)
- func DeregisterReaderHandler(name string)
- func DeregisterServerPubKey(name string)
- func DeregisterTLSConfig(key string)
- func GetColumns(conn *mysqlConn, dbName, tableName string) ([]schema.ColumnMeta, error)
- func GetIndexes(conn *mysqlConn, dbName, tableName string) ([]schema.IndexMeta, error)
- func GetSqlDataType(dataType string) int32
- func InitTableMetaCache(dbName string)
- func InsertBuildUndoSql(undoLog sqlUndoLog) string
- func NewConnector(cfg *Config) (driver.Connector, error)
- func RegisterATResource(dsn string)
- func RegisterDial(network string, dial DialFunc)deprecated
- func RegisterDialContext(net string, dial DialContextFunc)
- func RegisterLocalFile(filePath string)
- func RegisterReaderHandler(name string, handler func() io.Reader)
- func RegisterServerPubKey(name string, pubKey *rsa.PublicKey)
- func RegisterTLSConfig(key string, config *tls.Config) error
- func RegisterXAResource(db *sql.DB)
- func SetLogger(logger Logger) error
- func UpdateBuildUndoSql(undoLog sqlUndoLog) string
- type BuildUndoSql
- type Config
- type DataSourceManager
- func (resourceManager DataSourceManager) Commit(ctx context.Context, request *api.BranchSession) (api.BranchSession_BranchStatus, error)
- func (resourceManager DataSourceManager) GetConnection(resourceID string) *mysqlConn
- func (resourceManager DataSourceManager) Rollback(ctx context.Context, request *api.BranchSession) (api.BranchSession_BranchStatus, error)
- type DialContextFunc
- type DialFuncdeprecated
- type Logger
- type MySQLDriver
- type MySQLError
- type NullTimedeprecated
- type PbBranchUndoLog
- func (*PbBranchUndoLog) Descriptor() ([]byte, []int)deprecated
- func (x *PbBranchUndoLog) GetBranchSessionID() int64
- func (x *PbBranchUndoLog) GetSqlUndoLogs() []*PbSqlUndoLog
- func (x *PbBranchUndoLog) GetXID() string
- func (*PbBranchUndoLog) ProtoMessage()
- func (x *PbBranchUndoLog) ProtoReflect() protoreflect.Message
- func (x *PbBranchUndoLog) Reset()
- func (x *PbBranchUndoLog) String() string
- type PbField
- func (*PbField) Descriptor() ([]byte, []int)deprecated
- func (x *PbField) GetKeyType() int32
- func (x *PbField) GetName() string
- func (x *PbField) GetType() int32
- func (x *PbField) GetValue() []byte
- func (*PbField) ProtoMessage()
- func (x *PbField) ProtoReflect() protoreflect.Message
- func (x *PbField) Reset()
- func (x *PbField) String() string
- type PbRow
- type PbSqlUndoLog
- func (*PbSqlUndoLog) Descriptor() ([]byte, []int)deprecated
- func (x *PbSqlUndoLog) GetAfterImage() *PbTableRecords
- func (x *PbSqlUndoLog) GetBeforeImage() *PbTableRecords
- func (x *PbSqlUndoLog) GetLockKey() string
- func (x *PbSqlUndoLog) GetSchemaName() string
- func (x *PbSqlUndoLog) GetSqlType() int32
- func (x *PbSqlUndoLog) GetTableName() string
- func (*PbSqlUndoLog) ProtoMessage()
- func (x *PbSqlUndoLog) ProtoReflect() protoreflect.Message
- func (x *PbSqlUndoLog) Reset()
- func (x *PbSqlUndoLog) String() string
- type PbTableRecords
- func (*PbTableRecords) Descriptor() ([]byte, []int)deprecated
- func (x *PbTableRecords) GetRows() []*PbRow
- func (x *PbTableRecords) GetTableName() string
- func (*PbTableRecords) ProtoMessage()
- func (x *PbTableRecords) ProtoReflect() protoreflect.Message
- func (x *PbTableRecords) Reset()
- func (x *PbTableRecords) String() string
- type ProtoBufUndoLogParser
- type RawBytes
- type ResourceManager
- type SQLType
- type Scanner
- type SqlDataType
- type State
- type TableMetaCache
- func (cache *TableMetaCache) FetchSchema(conn *mysqlConn, tableName string) (schema.TableMeta, error)
- func (cache *TableMetaCache) GetCacheKey(tableName string) string
- func (cache *TableMetaCache) GetTableMeta(conn *mysqlConn, tableName string) (schema.TableMeta, error)
- func (cache *TableMetaCache) Refresh(conn *mysqlConn, resourceID string)
- type UndoExecutor
- type UndoLogManager
- func (manager UndoLogManager) BatchDeleteUndoLog(conn *mysqlConn, xids []string, branchSessionIDs []int64) error
- func (manager UndoLogManager) DeleteUndoLog(conn *mysqlConn, xid string, branchSessionID int64) error
- func (manager UndoLogManager) DeleteUndoLogByLogCreated(conn *mysqlConn, logCreated time.Time, limitRows int) (sql.Result, error)
- func (manager UndoLogManager) FlushUndoLogs(conn *mysqlConn) error
- func (manager UndoLogManager) Undo(conn *mysqlConn, xid string, branchSessionID int64, resourceID string) ([]string, error)
- type UndoLogParser
Constants ¶
const ( BIT SqlDataType = -7 TINYINT = -6 SMALLINT = 5 INTEGER = 4 BIGINT = -5 FLOAT = 6 REAL = 7 DOUBLE = 8 NUMERIC = 2 DECIMAL = 3 CHAR = 1 VARCHAR = 12 LONGVARCHAR = -1 DATE = 91 TIME = 92 TIMESTAMP = 93 BINARY = -2 VARBINARY = -3 LONGVARBINARY = -4 NULL = 0 OTHER = 1111 JAVA_OBJECT = 2000 DISTINCT = 2001 STRUCT = 2002 ARRAY = 2003 BLOB = 2004 CLOB = 2005 REF = 2006 DATALINK = 70 BOOLEAN = 16 ROWID = -8 NCHAR = -15 NVARCHAR = -9 LONGNVARCHAR = -16 NCLOB = 2011 SQLXML = 2009 REF_CURSOR = 2012 TIME_WITH_TIMEZONE = 2013 TIMESTAMP_WITH_TIMEZONE = 2014 )
const ( InsertSqlTemplate = "INSERT INTO %s (%s) VALUES (%s)" DeleteSqlTemplate = "DELETE FROM %s WHERE `%s` = ?" UpdateSqlTemplate = "UPDATE %s SET %s WHERE `%s` = ?" SelectSqlTemplate = "SELECT %s FROM %s WHERE `%s` IN %s" )
const ( DeleteUndoLogSql = "DELETE FROM undo_log WHERE xid = ? and branch_id = ?" DeleteUndoLogByCreateSql = "DELETE FROM undo_log WHERE log_created <= ? LIMIT ?" InsertUndoLogSql = `` /* 140-byte string literal not displayed */ SelectUndoLogSql = `SELECT branch_id, xid, context, rollback_info, log_status FROM undo_log WHERE xid = ? AND branch_id = ? FOR UPDATE` )
const GlobalLock = "GlobalLock"
Variables ¶
var ( ErrInvalidConn = errors.New("invalid connection") ErrMalformPkt = errors.New("malformed packet") ErrNoTLS = errors.New("TLS requested but server does not support TLS") ErrCleartextPassword = errors.New("this user requires clear text authentication. If you still want to use it, please add 'allowCleartextPasswords=1' to your DSN") ErrNativePassword = errors.New("this user requires mysql native password authentication.") ErrOldPassword = errors.New("this user requires old password authentication. If you still want to use it, please add 'allowOldPasswords=1' to your DSN. See also https://github.com/go-sql-driver/mysql/wiki/old_passwords") ErrUnknownPlugin = errors.New("this authentication plugin is not supported") ErrOldProtocol = errors.New("MySQL server does not support required protocol 41+") ErrPktSync = errors.New("commands out of sync. You can't run this command now") ErrPktSyncMul = errors.New("commands out of sync. Did you run multiple statements at once?") ErrPktTooLarge = errors.New("packet for query is too large. Try adjusting the 'max_allowed_packet' variable on the server") ErrBusyBuffer = errors.New("busy buffer") )
Various errors the driver might return. Can change between driver versions.
var EXPIRE_TIME = 15 * time.Minute
var File_table_records_proto protoreflect.FileDescriptor
var File_undo_log_proto protoreflect.FileDescriptor
var SqlDataTypes = map[string]int32{
"BIT": -7,
"TINYINT": -6,
"SMALLINT": 5,
"INTEGER": 4,
"BIGINT": -5,
"FLOAT": 6,
"REAL": 7,
"DOUBLE": 8,
"NUMERIC": 2,
"DECIMAL": 3,
"CHAR": 1,
"VARCHAR": 12,
"LONGVARCHAR": -1,
"DATE": 91,
"TIME": 92,
"TIMESTAMP": 93,
"BINARY": -2,
"VARBINARY": -3,
"LONGVARBINARY": -4,
"NULL": 0,
"OTHER": 1111,
"JAVA_OBJECT": 2000,
"DISTINCT": 2001,
"STRUCT": 2002,
"ARRAY": 2003,
"BLOB": 2004,
"CLOB": 2005,
"REF": 2006,
"DATALINK": 70,
"BOOLEAN": 16,
"ROWID": -8,
"NCHAR": -15,
"NVARCHAR": -9,
"LONGNVARCHAR": -16,
"NCLOB": 2011,
"SQLXML": 2009,
"REF_CURSOR": 2012,
"TIME_WITH_TIMEZONE": 2013,
"TIMESTAMP_WITH_TIMEZONE": 2014,
}
Functions ¶
func DeleteBuildUndoSql ¶
func DeleteBuildUndoSql(undoLog sqlUndoLog) string
func DeregisterLocalFile ¶
func DeregisterLocalFile(filePath string)
DeregisterLocalFile removes the given filepath from the allowlist.
func DeregisterReaderHandler ¶
func DeregisterReaderHandler(name string)
DeregisterReaderHandler removes the ReaderHandler function with the given name from the registry.
func DeregisterServerPubKey ¶
func DeregisterServerPubKey(name string)
DeregisterServerPubKey removes the public key registered with the given name.
func DeregisterTLSConfig ¶
func DeregisterTLSConfig(key string)
DeregisterTLSConfig removes the tls.Config associated with key.
func GetColumns ¶
func GetColumns(conn *mysqlConn, dbName, tableName string) ([]schema.ColumnMeta, error)
func GetIndexes ¶
func GetSqlDataType ¶
func InitTableMetaCache ¶
func InitTableMetaCache(dbName string)
func InsertBuildUndoSql ¶
func InsertBuildUndoSql(undoLog sqlUndoLog) string
func NewConnector ¶
NewConnector returns new driver.Connector.
func RegisterATResource ¶ added in v1.6.2
func RegisterATResource(dsn string)
func RegisterDial
deprecated
RegisterDial registers a custom dial function. It can then be used by the network address mynet(addr), where mynet is the registered new network. addr is passed as a parameter to the dial function.
Deprecated: users should call RegisterDialContext instead
func RegisterDialContext ¶
func RegisterDialContext(net string, dial DialContextFunc)
RegisterDialContext registers a custom dial function. It can then be used by the network address mynet(addr), where mynet is the registered new network. The current context for the connection and its address is passed to the dial function.
func RegisterLocalFile ¶
func RegisterLocalFile(filePath string)
RegisterLocalFile adds the given file to the file allowlist, so that it can be used by "LOAD DATA LOCAL INFILE <filepath>". Alternatively you can allow the use of all local files with the DSN parameter 'allowAllFiles=true'
filePath := "/home/gopher/data.csv" mysql.RegisterLocalFile(filePath) err := db.Exec("LOAD DATA LOCAL INFILE '" + filePath + "' INTO TABLE foo") if err != nil { ...
func RegisterReaderHandler ¶
RegisterReaderHandler registers a handler function which is used to receive a io.Reader. The Reader can be used by "LOAD DATA LOCAL INFILE Reader::<name>". If the handler returns a io.ReadCloser Close() is called when the request is finished.
mysql.RegisterReaderHandler("data", func() io.Reader { var csvReader io.Reader // Some Reader that returns CSV data ... // Open Reader here return csvReader }) err := db.Exec("LOAD DATA LOCAL INFILE 'Reader::data' INTO TABLE foo") if err != nil { ...
func RegisterServerPubKey ¶
RegisterServerPubKey registers a server RSA public key which can be used to send data in a secure manner to the server without receiving the public key in a potentially insecure way from the server first. Registered keys can afterwards be used adding serverPubKey=<name> to the DSN.
Note: The provided rsa.PublicKey instance is exclusively owned by the driver after registering it and may not be modified.
data, err := ioutil.ReadFile("mykey.pem") if err != nil { log.Fatal(err) } block, _ := pem.Decode(data) if block == nil || block.Type != "PUBLIC KEY" { log.Fatal("failed to decode PEM block containing public key") } pub, err := x509.ParsePKIXPublicKey(block.Bytes) if err != nil { log.Fatal(err) } if rsaPubKey, ok := pub.(*rsa.PublicKey); ok { mysql.RegisterServerPubKey("mykey", rsaPubKey) } else { log.Fatal("not a RSA public key") }
func RegisterTLSConfig ¶
RegisterTLSConfig registers a custom tls.Config to be used with sql.Open. Use the key as a value in the DSN where tls=value.
Note: The provided tls.Config is exclusively owned by the driver after registering it.
rootCertPool := x509.NewCertPool() pem, err := ioutil.ReadFile("/path/ca-cert.pem") if err != nil { log.Fatal(err) } if ok := rootCertPool.AppendCertsFromPEM(pem); !ok { log.Fatal("Failed to append PEM.") } clientCert := make([]tls.Certificate, 0, 1) certs, err := tls.LoadX509KeyPair("/path/client-cert.pem", "/path/client-key.pem") if err != nil { log.Fatal(err) } clientCert = append(clientCert, certs) mysql.RegisterTLSConfig("custom", &tls.Config{ RootCAs: rootCertPool, Certificates: clientCert, }) db, err := sql.Open("mysql", "user@tcp(localhost:3306)/test?tls=custom")
func RegisterXAResource ¶ added in v1.6.2
func SetLogger ¶
SetLogger is used to set the logger for critical errors. The initial logger is os.Stderr.
func UpdateBuildUndoSql ¶
func UpdateBuildUndoSql(undoLog sqlUndoLog) string
Types ¶
type BuildUndoSql ¶
type BuildUndoSql func(undoLog sqlUndoLog) string
type Config ¶
type Config struct { User string // Username Passwd string // Password (requires User) Net string // Network type Addr string // Network address (requires Net) DBName string // Database name Params map[string]string // Connection parameters Collation string // Connection collation Loc *time.Location // Location for time.Time values MaxAllowedPacket int // Max packet size allowed ServerPubKey string // Server public key name TLSConfig string // TLS configuration name Timeout time.Duration // Dial timeout ReadTimeout time.Duration // I/O read timeout WriteTimeout time.Duration // I/O write timeout AllowAllFiles bool // Allow all files to be used with LOAD DATA LOCAL INFILE AllowCleartextPasswords bool // Allows the cleartext client side plugin AllowNativePasswords bool // Allows the native password authentication method AllowOldPasswords bool // Allows the old insecure password method CheckConnLiveness bool // Check connections for liveness before using them ClientFoundRows bool // Return number of matching rows instead of rows changed ColumnsWithAlias bool // Prepend table alias to column names InterpolateParams bool // Interpolate placeholders into query string MultiStatements bool // Allow multiple statements in one query ParseTime bool // Parse time values to time.Time RejectReadOnly bool // Reject read-only connections // contains filtered or unexported fields }
Config is a configuration parsed from a DSN string. If a new Config is created instead of being parsed from a DSN string, the NewConfig function should be used, which sets default values.
type DataSourceManager ¶
type DataSourceManager struct { ResourceCache map[string]*connector sync.Mutex // contains filtered or unexported fields }
func (DataSourceManager) Commit ¶
func (resourceManager DataSourceManager) Commit(ctx context.Context, request *api.BranchSession) (api.BranchSession_BranchStatus, error)
func (DataSourceManager) GetConnection ¶
func (resourceManager DataSourceManager) GetConnection(resourceID string) *mysqlConn
func (DataSourceManager) Rollback ¶
func (resourceManager DataSourceManager) Rollback(ctx context.Context, request *api.BranchSession) (api.BranchSession_BranchStatus, error)
type DialContextFunc ¶
DialContextFunc is a function which can be used to establish the network connection. Custom dial functions must be registered with RegisterDialContext
type Logger ¶
type Logger interface {
Print(v ...interface{})
}
Logger is used to log critical error messages.
type MySQLDriver ¶
type MySQLDriver struct{}
MySQLDriver is exported to make the driver directly accessible. In general the driver is used via the database/sql package.
func (MySQLDriver) Open ¶
func (d MySQLDriver) Open(dsn string) (driver.Conn, error)
Open new Connection. See https://github.com/go-sql-driver/mysql#dsn-data-source-name for how the DSN string is formatted
func (MySQLDriver) OpenConnector ¶
func (d MySQLDriver) OpenConnector(dsn string) (driver.Connector, error)
OpenConnector implements driver.DriverContext.
type MySQLError ¶
MySQLError is an error type which represents a single MySQL error
func (*MySQLError) Error ¶
func (me *MySQLError) Error() string
func (*MySQLError) Is ¶
func (me *MySQLError) Is(err error) bool
type NullTime
deprecated
NullTime represents a time.Time that may be NULL. NullTime implements the Scanner interface so it can be used as a scan destination:
var nt NullTime err := db.QueryRow("SELECT time FROM foo WHERE id=?", id).Scan(&nt) ... if nt.Valid { // use nt.Time } else { // NULL value }
This NullTime implementation is not driver-specific ¶
Deprecated: NullTime doesn't honor the loc DSN parameter. NullTime.Scan interprets a time as UTC, not the loc DSN parameter. Use sql.NullTime instead.
type PbBranchUndoLog ¶
type PbBranchUndoLog struct { XID string `protobuf:"bytes,1,opt,name=XID,proto3" json:"XID,omitempty"` BranchSessionID int64 `protobuf:"varint,2,opt,name=BranchSessionID,proto3" json:"BranchSessionID,omitempty"` SqlUndoLogs []*PbSqlUndoLog `protobuf:"bytes,3,rep,name=SqlUndoLogs,proto3" json:"SqlUndoLogs,omitempty"` // contains filtered or unexported fields }
func (*PbBranchUndoLog) Descriptor
deprecated
func (*PbBranchUndoLog) Descriptor() ([]byte, []int)
Deprecated: Use PbBranchUndoLog.ProtoReflect.Descriptor instead.
func (*PbBranchUndoLog) GetBranchSessionID ¶
func (x *PbBranchUndoLog) GetBranchSessionID() int64
func (*PbBranchUndoLog) GetSqlUndoLogs ¶
func (x *PbBranchUndoLog) GetSqlUndoLogs() []*PbSqlUndoLog
func (*PbBranchUndoLog) GetXID ¶
func (x *PbBranchUndoLog) GetXID() string
func (*PbBranchUndoLog) ProtoMessage ¶
func (*PbBranchUndoLog) ProtoMessage()
func (*PbBranchUndoLog) ProtoReflect ¶
func (x *PbBranchUndoLog) ProtoReflect() protoreflect.Message
func (*PbBranchUndoLog) Reset ¶
func (x *PbBranchUndoLog) Reset()
func (*PbBranchUndoLog) String ¶
func (x *PbBranchUndoLog) String() string
type PbField ¶
type PbField struct { Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"` KeyType int32 `protobuf:"varint,2,opt,name=KeyType,proto3" json:"KeyType,omitempty"` Type int32 `protobuf:"zigzag32,3,opt,name=Type,proto3" json:"Type,omitempty"` Value []byte `protobuf:"bytes,4,opt,name=Value,proto3" json:"Value,omitempty"` // contains filtered or unexported fields }
func (*PbField) Descriptor
deprecated
func (*PbField) GetKeyType ¶
func (*PbField) ProtoMessage ¶
func (*PbField) ProtoMessage()
func (*PbField) ProtoReflect ¶
func (x *PbField) ProtoReflect() protoreflect.Message
type PbRow ¶
type PbRow struct { Fields []*PbField `protobuf:"bytes,1,rep,name=Fields,proto3" json:"Fields,omitempty"` // contains filtered or unexported fields }
func (*PbRow) Descriptor
deprecated
func (*PbRow) ProtoMessage ¶
func (*PbRow) ProtoMessage()
func (*PbRow) ProtoReflect ¶
func (x *PbRow) ProtoReflect() protoreflect.Message
type PbSqlUndoLog ¶
type PbSqlUndoLog struct { SqlType int32 `protobuf:"varint,1,opt,name=SqlType,proto3" json:"SqlType,omitempty"` SchemaName string `protobuf:"bytes,2,opt,name=SchemaName,proto3" json:"SchemaName,omitempty"` TableName string `protobuf:"bytes,3,opt,name=TableName,proto3" json:"TableName,omitempty"` LockKey string `protobuf:"bytes,4,opt,name=LockKey,proto3" json:"LockKey,omitempty"` BeforeImage *PbTableRecords `protobuf:"bytes,5,opt,name=BeforeImage,proto3" json:"BeforeImage,omitempty"` AfterImage *PbTableRecords `protobuf:"bytes,6,opt,name=AfterImage,proto3" json:"AfterImage,omitempty"` // contains filtered or unexported fields }
func (*PbSqlUndoLog) Descriptor
deprecated
func (*PbSqlUndoLog) Descriptor() ([]byte, []int)
Deprecated: Use PbSqlUndoLog.ProtoReflect.Descriptor instead.
func (*PbSqlUndoLog) GetAfterImage ¶
func (x *PbSqlUndoLog) GetAfterImage() *PbTableRecords
func (*PbSqlUndoLog) GetBeforeImage ¶
func (x *PbSqlUndoLog) GetBeforeImage() *PbTableRecords
func (*PbSqlUndoLog) GetLockKey ¶
func (x *PbSqlUndoLog) GetLockKey() string
func (*PbSqlUndoLog) GetSchemaName ¶
func (x *PbSqlUndoLog) GetSchemaName() string
func (*PbSqlUndoLog) GetSqlType ¶
func (x *PbSqlUndoLog) GetSqlType() int32
func (*PbSqlUndoLog) GetTableName ¶
func (x *PbSqlUndoLog) GetTableName() string
func (*PbSqlUndoLog) ProtoMessage ¶
func (*PbSqlUndoLog) ProtoMessage()
func (*PbSqlUndoLog) ProtoReflect ¶
func (x *PbSqlUndoLog) ProtoReflect() protoreflect.Message
func (*PbSqlUndoLog) Reset ¶
func (x *PbSqlUndoLog) Reset()
func (*PbSqlUndoLog) String ¶
func (x *PbSqlUndoLog) String() string
type PbTableRecords ¶
type PbTableRecords struct { TableName string `protobuf:"bytes,1,opt,name=TableName,proto3" json:"TableName,omitempty"` Rows []*PbRow `protobuf:"bytes,2,rep,name=Rows,proto3" json:"Rows,omitempty"` // contains filtered or unexported fields }
func (*PbTableRecords) Descriptor
deprecated
func (*PbTableRecords) Descriptor() ([]byte, []int)
Deprecated: Use PbTableRecords.ProtoReflect.Descriptor instead.
func (*PbTableRecords) GetRows ¶
func (x *PbTableRecords) GetRows() []*PbRow
func (*PbTableRecords) GetTableName ¶
func (x *PbTableRecords) GetTableName() string
func (*PbTableRecords) ProtoMessage ¶
func (*PbTableRecords) ProtoMessage()
func (*PbTableRecords) ProtoReflect ¶
func (x *PbTableRecords) ProtoReflect() protoreflect.Message
func (*PbTableRecords) Reset ¶
func (x *PbTableRecords) Reset()
func (*PbTableRecords) String ¶
func (x *PbTableRecords) String() string
type ProtoBufUndoLogParser ¶
type ProtoBufUndoLogParser struct { }
func (ProtoBufUndoLogParser) Decode ¶
func (parser ProtoBufUndoLogParser) Decode(data []byte) *branchUndoLog
func (ProtoBufUndoLogParser) Encode ¶
func (parser ProtoBufUndoLogParser) Encode(branchUndoLog *branchUndoLog) []byte
func (ProtoBufUndoLogParser) GetDefaultContent ¶
func (parser ProtoBufUndoLogParser) GetDefaultContent() []byte
func (ProtoBufUndoLogParser) GetName ¶
func (parser ProtoBufUndoLogParser) GetName() string
type ResourceManager ¶ added in v1.6.2
type ResourceManager struct {
// contains filtered or unexported fields
}
func (ResourceManager) Commit ¶ added in v1.6.2
func (resourceManager ResourceManager) Commit(ctx context.Context, bs *api.BranchSession) (api.BranchSession_BranchStatus, error)
func (ResourceManager) Rollback ¶ added in v1.6.2
func (resourceManager ResourceManager) Rollback(ctx context.Context, bs *api.BranchSession) (api.BranchSession_BranchStatus, error)
type SQLType ¶
type SQLType byte
const ( SQLType_SELECT SQLType = iota SQLType_INSERT SQLType_UPDATE SQLType_DELETE SQLType_SELECT_FOR_UPDATE SQLType_REPLACE SQLType_TRUNCATE SQLType_CREATE SQLType_DROP SQLType_LOAD SQLType_MERGE SQLType_SHOW SQLType_ALTER SQLType_RENAME SQLType_DUMP SQLType_DEBUG SQLType_EXPLAIN SQLType_PROCEDURE SQLType_DESC SQLType_SET SQLType = 27 SQLType_RELOAD SQLType = 28 SQLType_SELECT_UNION SQLType = 29 SQLType_CREATE_TABLE SQLType = 30 SQLType_DROP_TABLE SQLType = 31 SQLType_ALTER_TABLE SQLType = 32 SQLType_SAVE_POINT SQLType = 33 SQLType_SELECT_FROM_UPDATE SQLType = 34 SQLType_MULTI_DELETE SQLType = 35 SQLType_MULTI_UPDATE SQLType = 36 SQLType_CREATE_INDEX SQLType = 37 SQLType_DROP_INDEX SQLType = 38 )
type Scanner ¶
type Scanner interface { // Scan assigns a value from a database driver. // // The src value will be of one of the following types: // // int64 // float64 // bool // []byte // string // time.Time // nil - for NULL values // // An error should be returned if the value cannot be stored // without loss of information. // // Reference types such as []byte are only valid until the next call to Scan // and should not be retained. Their underlying memory is owned by the driver. // If retention is necessary, copy their values before the next call to Scan. Scan(src interface{}) error }
Scanner is an interface used by Scan.
type SqlDataType ¶
type SqlDataType int32
type TableMetaCache ¶
type TableMetaCache struct {
// contains filtered or unexported fields
}
func GetTableMetaCache ¶
func GetTableMetaCache(dbName string) *TableMetaCache
func (*TableMetaCache) FetchSchema ¶
func (cache *TableMetaCache) FetchSchema(conn *mysqlConn, tableName string) (schema.TableMeta, error)
func (*TableMetaCache) GetCacheKey ¶
func (cache *TableMetaCache) GetCacheKey(tableName string) string
func (*TableMetaCache) GetTableMeta ¶
func (cache *TableMetaCache) GetTableMeta(conn *mysqlConn, tableName string) (schema.TableMeta, error)
func (*TableMetaCache) Refresh ¶
func (cache *TableMetaCache) Refresh(conn *mysqlConn, resourceID string)
type UndoExecutor ¶
type UndoExecutor struct {
// contains filtered or unexported fields
}
func NewMysqlUndoExecutor ¶
func NewMysqlUndoExecutor(undoLog sqlUndoLog) UndoExecutor
func (UndoExecutor) Execute ¶
func (executor UndoExecutor) Execute(conn *mysqlConn) error
type UndoLogManager ¶
type UndoLogManager struct { }
func GetUndoLogManager ¶
func GetUndoLogManager() UndoLogManager
func (UndoLogManager) BatchDeleteUndoLog ¶
func (manager UndoLogManager) BatchDeleteUndoLog(conn *mysqlConn, xids []string, branchSessionIDs []int64) error
func (UndoLogManager) DeleteUndoLog ¶
func (manager UndoLogManager) DeleteUndoLog(conn *mysqlConn, xid string, branchSessionID int64) error
func (UndoLogManager) DeleteUndoLogByLogCreated ¶
func (UndoLogManager) FlushUndoLogs ¶
func (manager UndoLogManager) FlushUndoLogs(conn *mysqlConn) error
type UndoLogParser ¶
type UndoLogParser interface { GetName() string // GetDefaultContent return the default content if undo log is empty GetDefaultContent() []byte Encode(branchUndoLog *branchUndoLog) []byte Decode(data []byte) *branchUndoLog }
func GetUndoLogParser ¶
func GetUndoLogParser() UndoLogParser
Source Files ¶
- auth.go
- buffer.go
- collations.go
- conncheck.go
- connection.go
- connector.go
- const.go
- datasource_manager.go
- driver.go
- dsn.go
- errors.go
- executor.go
- fields.go
- infile.go
- nulltime.go
- packets.go
- protobuf_undo_log_parser.go
- result.go
- rows.go
- sql_data_type.go
- sql_type.go
- statement.go
- table_meta_cache.go
- table_records.pb.go
- transaction.go
- undo_executor.go
- undo_log.go
- undo_log.pb.go
- undo_log_manager.go
- undo_log_parser.go
- utils.go
- xa_resource_manager.go