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 Check(fieldOrTableName string) bool
- func CheckAndReplace(fieldOrTableName string) string
- func CheckEscape(fieldOrTableName string) bool
- 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 InitDataResourceManager()
- func InitTableMetaCache(dbName string)
- func InsertBuildUndoSql(undoLog sqlUndoLog) string
- func NewConnector(cfg *Config) (driver.Connector, error)
- 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 RegisterResource(dsn string)
- func RegisterServerPubKey(name string, pubKey *rsa.PublicKey)
- func RegisterTLSConfig(key string, config *tls.Config) error
- func SetLogger(logger Logger) error
- func UpdateBuildUndoSql(undoLog sqlUndoLog) string
- type BuildUndoSql
- type Config
- type DataSourceManager
- func (resourceManager DataSourceManager) BranchCommit(branchType meta.BranchType, xid string, branchID int64, resourceID string, ...) (meta.BranchStatus, error)
- func (resourceManager DataSourceManager) BranchRegister(branchType meta.BranchType, resourceID string, clientID string, xid string, ...) (int64, error)
- func (resourceManager DataSourceManager) BranchReport(branchType meta.BranchType, xid string, branchID int64, ...) error
- func (resourceManager DataSourceManager) BranchRollback(branchType meta.BranchType, xid string, branchID int64, resourceID string, ...) (meta.BranchStatus, error)
- func (resourceManager DataSourceManager) GetBranchType() meta.BranchType
- func (resourceManager DataSourceManager) LockQuery(branchType meta.BranchType, resourceID string, xid string, lockKeys string) (bool, error)
- type DialContextFunc
- type DialFuncdeprecated
- type Logger
- type MySQLDriver
- type MySQLError
- type MysqlUndoExecutor
- type MysqlUndoLogManager
- func (manager MysqlUndoLogManager) BatchDeleteUndoLog(conn *mysqlConn, xids []string, branchIDs []int64) error
- func (manager MysqlUndoLogManager) DeleteUndoLog(conn *mysqlConn, xid string, branchID int64) error
- func (manager MysqlUndoLogManager) DeleteUndoLogByLogCreated(conn *mysqlConn, logCreated time.Time, limitRows int) (sql.Result, error)
- func (manager MysqlUndoLogManager) FlushUndoLogs(conn *mysqlConn) error
- func (manager MysqlUndoLogManager) Undo(conn *mysqlConn, xid string, branchID int64, resourceID string) error
- type NullTimedeprecated
- type PbBranchUndoLog
- func (*PbBranchUndoLog) Descriptor() ([]byte, []int)
- func (m *PbBranchUndoLog) GetBranchID() int64
- func (m *PbBranchUndoLog) GetSqlUndoLogs() []*PbSqlUndoLog
- func (m *PbBranchUndoLog) GetXid() string
- func (*PbBranchUndoLog) ProtoMessage()
- func (m *PbBranchUndoLog) Reset()
- func (m *PbBranchUndoLog) String() string
- func (m *PbBranchUndoLog) XXX_DiscardUnknown()
- func (m *PbBranchUndoLog) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *PbBranchUndoLog) XXX_Merge(src proto.Message)
- func (m *PbBranchUndoLog) XXX_Size() int
- func (m *PbBranchUndoLog) XXX_Unmarshal(b []byte) error
- type PbField
- func (*PbField) Descriptor() ([]byte, []int)
- func (m *PbField) GetKeyType() int32
- func (m *PbField) GetName() string
- func (m *PbField) GetType() int32
- func (m *PbField) GetValue() []byte
- func (*PbField) ProtoMessage()
- func (m *PbField) Reset()
- func (m *PbField) String() string
- func (m *PbField) XXX_DiscardUnknown()
- func (m *PbField) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *PbField) XXX_Merge(src proto.Message)
- func (m *PbField) XXX_Size() int
- func (m *PbField) XXX_Unmarshal(b []byte) error
- type PbRow
- func (*PbRow) Descriptor() ([]byte, []int)
- func (m *PbRow) GetFields() []*PbField
- func (*PbRow) ProtoMessage()
- func (m *PbRow) Reset()
- func (m *PbRow) String() string
- func (m *PbRow) XXX_DiscardUnknown()
- func (m *PbRow) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *PbRow) XXX_Merge(src proto.Message)
- func (m *PbRow) XXX_Size() int
- func (m *PbRow) XXX_Unmarshal(b []byte) error
- type PbSqlUndoLog
- func (*PbSqlUndoLog) Descriptor() ([]byte, []int)
- func (m *PbSqlUndoLog) GetAfterImage() *PbTableRecords
- func (m *PbSqlUndoLog) GetBeforeImage() *PbTableRecords
- func (m *PbSqlUndoLog) GetSqlType() int32
- func (m *PbSqlUndoLog) GetTableName() string
- func (*PbSqlUndoLog) ProtoMessage()
- func (m *PbSqlUndoLog) Reset()
- func (m *PbSqlUndoLog) String() string
- func (m *PbSqlUndoLog) XXX_DiscardUnknown()
- func (m *PbSqlUndoLog) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *PbSqlUndoLog) XXX_Merge(src proto.Message)
- func (m *PbSqlUndoLog) XXX_Size() int
- func (m *PbSqlUndoLog) XXX_Unmarshal(b []byte) error
- type PbTableRecords
- func (*PbTableRecords) Descriptor() ([]byte, []int)
- func (m *PbTableRecords) GetRows() []*PbRow
- func (m *PbTableRecords) GetTableName() string
- func (*PbTableRecords) ProtoMessage()
- func (m *PbTableRecords) Reset()
- func (m *PbTableRecords) String() string
- func (m *PbTableRecords) XXX_DiscardUnknown()
- func (m *PbTableRecords) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *PbTableRecords) XXX_Merge(src proto.Message)
- func (m *PbTableRecords) XXX_Size() int
- func (m *PbTableRecords) XXX_Unmarshal(b []byte) error
- type ProtoBufUndoLogParser
- type RawBytes
- 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 UndoLogParser
Constants ¶
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 ( 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 XID = "XID"
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 (
DBKEYS_SPLIT_CHAR = ","
)
var EXPIRE_TIME = 15 * time.Minute
var MySQLKeyword = map[string]string{}/* 263 elements not displayed */
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 CheckAndReplace ¶
func CheckEscape ¶
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 InitDataResourceManager ¶
func InitDataResourceManager()
func InitTableMetaCache ¶
func InitTableMetaCache(dbName string)
func InsertBuildUndoSql ¶
func InsertBuildUndoSql(undoLog sqlUndoLog) string
func NewConnector ¶
NewConnector returns new driver.Connector.
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 RegisterResource ¶
func RegisterResource(dsn string)
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 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 { RpcClient *rpc_client.RpcRemoteClient ResourceCache map[string]*connector }
func (DataSourceManager) BranchCommit ¶
func (resourceManager DataSourceManager) BranchCommit(branchType meta.BranchType, xid string, branchID int64, resourceID string, applicationData []byte) (meta.BranchStatus, error)
func (DataSourceManager) BranchRegister ¶
func (resourceManager DataSourceManager) BranchRegister(branchType meta.BranchType, resourceID string, clientID string, xid string, applicationData []byte, lockKeys string) (int64, error)
func (DataSourceManager) BranchReport ¶
func (resourceManager DataSourceManager) BranchReport(branchType meta.BranchType, xid string, branchID int64, status meta.BranchStatus, applicationData []byte) error
func (DataSourceManager) BranchRollback ¶
func (resourceManager DataSourceManager) BranchRollback(branchType meta.BranchType, xid string, branchID int64, resourceID string, applicationData []byte) (meta.BranchStatus, error)
func (DataSourceManager) GetBranchType ¶
func (resourceManager DataSourceManager) GetBranchType() meta.BranchType
func (DataSourceManager) LockQuery ¶
func (resourceManager DataSourceManager) LockQuery(branchType meta.BranchType, resourceID string, xid string, lockKeys string) (bool, 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
type MysqlUndoExecutor ¶
type MysqlUndoExecutor struct {
// contains filtered or unexported fields
}
func NewMysqlUndoExecutor ¶
func NewMysqlUndoExecutor(undoLog sqlUndoLog) MysqlUndoExecutor
func (MysqlUndoExecutor) Execute ¶
func (executor MysqlUndoExecutor) Execute(conn *mysqlConn) error
type MysqlUndoLogManager ¶
type MysqlUndoLogManager struct { }
func GetUndoLogManager ¶
func GetUndoLogManager() MysqlUndoLogManager
func (MysqlUndoLogManager) BatchDeleteUndoLog ¶
func (manager MysqlUndoLogManager) BatchDeleteUndoLog(conn *mysqlConn, xids []string, branchIDs []int64) error
func (MysqlUndoLogManager) DeleteUndoLog ¶
func (manager MysqlUndoLogManager) DeleteUndoLog(conn *mysqlConn, xid string, branchID int64) error
func (MysqlUndoLogManager) DeleteUndoLogByLogCreated ¶
func (MysqlUndoLogManager) FlushUndoLogs ¶
func (manager MysqlUndoLogManager) FlushUndoLogs(conn *mysqlConn) error
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"` BranchID int64 `protobuf:"varint,2,opt,name=BranchID,proto3" json:"BranchID,omitempty"` SqlUndoLogs []*PbSqlUndoLog `protobuf:"bytes,3,rep,name=SqlUndoLogs,proto3" json:"SqlUndoLogs,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*PbBranchUndoLog) Descriptor ¶
func (*PbBranchUndoLog) Descriptor() ([]byte, []int)
func (*PbBranchUndoLog) GetBranchID ¶
func (m *PbBranchUndoLog) GetBranchID() int64
func (*PbBranchUndoLog) GetSqlUndoLogs ¶
func (m *PbBranchUndoLog) GetSqlUndoLogs() []*PbSqlUndoLog
func (*PbBranchUndoLog) GetXid ¶
func (m *PbBranchUndoLog) GetXid() string
func (*PbBranchUndoLog) ProtoMessage ¶
func (*PbBranchUndoLog) ProtoMessage()
func (*PbBranchUndoLog) Reset ¶
func (m *PbBranchUndoLog) Reset()
func (*PbBranchUndoLog) String ¶
func (m *PbBranchUndoLog) String() string
func (*PbBranchUndoLog) XXX_DiscardUnknown ¶
func (m *PbBranchUndoLog) XXX_DiscardUnknown()
func (*PbBranchUndoLog) XXX_Marshal ¶
func (m *PbBranchUndoLog) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*PbBranchUndoLog) XXX_Merge ¶
func (m *PbBranchUndoLog) XXX_Merge(src proto.Message)
func (*PbBranchUndoLog) XXX_Size ¶
func (m *PbBranchUndoLog) XXX_Size() int
func (*PbBranchUndoLog) XXX_Unmarshal ¶
func (m *PbBranchUndoLog) XXX_Unmarshal(b []byte) error
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"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*PbField) Descriptor ¶
func (*PbField) GetKeyType ¶
func (*PbField) ProtoMessage ¶
func (*PbField) ProtoMessage()
func (*PbField) XXX_DiscardUnknown ¶
func (m *PbField) XXX_DiscardUnknown()
func (*PbField) XXX_Marshal ¶
func (*PbField) XXX_Unmarshal ¶
type PbRow ¶
type PbRow struct { Fields []*PbField `protobuf:"bytes,1,rep,name=Fields,proto3" json:"Fields,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*PbRow) Descriptor ¶
func (*PbRow) ProtoMessage ¶
func (*PbRow) ProtoMessage()
func (*PbRow) XXX_DiscardUnknown ¶
func (m *PbRow) XXX_DiscardUnknown()
func (*PbRow) XXX_Marshal ¶
func (*PbRow) XXX_Unmarshal ¶
type PbSqlUndoLog ¶
type PbSqlUndoLog struct { SqlType int32 `protobuf:"varint,1,opt,name=SqlType,proto3" json:"SqlType,omitempty"` TableName string `protobuf:"bytes,2,opt,name=TableName,proto3" json:"TableName,omitempty"` BeforeImage *PbTableRecords `protobuf:"bytes,3,opt,name=BeforeImage,proto3" json:"BeforeImage,omitempty"` AfterImage *PbTableRecords `protobuf:"bytes,4,opt,name=AfterImage,proto3" json:"AfterImage,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*PbSqlUndoLog) Descriptor ¶
func (*PbSqlUndoLog) Descriptor() ([]byte, []int)
func (*PbSqlUndoLog) GetAfterImage ¶
func (m *PbSqlUndoLog) GetAfterImage() *PbTableRecords
func (*PbSqlUndoLog) GetBeforeImage ¶
func (m *PbSqlUndoLog) GetBeforeImage() *PbTableRecords
func (*PbSqlUndoLog) GetSqlType ¶
func (m *PbSqlUndoLog) GetSqlType() int32
func (*PbSqlUndoLog) GetTableName ¶
func (m *PbSqlUndoLog) GetTableName() string
func (*PbSqlUndoLog) ProtoMessage ¶
func (*PbSqlUndoLog) ProtoMessage()
func (*PbSqlUndoLog) Reset ¶
func (m *PbSqlUndoLog) Reset()
func (*PbSqlUndoLog) String ¶
func (m *PbSqlUndoLog) String() string
func (*PbSqlUndoLog) XXX_DiscardUnknown ¶
func (m *PbSqlUndoLog) XXX_DiscardUnknown()
func (*PbSqlUndoLog) XXX_Marshal ¶
func (m *PbSqlUndoLog) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*PbSqlUndoLog) XXX_Merge ¶
func (m *PbSqlUndoLog) XXX_Merge(src proto.Message)
func (*PbSqlUndoLog) XXX_Size ¶
func (m *PbSqlUndoLog) XXX_Size() int
func (*PbSqlUndoLog) XXX_Unmarshal ¶
func (m *PbSqlUndoLog) XXX_Unmarshal(b []byte) error
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"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*PbTableRecords) Descriptor ¶
func (*PbTableRecords) Descriptor() ([]byte, []int)
func (*PbTableRecords) GetRows ¶
func (m *PbTableRecords) GetRows() []*PbRow
func (*PbTableRecords) GetTableName ¶
func (m *PbTableRecords) GetTableName() string
func (*PbTableRecords) ProtoMessage ¶
func (*PbTableRecords) ProtoMessage()
func (*PbTableRecords) Reset ¶
func (m *PbTableRecords) Reset()
func (*PbTableRecords) String ¶
func (m *PbTableRecords) String() string
func (*PbTableRecords) XXX_DiscardUnknown ¶
func (m *PbTableRecords) XXX_DiscardUnknown()
func (*PbTableRecords) XXX_Marshal ¶
func (m *PbTableRecords) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*PbTableRecords) XXX_Merge ¶
func (m *PbTableRecords) XXX_Merge(src proto.Message)
func (*PbTableRecords) XXX_Size ¶
func (m *PbTableRecords) XXX_Size() int
func (*PbTableRecords) XXX_Unmarshal ¶
func (m *PbTableRecords) XXX_Unmarshal(b []byte) error
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 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 UndoLogParser ¶
type UndoLogParser interface { GetName() string // 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
- mysql_keyword_checker.go
- mysql_undo_executor.go
- mysql_undo_log_manager.go
- nulltime.go
- nulltime_go113.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_log.go
- undo_log.pb.go
- undo_log_parser.go
- utils.go