MySQL 9.4.0
Source Code Documentation
DTCollation Class Reference

#include <item.h>

Public Member Functions

void set_repertoire_from_charset (const CHARSET_INFO *cs)
 
 DTCollation ()
 
 DTCollation (const CHARSET_INFO *collation_arg, Derivation derivation_arg)
 
void set (const DTCollation &dt)
 
void set (const CHARSET_INFO *collation_arg, Derivation derivation_arg)
 
void set (const CHARSET_INFO *collation_arg, Derivation derivation_arg, uint repertoire_arg)
 
void set_numeric ()
 
void set (const CHARSET_INFO *collation_arg)
 
void set (Derivation derivation_arg)
 
void set_repertoire (uint repertoire_arg)
 
bool aggregate (DTCollation &dt, uint flags=0)
 Aggregate two collations together taking into account their coercibility (aka derivation). More...
 
bool set (DTCollation &dt1, DTCollation &dt2, uint flags=0)
 
const char * derivation_name () const
 

Public Attributes

const CHARSET_INFOcollation
 
Derivation derivation {DERIVATION_NONE}
 
uint repertoire
 

Constructor & Destructor Documentation

◆ DTCollation() [1/2]

DTCollation::DTCollation ( )
inline

◆ DTCollation() [2/2]

DTCollation::DTCollation ( const CHARSET_INFO collation_arg,
Derivation  derivation_arg 
)
inline

Member Function Documentation

◆ aggregate()

bool DTCollation::aggregate ( DTCollation dt,
uint  flags = 0 
)

Aggregate two collations together taking into account their coercibility (aka derivation).

Parameters
dtThe collation to be aggregated with the current one.
flagsModifier flags for the collation aggregation. MY_COLL_ALLOW_SUPERSET_CONV - allow conversion to a superset MY_COLL_ALLOW_COERCIBLE_CONV - allow conversion of a coercible value
Returns
false if the collations can be aggregated, otherwise true.

With successful return, the collation is set according to the rules of collation aggregation.

Collation derivation values are defined as follows:

DERIVATION_EXPLICIT - an explicitly written COLLATE clause
DERIVATION_IMPLICIT - a column
DERIVATION_SYSCONST - a system function
DERIVATION_COERCIBLE - a string constant
DERIVATION_NUMERIC - a numeric constant coerced to a character string
DERIVATION_NULL - a NULL value
DERIVATION_NONE - a mix of two different collations
These are ordered by strength from highest (DERIVATION_EXPLICIT) to lowest (DERIVATION_NONE), and a low enum value means higher strength.

Note that MySQL supports more coercibility types than the SQL standard, which only has explicit, implicit and none collation derivations.

Explicit collation derivation is applied by specifying a COLLATE clause to a character string expression.

Implicit collation derivation is typically used for a column reference.

NONE collation derivation is assigned in some cases where the rules make it impossible to assign a specific collation.

Note that the SYSCONST, COERCIBLE, NUMERIC and NULL collation derivations may be considered as subtypes of IMPLICIT, but with lesser strength.

The function is used in two contexts:

  1. With collation aggregation, the function is only called with collation descriptions with equal and highest derivation strength. The aggregation is performed only with these collation descriptions.
  2. For use in resolving of comparison functions, aggregation is performed on two collation descriptions, possibly with different derivation strength. If derivation strength is equal, the rules observed are the same as those above, otherwise strength is copied from collation description with highest strength.

The rules are as follows:

  1. With different derivation strengths: choose the collation with highest associated strength.
  2. If collations are the same: choose this collation, and the strongest derivation.
  3. If there are more than one entry with EXPLICIT derivation strength, and not all collations are equal, report an error.
  4. If character sets differ and one entry specifies the binary character set: choose this binary character set (with its binary collation).
  5. If character sets differ and one is a superset of another, choose the collation of the superset character set. A character set is a superset of another if: It is utf8mb4 and the other is any UNICODE character set. It is compatible with ASCII and the other character set is ASCII.
  6. If character sets differ and none of the above rules apply: report an error.
  7. If character sets are the same and one collation is binary: choose the binary collation. Exception: if multiple different binary collations are specified, report an error.
  8. If character sets are the same but collations are different: choose the binary collation and return NONE derivation strength if allowed, otherwise report an error.

Note that different character sets are allowed when strengths are different, even with different character repertoires. However, undefined character set conversions are flagged with errors during execution, thus it is always guaranteed that a character string generated during execution contains only characters in its assigned repertoire.

◆ derivation_name()

const char * DTCollation::derivation_name ( ) const
inline

◆ set() [1/6]

void DTCollation::set ( const CHARSET_INFO collation_arg)
inline

◆ set() [2/6]

void DTCollation::set ( const CHARSET_INFO collation_arg,
Derivation  derivation_arg 
)
inline

◆ set() [3/6]

void DTCollation::set ( const CHARSET_INFO collation_arg,
Derivation  derivation_arg,
uint  repertoire_arg 
)
inline

◆ set() [4/6]

void DTCollation::set ( const DTCollation dt)
inline

◆ set() [5/6]

void DTCollation::set ( Derivation  derivation_arg)
inline

◆ set() [6/6]

bool DTCollation::set ( DTCollation dt1,
DTCollation dt2,
uint  flags = 0 
)
inline

◆ set_numeric()

void DTCollation::set_numeric ( )
inline

◆ set_repertoire()

void DTCollation::set_repertoire ( uint  repertoire_arg)
inline

◆ set_repertoire_from_charset()

void DTCollation::set_repertoire_from_charset ( const CHARSET_INFO cs)
inline

Member Data Documentation

◆ collation

const CHARSET_INFO* DTCollation::collation

◆ derivation

Derivation DTCollation::derivation {DERIVATION_NONE}

◆ repertoire

uint DTCollation::repertoire

The documentation for this class was generated from the following files: