Documentation ¶
Overview ¶
Package tmutils contains helper methods to deal with the tabletmanagerdata proto3 structures.
Index ¶
- Constants
- func DbPermissionPrimaryKey(dp *tabletmanagerdatapb.DbPermission) string
- func DbPermissionString(dp *tabletmanagerdatapb.DbPermission) string
- func DiffPermissions(leftName string, left *tabletmanagerdatapb.Permissions, rightName string, ...)
- func DiffPermissionsToArray(leftName string, left *tabletmanagerdatapb.Permissions, rightName string, ...) (result []string)
- func DiffSchema(leftName string, left *tabletmanagerdatapb.SchemaDefinition, rightName string, ...)
- func DiffSchemaToArray(leftName string, left *tabletmanagerdatapb.SchemaDefinition, rightName string, ...) (result []string)
- func FilterTables(sd *tabletmanagerdatapb.SchemaDefinition, tables, excludeTables []string, ...) (*tabletmanagerdatapb.SchemaDefinition, error)
- func GenerateSchemaVersion(sd *tabletmanagerdatapb.SchemaDefinition)
- func NewDbPermission(fields []*querypb.Field, values []sqltypes.Value) *tabletmanagerdatapb.DbPermission
- func NewUserPermission(fields []*querypb.Field, values []sqltypes.Value) *tabletmanagerdatapb.UserPermission
- func PermissionsString(permissions *tabletmanagerdatapb.Permissions) string
- func SchemaDefinitionGetTable(sd *tabletmanagerdatapb.SchemaDefinition, table string) (td *tabletmanagerdatapb.TableDefinition, ok bool)
- func SchemaDefinitionToSQLStrings(sd *tabletmanagerdatapb.SchemaDefinition) []string
- func TableDefinitionGetColumn(td *tabletmanagerdatapb.TableDefinition, name string) (index int, ok bool)
- func UserPermissionPrimaryKey(up *tabletmanagerdatapb.UserPermission) string
- func UserPermissionString(up *tabletmanagerdatapb.UserPermission) string
- type SchemaChange
- type TableDefinitions
- type TableFilter
Constants ¶
const ( // TableBaseTable indicates the table type is a base table. TableBaseTable = "BASE TABLE" // TableView indicates the table type is a view. TableView = "VIEW" )
Variables ¶
This section is empty.
Functions ¶
func DbPermissionPrimaryKey ¶
func DbPermissionPrimaryKey(dp *tabletmanagerdatapb.DbPermission) string
DbPermissionPrimaryKey returns the sorting key for a DbPermission
func DbPermissionString ¶
func DbPermissionString(dp *tabletmanagerdatapb.DbPermission) string
DbPermissionString pretty-prints a DbPermission
func DiffPermissions ¶
func DiffPermissions(leftName string, left *tabletmanagerdatapb.Permissions, rightName string, right *tabletmanagerdatapb.Permissions, er concurrency.ErrorRecorder)
DiffPermissions records the errors between two permission sets
func DiffPermissionsToArray ¶
func DiffPermissionsToArray(leftName string, left *tabletmanagerdatapb.Permissions, rightName string, right *tabletmanagerdatapb.Permissions) (result []string)
DiffPermissionsToArray difs two sets of permissions, and returns the difference
func DiffSchema ¶
func DiffSchema(leftName string, left *tabletmanagerdatapb.SchemaDefinition, rightName string, right *tabletmanagerdatapb.SchemaDefinition, er concurrency.ErrorRecorder)
DiffSchema generates a report on what's different between two SchemaDefinitions including views, but Vitess internal tables are ignored.
func DiffSchemaToArray ¶
func DiffSchemaToArray(leftName string, left *tabletmanagerdatapb.SchemaDefinition, rightName string, right *tabletmanagerdatapb.SchemaDefinition) (result []string)
DiffSchemaToArray diffs two schemas and return the schema diffs if there is any.
func FilterTables ¶
func FilterTables(sd *tabletmanagerdatapb.SchemaDefinition, tables, excludeTables []string, includeViews bool) (*tabletmanagerdatapb.SchemaDefinition, error)
FilterTables returns a copy which includes only whitelisted tables (tables), no denied tables (excludeTables) and optionally views (includeViews).
func GenerateSchemaVersion ¶
func GenerateSchemaVersion(sd *tabletmanagerdatapb.SchemaDefinition)
GenerateSchemaVersion return a unique schema version string based on its TableDefinitions.
func NewDbPermission ¶
func NewDbPermission(fields []*querypb.Field, values []sqltypes.Value) *tabletmanagerdatapb.DbPermission
NewDbPermission is a helper method to create a tabletmanagerdatapb.DbPermission
func NewUserPermission ¶
func NewUserPermission(fields []*querypb.Field, values []sqltypes.Value) *tabletmanagerdatapb.UserPermission
NewUserPermission is a helper method to create a tabletmanagerdatapb.UserPermission
func PermissionsString ¶
func PermissionsString(permissions *tabletmanagerdatapb.Permissions) string
PermissionsString pretty-prints Permissions
func SchemaDefinitionGetTable ¶
func SchemaDefinitionGetTable(sd *tabletmanagerdatapb.SchemaDefinition, table string) (td *tabletmanagerdatapb.TableDefinition, ok bool)
SchemaDefinitionGetTable returns TableDefinition for a given table name.
func SchemaDefinitionToSQLStrings ¶
func SchemaDefinitionToSQLStrings(sd *tabletmanagerdatapb.SchemaDefinition) []string
SchemaDefinitionToSQLStrings 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.
func TableDefinitionGetColumn ¶
func TableDefinitionGetColumn(td *tabletmanagerdatapb.TableDefinition, name string) (index int, ok bool)
TableDefinitionGetColumn returns the index of a column inside a TableDefinition.
func UserPermissionPrimaryKey ¶
func UserPermissionPrimaryKey(up *tabletmanagerdatapb.UserPermission) string
UserPermissionPrimaryKey returns the sorting key for a UserPermission
func UserPermissionString ¶
func UserPermissionString(up *tabletmanagerdatapb.UserPermission) string
UserPermissionString pretty-prints a UserPermission
Types ¶
type SchemaChange ¶
type SchemaChange struct { SQL string Force bool AllowReplication bool BeforeSchema *tabletmanagerdatapb.SchemaDefinition AfterSchema *tabletmanagerdatapb.SchemaDefinition SQLMode string }
SchemaChange contains all necessary information to apply a schema change. It should not be sent over the wire, it's just a set of parameters.
func (*SchemaChange) Equal ¶
func (s *SchemaChange) Equal(s2 *SchemaChange) bool
Equal compares two SchemaChange objects.
type TableDefinitions ¶
type TableDefinitions []*tabletmanagerdatapb.TableDefinition
TableDefinitions is a list of TableDefinition, for sorting
func (TableDefinitions) Len ¶
func (tds TableDefinitions) Len() int
Len returns TableDefinitions length.
func (TableDefinitions) Swap ¶
func (tds TableDefinitions) Swap(i, j int)
Swap used for sorting TableDefinitions.
type TableFilter ¶
type TableFilter struct {
// contains filtered or unexported fields
}
TableFilter is a filter for table names and types.
func NewTableFilter ¶
func NewTableFilter(tables, excludeTables []string, includeViews bool) (*TableFilter, error)
NewTableFilter creates a TableFilter for whitelisted tables (tables), no denied tables (excludeTables) and optionally views (includeViews).