tmutils

package
Version: v2.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: May 22, 2017 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package tmutils contains helper methods to deal with the tabletmanagerdata proto3 structures.

Index

Constants

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

DiffSchema generates a report on what's different between two SchemaDefinitions including views.

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 blacklisted tables (excludeTables) and optionally views (includeViews).

func FindBlpPositionByID

func FindBlpPositionByID(list []*tabletmanagerdatapb.BlpPosition, uid uint32) *tabletmanagerdatapb.BlpPosition

FindBlpPositionByID returns the BlpPosition with the given id, or error

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
}

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.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL