utils

package
v0.5.0-prerelease Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package utils contains some common utilities used by all other packages.

Index

Constants

View Source
const (
	PrimaryKeySeparator = "-#-" // used to hash a composite primary key
)

Variables

This section is empty.

Functions

func AlgorithmInplaceConsideredSafe

func AlgorithmInplaceConsideredSafe(sql string) error

AlgorithmInplaceConsideredSafe checks to see if all clauses of an ALTER statement are "safe". We consider an operation to be "safe" if it is "In Place" and "Only Modifies Metadata". See https://dev.mysql.com/doc/refman/8.0/en/innodb-online-ddl-operations.html for details. INPLACE DDL is not generally safe for online use in MySQL 8.0, because ADD INDEX can block replicas.

func AlterContainsAddUnique

func AlterContainsAddUnique(sql string) error

AlterContainsAddUnique checks to see if any clauses of an ALTER contains add UNIQUE index. We use this to customize the error returned from checksum fails.

func AlterContainsIndexVisibility

func AlterContainsIndexVisibility(sql string) error

AlterContainsIndexVisibility checks to see if there are any clauses of an ALTER to change index visibility. It really does not make sense for visibility changes to be anything except metadata only changes, because they are used for experiments. An experiment is not rebuilding the table. If you are experimenting setting an index to invisible and plan to switch it back to visible quickly if required, going through a full table rebuild does not make sense.

func AlterContainsUnsupportedClause

func AlterContainsUnsupportedClause(sql string) error

AlterContainsUnsupportedClause checks to see if any clauses of an ALTER statement are unsupported by Spirit. These include clauses like ALGORITHM and LOCK, because they step on the toes of Spirit's own locking and algorithm selection.

func ErrInErr

func ErrInErr(_ error)

ErrInErr is a wrapper func to not nest too deeply in an error being handled inside of an already error path. Not catching the error makes linters unhappy, but because it's already in an error path, there's not much to do.

func HashKey

func HashKey(key []interface{}) string

HashKey is used to convert a composite key into a string so that it can be placed in a map.

func IntersectNonGeneratedColumns

func IntersectNonGeneratedColumns(t1, t2 *table.TableInfo) string

IntersectNonGeneratedColumns returns a string of columns that are in both tables

func StripPort

func StripPort(hostname string) string

func TrimAlter

func TrimAlter(alter string) string

func UnhashKey

func UnhashKey(key string) string

UnhashKey converts a hashed key to a string that can be used in a query.

Types

This section is empty.

Jump to

Keyboard shortcuts

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