Documentation ¶
Index ¶
- Constants
- func DiffPermissions(leftName string, left *Permissions, rightName string, right *Permissions, ...)
- func DiffPermissionsToArray(leftName string, left *Permissions, rightName string, right *Permissions) (result []string)
- func DiffSchema(leftName string, left *SchemaDefinition, rightName string, ...)
- func DiffSchemaToArray(leftName string, left *SchemaDefinition, rightName string, ...) (result []string)
- func EncodeGTID(gtid GTID) string
- func EncodeReplicationPosition(rp ReplicationPosition) string
- type ByReverseDataLength
- type DbPermission
- type DbPermissionList
- type GTID
- type GTIDField
- type GTIDSet
- type GoogleGTID
- func (gtid GoogleGTID) AddGTID(other GTID) GTIDSet
- func (gtid GoogleGTID) Contains(other GTIDSet) bool
- func (gtid GoogleGTID) ContainsGTID(other GTID) bool
- func (gtid GoogleGTID) Equal(other GTIDSet) bool
- func (gtid GoogleGTID) Flavor() string
- func (gtid GoogleGTID) GTIDSet() GTIDSet
- func (gtid GoogleGTID) Last() GTID
- func (gtid GoogleGTID) SequenceDomain() string
- func (gtid GoogleGTID) SequenceNumber() uint64
- func (gtid GoogleGTID) SourceServer() string
- func (gtid GoogleGTID) String() string
- type HostPermission
- type HostPermissionList
- type MariadbGTID
- func (gtid MariadbGTID) AddGTID(other GTID) GTIDSet
- func (gtid MariadbGTID) Contains(other GTIDSet) bool
- func (gtid MariadbGTID) ContainsGTID(other GTID) bool
- func (gtid MariadbGTID) Equal(other GTIDSet) bool
- func (gtid MariadbGTID) Flavor() string
- func (gtid MariadbGTID) GTIDSet() GTIDSet
- func (gtid MariadbGTID) Last() GTID
- func (gtid MariadbGTID) SequenceDomain() string
- func (gtid MariadbGTID) SequenceNumber() uint64
- func (gtid MariadbGTID) SourceServer() string
- func (gtid MariadbGTID) String() string
- type Permission
- type PermissionList
- type Permissions
- type ReplicationPosition
- func AppendGTID(rp ReplicationPosition, gtid GTID) ReplicationPosition
- func DecodeReplicationPosition(s string) (rp ReplicationPosition, err error)
- func MustParseReplicationPosition(flavor, value string) ReplicationPosition
- func ParseReplicationPosition(flavor, value string) (rp ReplicationPosition, err error)
- func (rp ReplicationPosition) AtLeast(other ReplicationPosition) bool
- func (rp ReplicationPosition) Equal(other ReplicationPosition) bool
- func (rp ReplicationPosition) IsZero() bool
- func (rp ReplicationPosition) MarshalBson(buf *bytes2.ChunkedWriter, key string)
- func (rp ReplicationPosition) MarshalJSON() ([]byte, error)
- func (rp ReplicationPosition) String() string
- func (rp *ReplicationPosition) UnmarshalBson(buf *bytes.Buffer, kind byte)
- func (rp *ReplicationPosition) UnmarshalJSON(buf []byte) error
- type ReplicationStatus
- type SchemaChange
- type SchemaChangeResult
- type SchemaDefinition
- type TableDefinition
- type TableDefinitions
- type UserPermission
- type UserPermissionList
Constants ¶
const ( TABLE_BASE_TABLE = "BASE TABLE" TABLE_VIEW = "VIEW" )
Variables ¶
This section is empty.
Functions ¶
func DiffPermissions ¶
func DiffPermissions(leftName string, left *Permissions, rightName string, right *Permissions, er concurrency.ErrorRecorder)
func DiffPermissionsToArray ¶
func DiffPermissionsToArray(leftName string, left *Permissions, rightName string, right *Permissions) (result []string)
func DiffSchema ¶
func DiffSchema(leftName string, left *SchemaDefinition, rightName string, right *SchemaDefinition, er concurrency.ErrorRecorder)
generates a report on what's different between two SchemaDefinition for now, we skip the VIEW entirely.
func DiffSchemaToArray ¶
func DiffSchemaToArray(leftName string, left *SchemaDefinition, rightName string, right *SchemaDefinition) (result []string)
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.
func EncodeReplicationPosition ¶
func EncodeReplicationPosition(rp ReplicationPosition) string
EncodeReplicationPosition returns a string that contains both the flavor and value of the ReplicationPosition, so that the correct parser can be selected when that string is passed to DecodeReplicationPosition.
Types ¶
type ByReverseDataLength ¶
type ByReverseDataLength struct {
TableDefinitions
}
sort by reverse DataLength
func (ByReverseDataLength) Less ¶
func (bdl ByReverseDataLength) Less(i, j int) bool
type DbPermission ¶
DbPermission describes a single row in the mysql.db table Primary key is Host+Db+User
func NewDbPermission ¶
func NewDbPermission(fields []proto.Field, values []sqltypes.Value) *DbPermission
func (*DbPermission) PrimaryKey ¶
func (dp *DbPermission) PrimaryKey() string
func (*DbPermission) String ¶
func (dp *DbPermission) String() string
type DbPermissionList ¶
type DbPermissionList []*DbPermission
func (DbPermissionList) Get ¶
func (upl DbPermissionList) Get(i int) Permission
func (DbPermissionList) Len ¶
func (upl DbPermissionList) Len() int
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() string // 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() uint64 // SequenceDomain returns the ID of the domain within which two sequence // numbers can be meaningfully compared. SequenceDomain() string // 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 GTIDField ¶
type GTIDField struct {
Value GTID
}
GTIDField is a concrete struct that contains a GTID interface value. This can be used as a field inside marshalable structs, which cannot contain interface values because there would be no way to know which concrete type to instantiate upon unmarshaling.
Note: GTIDField should not implement GTID, because it would tend to create subtle bugs. For example, the compiler would allow something like this:
GTIDField{googleGTID{1234}} == googleGTID{1234}
But it would evaluate to false (because the underlying types don't match), which is probably not what was expected.
func (GTIDField) MarshalBson ¶
func (gf GTIDField) MarshalBson(buf *bytes2.ChunkedWriter, key string)
MarshalBson bson-encodes GTIDField.
func (GTIDField) MarshalJSON ¶
MarshalJSON implements encoding/json.Marshaler.
func (GTIDField) String ¶
String returns a string representation of the underlying GTID. If the GTID value is nil, it returns "<nil>" in the style of Sprintf("%v", nil).
func (*GTIDField) UnmarshalBson ¶
UnmarshalBson bson-decodes into GTIDField.
func (*GTIDField) UnmarshalJSON ¶
UnmarshalJSON implements encoding/json.Unmarshaler.
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 // Last returns the GTID of the most recent transaction in the set. Last() GTID // Contains 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 ReplicationPosition, which is a concrete struct that enables JSON and BSON marshaling. Most code outside of this package should use ReplicationPosition rather than GTIDSet.
type GoogleGTID ¶
type GoogleGTID struct { // ServerID is the server_id of the server that originally generated the // transaction. ServerID uint32 // GroupID is the unique ID of a transaction group. GroupID uint64 }
GoogleGTID implements GTID and GTIDSet. In Google MySQL, a single GTID is already enough to define the set of all GTIDs that came before it.
func (GoogleGTID) AddGTID ¶
func (gtid GoogleGTID) AddGTID(other GTID) GTIDSet
AddGTID implements GTIDSet.AddGTID().
func (GoogleGTID) Contains ¶
func (gtid GoogleGTID) Contains(other GTIDSet) bool
Contains implements GTIDSet.Contains().
func (GoogleGTID) ContainsGTID ¶
func (gtid GoogleGTID) ContainsGTID(other GTID) bool
ContainsGTID implements GTIDSet.ContainsGTID().
func (GoogleGTID) Equal ¶
func (gtid GoogleGTID) Equal(other GTIDSet) bool
Equal implements GTIDSet.Equal().
func (GoogleGTID) GTIDSet ¶
func (gtid GoogleGTID) GTIDSet() GTIDSet
GTIDSet implements GTID.GTIDSet().
func (GoogleGTID) SequenceDomain ¶
func (gtid GoogleGTID) SequenceDomain() string
Domain implements GTID.SequenceDomain().
func (GoogleGTID) SequenceNumber ¶
func (gtid GoogleGTID) SequenceNumber() uint64
SequenceNumber implements GTID.SequenceNumber().
func (GoogleGTID) SourceServer ¶
func (gtid GoogleGTID) SourceServer() string
SourceServer implements GTID.SourceServer().
func (GoogleGTID) String ¶
func (gtid GoogleGTID) String() string
String implements GTID.String(). Google MySQL doesn't define a canonical way to represent both a group_id and a server_id together, so we've invented one.
type HostPermission ¶
HostPermission describes a single row in the mysql.host table Primary key is Host+Db
func NewHostPermission ¶
func NewHostPermission(fields []proto.Field, values []sqltypes.Value) *HostPermission
func (*HostPermission) PrimaryKey ¶
func (hp *HostPermission) PrimaryKey() string
func (*HostPermission) String ¶
func (hp *HostPermission) String() string
type HostPermissionList ¶
type HostPermissionList []*HostPermission
func (HostPermissionList) Get ¶
func (upl HostPermissionList) Get(i int) Permission
func (HostPermissionList) Len ¶
func (upl HostPermissionList) Len() int
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) AddGTID ¶
func (gtid MariadbGTID) AddGTID(other GTID) GTIDSet
AddGTID implements GTIDSet.AddGTID().
func (MariadbGTID) Contains ¶
func (gtid MariadbGTID) Contains(other GTIDSet) bool
Contains implements GTIDSet.Contains().
func (MariadbGTID) ContainsGTID ¶
func (gtid MariadbGTID) ContainsGTID(other GTID) bool
ContainsGTID implements GTIDSet.ContainsGTID().
func (MariadbGTID) Equal ¶
func (gtid MariadbGTID) Equal(other GTIDSet) bool
Equal implements GTIDSet.Equal().
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() string
SequenceDomain implements GTID.SequenceDomain().
func (MariadbGTID) SequenceNumber ¶
func (gtid MariadbGTID) SequenceNumber() uint64
SequenceNumber implements GTID.SequenceNumber().
func (MariadbGTID) SourceServer ¶
func (gtid MariadbGTID) SourceServer() string
SourceServer implements GTID.SourceServer().
func (MariadbGTID) String ¶
func (gtid MariadbGTID) String() string
String implements GTID.String().
type Permission ¶
type PermissionList ¶
type PermissionList interface { Get(int) Permission Len() int }
type Permissions ¶
type Permissions struct { UserPermissions UserPermissionList DbPermissions DbPermissionList HostPermissions HostPermissionList }
Permissions have all the rows in mysql.{user,db,host} tables, (all rows are sorted by primary key)
func (*Permissions) String ¶
func (permissions *Permissions) String() string
type ReplicationPosition ¶
type ReplicationPosition struct { GTIDSet GTIDSet // contains filtered or unexported fields }
ReplicationPosition represents the information necessary to describe which transactions a server has seen, so that it can request a replication stream from a new master that picks up where it left off.
This must be a concrete struct because custom Unmarshalers can't be registered on an interface.
The == operator should not be used with ReplicationPosition, because the underlying GTIDSet might use slices, which are not comparable. Using == in those cases will result in a run-time panic.
func AppendGTID ¶
func AppendGTID(rp ReplicationPosition, gtid GTID) ReplicationPosition
AppendGTID returns a new ReplicationPosition that represents the position after the given GTID is replicated.
func DecodeReplicationPosition ¶
func DecodeReplicationPosition(s string) (rp ReplicationPosition, err error)
DecodeReplicationPosition converts a string in the format returned by EncodeReplicationPosition back into a ReplicationPosition value with the correct underlying flavor.
func MustParseReplicationPosition ¶
func MustParseReplicationPosition(flavor, value string) ReplicationPosition
MustParseReplicationPosition calls ParseReplicationPosition and panics on error.
func ParseReplicationPosition ¶
func ParseReplicationPosition(flavor, value string) (rp ReplicationPosition, err error)
ParseReplicationPosition calls the parser for the specified flavor.
func (ReplicationPosition) AtLeast ¶
func (rp ReplicationPosition) AtLeast(other ReplicationPosition) bool
AtLeast returns true if this position is equal to or after another.
func (ReplicationPosition) Equal ¶
func (rp ReplicationPosition) Equal(other ReplicationPosition) bool
Equal returns true if this position is equal to another.
func (ReplicationPosition) IsZero ¶
func (rp ReplicationPosition) IsZero() bool
IsZero returns true if this is the zero value, ReplicationPosition{}.
func (ReplicationPosition) MarshalBson ¶
func (rp ReplicationPosition) MarshalBson(buf *bytes2.ChunkedWriter, key string)
MarshalBson bson-encodes ReplicationPosition.
func (ReplicationPosition) MarshalJSON ¶
func (rp ReplicationPosition) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json.Marshaler.
func (ReplicationPosition) String ¶
func (rp ReplicationPosition) String() string
String returns a string representation of the underlying GTIDSet. If the set is nil, it returns "<nil>" in the style of Sprintf("%v", nil).
func (*ReplicationPosition) UnmarshalBson ¶
func (rp *ReplicationPosition) UnmarshalBson(buf *bytes.Buffer, kind byte)
UnmarshalBson bson-decodes into ReplicationPosition.
func (*ReplicationPosition) UnmarshalJSON ¶
func (rp *ReplicationPosition) UnmarshalJSON(buf []byte) error
UnmarshalJSON implements encoding/json.Unmarshaler.
type ReplicationStatus ¶
type ReplicationStatus struct { Position ReplicationPosition SlaveIORunning bool SlaveSQLRunning bool SecondsBehindMaster uint MasterHost string MasterPort int MasterConnectRetry int }
ReplicationStatus holds replication information from SHOW SLAVE STATUS.
func NewReplicationStatus ¶
func NewReplicationStatus(masterAddr string) (*ReplicationStatus, error)
NewReplicationStatus creates a ReplicationStatus pointing to masterAddr.
func (*ReplicationStatus) MasterAddr ¶
func (rs *ReplicationStatus) MasterAddr() string
MasterAddr returns the host:port address of the master.
func (*ReplicationStatus) SlaveRunning ¶
func (rs *ReplicationStatus) SlaveRunning() bool
SlaveRunning returns true iff both the Slave IO and Slave SQL threads are running.
type SchemaChange ¶
type SchemaChange struct { Sql string Force bool AllowReplication bool BeforeSchema *SchemaDefinition AfterSchema *SchemaDefinition }
type SchemaChangeResult ¶
type SchemaChangeResult struct { BeforeSchema *SchemaDefinition AfterSchema *SchemaDefinition }
func (*SchemaChangeResult) String ¶
func (scr *SchemaChangeResult) String() string
type SchemaDefinition ¶
type SchemaDefinition struct { // the 'CREATE DATABASE...' statement, with db name as {{.DatabaseName}} DatabaseSchema string // ordered by TableDefinition.Name by default TableDefinitions TableDefinitions // the md5 of the concatenation of TableDefinition.Schema Version string }
func (*SchemaDefinition) GenerateSchemaVersion ¶
func (sd *SchemaDefinition) GenerateSchemaVersion()
func (*SchemaDefinition) GetTable ¶
func (sd *SchemaDefinition) GetTable(table string) (td *TableDefinition, ok bool)
func (*SchemaDefinition) SortByReverseDataLength ¶
func (sd *SchemaDefinition) SortByReverseDataLength()
func (*SchemaDefinition) String ¶
func (sd *SchemaDefinition) String() string
func (*SchemaDefinition) ToSQLStrings ¶
func (sd *SchemaDefinition) ToSQLStrings() []string
ToSQLStrings converts a SchemaDefinition to an array of SQL strings. The array contains all the SQL statements needed for creating the database, tables, and views - in that order. All SQL statements will have {{.DatabaseName}} in place of the actual db name.
type TableDefinition ¶
type TableDefinition struct { Name string // the table name Schema string // the SQL to run to create the table Columns []string // the columns in the order that will be used to dump and load the data PrimaryKeyColumns []string // the columns used by the primary key, in order Type string // TABLE_BASE_TABLE or TABLE_VIEW DataLength uint64 // how much space the data file takes. RowCount uint64 // how many rows in the table (may }
type TableDefinitions ¶
type TableDefinitions []*TableDefinition
helper methods for sorting
func (TableDefinitions) Len ¶
func (tds TableDefinitions) Len() int
func (TableDefinitions) Swap ¶
func (tds TableDefinitions) Swap(i, j int)
type UserPermission ¶
type UserPermission struct { Host string User string PasswordChecksum uint64 Privileges map[string]string }
UserPermission describes a single row in the mysql.user table Primary key is Host+User PasswordChecksum is the crc64 of the password, for security reasons
func NewUserPermission ¶
func NewUserPermission(fields []proto.Field, values []sqltypes.Value) *UserPermission
func (*UserPermission) PrimaryKey ¶
func (up *UserPermission) PrimaryKey() string
func (*UserPermission) String ¶
func (up *UserPermission) String() string
type UserPermissionList ¶
type UserPermissionList []*UserPermission
func (UserPermissionList) Get ¶
func (upl UserPermissionList) Get(i int) Permission
func (UserPermissionList) Len ¶
func (upl UserPermissionList) Len() int