Documentation ¶
Index ¶
- Constants
- Variables
- func CollationID2Name(id int32) string
- func CollationName2ID(name string) int
- func CollationToProto(c string) int32
- func CompatibleCollate(collate1, collate2 string) bool
- func ConvertAndGetBinCollation(collate string) string
- func GetCollationByName(name string) (coll *charset.Collation, err error)
- func GetSupportedCollations() []*charset.Collation
- func IsBinCollation(collate string) bool
- func IsCICollation(collate string) bool
- func IsDefaultCollationForUTF8MB4(collate string) bool
- func NewCollationEnabled() bool
- func ProtoToCollation(c int32) string
- func RestoreCollationIDIfNeeded(id int32) int32
- func RewriteNewCollationIDIfNeeded(id int32) int32
- func SetNewCollationEnabledForTest(flag bool)
- func SubstituteMissingCollationToDefault(co string) string
- type Collator
- type WildcardPattern
Constants ¶
const (
// DefaultLen is set for datum if the string datum don't know its length.
DefaultLen = 0
)
Variables ¶
var ( // ErrUnsupportedCollation is returned when an unsupported collation is specified. ErrUnsupportedCollation = dbterror.ClassDDL.NewStdErr(mysql.ErrUnknownCollation, mysql.Message("Unsupported collation when new collation is enabled: '%-.64s'", nil)) // ErrIllegalMixCollation is returned when illegal mix of collations. ErrIllegalMixCollation = dbterror.ClassExpression.NewStd(mysql.ErrCantAggregateNcollations) // ErrIllegalMix2Collation is returned when illegal mix of 2 collations. ErrIllegalMix2Collation = dbterror.ClassExpression.NewStd(mysql.ErrCantAggregate2collations) // ErrIllegalMix3Collation is returned when illegal mix of 3 collations. ErrIllegalMix3Collation = dbterror.ClassExpression.NewStd(mysql.ErrCantAggregate3collations) )
Functions ¶
func CollationID2Name ¶
CollationID2Name return the collation name by the given id. If the id is not found in the map, the default collation is returned.
func CollationName2ID ¶
CollationName2ID return the collation id by the given name. If the name is not found in the map, the default collation id is returned
func CollationToProto ¶
CollationToProto converts collation from string to int32(used by protocol).
func CompatibleCollate ¶
CompatibleCollate checks whether the two collate are the same.
func ConvertAndGetBinCollation ¶
ConvertAndGetBinCollation converts collation to binary collation
func GetCollationByName ¶
GetCollationByName wraps charset.GetCollationByName, it checks the collation.
func GetSupportedCollations ¶
GetSupportedCollations gets information for all collations supported so far.
func IsBinCollation ¶
IsBinCollation returns if the collation is 'xx_bin' or 'bin'. The function is to determine whether the sortkey of a char type of data under the collation is equal to the data itself, and both xx_bin and collationBin are satisfied.
func IsCICollation ¶
IsCICollation returns if the collation is case-insensitive
func IsDefaultCollationForUTF8MB4 ¶
IsDefaultCollationForUTF8MB4 returns if the collation is DefaultCollationForUTF8MB4.
func NewCollationEnabled ¶
func NewCollationEnabled() bool
NewCollationEnabled returns if the new collations are enabled.
func ProtoToCollation ¶
ProtoToCollation converts collation from int32(used by protocol) to string.
func RestoreCollationIDIfNeeded ¶
RestoreCollationIDIfNeeded restores a collation id if the new collations are enabled.
func RewriteNewCollationIDIfNeeded ¶
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 ¶
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.
func SubstituteMissingCollationToDefault ¶
SubstituteMissingCollationToDefault will switch to the default collation if new collations are enabled and the specified collation is not supported.
Types ¶
type Collator ¶
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 // KeyWithoutTrimRightSpace returns the collate key for str. The difference with Key is str will not be trimed. KeyWithoutTrimRightSpace(str string) []byte // Pattern get a collation-aware WildcardPattern. Pattern() WildcardPattern }
Collator provides functionality for comparing strings for a given collation order.
func ConvertAndGetBinCollator ¶
ConvertAndGetBinCollator converts collation to binary collator
func GetBinaryCollator ¶
func GetBinaryCollator() Collator
GetBinaryCollator gets the binary collator, it is often used when we want to apply binary compare.
func GetBinaryCollatorSlice ¶
GetBinaryCollatorSlice gets the binary collator slice with len n.
func GetCollator ¶
GetCollator get the collator according to collate, it will return the binary collator if the corresponding collator doesn't exist.
func GetCollatorByID ¶
GetCollatorByID get the collator according to id, it will return the binary collator if the corresponding collator doesn't exist.
type WildcardPattern ¶
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.