proto

package
v0.0.0-...-d271c08 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2014 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
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

func EncodeGTID(gtid GTID) string

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

type DbPermission struct {
	Host       string
	Db         string
	User       string
	Privileges map[string]string
}

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

func DecodeGTID(s string) (GTID, error)

DecodeGTID converts a string in the format returned by EncodeGTID back into a GTID interface value with the correct underlying flavor.

func MustDecodeGTID

func MustDecodeGTID(s string) GTID

MustDecodeGTID calls DecodeGTID and panics on error.

func MustParseGTID

func MustParseGTID(flavor, value string) GTID

MustParseGTID calls ParseGTID and panics on error.

func ParseGTID

func ParseGTID(flavor, value string) (GTID, error)

ParseGTID calls the GTID parser for the specified flavor.

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

func (gf GTIDField) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

func (GTIDField) String

func (gf GTIDField) String() 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

func (gf *GTIDField) UnmarshalBson(buf *bytes.Buffer, kind byte)

UnmarshalBson bson-decodes into GTIDField.

func (*GTIDField) UnmarshalJSON

func (gf *GTIDField) UnmarshalJSON(buf []byte) error

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) Flavor

func (gtid GoogleGTID) Flavor() string

Flavor implements GTID.Flavor().

func (GoogleGTID) GTIDSet

func (gtid GoogleGTID) GTIDSet() GTIDSet

GTIDSet implements GTID.GTIDSet().

func (GoogleGTID) Last

func (gtid GoogleGTID) Last() GTID

Last implements GTIDSet.Last().

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

type HostPermission struct {
	Host       string
	Db         string
	Privileges map[string]string
}

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) Last

func (gtid MariadbGTID) Last() GTID

Last implements GTIDSet.Last().

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 Permission interface {
	PrimaryKey() string
	String() string
}

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

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)

func (*ReplicationStatus) MasterAddr

func (rs *ReplicationStatus) MasterAddr() string

func (*ReplicationStatus) SlaveRunning

func (rs *ReplicationStatus) SlaveRunning() bool

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

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

Jump to

Keyboard shortcuts

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