vrepl

package
v0.12.5 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlterTableParser

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

AlterTableParser is a parser tool for ALTER TABLE statements This is imported from gh-ost. In the future, we should replace that with Vitess parsing.

func NewAlterTableParser

func NewAlterTableParser() *AlterTableParser

NewAlterTableParser creates a new parser

func NewParserFromAlterStatement

func NewParserFromAlterStatement(alterStatement string) *AlterTableParser

NewParserFromAlterStatement creates a new parser with a ALTER TABLE statement

func (*AlterTableParser) ColumnRenameMap

func (p *AlterTableParser) ColumnRenameMap() map[string]string

ColumnRenameMap returns the renamed column mapping

func (*AlterTableParser) DroppedColumnsMap

func (p *AlterTableParser) DroppedColumnsMap() map[string]bool

DroppedColumnsMap returns list of dropped columns

func (*AlterTableParser) GetAlterStatementOptions

func (p *AlterTableParser) GetAlterStatementOptions() string

GetAlterStatementOptions returns the options section in the ALTER TABLE statement

func (*AlterTableParser) GetExplicitSchema

func (p *AlterTableParser) GetExplicitSchema() string

GetExplicitSchema returns the explciit schema, if defined

func (*AlterTableParser) GetExplicitTable

func (p *AlterTableParser) GetExplicitTable() string

GetExplicitTable return the table name

func (*AlterTableParser) GetNonTrivialRenames

func (p *AlterTableParser) GetNonTrivialRenames() map[string]string

GetNonTrivialRenames gets a list of renamed column

func (*AlterTableParser) HasExplicitSchema

func (p *AlterTableParser) HasExplicitSchema() bool

HasExplicitSchema returns true when the ALTER TABLE statement includes the schema qualifier

func (*AlterTableParser) HasExplicitTable

func (p *AlterTableParser) HasExplicitTable() bool

HasExplicitTable checks if the ALTER TABLE statement has an explicit table name

func (*AlterTableParser) HasNonTrivialRenames

func (p *AlterTableParser) HasNonTrivialRenames() bool

HasNonTrivialRenames is true when columns have been renamed

func (*AlterTableParser) IsAutoIncrementDefined

func (p *AlterTableParser) IsAutoIncrementDefined() bool

IsAutoIncrementDefined returns true when alter options include an explicit AUTO_INCREMENT value

func (*AlterTableParser) IsRenameTable

func (p *AlterTableParser) IsRenameTable() bool

IsRenameTable returns true when the ALTER TABLE statement inclusdes renaming the table

func (*AlterTableParser) ParseAlterStatement

func (p *AlterTableParser) ParseAlterStatement(alterStatement string) (err error)

ParseAlterStatement is the main function of th eparser, and parses an ALTER TABLE statement

type Column

type Column struct {
	Name                 string
	IsUnsigned           bool
	Charset              string
	Collation            string
	Type                 ColumnType
	EnumValues           string
	EnumToTextConversion bool

	// add Octet length for binary type, fix bytes with suffix "00" get clipped in mysql binlog.
	// https://github.com/github/gh-ost/issues/909
	BinaryOctetLength uint64
}

Column represents a table column

func NewColumns

func NewColumns(names []string) []Column

NewColumns creates a new column array from non empty names

func ParseColumns

func ParseColumns(names string) []Column

ParseColumns creates a new column array fby parsing comma delimited names list

func (*Column) SetTypeIfUnknown added in v0.11.0

func (c *Column) SetTypeIfUnknown(t ColumnType)

SetTypeIfUnknown will set a new column type only if the current type is unknown, otherwise silently skip

type ColumnList

type ColumnList struct {
	Ordinals ColumnsMap
	// contains filtered or unexported fields
}

ColumnList makes for a named list of columns

func NewColumnList

func NewColumnList(names []string) *ColumnList

NewColumnList creates an object given ordered list of column names

func ParseColumnList

func ParseColumnList(names string) *ColumnList

ParseColumnList parses a comma delimited list of column names

func (*ColumnList) ColumnExists added in v0.12.0

func (l *ColumnList) ColumnExists(columnName string) bool

ColumnExists returns true if this column list has a column by a given name

func (*ColumnList) Columns

func (l *ColumnList) Columns() []Column

Columns returns the list of columns

func (*ColumnList) Difference added in v0.12.0

func (l *ColumnList) Difference(other *ColumnList) (diff *ColumnList)

Difference returns a (new copy) subset of this column list, consisting of all column NOT in given list. The result is never nil, even if the difference is empty

func (*ColumnList) Equals

func (l *ColumnList) Equals(other *ColumnList) bool

Equals checks for complete (deep) identities of columns, in order.

func (*ColumnList) EqualsByNames

func (l *ColumnList) EqualsByNames(other *ColumnList) bool

EqualsByNames chcks if the names in this list equals the names of another list, in order. Type is ignored.

func (*ColumnList) GetColumn

func (l *ColumnList) GetColumn(columnName string) *Column

GetColumn gets a column by name

func (*ColumnList) IsEnumToTextConversion added in v0.11.0

func (l *ColumnList) IsEnumToTextConversion(columnName string) bool

IsEnumToTextConversion tells whether an enum was converted to text

func (*ColumnList) IsSubsetOf

func (l *ColumnList) IsSubsetOf(other *ColumnList) bool

IsSubsetOf returns 'true' when column names of this list are a subset of another list, in arbitrary order (order agnostic)

func (*ColumnList) Len

func (l *ColumnList) Len() int

Len returns the length of this list

func (*ColumnList) MappedNamesColumnList added in v0.12.0

func (l *ColumnList) MappedNamesColumnList(columnNamesMap map[string]string) *ColumnList

MappedNamesColumnList returns a column list based on this list, with names possibly mapped by given map

func (*ColumnList) Names

func (l *ColumnList) Names() []string

Names returns list of column names

func (*ColumnList) SetEnumToTextConversion added in v0.11.0

func (l *ColumnList) SetEnumToTextConversion(columnName string, enumValues string)

SetEnumToTextConversion tells this column list that an enum is conveted to text

func (*ColumnList) String

func (l *ColumnList) String() string

String returns a comma separated list of column names

type ColumnType

type ColumnType int

ColumnType indicated some MySQL data types

const (
	UnknownColumnType ColumnType = iota
	TimestampColumnType
	DateTimeColumnType
	EnumColumnType
	MediumIntColumnType
	JSONColumnType
	FloatColumnType
	BinaryColumnType
	StringColumnType
	IntegerColumnType
)

type ColumnsMap

type ColumnsMap map[string]int

ColumnsMap maps a column name onto its ordinal position

func NewColumnsMap

func NewColumnsMap(orderedColumns []Column) ColumnsMap

NewColumnsMap creates a column map based on ordered list of columns

func NewEmptyColumnsMap

func NewEmptyColumnsMap() ColumnsMap

NewEmptyColumnsMap creates an empty map

type UniqueKey

type UniqueKey struct {
	Name            string
	Columns         ColumnList
	HasNullable     bool
	IsAutoIncrement bool
}

UniqueKey is the combination of a key's name and columns

func (*UniqueKey) IsPrimary

func (k *UniqueKey) IsPrimary() bool

IsPrimary checks if this unique key is primary

func (*UniqueKey) Len

func (k *UniqueKey) Len() int

Len returns the length of this list

func (*UniqueKey) String

func (k *UniqueKey) String() string

String returns a visual representation of this key

Jump to

Keyboard shortcuts

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