Documentation
¶
Overview ¶
Package replication 用于将binlog解析成可视的数据或者sql语句 是从github.com/youtube/vitess/go/mysql的基础上移植过来,其 主要功能如下:1.完全支持mysql 5.6.x的所有数据格式解析,2.支持 5.7.x的绝大多数数据格式解析,仅仅不支持JSON数据。
github.com/youtube/vitess/go/mysql已经完整地支持mysql 5.6以及 mysql 5.7所有的bonlog解析,但是由于以下原因需要修改:1。该包不够 轻量级,在vitess中有较多依赖,不便在其他项目中使用。2.该包的mysql 协议有些变化,如Decimal数据小数点后的缺少前置0等问题。
目前已经支持mysql 5.6.x以及5.7.x的所有数据类型变更,但是json格式写成 对应的sql语句
Index ¶
- Constants
- Variables
- func CellBytes(data []byte, pos int, typ byte, metadata uint16, isUnSignedInt bool) ([]byte, int, error)
- func EncodeGTID(gtid GTID) string
- type BinlogEvent
- func NewDeleteRowsEvent(f BinlogFormat, s *FakeBinlogStream, tableID uint64, rows Rows) BinlogEvent
- func NewFormatDescriptionEvent(f BinlogFormat, s *FakeBinlogStream) BinlogEvent
- func NewIntVarEvent(f BinlogFormat, s *FakeBinlogStream, typ byte, value uint64) BinlogEvent
- func NewInvalidEvent() BinlogEvent
- func NewInvalidFormatDescriptionEvent(f BinlogFormat, s *FakeBinlogStream) BinlogEvent
- func NewInvalidQueryEvent(f BinlogFormat, s *FakeBinlogStream) BinlogEvent
- func NewMariaDBGTIDEvent(f BinlogFormat, s *FakeBinlogStream, gtid MariadbGTID, hasBegin bool) BinlogEvent
- func NewMariadbBinlogEvent(buf []byte) BinlogEvent
- func NewMysql56BinlogEvent(buf []byte) BinlogEvent
- func NewQueryEvent(f BinlogFormat, s *FakeBinlogStream, q Query) BinlogEvent
- func NewRotateEvent(f BinlogFormat, s *FakeBinlogStream, position uint64, filename string) BinlogEvent
- func NewTableMapEvent(f BinlogFormat, s *FakeBinlogStream, tableID uint64, tm *TableMap) BinlogEvent
- func NewUpdateRowsEvent(f BinlogFormat, s *FakeBinlogStream, tableID uint64, rows Rows) BinlogEvent
- func NewWriteRowsEvent(f BinlogFormat, s *FakeBinlogStream, tableID uint64, rows Rows) BinlogEvent
- func NewXIDEvent(f BinlogFormat, s *FakeBinlogStream) BinlogEvent
- type BinlogFormat
- type Bitmap
- type Charset
- type FakeBinlogStream
- type GTID
- type GTIDSet
- type MariadbGTID
- type MariadbGTIDSet
- func (gtidSet MariadbGTIDSet) AddGTID(other GTID) GTIDSet
- func (gtidSet MariadbGTIDSet) Contains(other GTIDSet) bool
- func (gtidSet MariadbGTIDSet) ContainsGTID(other GTID) bool
- func (gtidSet MariadbGTIDSet) Equal(other GTIDSet) bool
- func (gtidSet MariadbGTIDSet) Flavor() string
- func (gtidSet MariadbGTIDSet) String() string
- type Mysql56GTID
- type Mysql56GTIDSet
- func (set Mysql56GTIDSet) AddGTID(gtid GTID) GTIDSet
- func (set Mysql56GTIDSet) Contains(other GTIDSet) bool
- func (set Mysql56GTIDSet) ContainsGTID(gtid GTID) bool
- func (set Mysql56GTIDSet) Equal(other GTIDSet) bool
- func (Mysql56GTIDSet) Flavor() string
- func (set Mysql56GTIDSet) SIDBlock() []byte
- func (set Mysql56GTIDSet) SIDs() []SID
- func (set Mysql56GTIDSet) String() string
- type Query
- type Row
- type Rows
- type SID
- type TableMap
Constants ¶
const ( // TypeDecimal is MYSQL_TYPE_DECIMAL. It is deprecated. TypeDecimal = 0 // TypeTiny is MYSQL_TYPE_TINY TypeTiny = 1 // TypeShort is MYSQL_TYPE_SHORT TypeShort = 2 // TypeLong is MYSQL_TYPE_LONG TypeLong = 3 // TypeFloat is MYSQL_TYPE_FLOAT TypeFloat = 4 // TypeDouble is MYSQL_TYPE_DOUBLE TypeDouble = 5 // TypeNull is MYSQL_TYPE_NULL TypeNull = 6 // TypeTimestamp is MYSQL_TYPE_TIMESTAMP TypeTimestamp = 7 // TypeLongLong is MYSQL_TYPE_LONGLONG TypeLongLong = 8 // TypeInt24 is MYSQL_TYPE_INT24 TypeInt24 = 9 // TypeDate is MYSQL_TYPE_DATE TypeDate = 10 // TypeTime is MYSQL_TYPE_TIME TypeTime = 11 // TypeDateTime is MYSQL_TYPE_DATETIME TypeDateTime = 12 // TypeYear is MYSQL_TYPE_YEAR TypeYear = 13 // TypeNewDate is MYSQL_TYPE_NEWDATE TypeNewDate = 14 // TypeVarchar is MYSQL_TYPE_VARCHAR TypeVarchar = 15 // TypeBit is MYSQL_TYPE_BIT TypeBit = 16 // TypeTimestamp2 is MYSQL_TYPE_TIMESTAMP2 TypeTimestamp2 = 17 // TypeDateTime2 is MYSQL_TYPE_DATETIME2 TypeDateTime2 = 18 // TypeTime2 is MYSQL_TYPE_TIME2 TypeTime2 = 19 // TypeJSON is MYSQL_TYPE_JSON TypeJSON = 245 // TypeNewDecimal is MYSQL_TYPE_NEWDECIMAL TypeNewDecimal = 246 // TypeEnum is MYSQL_TYPE_ENUM TypeEnum = 247 // TypeSet is MYSQL_TYPE_SET TypeSet = 248 // TypeTinyBlob is MYSQL_TYPE_TINY_BLOB TypeTinyBlob = 249 // TypeMediumBlob is MYSQL_TYPE_MEDIUM_BLOB TypeMediumBlob = 250 // TypeLongBlob is MYSQL_TYPE_LONG_BLOB TypeLongBlob = 251 // TypeBlob is MYSQL_TYPE_BLOB TypeBlob = 252 // TypeVarString is MYSQL_TYPE_VAR_STRING TypeVarString = 253 // TypeString is MYSQL_TYPE_STRING TypeString = 254 // TypeGeometry is MYSQL_TYPE_GEOMETRY TypeGeometry = 255 )
This is the data type for a field. Values taken from include/mysql/mysql_com.h
const ( // IntVarInvalidInt is INVALID_INT_EVENT IntVarInvalidInt = 0 // IntVarLastInsertID is LAST_INSERT_ID_EVENT IntVarLastInsertID = 1 // IntVarInsertID is INSERT_ID_EVENT IntVarInsertID = 2 )
Constants for the type of an INTVAR_EVENT.
const ( // BinlogChecksumAlgOff indicates that checksums are supported but off. BinlogChecksumAlgOff = 0 // BinlogChecksumAlgCRC32 indicates that CRC32 checksums are used. BinlogChecksumAlgCRC32 = 1 // BinlogChecksumAlgUndef indicates that checksums are not supported. BinlogChecksumAlgUndef = 255 )
Constants about the type of checksum in a packet. These constants are common between MariaDB 10.0 and MySQL 5.6.
const ( // QFlags2Code is Q_FLAGS2_CODE QFlags2Code = 0 // QSQLModeCode is Q_SQL_MODE_CODE QSQLModeCode = 1 // QCatalog is Q_CATALOG QCatalog = 2 // QAutoIncrement is Q_AUTO_INCREMENT QAutoIncrement = 3 // QCharsetCode is Q_CHARSET_CODE QCharsetCode = 4 // QTimeZoneCode is Q_TIME_ZONE_CODE QTimeZoneCode = 5 // QCatalogNZCode is Q_CATALOG_NZ_CODE QCatalogNZCode = 6 )
These constants describe the type of status variables in q Query packet.
Variables ¶
var ( // IntVarNames maps a InVar type to the variable name it represents. IntVarNames = map[byte]string{ IntVarLastInsertID: "LAST_INSERT_ID", IntVarInsertID: "INSERT_ID", } )
Name of the variable represented by an IntVar.
var ZeroTimestamp = []byte("0000-00-00 00:00:00")
ZeroTimestamp is the special value 0 for a timestamp.
Functions ¶
func CellBytes ¶
func CellBytes(data []byte, pos int, typ byte, metadata uint16, isUnSignedInt bool) ([]byte, int, error)
CellBytes is used to parse value of a column for a row as []byte to output
data input the data form a row pos input where the data begin typ input the type of the column data metadata input it may contains the length or the precision of the column data isUnSignedInt input it is unsigned int for this column return []byte as value, int as the of length of value occupied in data
func EncodeGTID ¶
EncodeGTID returns a string that contains both the flavor and value of the GTID, so that the correct parser can be selected when that string is passed to DecodeGTID.
Types ¶
type BinlogEvent ¶
type BinlogEvent interface { // IsValid returns true if the underlying data buffer contains a valid // event. This should be called first on any BinlogEvent, and other // methods should only be called if this one returns true. This ensures // you won't get panics due to bounds checking on the byte array. IsValid() bool // IsFormatDescription returns true if this is a // FORMAT_DESCRIPTION_EVENT. Do not call StripChecksum before // calling Format (Format returns the BinlogFormat anyway, // required for calling StripChecksum). IsFormatDescription() bool // IsQuery returns true if this is a QUERY_EVENT, which encompasses // all SQL statements. IsQuery() bool // IsXID returns true if this is an XID_EVENT, which is an alternate // form of COMMIT. IsXID() bool // IsGTID returns true if this is a GTID_EVENT. IsGTID() bool // IsRotate returns true if this is a ROTATE_EVENT. IsRotate() bool // IsIntVar returns true if this is an INTVAR_EVENT. IsIntVar() bool // IsRand returns true if this is a RAND_EVENT. IsRand() bool // IsPreviousGTIDs returns true if this event is a PREVIOUS_GTIDS_EVENT. IsPreviousGTIDs() bool // RBR events. Replication Based Rows // IsRowsQuery returns true if this is a ROWS_QUERY_EVENT. IsRowsQuery() bool // IsTableMapEvent returns true if this is a TABLE_MAP_EVENT. IsTableMap() bool // IsWriteRowsEvent returns true if this is a WRITE_ROWS_EVENT. IsWriteRows() bool // IsUpdateRowsEvent returns true if this is a UPDATE_ROWS_EVENT. IsUpdateRows() bool // IsDeleteRowsEvent returns true if this is a DELETE_ROWS_EVENT. IsDeleteRows() bool // Timestamp returns the timestamp from the event header. Timestamp() uint32 // NextPosition return Next binlog event position from the event header. NextPosition() int64 // Format returns a BinlogFormat struct based on the event data. // This is only valid if IsFormatDescription() returns true. Format() (BinlogFormat, error) // GTID returns the GTID from the event, and if this event // also serves as a BEGIN statement. // This is only valid if IsGTID() returns true. GTID(BinlogFormat) (GTID, bool, error) // Query returns a Query struct representing data from a QUERY_EVENT. // This is only valid if IsQuery() returns true. Query(BinlogFormat) (Query, error) // IntVar returns the type and value of the variable for an INTVAR_EVENT. // This is only valid if IsIntVar() returns true. IntVar(BinlogFormat) (byte, uint64, error) // Rand returns the two seed values for a RAND_EVENT. // This is only valid if IsRand() returns true. Rand(BinlogFormat) (uint64, uint64, error) // Rotate returns the binlog filename and offset for a ROTATE_EVENT. // This is only valid if IsRotate() returns true. Rotate(BinlogFormat) (string, int64, error) // PreviousGTIDs returns the Position from the event. // This is only valid if IsPreviousGTIDs() returns true. PreviousGTIDs(BinlogFormat) (GTIDSet, error) // TableID returns the table ID for a TableMap, UpdateRows, // WriteRows or DeleteRows event. TableID(BinlogFormat) uint64 // TableMap returns a TableMap struct representing data from a // TABLE_MAP_EVENT. This is only valid if IsTableMapEvent() returns // true. TableMap(BinlogFormat) (*TableMap, error) // Rows returns a Rows struct representing data from a // {WRITE,UPDATE,DELETE}_ROWS_EVENT. This is only valid if // IsWriteRows(), IsUpdateRows(), or IsDeleteRows() returns // true. Rows(BinlogFormat, *TableMap) (Rows, error) // StripChecksum returns the checksum and a modified event with the // checksum stripped off, if any. If there is no checksum, it returns // the same event and a nil checksum. StripChecksum(BinlogFormat) (ev BinlogEvent, checksum []byte, err error) // IsPseudo is for custom implemetations of GTID. IsPseudo() bool Bytes() []byte }
BinlogEvent represents a single event from a raw MySQL binlog dump stream. The implementation is provided by each supported flavor in go/vt/mysqlctl.
binlog.Streamer receives these events through a mysqlctl.SlaveConnection and processes them, grouping statements into BinlogTransactions as appropriate.
Methods that only access header fields can't fail as long as IsValid() returns true, so they have a single return value. Methods that might fail even when IsValid() is true return an error value.
Methods that require information from the initial FORMAT_DESCRIPTION_EVENT will have a BinlogFormat parameter.
A BinlogEvent should never be sent over the wire. UpdateStream service will send BinlogTransactions from these events.
func NewDeleteRowsEvent ¶
func NewDeleteRowsEvent(f BinlogFormat, s *FakeBinlogStream, tableID uint64, rows Rows) BinlogEvent
NewDeleteRowsEvent returns an DeleteRows event. Uses v2.
func NewFormatDescriptionEvent ¶
func NewFormatDescriptionEvent(f BinlogFormat, s *FakeBinlogStream) BinlogEvent
NewFormatDescriptionEvent creates a new FormatDescriptionEvent based on the provided BinlogFormat. It uses a mysql56BinlogEvent but could use a MariaDB one.
func NewIntVarEvent ¶
func NewIntVarEvent(f BinlogFormat, s *FakeBinlogStream, typ byte, value uint64) BinlogEvent
NewIntVarEvent returns an IntVar event.
func NewInvalidEvent ¶
func NewInvalidEvent() BinlogEvent
NewInvalidEvent returns an invalid event (its size is <19).
func NewInvalidFormatDescriptionEvent ¶
func NewInvalidFormatDescriptionEvent(f BinlogFormat, s *FakeBinlogStream) BinlogEvent
NewInvalidFormatDescriptionEvent returns an invalid FormatDescriptionEvent. The binlog version is set to 3. It IsValid() though.
func NewInvalidQueryEvent ¶
func NewInvalidQueryEvent(f BinlogFormat, s *FakeBinlogStream) BinlogEvent
NewInvalidQueryEvent returns an invalid QueryEvent. IsValid is however true. sqlPos is out of bounds.
func NewMariaDBGTIDEvent ¶
func NewMariaDBGTIDEvent(f BinlogFormat, s *FakeBinlogStream, gtid MariadbGTID, hasBegin bool) BinlogEvent
NewMariaDBGTIDEvent returns a MariaDB specific GTID event. It ignores the Server in the gtid, instead uses the FakeBinlogStream.ServerID.
func NewMariadbBinlogEvent ¶
func NewMariadbBinlogEvent(buf []byte) BinlogEvent
NewMariadbBinlogEvent creates a BinlogEvent instance from given byte array
func NewMysql56BinlogEvent ¶
func NewMysql56BinlogEvent(buf []byte) BinlogEvent
NewMysql56BinlogEvent creates a BinlogEvent from given byte array
func NewQueryEvent ¶
func NewQueryEvent(f BinlogFormat, s *FakeBinlogStream, q Query) BinlogEvent
NewQueryEvent makes up a QueryEvent based on the Query structure.
func NewRotateEvent ¶
func NewRotateEvent(f BinlogFormat, s *FakeBinlogStream, position uint64, filename string) BinlogEvent
NewRotateEvent returns a RotateEvent. The timestamp of such an event should be zero, so we patch it in.
func NewTableMapEvent ¶
func NewTableMapEvent(f BinlogFormat, s *FakeBinlogStream, tableID uint64, tm *TableMap) BinlogEvent
NewTableMapEvent returns a TableMap event. Only works with post_header_length=8.
func NewUpdateRowsEvent ¶
func NewUpdateRowsEvent(f BinlogFormat, s *FakeBinlogStream, tableID uint64, rows Rows) BinlogEvent
NewUpdateRowsEvent returns an UpdateRows event. Uses v2.
func NewWriteRowsEvent ¶
func NewWriteRowsEvent(f BinlogFormat, s *FakeBinlogStream, tableID uint64, rows Rows) BinlogEvent
NewWriteRowsEvent returns a WriteRows event. Uses v2.
func NewXIDEvent ¶
func NewXIDEvent(f BinlogFormat, s *FakeBinlogStream) BinlogEvent
NewXIDEvent returns a XID event. We do not use the data, so keep it 0.
type BinlogFormat ¶
type BinlogFormat struct { // FormatVersion is the version number of the binlog file format. // We only support version 4. FormatVersion uint16 // ServerVersion is the name of the MySQL server version. // It starts with something like 5.6.33-xxxx. ServerVersion string // HeaderLength is the size in bytes of event headers other // than FORMAT_DESCRIPTION_EVENT. Almost always 19. HeaderLength byte // ChecksumAlgorithm is the ID number of the binlog checksum algorithm. // See three possible values below. ChecksumAlgorithm byte // HeaderSizes is an array of sizes of the headers for each message. HeaderSizes []byte }
BinlogFormat contains relevant data from the FORMAT_DESCRIPTION_EVENT. This structure is passed to subsequent event types to let them know how to parse themselves.
func NewMariaDBBinlogFormat ¶
func NewMariaDBBinlogFormat() BinlogFormat
NewMariaDBBinlogFormat returns a typical BinlogFormat for MariaDB 10.0.
func NewMySQL56BinlogFormat ¶
func NewMySQL56BinlogFormat() BinlogFormat
NewMySQL56BinlogFormat returns a typical BinlogFormat for MySQL 5.6.
func (BinlogFormat) HeaderSize ¶
func (f BinlogFormat) HeaderSize(typ byte) byte
HeaderSize returns the header size of any event type.
func (BinlogFormat) IsZero ¶
func (f BinlogFormat) IsZero() bool
IsZero returns true if the BinlogFormat has not been initialized.
type Bitmap ¶
type Bitmap struct {
// contains filtered or unexported fields
}
Bitmap is used by the previous structures.
func NewServerBitmap ¶
NewServerBitmap returns a bitmap that can hold 'count' bits.
func (*Bitmap) BitCount ¶
BitCount returns how many bits are set in the bitmap. Note values that are not used may be set to 0 or 1, hence the non-efficient logic.
type Charset ¶
type Charset struct { // @@session.character_set_client Client int32 // @@session.collation_connection Conn int32 // @@session.collation_server Server int32 }
Charset 字符集(客户端,连接,服务器)
type FakeBinlogStream ¶
type FakeBinlogStream struct { // ServerID is the server ID of the originating mysql-server. ServerID uint32 // LogPosition is an incrementing log position. LogPosition uint32 // Timestamp is a uint32 of when the events occur. It is not changed. Timestamp uint32 }
FakeBinlogStream is used to generate consistent BinlogEvent packets for a stream. It makes sure the ServerID and log positions are reasonable.
func NewFakeBinlogStream ¶
func NewFakeBinlogStream() *FakeBinlogStream
NewFakeBinlogStream returns a simple FakeBinlogStream.
func (*FakeBinlogStream) Packetize ¶
func (s *FakeBinlogStream) Packetize(f BinlogFormat, typ byte, flags uint16, data []byte) []byte
Packetize adds the binlog event header to a packet, and optionally the checksum.
type GTID ¶
type GTID interface { // String returns the canonical printed form of the GTID as expected by a // particular flavor of MySQL. String() string // Flavor returns the key under which the corresponding GTID parser function // is registered in the gtidParsers map. Flavor() string // SourceServer returns the ID of the server that generated the transaction. SourceServer() interface{} // SequenceNumber returns the ID number that increases with each transaction. // It is only valid to compare the sequence numbers of two GTIDs if they have // the same domain value. SequenceNumber() interface{} // SequenceDomain returns the ID of the domain within which two sequence // numbers can be meaningfully compared. SequenceDomain() interface{} // GTIDSet returns a GTIDSet of the same flavor as this GTID, containing only // this GTID. GTIDSet() GTIDSet }
GTID represents a Global Transaction ID, also known as Transaction Group ID. Each flavor of MySQL has its own format for the GTID. This interface is used along with various MysqlFlavor implementations to abstract the differences.
Types that implement GTID should use a non-pointer receiver. This ensures that comparing GTID interface values with == has the expected semantics.
func DecodeGTID ¶
DecodeGTID converts a string in the format returned by EncodeGTID back into a GTID interface value with the correct underlying flavor.
func MustDecodeGTID ¶
MustDecodeGTID calls DecodeGTID and panics on error.
func MustParseGTID ¶
MustParseGTID calls ParseGTID and panics on error.
type GTIDSet ¶
type GTIDSet interface { // String returns the canonical printed form of the set as expected by a // particular flavor of MySQL. String() string // Flavor returns the key under which the corresponding parser function is // registered in the transactionSetParsers map. Flavor() string // ContainsGTID returns true if the set contains the specified transaction. ContainsGTID(GTID) bool // Contains returns true if the set is a superset of another set. Contains(GTIDSet) bool // Equal returns true if the set is equal to another set. Equal(GTIDSet) bool // AddGTID returns a new GTIDSet that is expanded to contain the given GTID. AddGTID(GTID) GTIDSet }
GTIDSet represents the set of transactions received or applied by a server. In some flavors, a single GTID is enough to specify the set of all transactions that came before it, but in others a more complex structure is required.
GTIDSet is wrapped by replication.Position, which is a concrete struct. When sending a GTIDSet over RPCs, encode/decode it as a string. Most code outside of this package should use replication.Position rather than GTIDSet.
type MariadbGTID ¶
type MariadbGTID struct { // Domain is the ID number of the domain within which sequence numbers apply. Domain uint32 // Server is the ID of the server that generated the transaction. Server uint32 // Sequence is the sequence number of the transaction within the domain. Sequence uint64 }
MariadbGTID implements GTID.
func (MariadbGTID) Flavor ¶
func (gtid MariadbGTID) Flavor() string
Flavor implements GTID.Flavor().
func (MariadbGTID) GTIDSet ¶
func (gtid MariadbGTID) GTIDSet() GTIDSet
GTIDSet implements GTID.GTIDSet().
func (MariadbGTID) SequenceDomain ¶
func (gtid MariadbGTID) SequenceDomain() interface{}
SequenceDomain implements GTID.SequenceDomain().
func (MariadbGTID) SequenceNumber ¶
func (gtid MariadbGTID) SequenceNumber() interface{}
SequenceNumber implements GTID.SequenceNumber().
func (MariadbGTID) SourceServer ¶
func (gtid MariadbGTID) SourceServer() interface{}
SourceServer implements GTID.SourceServer().
func (MariadbGTID) String ¶
func (gtid MariadbGTID) String() string
String implements GTID.String().
type MariadbGTIDSet ¶
type MariadbGTIDSet []MariadbGTID
MariadbGTIDSet implements GTIDSet
func (MariadbGTIDSet) AddGTID ¶
func (gtidSet MariadbGTIDSet) AddGTID(other GTID) GTIDSet
AddGTID implements GTIDSet.AddGTID().
func (MariadbGTIDSet) Contains ¶
func (gtidSet MariadbGTIDSet) Contains(other GTIDSet) bool
Contains implements GTIDSet.Contains().
func (MariadbGTIDSet) ContainsGTID ¶
func (gtidSet MariadbGTIDSet) ContainsGTID(other GTID) bool
ContainsGTID implements GTIDSet.ContainsGTID().
func (MariadbGTIDSet) Equal ¶
func (gtidSet MariadbGTIDSet) Equal(other GTIDSet) bool
Equal implements GTIDSet.Equal().
func (MariadbGTIDSet) Flavor ¶
func (gtidSet MariadbGTIDSet) Flavor() string
Flavor implements GTIDSet.Flavor()
func (MariadbGTIDSet) String ¶
func (gtidSet MariadbGTIDSet) String() string
String implements GTIDSet.String()
type Mysql56GTID ¶
type Mysql56GTID struct { // Server is the SID of the server that originally committed the transaction. Server SID // Sequence is the sequence number of the transaction within a given Server's // scope. Sequence int64 }
Mysql56GTID implements GTID
func (Mysql56GTID) GTIDSet ¶
func (m Mysql56GTID) GTIDSet() GTIDSet
GTIDSet implements GTID.GTIDSet().
func (Mysql56GTID) SequenceDomain ¶
func (m Mysql56GTID) SequenceDomain() interface{}
SequenceDomain implements GTID.SequenceDomain().
func (Mysql56GTID) SequenceNumber ¶
func (m Mysql56GTID) SequenceNumber() interface{}
SequenceNumber implements GTID.SequenceNumber().
func (Mysql56GTID) SourceServer ¶
func (m Mysql56GTID) SourceServer() interface{}
SourceServer implements GTID.SourceServer().
type Mysql56GTIDSet ¶
type Mysql56GTIDSet map[SID][]interval
Mysql56GTIDSet implements GTIDSet for MySQL 5.6.
func NewMysql56GTIDSetFromSIDBlock ¶
func NewMysql56GTIDSetFromSIDBlock(data []byte) (Mysql56GTIDSet, error)
NewMysql56GTIDSetFromSIDBlock builds a Mysql56GTIDSet from parsing a SID Block. This is the reverse of the SIDBlock method.
Expected format:
# bytes field 8 nSIDs
(nSIDs times)
16 SID 8 nIntervals
(nIntervals times)
8 start 8 end
func (Mysql56GTIDSet) AddGTID ¶
func (set Mysql56GTIDSet) AddGTID(gtid GTID) GTIDSet
AddGTID implements GTIDSet.
func (Mysql56GTIDSet) Contains ¶
func (set Mysql56GTIDSet) Contains(other GTIDSet) bool
Contains implements GTIDSet.
func (Mysql56GTIDSet) ContainsGTID ¶
func (set Mysql56GTIDSet) ContainsGTID(gtid GTID) bool
ContainsGTID implements GTIDSet.
func (Mysql56GTIDSet) Equal ¶
func (set Mysql56GTIDSet) Equal(other GTIDSet) bool
Equal implements GTIDSet.
func (Mysql56GTIDSet) SIDBlock ¶
func (set Mysql56GTIDSet) SIDBlock() []byte
SIDBlock returns the binary encoding of a MySQL 5.6 GTID set as expected by internal commands that refer to an "SID block".
e.g. https://dev.mysql.com/doc/internals/en/com-binlog-dump-gtid.html
func (Mysql56GTIDSet) SIDs ¶
func (set Mysql56GTIDSet) SIDs() []SID
SIDs returns a sorted list of SIDs in the set.
type Row ¶
type Row struct { // NullIdentifyColumns describes which of the identify columns are NULL. // It is only set for UPDATE and DELETE events. NullIdentifyColumns Bitmap // NullColumns describes which of the present columns are NULL. // It is only set for WRITE and UPDATE events. NullColumns Bitmap // It means the WHERE condition which they UPDATE or DELETE(add from xd.fang) Identify []byte // It means the Value which they INSERT or UPDATE(add from xd.fang) Data []byte }
Row contains data for a single Row in a Rows event.
type Rows ¶
type Rows struct { // Flags has the flags from the event. Flags uint16 // It means the WHERE condition which they UPDATE or DELETE(add from xd.fang) IdentifyColumns Bitmap // It means the Value which they INSERT or UPDATE(add from xd.fang) DataColumns Bitmap // Rows is an array of Row in the event. Rows []Row }
Rows contains data from a {WRITE,UPDATE,DELETE}_ROWS_EVENT.
type SID ¶
type SID [16]byte
SID is the 16-byte unique ID of a MySQL 5.6 server.
type TableMap ¶
type TableMap struct { // Flags is the table's flags. Flags uint16 // Database is the database name. Database string // Name is the name of the table. Name string // Types is an array of MySQL types for the fields. Types []byte // CanBeNull's bits are set if the column can be NULL. CanBeNull Bitmap // Metadata is an array of uint16, one per column. // It contains a few extra information about each column, // that is dependent on the type. // - If the metadata is not present, this is zero. // - If the metadata is one byte, only the lower 8 bits are used. // - If the metadata is two bytes, all 16 bits are used. Metadata []uint16 }
TableMap contains data from a TABLE_MAP_EVENT.