Documentation ¶
Index ¶
- func BuildEqualsComparison(columns []string, values []string) (result string, err error)
- func BuildEqualsPreparedComparison(columns []string) (result string, err error)
- func BuildRangeComparison(columns []string, values []string, args []interface{}, ...) (result string, explodedArgs []interface{}, err error)
- func BuildRangeInsertPreparedQuery(databaseName, originalTableName, ghostTableName string, sharedColumns []string, ...) (result string, explodedArgs []interface{}, err error)
- func BuildRangeInsertQuery(databaseName, originalTableName, ghostTableName string, sharedColumns []string, ...) (result string, explodedArgs []interface{}, err error)
- func BuildRangePreparedComparison(columns *ColumnList, args []interface{}, comparisonSign ValueComparisonSign) (result string, explodedArgs []interface{}, err error)
- func BuildSetPreparedClause(columns *ColumnList) (result string, err error)
- func BuildUniqueKeyMaxValuesPreparedQuery(databaseName, tableName string, uniqueKey *UniqueKey) (string, error)
- func BuildUniqueKeyMinValuesPreparedQuery(databaseName, tableName string, uniqueKey *UniqueKey) (string, error)
- func BuildUniqueKeyRangeEndPreparedQueryViaOffset(databaseName, tableName string, uniqueKeyColumns *ColumnList, ...) (result string, explodedArgs []interface{}, err error)
- func BuildUniqueKeyRangeEndPreparedQueryViaTemptable(databaseName, tableName string, uniqueKeyColumns *ColumnList, ...) (result string, explodedArgs []interface{}, err error)
- func BuildValueComparison(column string, value string, comparisonSign ValueComparisonSign) (result string, err error)
- func EscapeName(name string) string
- func ParseEnumValues(enumColumnType string) string
- type AlterTableParser
- func (this *AlterTableParser) DroppedColumnsMap() map[string]bool
- func (this *AlterTableParser) GetAlterStatementOptions() string
- func (this *AlterTableParser) GetExplicitSchema() string
- func (this *AlterTableParser) GetExplicitTable() string
- func (this *AlterTableParser) GetNonTrivialRenames() map[string]string
- func (this *AlterTableParser) HasExplicitSchema() bool
- func (this *AlterTableParser) HasExplicitTable() bool
- func (this *AlterTableParser) HasNonTrivialRenames() bool
- func (this *AlterTableParser) IsAutoIncrementDefined() bool
- func (this *AlterTableParser) IsRenameTable() bool
- func (this *AlterTableParser) ParseAlterStatement(alterStatement string) (err error)
- type CharacterSetConversion
- type Column
- type ColumnList
- func (this *ColumnList) Columns() []Column
- func (this *ColumnList) Equals(other *ColumnList) bool
- func (this *ColumnList) EqualsByNames(other *ColumnList) bool
- func (this *ColumnList) FilterBy(f func(Column) bool) *ColumnList
- func (this *ColumnList) GetCharset(columnName string) string
- func (this *ColumnList) GetColumn(columnName string) *Column
- func (this *ColumnList) GetColumnType(columnName string) ColumnType
- func (this *ColumnList) HasTimezoneConversion(columnName string) bool
- func (this *ColumnList) IsEnumToTextConversion(columnName string) bool
- func (this *ColumnList) IsSubsetOf(other *ColumnList) bool
- func (this *ColumnList) IsUnsigned(columnName string) bool
- func (this *ColumnList) Len() int
- func (this *ColumnList) Names() []string
- func (this *ColumnList) SetCharset(columnName string, charset string)
- func (this *ColumnList) SetCharsetConversion(columnName string, fromCharset string, toCharset string)
- func (this *ColumnList) SetColumnType(columnName string, columnType ColumnType)
- func (this *ColumnList) SetConvertDatetimeToTimestamp(columnName string, toTimezone string)
- func (this *ColumnList) SetEnumToTextConversion(columnName string)
- func (this *ColumnList) SetEnumValues(columnName string, enumValues string)
- func (this *ColumnList) SetUnsigned(columnName string)
- func (this *ColumnList) String() string
- type ColumnType
- type ColumnValues
- type ColumnsMap
- type DMLDeleteQueryBuilder
- type DMLInsertQueryBuilder
- type DMLUpdateQueryBuilder
- type TimezoneConversion
- type UniqueKey
- type ValueComparisonSign
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildEqualsComparison ¶
func BuildRangeComparison ¶
func BuildRangeComparison(columns []string, values []string, args []interface{}, comparisonSign ValueComparisonSign) (result string, explodedArgs []interface{}, err error)
func BuildRangeInsertPreparedQuery ¶
func BuildRangeInsertPreparedQuery(databaseName, originalTableName, ghostTableName string, sharedColumns []string, mappedSharedColumns []string, uniqueKey string, uniqueKeyColumns *ColumnList, rangeStartArgs, rangeEndArgs []interface{}, includeRangeStartValues bool, transactionalTable bool, noWait bool) (result string, explodedArgs []interface{}, err error)
func BuildRangeInsertQuery ¶
func BuildRangeInsertQuery(databaseName, originalTableName, ghostTableName string, sharedColumns []string, mappedSharedColumns []string, uniqueKey string, uniqueKeyColumns *ColumnList, rangeStartValues, rangeEndValues []string, rangeStartArgs, rangeEndArgs []interface{}, includeRangeStartValues bool, transactionalTable bool, noWait bool) (result string, explodedArgs []interface{}, err error)
func BuildRangePreparedComparison ¶
func BuildRangePreparedComparison(columns *ColumnList, args []interface{}, comparisonSign ValueComparisonSign) (result string, explodedArgs []interface{}, err error)
func BuildSetPreparedClause ¶
func BuildSetPreparedClause(columns *ColumnList) (result string, err error)
func BuildUniqueKeyRangeEndPreparedQueryViaOffset ¶ added in v1.0.42
func BuildUniqueKeyRangeEndPreparedQueryViaTemptable ¶ added in v1.0.42
func BuildValueComparison ¶
func BuildValueComparison(column string, value string, comparisonSign ValueComparisonSign) (result string, err error)
func EscapeName ¶
EscapeName will escape a db/table/column/... name by wrapping with backticks. It is not fool proof. I'm just trying to do the right thing here, not solving SQL injection issues, which should be irrelevant for this tool.
func ParseEnumValues ¶ added in v1.1.2
Types ¶
type AlterTableParser ¶ added in v1.1.0
type AlterTableParser struct {
// contains filtered or unexported fields
}
func NewAlterTableParser ¶ added in v1.1.0
func NewAlterTableParser() *AlterTableParser
func NewParserFromAlterStatement ¶ added in v1.1.0
func NewParserFromAlterStatement(alterStatement string) *AlterTableParser
func (*AlterTableParser) DroppedColumnsMap ¶ added in v1.1.0
func (this *AlterTableParser) DroppedColumnsMap() map[string]bool
func (*AlterTableParser) GetAlterStatementOptions ¶ added in v1.1.0
func (this *AlterTableParser) GetAlterStatementOptions() string
func (*AlterTableParser) GetExplicitSchema ¶ added in v1.1.0
func (this *AlterTableParser) GetExplicitSchema() string
func (*AlterTableParser) GetExplicitTable ¶ added in v1.1.0
func (this *AlterTableParser) GetExplicitTable() string
func (*AlterTableParser) GetNonTrivialRenames ¶ added in v1.1.0
func (this *AlterTableParser) GetNonTrivialRenames() map[string]string
func (*AlterTableParser) HasExplicitSchema ¶ added in v1.1.0
func (this *AlterTableParser) HasExplicitSchema() bool
func (*AlterTableParser) HasExplicitTable ¶ added in v1.1.0
func (this *AlterTableParser) HasExplicitTable() bool
func (*AlterTableParser) HasNonTrivialRenames ¶ added in v1.1.0
func (this *AlterTableParser) HasNonTrivialRenames() bool
func (*AlterTableParser) IsAutoIncrementDefined ¶ added in v1.1.2
func (this *AlterTableParser) IsAutoIncrementDefined() bool
func (*AlterTableParser) IsRenameTable ¶ added in v1.1.0
func (this *AlterTableParser) IsRenameTable() bool
func (*AlterTableParser) ParseAlterStatement ¶ added in v1.1.0
func (this *AlterTableParser) ParseAlterStatement(alterStatement string) (err error)
type CharacterSetConversion ¶ added in v1.1.6
type Column ¶ added in v1.0.20
type Column struct { Name string IsUnsigned bool IsVirtual bool Charset string Type ColumnType EnumValues string // 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 uint // contains filtered or unexported fields }
func NewColumns ¶ added in v1.0.20
func ParseColumns ¶ added in v1.0.20
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) Columns ¶ added in v1.0.20
func (this *ColumnList) Columns() []Column
func (*ColumnList) Equals ¶
func (this *ColumnList) Equals(other *ColumnList) bool
func (*ColumnList) EqualsByNames ¶ added in v1.0.20
func (this *ColumnList) EqualsByNames(other *ColumnList) bool
func (*ColumnList) FilterBy ¶ added in v1.1.7
func (this *ColumnList) FilterBy(f func(Column) bool) *ColumnList
func (*ColumnList) GetCharset ¶ added in v1.0.20
func (this *ColumnList) GetCharset(columnName string) string
func (*ColumnList) GetColumn ¶ added in v1.0.28
func (this *ColumnList) GetColumn(columnName string) *Column
func (*ColumnList) GetColumnType ¶ added in v1.0.28
func (this *ColumnList) GetColumnType(columnName string) ColumnType
func (*ColumnList) HasTimezoneConversion ¶ added in v1.0.28
func (this *ColumnList) HasTimezoneConversion(columnName string) bool
func (*ColumnList) IsEnumToTextConversion ¶ added in v1.1.2
func (this *ColumnList) IsEnumToTextConversion(columnName string) bool
func (*ColumnList) IsSubsetOf ¶
func (this *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) IsUnsigned ¶ added in v1.0.10
func (this *ColumnList) IsUnsigned(columnName string) bool
func (*ColumnList) Len ¶
func (this *ColumnList) Len() int
func (*ColumnList) Names ¶
func (this *ColumnList) Names() []string
func (*ColumnList) SetCharset ¶ added in v1.0.20
func (this *ColumnList) SetCharset(columnName string, charset string)
func (*ColumnList) SetCharsetConversion ¶ added in v1.1.6
func (this *ColumnList) SetCharsetConversion(columnName string, fromCharset string, toCharset string)
func (*ColumnList) SetColumnType ¶ added in v1.0.28
func (this *ColumnList) SetColumnType(columnName string, columnType ColumnType)
func (*ColumnList) SetConvertDatetimeToTimestamp ¶ added in v1.0.28
func (this *ColumnList) SetConvertDatetimeToTimestamp(columnName string, toTimezone string)
func (*ColumnList) SetEnumToTextConversion ¶ added in v1.1.2
func (this *ColumnList) SetEnumToTextConversion(columnName string)
func (*ColumnList) SetEnumValues ¶ added in v1.1.2
func (this *ColumnList) SetEnumValues(columnName string, enumValues string)
func (*ColumnList) SetUnsigned ¶ added in v1.0.10
func (this *ColumnList) SetUnsigned(columnName string)
func (*ColumnList) String ¶
func (this *ColumnList) String() string
type ColumnType ¶ added in v1.0.28
type ColumnType int
const ( UnknownColumnType ColumnType = iota TimestampColumnType DateTimeColumnType EnumColumnType MediumIntColumnType JSONColumnType FloatColumnType BinaryColumnType )
type ColumnValues ¶
type ColumnValues struct { ValuesPointers []interface{} // contains filtered or unexported fields }
func NewColumnValues ¶
func NewColumnValues(length int) *ColumnValues
func ToColumnValues ¶
func ToColumnValues(abstractValues []interface{}) *ColumnValues
func (*ColumnValues) AbstractValues ¶
func (this *ColumnValues) AbstractValues() []interface{}
func (*ColumnValues) String ¶
func (this *ColumnValues) String() string
func (*ColumnValues) StringColumn ¶
func (this *ColumnValues) StringColumn(index int) string
type ColumnsMap ¶
ColumnsMap maps a column name onto its ordinal position
func NewColumnsMap ¶
func NewColumnsMap(orderedColumns []Column) ColumnsMap
func NewEmptyColumnsMap ¶ added in v1.0.10
func NewEmptyColumnsMap() ColumnsMap
type DMLDeleteQueryBuilder ¶ added in v1.1.7
type DMLDeleteQueryBuilder struct {
// contains filtered or unexported fields
}
DMLDeleteQueryBuilder can build DELETE queries for DML events. It holds the prepared query statement so it doesn't need to be recreated every time.
func NewDMLDeleteQueryBuilder ¶ added in v1.1.7
func NewDMLDeleteQueryBuilder(databaseName, tableName string, tableColumns, uniqueKeyColumns *ColumnList) (*DMLDeleteQueryBuilder, error)
NewDMLDeleteQueryBuilder creates a new DMLDeleteQueryBuilder. It prepares the DELETE query statement. Returns an error if no unique key columns are given or the prepared statement cannot be built.
func (*DMLDeleteQueryBuilder) BuildQuery ¶ added in v1.1.7
func (b *DMLDeleteQueryBuilder) BuildQuery(args []interface{}) (string, []interface{}, error)
BuildQuery builds the arguments array for a DML event DELETE query. It returns the query string and the unique key arguments array. Returns an error if the number of arguments is not equal to the number of table columns.
type DMLInsertQueryBuilder ¶ added in v1.1.7
type DMLInsertQueryBuilder struct {
// contains filtered or unexported fields
}
DMLInsertQueryBuilder can build INSERT queries for DML events. It holds the prepared query statement so it doesn't need to be recreated every time.
func NewDMLInsertQueryBuilder ¶ added in v1.1.7
func NewDMLInsertQueryBuilder(databaseName, tableName string, tableColumns, sharedColumns, mappedSharedColumns *ColumnList) (*DMLInsertQueryBuilder, error)
NewDMLInsertQueryBuilder creates a new DMLInsertQueryBuilder. It prepares the INSERT query statement. Returns an error if no shared columns are given, the shared columns are not a subset of the table columns, or the prepared statement cannot be built.
func (*DMLInsertQueryBuilder) BuildQuery ¶ added in v1.1.7
func (b *DMLInsertQueryBuilder) BuildQuery(args []interface{}) (string, []interface{}, error)
BuildQuery builds the arguments array for a DML event INSERT query. It returns the query string and the shared arguments array. Returns an error if the number of arguments differs from the number of table columns.
type DMLUpdateQueryBuilder ¶ added in v1.1.7
type DMLUpdateQueryBuilder struct {
// contains filtered or unexported fields
}
DMLUpdateQueryBuilder can build UPDATE queries for DML events. It holds the prepared query statement so it doesn't need to be recreated every time.
func NewDMLUpdateQueryBuilder ¶ added in v1.1.7
func NewDMLUpdateQueryBuilder(databaseName, tableName string, tableColumns, sharedColumns, mappedSharedColumns, uniqueKeyColumns *ColumnList) (*DMLUpdateQueryBuilder, error)
NewDMLUpdateQueryBuilder creates a new DMLUpdateQueryBuilder. It prepares the UPDATE query statement. Returns an error if no shared columns are given, the shared columns are not a subset of the table columns, no unique key columns are given or the prepared statement cannot be built.
func (*DMLUpdateQueryBuilder) BuildQuery ¶ added in v1.1.7
func (b *DMLUpdateQueryBuilder) BuildQuery(valueArgs, whereArgs []interface{}) (string, []interface{}, []interface{}, error)
BuildQuery builds the arguments array for a DML event UPDATE query. It returns the query string, the shared arguments array, and the unique key arguments array.
type TimezoneConversion ¶ added in v1.0.44
type TimezoneConversion struct {
ToTimezone string
}
type UniqueKey ¶
type UniqueKey struct { Name string Columns ColumnList HasNullable bool IsAutoIncrement bool }
UniqueKey is the combination of a key's name and columns
type ValueComparisonSign ¶
type ValueComparisonSign string
const ( LessThanComparisonSign ValueComparisonSign = "<" LessThanOrEqualsComparisonSign ValueComparisonSign = "<=" EqualsComparisonSign ValueComparisonSign = "=" GreaterThanOrEqualsComparisonSign ValueComparisonSign = ">=" GreaterThanComparisonSign ValueComparisonSign = ">" NotEqualsComparisonSign ValueComparisonSign = "!=" )