MySQL 9.1.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):.

DERIVATION_EXPLICIT - an explicitly written COLLATE clause
DERIVATION_NONE - a mix of two different collations
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_IGNORABLE - a NULL value.

These are ordered by strength from highest (DERIVATION_EXPLICIT) to lowest (DERIVATION_IGNORABLE), 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 are applied by specifying a COLLATE clause to a character string expression.

The most important rules are:

  1. If collations are the same: choose this collation, and the strongest derivation.
  2. If collations are different:
  • Character sets may differ, but only if conversion without data loss is possible. The caller provides flags whether character set conversion attempts should be done. If no flags are substituted, then the character sets must be the same. Currently processed flags are: MY_COLL_ALLOW_SUPERSET_CONV - allow conversion to a superset MY_COLL_ALLOW_COERCIBLE_CONV - allow conversion of a coercible value
  • two EXPLICIT collations produce an error, e.g. this is wrong: CONCAT(expr1 collate latin1_swedish_ci, expr2 collate latin1_german_ci)
  • the side with smaller derivation value wins, i.e. a column is stronger than a string constant, an explicit COLLATE clause is stronger than a column.
  • if derivations are the same, we have DERIVATION_NONE, we'll wait for an explicit COLLATE clause which possibly can come from another argument later: for example, this is valid, but we don't know yet when collecting the first two arguments:
    CONCAT(latin1_swedish_ci_column,
    latin1_german1_ci_column,
    expr COLLATE latin1_german2_ci)
Return values
trueIf the two collations are incompatible and cannot be aggregated.
falseIf the two collations can be aggregated, possibly with DERIVATION_NONE to indicate that they need a third explicit collation as a tiebreaker.

◆ 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: