CREATE TABLE t1 (a INT, b VARCHAR(10) CHARACTER SET latin1); INSERT INTO t1 VALUES (1,’b’); SELECT CONCAT(FORMAT(a, 4), b) FROM t1; 

Without repertoire, this error occurs: 

ERROR 1267 (HY000): Illegal mix of collations (ascii_general_ci,COERCIBLE) and (latin1_swedish_ci,IMPLICIT) for operation ’concat’ 

With repertoire, a result is returned: 

+-------------------------+ | CONCAT(FORMAT(a, 4), b) | +-------------------------+ | 1.0000b | +-------------------------+ 

•Functions with two or more string arguments use the “widest”  argument repertoire for the result repertoire, where UNICODE  is wider than ASCII . Consider the following CONCAT()  calls: 

CONCAT(_ucs2 X’0041’, _ucs2 X’0042’) CONCAT(_ucs2 X’0041’, _ucs2 X’00C2’) 

For the first call, the repertoire is ASCII  because both arguments are within the ASCII range. For the second call, the repertoire is UNICODE  because the second argument is outside the ASCII range. 

•The repertoire for function return values is determined based on the repertoire of only those arguments that affect the result’s character set and collation. 

IF(column1 < column2, ’smaller’, ’greater’) 

The result repertoire is ASCII  because the two string arguments (the second argument and the third argument) both have ASCII  repertoire. The first argument does not matter for the result repertoire, even if the expression uses string values. 

## 10.2.2 UTF-8 for Metadata 

Metadata  is “the data about the data.”  Anything that describes  the database—as opposed to being the contents  of the database—is metadata. Thus column names, database names, user names, version names, and most of the string results from SHOW  are metadata. This is also true of the contents of tables in INFORMATION_SCHEMA  because those tables by definition contain information about database objects. 

Representation of metadata must satisfy these requirements: 

•All metadata must be in the same character set. Otherwise, neither the SHOW  statements nor SELECT statements for tables in INFORMATION_SCHEMA  would work properly because different rows in the same column of the results of these operations would be in different character sets. 

•Metadata must include all characters in all languages. Otherwise, users would not be able to name columns and tables using their own languages. 

To satisfy both requirements, MySQL stores metadata in a Unicode character set, namely UTF-8. This does not cause any disruption if you never use accented or non-Latin characters. But if you do, you should be aware that metadata is in UTF-8. 

The metadata requirements mean that the return values of the USER() , CURRENT_USER() , SESSION_USER() , SYSTEM_USER() , DATABASE() , and VERSION()  functions have the UTF-8 character set by default. 

The server sets the character_set_system  system variable to the name of the metadata character set: 

