compat

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package compat holds TiDB compatibility facts shared by the loader and the transformation rules: which collations and engines TiDB accepts, how MariaDB-only names map onto them, and a collector for migration warnings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccentSensitive

func AccentSensitive(name string) bool

AccentSensitive reports a case-insensitive collation that still tells accents apart: MariaDB's *_as_* collations and latin1_general_ci (checked on MariaDB 11.4: 'e' = 'é' is false only for these). Every TiDB *_ci collation is accent-insensitive.

func AccentSensitivityLost

func AccentSensitivityLost(from, to string) bool

AccentSensitivityLost reports a mapping from an accent-sensitive, case-insensitive collation to an accent-insensitive one: values that were distinct (e.g. 'e' and 'é') become equal, so unique keys may reject rows on import.

func CaseSensitive

func CaseSensitive(name string) bool

CaseSensitive reports whether a collation name compares case-sensitively (binary, or an explicit _cs suffix).

func Caveats

func Caveats(from, to string, fallback bool) []string

Caveats describes how comparisons change when a column's collation goes from one name to another; fallback marks a mapping no config chose.

func CharsetSupported

func CharsetSupported(name string) bool

CharsetSupported reports whether TiDB accepts the charset name.

func CollationCharset

func CollationCharset(name string) string

CollationCharset returns the charset prefix of a collation name.

func CollationSupported

func CollationSupported(name string) bool

CollationSupported reports whether TiDB accepts the collation name.

func SensitivityChanged

func SensitivityChanged(from, to string) bool

SensitivityChanged reports a mapping that makes case-insensitive comparisons case-sensitive (only possible for charsets TiDB supports with a binary collation alone, e.g. ascii, latin1 without a mapping).

Types

type CollationResolver

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

CollationResolver maps source collations onto TiDB ones: configured exact names first, then configured wildcard patterns (most specific first, so overlapping patterns resolve deterministically), then a fallback by charset for names TiDB does not support.

func NewCollationResolver

func NewCollationResolver(cfg *config.Config) *CollationResolver

NewCollationResolver builds a resolver from cfg's collation_mappings and charset_mappings. A nil cfg yields the built-in fallback only.

func (*CollationResolver) Resolve

func (r *CollationResolver) Resolve(name string) (string, bool)

Resolve returns the TiDB collation for name and whether it differs from name. Supported names are kept unless explicitly mapped or their charset is mapped to another one (latin1_bin under latin1 -> utf8mb4 becomes utf8mb4_bin; keeping it would be rejected with error 1253).

func (*CollationResolver) ResolveDetail

func (r *CollationResolver) ResolveDetail(name string) (dst string, changed, fallback bool)

ResolveDetail is Resolve that also reports whether the result is a fallback (no configured mapping matched), whose comparison rules are the closest TiDB has rather than a choice the user made.

func (*CollationResolver) ResolveInCharset

func (r *CollationResolver) ResolveInCharset(name string) (dst string, changed, fallback bool)

ResolveInCharset resolves a collation that must stay in its own charset: a COLLATE applied to an expression with an explicit charset, such as CONVERT(x USING latin1) COLLATE latin1_general_cs, whose charset the conversion leaves alone. Supported names are kept.

type Reporter

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

Reporter collects migration warnings: things the conversion changed or dropped that a human should know about. It is safe for concurrent use and all methods are no-ops on a nil *Reporter.

func NewReporter

func NewReporter() *Reporter

NewReporter returns an empty Reporter.

func (*Reporter) Warnf

func (r *Reporter) Warnf(format string, args ...any)

Warnf records a warning; identical messages are recorded once.

func (*Reporter) Warnings

func (r *Reporter) Warnings() []string

Warnings returns the recorded warnings in order of first occurrence.

Jump to

Keyboard shortcuts

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