binlog

package
v0.0.0-...-1609ee8 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// A start event is the first event of a binlog for binlog-version 1 to 3.
	StartEventV3Type
	QueryEventType
	StopEventType
	RotateEventType
	IntvarEventType
	LoadEventType
	SlaveEventType
	CreateFileEventType
	AppendBlockEventType
	ExecLoadEventType
	DeleteFileEventType
	NewLoadEventType
	RandEventType
	UserVarEventType
	// A format description event is the first event of a binlog for binlog-version 4.
	// It describes how the other events are layed out.
	FormatDescriptionEventType
	XidEventType
	BeginLoadQueryEventType
	ExecuteLoadQueryEventType
	TableMapEventType
	WriteRowsEventV0Type
	UpdateRowsEventV0Type
	DeleteRowsEventV0Type
	WriteRowsEventV1Type
	UpdateRowsEventV1Type
	DeleteRowsEventV1Type
	IncidentEventType
	HeartbeatEventType
	IgnoreableEventType
	RowsQueryEventType
	WriteRowsEventV2Type
	UpdateRowsEventV2Type
	DeleteRowsEventV2Type
	GTIDEventType
	AnonymousGtidEventType
	PreviousGtidsEventType
)

Event type of binlog event https://dev.mysql.com/doc/internals/en/binlog-event-type.html

View Source
const (
	MariadbAnnotateRowsEventType = 160 + iota
	MariadbBinlogCheckpointEventType
	MariadbGTIDEventType
	MariadbGTIDListEventType
)

MariaDB binlog events

View Source
const (
	LogEventBinlogInUseFlag = 1 << iota
	LogEventForcedRotateFlag
	LogEventThreadSpecificFlag
	LogEventSuppressUseFlag
	LogEventUpdateTableMapVersionFlag
	LogEventArtificialFlag
	LogEventRelayLogFlag
	LogEventIgnorableFlag
	LogEventNoFilterFlag
	LogEventMtsIsolateFlag
)

Flags of binlog event header's flag https://dev.mysql.com/doc/internals/en/binlog-event-flag.html

View Source
const (
	ChecksumAlgOff   = 0x00
	ChecksumAlgCRC32 = 0x01
	ChecksumAlgUndef = 0xff
)

Binlog checksum

View Source
const (
	RowWrite = iota
	RowUpdate
	RowDelete
)

Specify the rows event action

View Source
const (
	RowsEventFlagStmtEnd = 0x01
)

Rows event flags

Variables

This section is empty.

Functions

func TimeStringFromInt64TimePacked

func TimeStringFromInt64TimePacked(tm int64) string

TimeStringFromInt64TimePacked see log_event.cc TIME_from_longlong_time_packed

Types

type Event

type Event struct {
	// Data is the original binlog data
	Data    []byte
	Header  EventHeader
	Payload EventSet
}

Event is a binlog event send from mysql

type EventHeader

type EventHeader struct {
	// Timestamp seconds since unix epoch
	Timestamp uint32
	// EventType https://dev.mysql.com/doc/internals/en/binlog-event-type.html
	EventType uint8
	// ServerID
	// server-id of the originating mysql-server. Used to filter out events in circular replication.
	ServerID uint32
	// EventSize size of the event (header, post-header, body)
	EventSize uint32
	// LogPos  position of the next event
	LogPos uint32
	// Flags
	// https://dev.mysql.com/doc/internals/en/binlog-event-flag.html
	Flags uint16
}

EventHeader is the header of a binlog event https://dev.mysql.com/doc/internals/en/binlog-event-header.html

type EventSet

type EventSet struct {
	// Parsed is true when the event is parsed
	Parsed bool
	// FormatDescription event
	FormatDescription *FormatDescriptionEvent
	// Rotate event
	Rotate *RotateEvent
	// Query event
	Query *QueryEvent
	// Xid event
	Xid *XidEvent
	// Table map event
	TableMap *TableMapEvent
	// Rows event
	Rows *RowsEvent
	// Rows query event
	RowsQuery *RowsQueryEvent
	// Gtid event
	GTID *GTIDEvent
	// Mariadb gtid event
	MariadbGTID *MariadbGTIDEvent
	// Heartbeat event
	Heartbeat *HeartbeatEvent
}

EventSet has all event type

func (*EventSet) Decode

func (s *EventSet) Decode(tp int, tables map[int]*TableMapEvent, data []byte) error

Decode decodes binary data to a binlog event

type FormatDescriptionEvent

type FormatDescriptionEvent struct {
	BinlogVersion          uint16
	MysqlServerVersion     [50]byte
	CreateTimestamp        uint32
	EventHeaderLength      uint8
	EventTypeHeaderLengths []byte
}

FormatDescriptionEvent see below https://dev.mysql.com/doc/internals/en/format-description-event.html

func (*FormatDescriptionEvent) Decode

func (e *FormatDescriptionEvent) Decode(data []byte) error

Decode decodes the binary data into payload

type GTIDEvent

type GTIDEvent struct {
	CommitFlag uint8
	SID        []byte
	GNO        int64
}

GTIDEvent sees below rpl_gtid.h

func (*GTIDEvent) Decode

func (e *GTIDEvent) Decode(data []byte) error

Decode decodes the binary data into payload

func (*GTIDEvent) String

func (e *GTIDEvent) String() string

type HeartbeatEvent

type HeartbeatEvent struct {
	LogIdent string
}

HeartbeatEvent is sent by master if no more binlog produce See control_events.h

func (*HeartbeatEvent) Decode

func (e *HeartbeatEvent) Decode(data []byte) error

Decode decodes the binary data into payload

type IPayload

type IPayload interface {
	Decode([]byte) error
}

IPayload defines a binlog payload

type MariadbGTIDEvent

type MariadbGTIDEvent struct {
	DomainID       uint32
	ServerID       uint32
	SequenceNumber uint64
}

MariadbGTIDEvent no document ...

func (*MariadbGTIDEvent) Decode

func (e *MariadbGTIDEvent) Decode(data []byte) error

Decode decodes the binary data into payload

func (*MariadbGTIDEvent) String

func (e *MariadbGTIDEvent) String() string

type Parser

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

Parser parse the binlog event

func NewParser

func NewParser() *Parser

NewParser create a new binlog parser

func (*Parser) Parse

func (p *Parser) Parse(data []byte) (*Event, error)

Parse parses binary data to binlog event

func (*Parser) Reset

func (p *Parser) Reset()

Reset resets the parser

func (*Parser) SetChecksum

func (p *Parser) SetChecksum(cs uint8)

SetChecksum set the checksum of server binlog

func (*Parser) SetSyncRule

func (p *Parser) SetSyncRule(r rule.ISyncRule)

SetSyncRule set the sync rule for the parser Sync rule only effect rows event, ddl (query event) won't be effected

type QueryEvent

type QueryEvent struct {
	// Post header
	SlaveProxyID     uint32
	ExecutionTime    uint32
	SchemaLength     uint8
	ErrorCode        uint16
	StatusVarsLength uint16
	// Payload
	StatusVars string
	Schema     string

	Query string
	// contains filtered or unexported fields
}

QueryEvent sees below https://dev.mysql.com/doc/internals/en/query-event.html

func (*QueryEvent) Decode

func (e *QueryEvent) Decode(data []byte) error

Decode decodes the binary data into payload

type RotateEvent

type RotateEvent struct {
	Position uint64
	NextName string
}

RotateEvent see below https://dev.mysql.com/doc/internals/en/rotate-event.html

func (*RotateEvent) Decode

func (e *RotateEvent) Decode(data []byte) error

Decode decodes the binary data into payload

type Row

type Row struct {
	ColumnDatas []interface{}
}

Row is a row data contain columns

type RowsEvent

type RowsEvent struct {
	Action      int
	TableID     uint64
	Table       *TableMapEvent
	Flags       uint16
	ExtraData   []byte
	ColumnCount uint64
	Bitmap1     []byte
	Bitmap2     []byte
	Rows        []*Row
	// Sync desc
	Rule *rule.SyncDesc
	// contains filtered or unexported fields
}

RowsEvent see below https://dev.mysql.com/doc/internals/en/rows-event.html

func (*RowsEvent) Decode

func (e *RowsEvent) Decode(data []byte) error

Decode decodes the binary data into payload

type RowsQueryEvent

type RowsQueryEvent struct {
	QueryText string
}

RowsQueryEvent sees below https://dev.mysql.com/doc/internals/en/rows-query-event.html

func (*RowsQueryEvent) Decode

func (e *RowsQueryEvent) Decode(data []byte) error

Decode decodes the binary data into payload

type TableMapEvent

type TableMapEvent struct {
	TableID      uint64
	Flags        uint16
	SchemaName   string
	TableName    string
	ColumnCount  uint64
	ColumnDefine []byte
	ColumnMeta   []uint16
	NullBitmask  []byte
	// contains filtered or unexported fields
}

TableMapEvent event of TableMapEvent https://dev.mysql.com/doc/internals/en/table-map-event.html

func (*TableMapEvent) Decode

func (e *TableMapEvent) Decode(data []byte) error

Decode decodes the binary data into payload

type XidEvent

type XidEvent struct {
	Xid uint64
}

XidEvent sees below https://dev.mysql.com/doc/internals/en/xid-event.html

func (*XidEvent) Decode

func (e *XidEvent) Decode(data []byte) error

Decode decodes the binary data into payload

Jump to

Keyboard shortcuts

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