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 ¶
- func AccentSensitive(name string) bool
- func AccentSensitivityLost(from, to string) bool
- func CaseSensitive(name string) bool
- func Caveats(from, to string, fallback bool) []string
- func CharsetSupported(name string) bool
- func CollationCharset(name string) string
- func CollationSupported(name string) bool
- func SensitivityChanged(from, to string) bool
- type CollationResolver
- type Reporter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AccentSensitive ¶
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 ¶
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 ¶
CaseSensitive reports whether a collation name compares case-sensitively (binary, or an explicit _cs suffix).
func Caveats ¶
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 ¶
CharsetSupported reports whether TiDB accepts the charset name.
func CollationCharset ¶
CollationCharset returns the charset prefix of a collation name.
func CollationSupported ¶
CollationSupported reports whether TiDB accepts the collation name.
func SensitivityChanged ¶
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.