tidb: github.com/pingcap/tidb/util/collate Index | Files

package collate

import "github.com/pingcap/tidb/util/collate"

Index

Package Files

bin.go collate.go general_ci.go

Constants

const (
    DefaultLen = 0
)

DefaultLen is set for datum if the string datum don't know its length.

Variables

var (

    // ErrUnsupportedCollation is returned when an unsupported collation is specified.
    ErrUnsupportedCollation = terror.ClassDDL.New(mysql.ErrUnknownCollation, "Unsupported collation when new collation is enabled: '%-.64s'")
    // ErrIllegalMixCollation is returned when illegal mix of collations.
    ErrIllegalMixCollation = terror.ClassExpression.New(mysql.ErrCantAggregate2collations, mysql.MySQLErrName[mysql.ErrCantAggregate2collations])
)

func CollationID2Name Uses

func CollationID2Name(id int32) string

CollationID2Name return the collation name by the given id. If the id is not found in the map, the default collation is returned.

func CompatibleCollate Uses

func CompatibleCollate(collate1, collate2 string) bool

CompatibleCollate checks whether the two collate are the same.

func EnableNewCollations Uses

func EnableNewCollations()

EnableNewCollations enables the new collation.

func GetCollationByName Uses

func GetCollationByName(name string) (coll *charset.Collation, err error)

GetCollationByName wraps charset.GetCollationByName, it checks the collation.

func GetSupportedCollations Uses

func GetSupportedCollations() []*charset.Collation

GetSupportedCollations gets information for all collations supported so far.

func IsCICollation Uses

func IsCICollation(collate string) bool

IsCICollation returns if the collation is case-sensitive

func NewCollationEnabled Uses

func NewCollationEnabled() bool

NewCollationEnabled returns if the new collations are enabled.

func RestoreCollationIDIfNeeded Uses

func RestoreCollationIDIfNeeded(id int32) int32

RestoreCollationIDIfNeeded restores a collation id if the new collations are enabled.

func RewriteNewCollationIDIfNeeded Uses

func RewriteNewCollationIDIfNeeded(id int32) int32

RewriteNewCollationIDIfNeeded rewrites a collation id if the new collations are enabled. When new collations are enabled, we turn the collation id to negative so that other the components of the cluster(for example, TiKV) is able to aware of it without any change to the protocol definition. When new collations are not enabled, collation id remains the same.

func SetNewCollationEnabledForTest Uses

func SetNewCollationEnabledForTest(flag bool)

SetNewCollationEnabledForTest sets if the new collation are enabled in test. Note: Be careful to use this function, if this functions is used in tests, make sure the tests are serial.

type Collator Uses

type Collator interface {
    // Compare returns an integer comparing the two strings. The result will be 0 if a == b, -1 if a < b, and +1 if a > b.
    Compare(a, b string) int
    // Key returns the collate key for str. If the collation is padding, make sure the PadLen >= len(rune[]str) in opt.
    Key(str string) []byte
    // Pattern get a collation-aware WildcardPattern.
    Pattern() WildcardPattern
}

Collator provides functionality for comparing strings for a given collation order.

func GetCollator Uses

func GetCollator(collate string) Collator

GetCollator get the collator according to collate, it will return the binary collator if the corresponding collator doesn't exist.

func GetCollatorByID Uses

func GetCollatorByID(id int) Collator

GetCollatorByID get the collator according to id, it will return the binary collator if the corresponding collator doesn't exist.

type WildcardPattern Uses

type WildcardPattern interface {
    // Compile compiles the patternStr with specified escape character.
    Compile(patternStr string, escape byte)
    // DoMatch tries to match the str with compiled pattern, `Compile()` must be called before calling it.
    DoMatch(str string) bool
}

WildcardPattern is the interface used for wildcard pattern match.

Package collate imports 11 packages (graph) and is imported by 26 packages. Updated 2020-06-01. Refresh now. Tools for package owners.