MySQL 8.3.0
Source Code Documentation
MY_COLLATION_HANDLER Struct Reference

#include <m_ctype.h>

Public Attributes

bool(* init )(CHARSET_INFO *, MY_CHARSET_LOADER *, MY_CHARSET_ERRMSG *)
 
void(* uninit )(CHARSET_INFO *, MY_CHARSET_LOADER *)
 
int(* strnncoll )(const CHARSET_INFO *, const uint8_t *, size_t, const uint8_t *, size_t, bool)
 
int(* strnncollsp )(const CHARSET_INFO *, const uint8_t *, size_t, const uint8_t *, size_t)
 Compare the two strings under the pad rules given by the collation. More...
 
size_t(* strnxfrm )(const CHARSET_INFO *, uint8_t *dst, size_t dstlen, unsigned num_codepoints, const uint8_t *src, size_t srclen, unsigned flags)
 Transform the string into a form such that memcmp() between transformed strings yields the correct collation order. More...
 
size_t(* strnxfrmlen )(const CHARSET_INFO *, size_t num_bytes)
 Return the maximum number of output bytes needed for strnxfrm() to output all weights for any string of the given input length. More...
 
bool(* like_range )(const CHARSET_INFO *, const char *s, size_t s_length, char w_prefix, char w_one, char w_many, size_t res_length, char *min_str, char *max_str, size_t *min_len, size_t *max_len)
 
int(* wildcmp )(const CHARSET_INFO *, const char *str, const char *str_end, const char *wildstr, const char *wildend, int escape, int w_one, int w_many)
 
int(* strcasecmp )(const CHARSET_INFO *, const char *, const char *)
 
unsigned(* strstr )(const CHARSET_INFO *, const char *b, size_t b_length, const char *s, size_t s_length, my_match_t *match, unsigned nmatch)
 
void(* hash_sort )(const CHARSET_INFO *cs, const uint8_t *key, size_t len, uint64_t *nr1, uint64_t *nr2)
 Compute a sort hash for the given key. More...
 
bool(* propagate )(const CHARSET_INFO *cs, const uint8_t *str, size_t len)
 

Member Data Documentation

◆ hash_sort

void(* MY_COLLATION_HANDLER::hash_sort) (const CHARSET_INFO *cs, const uint8_t *key, size_t len, uint64_t *nr1, uint64_t *nr2)

Compute a sort hash for the given key.

This hash must preserve equality under the given collation, so that a=b => H(a)=H(b). Note that this hash is used for hash-based partitioning (PARTITION KEY), so you cannot change it except when writing a new collation; it needs to be unchanged across releases, so that the on-disk format does not change. (It is also used for testing equality in the MEMORY storage engine.)

nr1 and nr2 are both in/out parameters. nr1 is the actual hash value; nr2 holds extra state between invocations.

◆ init

bool(* MY_COLLATION_HANDLER::init) (CHARSET_INFO *, MY_CHARSET_LOADER *, MY_CHARSET_ERRMSG *)

◆ like_range

bool(* MY_COLLATION_HANDLER::like_range) (const CHARSET_INFO *, const char *s, size_t s_length, char w_prefix, char w_one, char w_many, size_t res_length, char *min_str, char *max_str, size_t *min_len, size_t *max_len)

◆ propagate

bool(* MY_COLLATION_HANDLER::propagate) (const CHARSET_INFO *cs, const uint8_t *str, size_t len)

◆ strcasecmp

int(* MY_COLLATION_HANDLER::strcasecmp) (const CHARSET_INFO *, const char *, const char *)

◆ strnncoll

int(* MY_COLLATION_HANDLER::strnncoll) (const CHARSET_INFO *, const uint8_t *, size_t, const uint8_t *, size_t, bool)

◆ strnncollsp

int(* MY_COLLATION_HANDLER::strnncollsp) (const CHARSET_INFO *, const uint8_t *, size_t, const uint8_t *, size_t)

Compare the two strings under the pad rules given by the collation.

Thus, for NO PAD collations, this is identical to strnncoll with is_prefix set to false. For PAD SPACE collations, the two strings are conceptually extended infinitely at the end using space characters (0x20) and then compared under the collation's normal comparison rules, so that e.g 'a' is equal to 'a '.

◆ strnxfrm

size_t(* MY_COLLATION_HANDLER::strnxfrm) (const CHARSET_INFO *, uint8_t *dst, size_t dstlen, unsigned num_codepoints, const uint8_t *src, size_t srclen, unsigned flags)

Transform the string into a form such that memcmp() between transformed strings yields the correct collation order.

Parameters
[out]dstBuffer for the transformed string.
[out]dstlenNumber of bytes available in dstlen. Must be even.
num_codepointsTreat the string as if it were of type CHAR(num_codepoints). In particular, this means that if the collation is a pad collation (pad_attribute is PAD_SPACE) and string has fewer than "num_codepoints" codepoints, the string will be transformed as if it ended in (num_codepoints-n) extra spaces. If the string has more than "num_codepoints" codepoints, behavior is undefined; may truncate, may crash, or do something else entirely. Note that MY_STRXFRM_PAD_TO_MAXLEN overrides this; if it is given for a PAD SPACE collation, this value is taken to be effectively infinity.
srcThe source string, in the required character set for the collation.
srclenNumber of bytes in src.
flagsORed bitmask of MY_STRXFRM_* flags.
Returns
Number of bytes written to dst.

◆ strnxfrmlen

size_t(* MY_COLLATION_HANDLER::strnxfrmlen) (const CHARSET_INFO *, size_t num_bytes)

Return the maximum number of output bytes needed for strnxfrm() to output all weights for any string of the given input length.

You can use this to e.g. size buffers for sort keys.

Parameters
num_bytesNumber of bytes in the input string. Note that for multibyte character sets, this must be a pessimistic estimate, ie., one that's cs->mbmaxlen * max_num_codepoints. So for e.g. the utf8mb4 string "foo", you will need to give in 12, not 3.

◆ strstr

unsigned(* MY_COLLATION_HANDLER::strstr) (const CHARSET_INFO *, const char *b, size_t b_length, const char *s, size_t s_length, my_match_t *match, unsigned nmatch)

◆ uninit

void(* MY_COLLATION_HANDLER::uninit) (CHARSET_INFO *, MY_CHARSET_LOADER *)

◆ wildcmp

int(* MY_COLLATION_HANDLER::wildcmp) (const CHARSET_INFO *, const char *str, const char *str_end, const char *wildstr, const char *wildend, int escape, int w_one, int w_many)

The documentation for this struct was generated from the following file: