1
0
mirror of https://github.com/MariaDB/server.git synced 2026-10-23 18:49:29 +03:00

MDEV-41246 "Illegal mix of collations" on the mysql.user view

This SQL script failed:

SET NAMES latin1 COLLATE latin1_swedish_ci;
CREATE OR REPLACE VIEW v1 AS SELECT 'Y' AS c1;
SET NAMES big5 COLLATE big5_chinese_ci;
SELECT * FROM v1 WHERE c1='y';

with the following error:

ERROR 1267 (HY000): Illegal mix of collations
(latin1_swedish_ci,COERCIBLE) and (big5_chinese_ci,COERCIBLE)
for operation '='

Note, latin1_swedish_ci and big5_chinese_ci are used here as examples.
The error also happened with different collation combinations.

Fix main idea:

If two collations have equal comparison rules (known as "tailoring")
on a given character repertoire,
like latin1_swedish_ci and big5_chinese_ci on ASCII letters,
then the "Illegal mix of collations" error can be avoided in
a comparison operator. We can choose any of the sides as the operation
effective collation - the result will be equal.

This optimization is not applied when at least one side has an explicit
COLLATE clause. Two explicit COLLATE clauses in one comparison are
already illegal when the character sets are the same, so for
consistency this stays illegal when the character sets differ too.

Most important details:

- Splitting enum_repertoire_t into smaller subsets,
  for better repertoire granularity.
  A variable holding a repertoire value can now have multiple
  MY_REPERTOIRE_XXX flags set.

  This patch implements detecting tailoring equality
  on these repertoires:
  * MY_REPERTOIRE_ASCII_DIGITS - [0..9]
  * MY_REPERTOIRE_ASCII_MINUS_DOT_DIGITS - [-.0..9], e.g. '-10.5'.
    It consists of the new bits MY_REPERTOIRE_ASCII_MINUS and
    MY_REPERTOIRE_ASCII_DOT. They were a part of
    MY_REPERTOIRE_ASCII_NOT_IDENT before. As a result, the numeric values
    of MY_REPERTOIRE_ASCII and MY_REPERTOIRE_UNICODE30 changed
    (223 and 255).
  * MY_REPERTOIRE_ASCII_ALNUM - [A..Z,a..z,0..9].
  * MY_REPERTOIRE_ASCII_IDENT - ALNUM + underscore
  * MY_REPERTOIRE_ASCII       - the entire range U+0000..U+007F

- Adding a new virtual function "tailoring" in my_collation_handler_st.

  It returns the tailoring on the given repertoire for the given
  collation.

  If cs1->coll->tailoring(cs1, some_repertoire) returns {0,0},
  it means the illegal mix optimization cannot be used
  for this collation on the given repertoire.

  If these calls:
     tr1= cs1->coll->tailoring(cs1, some_repertoire);
     tr2= cs2->coll->tailoring(cs2, some_repertoire);
  return both non-NULL results and tr1.str==tr2.str,
  then these collations are equal on the given repertoire
  and are mutually replaceable for a comparison operator,
  so "Illegal mix of collations" can be avoided.

- Tailoring strings are shared constants my_tailoring_str_*
  (strings/strings_def.h). Tailorings are compared by the string
  pointer, so tailoring() implementations return strings only from
  these constants. The strings do not depend on PAD/NOPAD.

- my_string_repertoire() for ucs2, utf16, utf32 and NONASCII 8bit
  character sets no longer stops at the first bad byte sequence with
  the repertoire found so far, which could be MY_REPERTOIRE_NONE
  (compatible with everything). It returns MY_REPERTOIRE_EXTENDED
  for such strings. A unit test was added into unittest/strings.

- Adding CHARSET_INFO::is_ascii_superset(). It tells if a character set
  can store all ASCII characters (it is false for swe7).
  It is used in Item_func_conv_charset to calculate "safe", and in
  left_is_algorithmically_simpler() to prefer other character sets
  to those where ASCII strings cannot be converted safely.

- DBUG_ASSERTs were added into mysys/charset.c, to check that
  the "tailoring" method is set in collation handlers when a collation
  is added: compiled-in, from ctype-extra.c, or loaded from Index.xml.

- Adding a new function my_collations_equal_on_repertoire(cs1, cs2,
  repertoire) in strings/. It tells if two collations are equal on
  the repertoire, taking tailoring() results and PAD/NOPAD and the UCA
  version into account. Callers do not compare tailoring() results
  directly, so the way tailorings are compared (currently by the pointer
  to the shared constant string) is private to strings/ and can be
  extended later, e.g. for UCA collations on MY_REPERTOIRE_UNICODE30.

- Adding a new method DTCollation::aggregate_by_tailoring().
  Collations with different MY_CS_NOPAD are never compatible.
  UCA collations of different versions are not compatible on
  the repertoire with ASCII punctuation, as the UCA version
  affects its order (e.g. UCA-6.2.0 moved GRAVE ACCENT
  and CIRCUMFLEX ACCENT after PERCENT SIGN).

- DTCollation::aggregate() now makes the repertoire of the result cover
  the repertoires of both sides in all successful branches.
  Before, set(dt) replaced the repertoire with the repertoire of the
  winner side only, so the result could have a too narrow repertoire,
  e.g. IF(1, 1.5, HEX(255)) had MY_REPERTOIRE_ASCII_ALNUM although the
  value '1.5' has a punctuation character. With the more granular
  repertoires this could wrongly allow mixing collations which are
  equal on ALNUM but different on punctuation.

- Adding a new flag MY_COLL_ALLOW_BY_TAILORING.
  It indicates to DTCollation::aggregate() that the illegal
  mix optimization by repertoire can be used in the given context.

  MY_COLL_CMP_CONV now includes MY_COLL_ALLOW_BY_TAILORING.
  Note, only comparison operators pass this flag.
  Functions returning a string result do not pass this flag,
  because in operations like CONCAT(a,b) we still need to evaluate
  precisely the collation of the result - we cannot just choose
  a collation of one of the sides (even if they are compatible
  on the given repertoire). This also applies to ExtractValue()
  and UpdateXML(), which now aggregate their arguments without
  this flag.

- As in my_repertoire_t the value MY_REPERTOIRE_ASCII is now a set of
  bits rather than a single bit, the way to detect "is only ASCII"
  repertoires has changed in the code.

  For example:
    // repertoire *IS* ascii
    if (repertoire == MY_REPERTOIRE_ASCII)

  has changed in multiple places in the code to

    // repertoire *HAS* only ascii characters
    if (my_repertoire_is_subset_of(repertoire, MY_REPERTOIRE_ASCII))

  The new function my_repertoire_is_subset_of() in m_ctype.h
  is used for this purpose in C code. In C++ code
  DTCollation::repertoire_is_subset_of() is used, e.g.:

    if (collation.repertoire_is_subset_of(MY_REPERTOIRE_ASCII))

- Repertoire of some expressions was adjusted to the new meaning:
  * Item_null now has MY_REPERTOIRE_NONE (was ASCII).
  * MY_LOCALE::repertoire() now returns MY_REPERTOIRE_UNICODE30
    (was EXTENDED).
  * Lex_string_with_metadata_st::repertoire(cs) now scans the string
    contents to detect the actual repertoire.
  * HEX() now has MY_REPERTOIRE_ASCII_ALNUM.
  * DATE_FORMAT() decides on MY_REPERTOIRE_EXTENDED using the locale
    which is actually used: the explicit third argument, or
    @@lc_time_names. It was always @@lc_time_names before.
    A non-constant locale argument is assumed to be non-ASCII.
  * QUOTE, MAKE_SET, EXPORT_SET, LPAD, RPAD, GROUP_CONCAT, JSON_ARRAY,
    JSON_OBJECT and JSON_OBJECTAGG add the repertoire of the extra
    characters they put into the result (quotes, separators, padding,
    brackets).
  * LOWER() and UPPER() add the letters of both cases to the repertoire,
    because the result can contain letters of the opposite case.
    In Turkish collations they also add MY_REPERTOIRE_EXTENDED, as an
    ASCII letter can be converted to a non-ASCII one (I -> dotless i).
    Unicode collations are detected by the new member
    casefold_info_st::can_convert_to_non_ascii_on_casefolding,
    simple 8bit collations by to_lower['I'] and to_upper['i'].

- Lex_string_with_metadata_st::repertoire(cs) now scans a string literal
  for any byte oriented character set (mbminlen==1), not only for
  ASCII based ones. It was assumed to have the full repertoire for swe7,
  which is not ASCII based. The scan is done by Unicode code points, so
  swe7 strings with digits and letters get a narrow repertoire, while
  e.g. 0x5B (LATIN CAPITAL LETTER A WITH DIAERESIS in swe7) is non-ASCII.
  Therefore swe7_swedish_ci can be mixed with other collations now,
  in the same way as other collations with MY_CS_IDENT_CASEUP_CI.
  The test func_time was adjusted: a swe7 literal ' ull' with ASCII
  characters is now safe to convert, the error is still tested for '[ull'.

- cp1250_czech_cs sorts -, . and 0..9 in the code point order, so it gets
  the MINUS_DOT_DIGITS tailoring. latin2_czech_cs gets only DIGITS,
  as it sorts the minus and the dot differently. Both were verified
  with ctype_digits_verify.

- The tis620 collations now set CHARSET_INFO::tab_to_uni (was NULL),
  so my_charset_is_ascii_based() is true for tis620.
  It was false for tis620, although tis620 is ASCII compatible.
  Therefore tis620 string literals were always considered to have
  a non-ASCII repertoire, and the repertoire optimizations did not work
  for them. Now ASCII-only tis620 literals are detected as ASCII.
  This changes the result of subselect_extra_no_semijoin
  from an error to success.

- tis620_thai_ci and tis620_thai_nopad_ci fold letters to lower case
  and then compare by the code point on the entire ASCII range
  (the Thai specific rules affect only non-ASCII characters).
  A new function my_tailoring_ascii_casedn_ci() returns tailorings
  for such collations on ALNUM, IDENT and ASCII. For example, the
  underscore sorts before the letters, unlike in the caseup tailorings.

- New flags were added for CHARSET_INFO::state
  * MY_CS_ASCII_CASEUP_CI - for simple 8bit case insensitive collations.
    It means that this collation has no irregularities on the ASCII
    repertoire, and converts lower case letters to upper case ones,
    so the underscore sorts after the letters (with an upper to lower
    case conversion it would sort before the letters).

  * MY_CS_IDENT_CASEUP_CI - for simple 8bit case insensitive collations.
    It means that this collation has no irregularities on the IDENT
    repertoire (but can have irregularities say on punctuation).

  * MY_CS_ASCII_STD_UCA - for UCA collations.
    It means that a UCA collation does not reorder ASCII characters.

  * MY_CS_DIGITS_STD - for any collation. It means that the ASCII digits
    0..9 are sorted in the code point order and are not tailored, and,
    for PAD collations, the space sorts before the digits. Strings of
    digits are compared in the same way in all such collations, even if
    they have irregularities on letters (latin7, cp866, czech, danish,
    turkish UCA, etc.), or differ by case sensitivity. It is detected
    from sort_order for 8bit collations, and from the tailoring rules
    for UCA collations. Collations with MY_CS_DIGITS_STD still must have
    the same PAD/NOPAD attribute.

  * MY_CS_ASCII_MINUS_DOT_DIGITS - for any collation. Means
    MY_CS_DIGITS_STD, and additionally the minus sorts before the dot,
    which sorts before the digits (and the space sorts before the minus
    in PAD collations). Strings like '-10.5' are compared in the same
    way in all such collations. It is detected from sort_order for simple
    8bit collations (my_coll_init_simple()), and from the tailoring rules
    for UCA collations. For the multi-byte collations big5_chinese_ci,
    gbk_chinese_ci, gb2312_chinese_ci and sjis_japanese_ci it is declared
    by my_tailoring_ident_caseup_ci_generic(). The flags MY_CS_DIGITS_STD
    and MY_CS_ASCII_MINUS_DOT_DIGITS are stored in ctype-extra.c for
    compiled collations (conf_to_src.c prints them), and the detection is
    skipped for a collation which already has any of the repertoire flags
    (MY_CS_REPERTOIRE_FLAGS).

- strings/conf_to_src.c was modified to detect and print
  MY_CS_ASCII_CASEUP_CI and MY_CS_IDENT_CASEUP_CI flags.

- strings/ctype-extra.c was regenerated with new flags.

- 8bit collations are not given MY_CS_ASCII_CASEUP_CI and
  MY_CS_IDENT_CASEUP_CI if they are PAD and the space does not sort
  before the digits. A shorter string is padded with spaces for
  comparison, so the position of the space matters even for strings
  without spaces ("ab" is compared to "abc" as "ab " to "abc").
  A test collation latin1_space_after_letters_ci was added to
  mysql-test/std_data/ldml/ for this. ctype-extra.c does not change.

- The initializer of my_collation_cs_handler in ctype-utf8.c
  (utf8mb3_general_cs, under HAVE_UTF8_GENERAL_CS) was fixed to match
  my_collation_handler_st: the missing get_id and get_collation_name
  members were added, so that eq_collation was not initialized in their
  place, and the new member "tailoring" is now set to my_tailoring_none.

- Results of the existing tests func_str, func_test, ps, view
  and subselect_sj changed from "Illegal mix of collations" to success.
  In these tests ASCII-only strings were compared using collations
  with equal tailoring on ASCII, e.g. latin1_swedish_ci with
  latin2_general_ci (func_str, ps), koi8r_general_ci with
  latin1_swedish_ci (func_test), latin1_general_ci with
  latin1_swedish_ci on letters and digits (view), cp932_japanese_ci
  with latin1_swedish_ci (subselect_sj).
  Such comparisons are now allowed.
  Cases with collations that are still incompatible on ASCII,
  e.g. latin7_general_ci, were added to the tests and still fail.

- Adding a number of MTR tests in
  plugin/func_test/mysql-test/func_test/.
  They display a tailoring by collation name and repertoire as
  returned by:
    cs->coll->tailoring(cs, some_repertoire)
  A dynamically linked plugin function collation_tailoring() was added
  for the purpose of these tests. Tailorings do not depend on PAD/NOPAD
  and on the UCA version, so the function shows "[nopad]" for NOPAD
  collations, and "[version X.Y.Z]" for UCA collations on the ASCII
  repertoire. The version is formatted by a new class UCAVersion,
  which uses a new method CharBuffer::append_uint8().

- Adding the test plugin/func_test/mysql-test/func_test/
  ctype_caseup_ci_verify.test. It checks the order of ASCII characters
  for all collations declared "caseup CI" on the ASCII or IDENT range.

- Adding the test plugin/func_test/mysql-test/func_test/
  collation_tailoring_args.test. It checks the arguments of the plugin
  function collation_tailoring(): the repertoire passed by name or by
  number, and the NULL results for unknown names.

- Adding the test plugin/func_test/mysql-test/func_test/ctype_ldml.test.
  It displays the tailorings of collations loaded at runtime from
  Index.xml: simple 8bit collations (flags detected from the weights)
  and Unicode collations (LDML rules which do or do not reorder ASCII).

- Adding a number of MTR tests mysql-test/main/ctype_xxx_tailoring.test
  They display two-dimensional charts showing which collations
  are compatible on which repertoires.
  Tests for DATE_FORMAT() with an explicit locale were added to
  ctype_big5_tailoring.test, ctype_cp932_tailoring.test and
  ctype_latin5_tailoring.test, which also has the chart for latin5.

- Adding a number of MTR tests in the form of the originally
  reported script for various collations:

    SELECT Insert_priv FROM mysql.user WHERE Insert_priv='...';

  The repeated blocks of queries are shared through
  mysql-test/include/
  ctype_tailoring_0{1,2,3}_mysql_user_Insert_priv*.inc.

- Adding tests to ctype_cp932.test checking that ExtractValue() and
  UpdateXML() still raise "Illegal mix of collations".
This commit is contained in:
Alexander Barkov
2026-09-24 13:18:07 +04:00
parent 8136047738
commit 8c4943d208
224 changed files with 52005 additions and 239 deletions

View File

@@ -97,6 +97,12 @@ struct casefold_info_st
my_wc_t maxchar;
const MY_CASEFOLD_CHARACTER * const *page;
const uint16 * const *simple_weight; /* For general_ci-alike collations */
/*
TRUE if an ASCII character can be converted to a non-ASCII character
by LOWER() or UPPER(), e.g. in Turkish: LOWER('I') -> U+0131,
UPPER('i') -> U+0130.
*/
my_bool can_convert_to_non_ascii_on_casefolding;
};
@@ -297,18 +303,116 @@ extern MY_UNI_CTYPE my_uni_ctype[256];
to weights, e.g. contractions, expansions,
ignorable characters */
#define MY_CS_UPPER_EQUAL_AS_EQUAL 0x80000 /* (UPPER(x)=UPPER(y)) <=> (x=y)*/
/*
MY_CS_ASCII_CASEUP_CI means that the collation maps lower case ASCII
letters a-z to their upper case counter parts A-Z, and sorts the ASCII
range according to the code point otherwise. Therefore the underscore
(0x5F) sorts after the letters. A collation which converts upper case
letters to lower case would sort the underscore before the letters.
Sorting on the non-ASCII range can be any, not necessarily
according to the code point.
*/
#define MY_CS_ASCII_CASEUP_CI 0x100000 /* ASCII CASEUP CI sorting */
/*
MY_CS_IDENT_CASEUP_CI means that the collation maps lower case ASCII
letters a-z to their upper case counter parts A-Z, and sorts "identifier"
ranges (0-9,A-Z,_) according to the code point. As a-z are folded
to A-Z, the order is: digits < letters (case insensitive) < underscore,
i.e. the underscore (0x5F) sorts after all letters.
Sorting on the other ASCII characters is not important, sorting on
non-ASCII characters is not important.
*/
#define MY_CS_IDENT_CASEUP_CI 0x200000 /* CASEUP CI sorting, IDENT range */
/*
MY_CS_ASCII_STD_UCA means that the collation sorts all characters in the
range U+0000..U+007F like the default (not-tailored) UCA collations do:
utf8mb3_unicode_ci, utf8mb3_uca1400_ai_ci.
*/
#define MY_CS_ASCII_STD_UCA 0x400000 /* Standard UCA sorting on ASCII */
/*
MY_CS_DIGITS_STD means that the collation sorts the ASCII digits 0..9
in the code point order, and does not tailor them (no contractions,
expansions or ignorable digits). For a PAD collation it also means that
the space sorts before the digits, as a shorter string is padded with
spaces for comparison. Therefore strings consisting of ASCII digits
are compared in the same way in all collations having this flag
(with the same MY_CS_NOPAD), regardless of case sensitivity
and the order of letters.
*/
#define MY_CS_DIGITS_STD 0x800000 /* Standard sorting of 0..9 */
/*
MY_CS_ASCII_MINUS_DOT_DIGITS means MY_CS_DIGITS_STD, and additionally,
the ASCII minus (-) sorts before the ASCII dot (.), which sorts before
the digits, and, for PAD collations, the space sorts before the minus.
Therefore strings consisting of minuses, dots and digits
(e.g. decimal numbers like '-10.5') are compared in the same way
in all collations having this flag (with the same MY_CS_NOPAD).
*/
#define MY_CS_ASCII_MINUS_DOT_DIGITS 0x1000000 /* Standard order of -.0..9 */
#define MY_CHARSET_UNDEFINED 0
/* Character repertoire flags */
typedef enum enum_repertoire_t
{
MY_REPERTOIRE_NONE= 0,
MY_REPERTOIRE_ASCII= 1, /* Pure ASCII U+0000..U+007F */
MY_REPERTOIRE_EXTENDED= 2, /* Extended characters: U+0080..U+FFFF */
MY_REPERTOIRE_UNICODE30= 3 /* ASCII | EXTENDED: U+0000..U+FFFF */
MY_REPERTOIRE_NONE= 0,
/* ASCII digits 0..9 */
MY_REPERTOIRE_ASCII_DIGITS= 1,
/* ASCII letters A..Z */
MY_REPERTOIRE_ASCII_LETTERS_UPPER= 2,
/* ASCII letters a..z */
MY_REPERTOIRE_ASCII_LETTERS_LOWER= 4,
/* ASCII letters A..Z, a..z */
MY_REPERTOIRE_ASCII_LETTERS= MY_REPERTOIRE_ASCII_LETTERS_UPPER |
MY_REPERTOIRE_ASCII_LETTERS_LOWER,
/* ASCII letters and digits */
MY_REPERTOIRE_ASCII_ALNUM= MY_REPERTOIRE_ASCII_DIGITS |
MY_REPERTOIRE_ASCII_LETTERS,
/* ASCII underscore character */
MY_REPERTOIRE_ASCII_UNDERSCORE= 8,
/* A combination of alnum and underscore */
MY_REPERTOIRE_ASCII_IDENT= MY_REPERTOIRE_ASCII_ALNUM |
MY_REPERTOIRE_ASCII_UNDERSCORE,
/*
Other ASCII characters, not covered by MY_REPERTOIRE_ASCII_IDENT,
MY_REPERTOIRE_ASCII_DOT and MY_REPERTOIRE_ASCII_MINUS:
*/
MY_REPERTOIRE_ASCII_NOT_IDENT= 16,
/* Extended characters: U+0080..U+10FFFF */
MY_REPERTOIRE_EXTENDED= 32,
/* ASCII dot (full stop) character: . */
MY_REPERTOIRE_ASCII_DOT= 64,
/* ASCII minus (hyphen-minus) character: - */
MY_REPERTOIRE_ASCII_MINUS= 128,
/* Decimal numbers, e.g. '-10.5': digits, dot and minus */
MY_REPERTOIRE_ASCII_MINUS_DOT_DIGITS= MY_REPERTOIRE_ASCII_DIGITS |
MY_REPERTOIRE_ASCII_DOT |
MY_REPERTOIRE_ASCII_MINUS,
/* Entire pure ASCII: U+0000..U+007F */
MY_REPERTOIRE_ASCII= MY_REPERTOIRE_ASCII_IDENT |
MY_REPERTOIRE_ASCII_NOT_IDENT |
MY_REPERTOIRE_ASCII_DOT |
MY_REPERTOIRE_ASCII_MINUS,
/* All characters: U+0000..U+10FFFF */
MY_REPERTOIRE_UNICODE30= MY_REPERTOIRE_ASCII |
MY_REPERTOIRE_EXTENDED
} my_repertoire_t;
/*
Check if all characters of "repertoire" belong to "of",
e.g. my_repertoire_is_subset_of(rep, MY_REPERTOIRE_ASCII) means
"rep contains only ASCII".
Note, do not use "repertoire == MY_REPERTOIRE_ASCII" for this purpose,
as repertoire values are sets of bits.
*/
static inline
my_bool my_repertoire_is_subset_of(my_repertoire_t repertoire,
my_repertoire_t of)
{
return (repertoire & ~of) == 0;
}
/* ID compatibility */
typedef enum enum_collation_id_type
{
@@ -618,6 +722,54 @@ struct my_collation_handler_st
@return 1 Identical
*/
my_bool (*eq_collation)(CHARSET_INFO *self, CHARSET_INFO *other);
/*
Get collation rules on the given repertoire.
This virtual function is used for tailoring-based optimization.
If two different collations have equal rules (tailoring) on the
given repertoire, then they can be mutually substituted in a comparison
operator instead of raising an "Illegal mix of collations" error,
if the additional conditions listed below are met.
For example:
SET NAMES latin1 COLLATE latin1_swedish_ci;
CREATE VIEW v1 AS SELECT IF(cond,'Y','N') AS c1 FROM t1;
SET NAMES big5 COLLATE big5_chinese_ci;
SELECT * FROM v1 WHERE c1='Y';
Although latin1_swedish_ci and big5_chinese_ci are different collations,
their rules on the given range (i.e. MY_REPERTOIRE_ASCII_ALNUM) are
exactly the same, so it does not matter which collation to use for
comparison purposes - the result will be the same. There is no need
to raise the "Illegal mix of collations".
If "tailoring()" returns a null LEX_CSTRING {0,0}, it means this
collation can not use tailoring-based optimization in the passed
repertoire.
The tailoring() results must not be compared directly by the callers.
Use my_collations_equal_on_repertoire(), which knows how tailorings
are compared and which additional properties of the collations
(PAD/NOPAD, UCA version) must be checked.
Currently two tailorings are considered equal when the str pointers
of the returned LEX_CSTRING values are equal (not when their texts
are equal). So an implementation must return shared constant strings,
and never its own literals, even if the text of such a literal is the
same. The shared constants (my_tailoring_str_*) are defined in
strings/ctype.c and declared in strings/strings_def.h, which is not
a public header. So only the implementations inside strings/ can
return them. An implementation defined elsewhere should return {0,0}
on all repertoires, which disables the optimization for its collations.
Equal tailorings are necessary, but not sufficient for the collations
to be interchangeable. The returned string does not describe the PAD/
NOPAD attribute and the UCA version of the collation, which are
additionally checked by my_collations_equal_on_repertoire().
For MY_REPERTOIRE_NONE (the empty repertoire) the implementations
inside strings/ return the shared constant my_tailoring_str_empty:
any two collations are trivially compatible on the empty repertoire
(the additional checks above still apply).
*/
LEX_CSTRING (*tailoring)(CHARSET_INFO *self, my_repertoire_t repertoire);
};
@@ -1233,6 +1385,21 @@ struct charset_info_st
return this == rhs || (coll->eq_collation)(this, rhs);
}
/*
Check if the character set can store all ASCII characters
U+0000..U+007F. An expression with the ASCII repertoire can be safely
converted to such a character set.
- All supported multibyte character sets can store U+0000..U+007F
- All supported 7bit character sets can store U+0000..U+007F
except those marked with MY_CS_NONASCII (e.g. swe7).
Note, this is not the same as the byte level ASCII compatibility,
see my_charset_is_ascii_based().
*/
bool is_ascii_superset() const
{
return mbmaxlen > 1 || !(state & MY_CS_NONASCII);
}
#endif /* __cplusplus */
};
@@ -1803,6 +1970,8 @@ void my_string_metadata_get(MY_STRING_METADATA *metadata,
my_repertoire_t my_string_repertoire(CHARSET_INFO *cs,
const char *str, size_t len);
my_bool my_charset_is_ascii_based(CHARSET_INFO *cs);
my_bool my_collations_equal_on_repertoire(CHARSET_INFO *cs1, CHARSET_INFO *cs2,
my_repertoire_t repertoire);
my_repertoire_t my_charset_repertoire(CHARSET_INFO *cs);
uint my_strxfrm_flag_normalize(CHARSET_INFO *cs, uint flags);

View File

@@ -0,0 +1,341 @@
CREATE TABLE cmp_result (
cl1 VARCHAR(64), cl2 VARCHAR(64), is_error INT, is_error_expected INT, expected_reason TEXT
) ENGINE=MyISAM;
CREATE TABLE cmp_result_all AS SELECT *, SPACE(32) AS repertoire FROM cmp_result LIMIT 0;
# Unicode collations that reorder ASCII letters
DELIMITER $$;
CREATE FUNCTION unicode_reorders_ascii_letters(cl VARCHAR(64)) RETURNS BOOL
BEGIN
/* Old collations */
CASE
WHEN cl RLIKE '^(utf8mb3|ucs2|utf8mb4|utf16|utf32)'
'_(czech|croatian|croatian_mysql561|danish|estonian|latvian|lithuanian|roman|slovak|spanish2|turkish)'
'_ci$'
THEN RETURN 1;
/* MySQL 0900 compatibility collations */
WHEN cl RLIKE '^utf8mb4'
'_(es_trad|cs|et|la|lt|lv|sk|tr)'
'_0900_ai_(ci|cs)$'
THEN RETURN 1;
/* uca1400 collations*/
WHEN cl RLIKE '^(utf8mb3|ucs2|utf8mb4|utf16|utf32)'
'_uca1400'
'_(czech|croatian|danish|estonian|latvian|lithuanian|roman|slovak|spanish2|turkish)'
'_(|nopad_)'
'(ai_cs|ai_ci|as_cs|as_ci)$'
THEN RETURN 1;
ELSE
RETURN 0;
END CASE;
RETURN 0;
END;
$$
DELIMITER ;$$
DELIMITER $$;
CREATE PROCEDURE update_expected_reasons(repertoire VARCHAR(32))
BEGIN
UPDATE cmp_result SET is_error_expected=0, expected_reason='000 cl1 = cl2' WHERE is_error_expected IS NULL AND cl1=cl2;
UPDATE cmp_result SET is_error_expected=0, expected_reason='001 LEFT binary' WHERE is_error_expected IS NULL AND cl1='binary' AND cl2<>'binary';
UPDATE cmp_result SET is_error_expected=0, expected_reason='001 RIGHT binary' WHERE is_error_expected IS NULL AND cl1<>'binary' AND cl2='binary';
UPDATE cmp_result SET is_error_expected=0, expected_reason='002 RIGHT sameCS_bin' WHERE is_error_expected IS NULL AND cl1 NOT LIKE '%_bin' AND concat(substring_index(cl1,'_',1),'_bin')=cl2;
UPDATE cmp_result SET is_error_expected=0, expected_reason='002 RIGHT sameCS_bin' WHERE is_error_expected IS NULL AND cl1 NOT LIKE '%_bin' AND concat(substring_index(cl1,'_',1),'_nopad_bin')=cl2;
UPDATE cmp_result SET is_error_expected=0, expected_reason='002 RIGHT sameCS_bin' WHERE is_error_expected IS NULL AND cl1 NOT LIKE '%_bin' AND concat(substring_index(cl1,'_',1),'_0900_bin')=cl2;
UPDATE cmp_result SET is_error_expected=0, expected_reason='002 LEFT sameCS_bin' WHERE is_error_expected IS NULL AND cl2 NOT LIKE '%_bin' AND cl1=concat(substring_index(cl2,'_',1),'_bin');
UPDATE cmp_result SET is_error_expected=0, expected_reason='002 LEFT sameCS_bin' WHERE is_error_expected IS NULL AND cl2 NOT LIKE '%_bin' AND cl1=concat(substring_index(cl2,'_',1),'_nopad_bin');
UPDATE cmp_result SET is_error_expected=0, expected_reason='002 LEFT sameCS_bin' WHERE is_error_expected IS NULL AND cl2 NOT LIKE '%_bin' AND cl1=concat(substring_index(cl2,'_',1),'_0900_bin');
UPDATE cmp_result SET is_error_expected=0, expected_reason='003 LEFT superset' WHERE is_error_expected IS NULL AND cl1 RLIKE '^(utf8mb4).*' AND cl2 NOT RLIKE '^(ucs2|utf8mb4|utf32|utf16).*';
UPDATE cmp_result SET is_error_expected=0, expected_reason='003 RIGHT superset' WHERE is_error_expected IS NULL AND cl1 NOT RLIKE '^(ucs2|utf8mb4|utf32|utf16).*' AND cl2 RLIKE '^(utf8mb4).*';
UPDATE cmp_result SET is_error_expected=0, expected_reason='003 LEFT superset' WHERE is_error_expected IS NULL AND cl1 RLIKE '^(utf16|utf32).*' AND cl2 NOT RLIKE '^(ucs2|utf8mb3|utf8mb4|utf32|utf16).*';
UPDATE cmp_result SET is_error_expected=0, expected_reason='003 RIGHT superset' WHERE is_error_expected IS NULL AND cl1 NOT RLIKE '^(ucs2|utf8mb3|utf8mb4|utf32|utf16).*' AND cl2 RLIKE '^(utf16|utf32).*';
UPDATE cmp_result SET is_error_expected=0, expected_reason='004 LEFT superset' WHERE is_error_expected IS NULL AND cl1 RLIKE '^(ucs2|utf8mb3).*' AND cl2 NOT RLIKE '^(utf8mb4|utf32|utf16|ucs2|utf8mb3).*';
UPDATE cmp_result SET is_error_expected=0, expected_reason='004 RIGHT superset' WHERE is_error_expected IS NULL AND cl1 NOT RLIKE '^(utf8mb4|utf32|utf16|utf8mb3|ucs2).*' AND cl2 RLIKE '^(ucs2|utf8mb3).*';
IF repertoire ='ascii' THEN
UPDATE cmp_result SET is_error_expected=1, expected_reason='010 sjis_bin reorders ASCII punctuation' WHERE is_error_expected IS NULL AND (cl1='sjis_bin' OR cl2='sjis_bin');
UPDATE cmp_result SET is_error_expected=1, expected_reason='010 sjis_nopad_bin reorders ASCII punctuation' WHERE is_error_expected IS NULL AND (cl1='sjis_nopad_bin' OR cl2='sjis_nopad_bin');
END IF;
IF repertoire ='ascii' THEN
/* These collations have no tailoring on the entire ASCII repertoire */
UPDATE cmp_result SET is_error_expected=1, expected_reason='010 no tailoring on the entire ASCII repertoire'
WHERE is_error_expected IS NULL
AND (cl1 RLIKE '^(big5_chinese|gb2312_chinese|gbk_chinese|sjis_japanese)' OR
cl2 RLIKE '^(big5_chinese|gb2312_chinese|gbk_chinese|sjis_japanese)');
UPDATE cmp_result SET is_error_expected=1, expected_reason='010 hp8_english_ci has anomalies on ASCII punctuation'
WHERE is_error_expected IS NULL AND (cl1='hp8_english_ci' OR cl2='hp8_english_ci');
UPDATE cmp_result SET is_error_expected=1, expected_reason='010 swe7_swedish_nopad_ci reorders ASCII punctuation'
WHERE is_error_expected IS NULL AND (cl1='swe7_swedish_nopad_ci' OR cl2='swe7_swedish_nopad_ci');
END IF;
/*
The ASCII digits are sorted in the code point order in all collations,
regardless of the order of the letters and the case sensitivity.
So on the digits repertoire only PAD vs NOPAD collations are incompatible.
*/
IF repertoire NOT IN ('digits', 'minus_dot_digits') THEN
UPDATE cmp_result SET is_error_expected=1, expected_reason='010 cp1257_lithuanian_ci reorders ASCII letters: I<Y<J' WHERE is_error_expected IS NULL AND (cl1='cp1257_lithuanian_ci' OR cl2='cp1257_lithuanian_ci');
UPDATE cmp_result SET is_error_expected=1, expected_reason='010 latin5_turkish_ci reorders ASCII letters: I<i<J' WHERE is_error_expected IS NULL AND (cl1 RLIKE '^latin5_turkish' OR cl2 RLIKE '^latin5_turkish');
UPDATE cmp_result SET is_error_expected=1, expected_reason='010 cp866_general_ci reorders ASCII letters: J<j (bug)' WHERE is_error_expected IS NULL AND (cl1='cp866_general_ci' OR cl2='cp866_general_ci');
UPDATE cmp_result SET is_error_expected=1, expected_reason='010 macce_general_ci reorders ASCII letters: M=m=N=n' WHERE is_error_expected IS NULL AND (cl1='macce_general_ci' OR cl2='macce_general_ci');
UPDATE cmp_result SET is_error_expected=1, expected_reason='010 latin7_general_ci reorders ASCII letters: t<T (bug)' WHERE is_error_expected IS NULL AND (cl1='latin7_general_ci' OR cl2='latin7_general_ci');
UPDATE cmp_result SET is_error_expected=1, expected_reason='020 reorders ASCII letters' WHERE is_error_expected IS NULL AND unicode_reorders_ascii_letters(cl1)=TRUE;
UPDATE cmp_result SET is_error_expected=1, expected_reason='020 reorders ASCII letters' WHERE is_error_expected IS NULL AND unicode_reorders_ascii_letters(cl2)=TRUE;
UPDATE cmp_result SET is_error_expected=1, expected_reason='030 diffCS cs vs bin' WHERE is_error_expected IS NULL AND cl1 RLIKE '_cs$' AND cl2 RLIKE '_bin$';
UPDATE cmp_result SET is_error_expected=1, expected_reason='030 diffCS cs vs ci' WHERE is_error_expected IS NULL AND cl1 RLIKE '_cs$' AND cl2 RLIKE '_ci$';
UPDATE cmp_result SET is_error_expected=1, expected_reason='030 diffCS ci vs cs' WHERE is_error_expected IS NULL AND cl1 RLIKE '_ci$' AND cl2 RLIKE '_cs$';
UPDATE cmp_result SET is_error_expected=1, expected_reason='030 diffCS bin vs cs' WHERE is_error_expected IS NULL AND cl1 RLIKE '_bin$' AND cl2 RLIKE '_cs$';
UPDATE cmp_result SET is_error_expected=1, expected_reason='030 diffCS ci vs bin' WHERE is_error_expected IS NULL AND cl1 RLIKE '_ci$' AND cl2 RLIKE '_bin$';
UPDATE cmp_result SET is_error_expected=1, expected_reason='030 diffCS bin vs ci' WHERE is_error_expected IS NULL AND cl1 RLIKE '_bin$' AND cl2 RLIKE '_ci$';
END IF;
UPDATE cmp_result SET is_error_expected=1, expected_reason='030 nopad vs pad' WHERE is_error_expected IS NULL AND cl1 RLIKE '_(nopad|0900)_' AND cl2 NOT RLIKE '_(nopad|0900)_';
UPDATE cmp_result SET is_error_expected=1, expected_reason='030 pad vs nopad' WHERE is_error_expected IS NULL AND cl1 NOT RLIKE '_(nopad|0900)_' AND cl2 RLIKE '_(nopad|0900)_';
/*
tis620_thai_ci and tis620_thai_nopad_ci fold letters to lower case,
so they sort the underscore before the letters.
They are compatible with other collations only on the ALNUM repertoire.
*/
IF repertoire IN ('ident','ascii') THEN
UPDATE cmp_result SET is_error_expected=1, expected_reason='040 tis620_thai_ci sorts underscore before letters'
WHERE is_error_expected IS NULL
AND ((cl1 RLIKE '^tis620_thai' AND cl2 NOT RLIKE '^tis620_thai')
OR (cl2 RLIKE '^tis620_thai' AND cl1 NOT RLIKE '^tis620_thai'));
END IF;
/*
Unicode _general_ vs UCA collations
have different position of the underscore
*/
IF repertoire IN ('ident','ascii') THEN
UPDATE cmp_result SET is_error_expected=1, expected_reason='040 different underscore position'
WHERE is_error_expected IS NULL
AND cl1 RLIKE '^(utf8mb4|utf32|utf16|utf8mb3|ucs2)_general.*'
AND cl2 RLIKE '^(utf8mb4|utf32|utf16|utf8mb3|ucs2)_(unicode|swedish|czech|uca).*';
UPDATE cmp_result SET is_error_expected=1, expected_reason='040 different underscore position'
WHERE is_error_expected IS NULL
AND cl1 RLIKE '^(utf8mb4|utf32|utf16|utf8mb3|ucs2)_(unicode|swedish|czech|uca).*'
AND cl2 RLIKE '^(utf8mb4|utf32|utf16|utf8mb3|ucs2)_(general).*';
END IF;
/*
Old UCA vs uca1400 collations have different punctuation order.
The minus and the dot are punctuation characters, so the UCA versions
must be equal on the repertoire with them.
*/
IF repertoire IN ('minus_dot_digits','ascii') THEN
UPDATE cmp_result SET is_error_expected=1, expected_reason='050 different punctuation order'
WHERE is_error_expected IS NULL
AND cl1 RLIKE '^(utf8mb4|utf32|utf16|utf8mb3|ucs2)_(unicode|swedish|czech).*'
AND cl2 RLIKE '^(utf8mb4|utf32|utf16|utf8mb3|ucs2)_(uca1400|0900).*';
UPDATE cmp_result SET is_error_expected=1, expected_reason='050 different punctuation order'
WHERE is_error_expected IS NULL
AND cl1 RLIKE '^(utf8mb4|utf32|utf16|utf8mb3|ucs2)_(uca1400|0900).*'
AND cl2 RLIKE '^(utf8mb4|utf32|utf16|utf8mb3|ucs2)_(unicode|swedish|czech).*';
END IF;
/*
All other pairs are expected to be compatible: the collations
have equal tailorings on the repertoire.
Without this update is_error_expected would stay NULL for these pairs,
and the check "is_error<>is_error_expected" would skip them.
*/
UPDATE cmp_result SET is_error_expected=0, expected_reason='100 equal tailoring' WHERE is_error_expected IS NULL;
END;
$$
DELIMITER ;$$
DELIMITER $$;
CREATE PROCEDURE check_compatibility(repertoire VARCHAR(32), param VARCHAR(32))
BEGIN
DECLARE mask VARCHAR(32) DEFAULT COALESCE(@mask,'');
DECLARE errmsg TEXT;
DECLARE c1 CURSOR FOR SELECT full_collation_name
FROM collations
ORDER BY full_collation_name;
DECLARE c2 CURSOR FOR SELECT full_collation_name
FROM collations
ORDER BY full_collation_name;
DECLARE CONTINUE HANDLER FOR 1267 /*Illegal mix of collations*/
BEGIN
GET DIAGNOSTICS CONDITION 1 errmsg = MESSAGE_TEXT;
END;
TRUNCATE TABLE cmp_result;
FOR rec1 IN c1 DO
SET @@collation_connection=rec1.full_collation_name;
EXECUTE IMMEDIATE REPLACE('CREATE VIEW v1 AS '
'SELECT ''PARAM'' AS alnum', 'PARAM', param);
SET NAMES DEFAULT;
FOR rec2 IN c2 DO
SET errmsg= NULL;
SET @@collation_connection=rec2.full_collation_name;
/* This query raises an error on incompatible collations */
IF (rec1.full_collation_name RLIKE mask OR
rec2.full_collation_name RLIKE mask)
THEN
SET @a= NULL;
EXECUTE IMMEDIATE
REPLACE('SET @a=(SELECT COUNT(*) FROM v1 WHERE v1.alnum=''PARAM'')',
'PARAM', param);
/*
is_error is set to 1 if the query raised an error, and to 2 if it
did not raise an error but did not return the expected single row.
So a wrong result is reported by "is_error<>is_error_expected",
as is_error_expected can be only 0 or 1.
*/
INSERT INTO cmp_result (cl1, cl2, is_error)
VALUES (rec1.full_collation_name,
rec2.full_collation_name,
IF(errmsg IS NOT NULL, 1, IF(@a=1, 0, 2)));
END IF;
END FOR;
DROP VIEW v1;
END FOR;
SET NAMES DEFAULT;
CALL update_expected_reasons(repertoire);
END;
$$
DELIMITER ;$$
CREATE TABLE collations (full_collation_name VARCHAR(64) NOT NULL PRIMARY KEY);
INSERT INTO collations VALUES
('latin1_general_cs'), ('latin5_turkish_ci'),
('latin1_swedish_nopad_ci'), ('swe7_swedish_nopad_ci'),
('utf8mb3_uca1400_nopad_ai_cs'),('utf8mb4_0900_as_cs'),
('latin1_nopad_bin'), ('swe7_nopad_bin'),
('latin1_german1_ci'),('latin1_swedish_ci'),
('utf8mb3_uca1400_ai_cs'),('utf32_uca1400_as_cs'),
('latin1_bin'),('latin5_bin'),
('hp8_english_ci');
INSERT INTO collations VALUES
('utf8mb3_general_ci'),('utf8mb3_general_nopad_ci'),
('utf8mb3_unicode_ci'),('utf8mb3_unicode_nopad_ci'),
('utf8mb3_bin'),('utf8mb3_nopad_bin'),
('utf8mb4_general_ci'),('utf8mb4_general_nopad_ci'),
('utf8mb4_uca1400_ai_ci'),('utf8mb4_uca1400_nopad_ai_ci'),
('utf8mb4_unicode_ci'),('utf8mb4_unicode_nopad_ci'),
('utf8mb4_bin'),('utf8mb4_nopad_bin');
DELIMITER $$;
BEGIN NOT ATOMIC
IF @extra_collations_query IS NOT NULL
THEN
EXECUTE IMMEDIATE @extra_collations_query;
END IF;
END;
$$
DELIMITER ;$$
--echo #
--echo # ASCII digits repertoire
--echo #
CALL check_compatibility('digits', '12');
SELECT * FROM cmp_result WHERE is_error<>is_error_expected;
SELECT
RPAD(cl1, 32) AS cl1, RPAD(cl2, 32) AS cl2,
is_error, is_error_expected, expected_reason
FROM cmp_result ORDER BY expected_reason,cl1, cl2;
INSERT INTO cmp_result_all SELECT *, '0_digits' FROM cmp_result;
--echo #
--echo # ASCII minus, dot and digits repertoire
--echo #
CALL check_compatibility('minus_dot_digits', '-1.5');
SELECT * FROM cmp_result WHERE is_error<>is_error_expected;
SELECT
RPAD(cl1, 32) AS cl1, RPAD(cl2, 32) AS cl2,
is_error, is_error_expected, expected_reason
FROM cmp_result ORDER BY expected_reason,cl1, cl2;
INSERT INTO cmp_result_all SELECT *, '1_minus_dot_digits' FROM cmp_result;
--echo #
--echo # ALNUM repertoire
--echo #
CALL check_compatibility('alnum', 'a1');
SELECT * FROM cmp_result WHERE is_error<>is_error_expected;
SELECT
RPAD(cl1, 32) AS cl1, RPAD(cl2, 32) AS cl2,
is_error, is_error_expected, expected_reason
FROM cmp_result ORDER BY expected_reason,cl1, cl2;
INSERT INTO cmp_result_all SELECT *, 'A_alnum' FROM cmp_result;
--echo #
--echo # IDENT repertoire
--echo #
CALL check_compatibility('ident', 'a_');
SELECT * FROM cmp_result WHERE is_error<>is_error_expected;
SELECT
RPAD(cl1, 32) AS cl1, RPAD(cl2, 32) AS cl2,
is_error, is_error_expected, expected_reason
FROM cmp_result ORDER BY expected_reason,cl1, cl2;
INSERT INTO cmp_result_all SELECT *, 'B_ident' FROM cmp_result;
--echo #
--echo # Entire ASCII-7 repertoire
--echo #
CALL check_compatibility('ascii', 'a#');
SELECT * FROM cmp_result WHERE is_error<>is_error_expected;
SELECT
RPAD(cl1, 32) AS cl1, RPAD(cl2, 32) AS cl2,
is_error, is_error_expected, expected_reason
FROM cmp_result ORDER BY expected_reason,cl1, cl2;
INSERT INTO cmp_result_all SELECT *, 'C_ascii' FROM cmp_result;
--echo #
--echo # Collation pairs having different results on different repertoires
--echo #
SELECT
RPAD(cl1,32) AS cl1, RPAD(cl2,32) AS cl2,
GROUP_CONCAT(repertoire, is_error ORDER BY repertoire) AS is_error_all
FROM cmp_result_all
GROUP BY cmp_result_all.cl1, cmp_result_all.cl2
HAVING is_error_all NOT IN
('0_digits0,1_minus_dot_digits0,A_alnum0,B_ident0,C_ascii0',
'0_digits1,1_minus_dot_digits1,A_alnum1,B_ident1,C_ascii1')
ORDER BY is_error_all;
DROP TABLE cmp_result_all;
DROP TABLE cmp_result;
DROP TABLE collations;
DROP PROCEDURE check_compatibility;
DROP PROCEDURE update_expected_reasons;
DROP FUNCTION unicode_reorders_ascii_letters;
SET @extra_collations_query=NULL;
SET @mask=NULL;

View File

@@ -0,0 +1,28 @@
# The ASCII digits repertoire. It is compatible even with collations having
# anomalies on letters, but not with a collation with a different PAD/NOPAD.
# The result is printed instead of raising the error, to show both outcomes.
--echo # ASCII digits
--disable_query_log
DELIMITER $$;
BEGIN NOT ATOMIC
DECLARE CONTINUE HANDLER FOR 1267 /*Illegal mix of collations*/
SELECT 'ER_CANT_AGGREGATE_2COLLATIONS' AS d;
SELECT d FROM v_tailoring WHERE d='1';
END;
$$
DELIMITER ;$$
--enable_query_log
--echo # ASCII minus, dot and digits
--disable_query_log
DELIMITER $$;
BEGIN NOT ATOMIC
DECLARE CONTINUE HANDLER FOR 1267 /*Illegal mix of collations*/
SELECT 'ER_CANT_AGGREGATE_2COLLATIONS' AS e;
SELECT e FROM v_tailoring WHERE e='-1.5';
END;
$$
DELIMITER ;$$
--enable_query_log
SELECT c FROM v_tailoring WHERE c='Y';
SELECT c FROM v_tailoring WHERE c<>'Y_';
SELECT c FROM v_tailoring WHERE c<>'Y+';

View File

@@ -0,0 +1,31 @@
# The ASCII digits repertoire. It is compatible even with collations having
# anomalies on letters, but not with a collation with a different PAD/NOPAD.
# The result is printed instead of raising the error, to show both outcomes.
--echo # ASCII digits
--disable_query_log
DELIMITER $$;
BEGIN NOT ATOMIC
DECLARE CONTINUE HANDLER FOR 1267 /*Illegal mix of collations*/
SELECT 'ER_CANT_AGGREGATE_2COLLATIONS' AS d;
SELECT d FROM v_tailoring WHERE d='1';
END;
$$
DELIMITER ;$$
--enable_query_log
--echo # ASCII minus, dot and digits
--disable_query_log
DELIMITER $$;
BEGIN NOT ATOMIC
DECLARE CONTINUE HANDLER FOR 1267 /*Illegal mix of collations*/
SELECT 'ER_CANT_AGGREGATE_2COLLATIONS' AS e;
SELECT e FROM v_tailoring WHERE e='-1.5';
END;
$$
DELIMITER ;$$
--enable_query_log
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c<>'Y_';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c<>'Y+';

View File

@@ -0,0 +1,4 @@
SELECT Insert_priv FROM mysql.user WHERE Insert_priv='Y' LIMIT 0;
SELECT Insert_priv FROM mysql.user WHERE Insert_priv='Y_' LIMIT 0;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT Insert_priv FROM mysql.user WHERE Insert_priv='Y+' LIMIT 0;

View File

@@ -0,0 +1,29 @@
# The ASCII digits repertoire. It is compatible even with collations having
# anomalies on letters, but not with a collation with a different PAD/NOPAD.
# The result is printed instead of raising the error, to show both outcomes.
--echo # ASCII digits
--disable_query_log
DELIMITER $$;
BEGIN NOT ATOMIC
DECLARE CONTINUE HANDLER FOR 1267 /*Illegal mix of collations*/
SELECT 'ER_CANT_AGGREGATE_2COLLATIONS' AS d;
SELECT d FROM v_tailoring WHERE d='1';
END;
$$
DELIMITER ;$$
--enable_query_log
--echo # ASCII minus, dot and digits
--disable_query_log
DELIMITER $$;
BEGIN NOT ATOMIC
DECLARE CONTINUE HANDLER FOR 1267 /*Illegal mix of collations*/
SELECT 'ER_CANT_AGGREGATE_2COLLATIONS' AS e;
SELECT e FROM v_tailoring WHERE e='-1.5';
END;
$$
DELIMITER ;$$
--enable_query_log
SELECT c FROM v_tailoring WHERE c='Y';
SELECT c FROM v_tailoring WHERE c<>'Y_';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c<>'Y+';

View File

@@ -0,0 +1,24 @@
# Create a test view similar to mysql.user, which caused MDEV-41246:
# a latin1_swedish_ci column with the narrow repertoire ASCII_ALNUM,
# calculated by IF() from two literals. It always has exactly one row.
# The column c has the value 'Y', the column d (ASCII digits repertoire)
# has the value '1', and the column e (ASCII minus, dot and digits repertoire)
# has the value '-1.5'.
# The current client/connection character sets are preserved.
# The view is dropped by ctype_tailoring_view_drop.inc.
--disable_query_log
SET @ctype_tailoring_save_client= @@character_set_client;
SET @ctype_tailoring_save_results= @@character_set_results;
SET @ctype_tailoring_save_collation= @@collation_connection;
SET NAMES latin1 COLLATE latin1_swedish_ci;
CREATE TABLE t_tailoring (a INT);
INSERT INTO t_tailoring VALUES (1);
CREATE VIEW v_tailoring AS
SELECT IF(a=1,'Y','N') AS c, IF(a=1,'1','2') AS d,
IF(a=1,'-1.5','2.5') AS e
FROM t_tailoring;
SET @@character_set_client= @ctype_tailoring_save_client;
SET @@character_set_results= @ctype_tailoring_save_results;
SET @@collation_connection= @ctype_tailoring_save_collation;
--enable_query_log

View File

@@ -0,0 +1,7 @@
--disable_query_log
DROP VIEW v_tailoring;
DROP TABLE t_tailoring;
SET @ctype_tailoring_save_client= NULL;
SET @ctype_tailoring_save_results= NULL;
SET @ctype_tailoring_save_collation= NULL;
--enable_query_log

View File

@@ -0,0 +1,24 @@
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES armscii8 COLLATE armscii8_general_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES armscii8 COLLATE armscii8_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (armscii8_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -0,0 +1,17 @@
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES armscii8 COLLATE armscii8_general_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_01_probe.inc
SET NAMES armscii8 COLLATE armscii8_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -175,3 +175,27 @@ z z
~ ~
drop table t1;
End of 5.0 tests.
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES ascii COLLATE ascii_general_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES ascii COLLATE ascii_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (ascii_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -11,3 +11,21 @@ drop table t1;
#
--echo End of 5.0 tests.
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES ascii COLLATE ascii_general_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_01_probe.inc
SET NAMES ascii COLLATE ascii_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -5644,3 +5644,406 @@ c1
#
# End of 10.5 tests
#
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
# Two different explicit COLLATE clauses are still not accepted,
# whether the character sets are different or the same
SELECT _latin1'a' COLLATE latin1_swedish_ci = _big5'a' COLLATE big5_chinese_ci;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,EXPLICIT) and (big5_chinese_ci,EXPLICIT) for operation '='
SELECT _latin1'a' COLLATE latin1_german1_ci = _latin1'a' COLLATE latin1_swedish_ci;
ERROR HY000: Illegal mix of collations (latin1_german1_ci,EXPLICIT) and (latin1_swedish_ci,EXPLICIT) for operation '='
SET NAMES big5 COLLATE big5_chinese_ci;
SELECT Insert_priv FROM mysql.user WHERE Insert_priv='Y' LIMIT 0;
Insert_priv
SELECT Insert_priv FROM mysql.user WHERE Insert_priv='Y_' LIMIT 0;
Insert_priv
SELECT Insert_priv FROM mysql.user WHERE Insert_priv='Y+' LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_chinese_ci,COERCIBLE) for operation '='
# Same as above, but using BETWEEN (3-operand aggregation)
SELECT Insert_priv FROM mysql.user WHERE Insert_priv BETWEEN 'A' AND 'Z' LIMIT 0;
Insert_priv
SELECT Insert_priv FROM mysql.user WHERE Insert_priv BETWEEN 'A' AND 'Z_' LIMIT 0;
Insert_priv
SELECT Insert_priv FROM mysql.user WHERE Insert_priv BETWEEN 'A_' AND 'Z' LIMIT 0;
Insert_priv
SELECT Insert_priv FROM mysql.user WHERE Insert_priv BETWEEN 'A' AND 'Z+' LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE) for operation 'between'
SELECT Insert_priv FROM mysql.user WHERE Insert_priv BETWEEN 'A+' AND 'Z' LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE) for operation 'between'
# Same as above, but using IN() (N-operand aggregation)
SELECT Insert_priv FROM mysql.user WHERE Insert_priv IN ('Y','N') LIMIT 0;
Insert_priv
SELECT Insert_priv FROM mysql.user WHERE Insert_priv IN ('Y_','N') LIMIT 0;
Insert_priv
SELECT Insert_priv FROM mysql.user WHERE Insert_priv IN ('Y','N+') LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE) for operation 'in'
SELECT Insert_priv FROM mysql.user WHERE Insert_priv IN ('Y+','N') LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE) for operation 'in'
# Same as above, but using STRCMP()
SELECT STRCMP(Insert_priv,'Y') FROM mysql.user LIMIT 0;
STRCMP(Insert_priv,'Y')
SELECT STRCMP(Insert_priv,'Y_') FROM mysql.user LIMIT 0;
STRCMP(Insert_priv,'Y_')
SELECT STRCMP(Insert_priv,'Y+') FROM mysql.user LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_chinese_ci,COERCIBLE) for operation 'strcmp'
# Same as above, but using LOCATE()/POSITION()/INSTR()
SELECT LOCATE('Y',Insert_priv) FROM mysql.user LIMIT 0;
LOCATE('Y',Insert_priv)
SELECT LOCATE('Y_',Insert_priv) FROM mysql.user LIMIT 0;
LOCATE('Y_',Insert_priv)
SELECT LOCATE('Y+',Insert_priv) FROM mysql.user LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_chinese_ci,COERCIBLE) for operation 'locate'
SELECT POSITION('Y' IN Insert_priv) FROM mysql.user LIMIT 0;
POSITION('Y' IN Insert_priv)
SELECT POSITION('Y+' IN Insert_priv) FROM mysql.user LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_chinese_ci,COERCIBLE) for operation 'locate'
SELECT INSTR(Insert_priv,'Y') FROM mysql.user LIMIT 0;
INSTR(Insert_priv,'Y')
SELECT INSTR(Insert_priv,'Y+') FROM mysql.user LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_chinese_ci,COERCIBLE) for operation 'locate'
# Same as above, but using FIELD()
SELECT FIELD(Insert_priv,'Y','N') FROM mysql.user LIMIT 0;
FIELD(Insert_priv,'Y','N')
SELECT FIELD(Insert_priv,'Y_','N') FROM mysql.user LIMIT 0;
FIELD(Insert_priv,'Y_','N')
SELECT FIELD(Insert_priv,'Y','N+') FROM mysql.user LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE) for operation 'field'
SELECT FIELD(Insert_priv,'Y+','N') FROM mysql.user LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE) for operation 'field'
# Same as above, but using FIND_IN_SET()
# (a single-value haystack, so the ',' separator does not
# itself force a wider repertoire)
SELECT FIND_IN_SET(Insert_priv,'Y') FROM mysql.user LIMIT 0;
FIND_IN_SET(Insert_priv,'Y')
SELECT FIND_IN_SET(Insert_priv,'Y_') FROM mysql.user LIMIT 0;
FIND_IN_SET(Insert_priv,'Y_')
SELECT FIND_IN_SET(Insert_priv,'Y+') FROM mysql.user LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_chinese_ci,COERCIBLE) for operation 'find_in_set'
# Same as above, but using LIKE
SELECT Insert_priv FROM mysql.user WHERE Insert_priv LIKE 'Y' LIMIT 0;
Insert_priv
SELECT Insert_priv FROM mysql.user WHERE Insert_priv LIKE 'Y_' LIMIT 0;
Insert_priv
SELECT Insert_priv FROM mysql.user WHERE Insert_priv LIKE 'Y+' LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_chinese_ci,COERCIBLE) for operation 'like'
# Same as above, but using RLIKE
SELECT Insert_priv FROM mysql.user WHERE Insert_priv RLIKE 'Y' LIMIT 0;
Insert_priv
SELECT Insert_priv FROM mysql.user WHERE Insert_priv RLIKE 'Y_' LIMIT 0;
Insert_priv
SELECT Insert_priv FROM mysql.user WHERE Insert_priv RLIKE 'Y+' LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_chinese_ci,COERCIBLE) for operation 'regexp'
# Same as above, but using REGEXP_INSTR()
SELECT REGEXP_INSTR(Insert_priv,'Y') FROM mysql.user LIMIT 0;
REGEXP_INSTR(Insert_priv,'Y')
SELECT REGEXP_INSTR(Insert_priv,'Y_') FROM mysql.user LIMIT 0;
REGEXP_INSTR(Insert_priv,'Y_')
SELECT REGEXP_INSTR(Insert_priv,'Y+') FROM mysql.user LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_chinese_ci,COERCIBLE) for operation 'regexp_instr'
# Same as above, but using MATCH ... AGAINST().
# Unlike the other comparison functions above, MATCH ... AGAINST()
# does not aggregate the AGAINST phrase's collation for the illegal-mix
# check: Item_func_match::fix_fields() calls
# agg_arg_charsets_for_comparison() on args+1 (the indexed column(s)
# only), skipping args[0], which is the AGAINST phrase (key_item()).
# The phrase is instead silently converted to the column's collation
# (search_value), so none of the queries below raise an error, even
# with a _bin column.
CREATE TABLE t1 (a VARCHAR(200) CHARACTER SET latin1 COLLATE latin1_swedish_ci,
FULLTEXT(a));
INSERT INTO t1 VALUES ('Y'),('N');
SET NAMES big5 COLLATE big5_chinese_ci;
SELECT MATCH(a) AGAINST('Y') FROM t1;
MATCH(a) AGAINST('Y')
0
0
SELECT MATCH(a) AGAINST('Y_') FROM t1;
MATCH(a) AGAINST('Y_')
0
0
SELECT MATCH(a) AGAINST('Y+') FROM t1;
MATCH(a) AGAINST('Y+')
0
0
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(200) CHARACTER SET latin1 COLLATE latin1_bin,
FULLTEXT(a));
INSERT INTO t1 VALUES ('Y'),('N');
SELECT MATCH(a) AGAINST('Y') FROM t1;
MATCH(a) AGAINST('Y')
0
0
DROP TABLE t1;
# Same as above, but using the simple CASE operator
SELECT CASE Insert_priv WHEN 'Y' THEN 1 WHEN 'N' THEN 0 END FROM mysql.user LIMIT 0;
CASE Insert_priv WHEN 'Y' THEN 1 WHEN 'N' THEN 0 END
SELECT CASE Insert_priv WHEN 'Y_' THEN 1 WHEN 'N' THEN 0 END FROM mysql.user LIMIT 0;
CASE Insert_priv WHEN 'Y_' THEN 1 WHEN 'N' THEN 0 END
SELECT CASE Insert_priv WHEN 'Y' THEN 1 WHEN 'N+' THEN 0 END FROM mysql.user LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE) for operation 'case'
SELECT CASE Insert_priv WHEN 'Y+' THEN 1 WHEN 'N' THEN 0 END FROM mysql.user LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE) for operation 'case'
SET NAMES big5 COLLATE big5_bin;
SELECT Insert_priv FROM mysql.user WHERE Insert_priv='Y' LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_bin,COERCIBLE) for operation '='
SELECT Insert_priv FROM mysql.user WHERE Insert_priv LIKE 'Y' LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_bin,COERCIBLE) for operation 'like'
SELECT Insert_priv FROM mysql.user WHERE Insert_priv RLIKE 'Y' LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_bin,COERCIBLE) for operation 'regexp'
SELECT REGEXP_INSTR(Insert_priv,'Y') FROM mysql.user LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_bin,COERCIBLE) for operation 'regexp_instr'
SELECT Insert_priv FROM mysql.user WHERE Insert_priv BETWEEN 'A' AND 'Z' LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (big5_bin,COERCIBLE), (big5_bin,COERCIBLE) for operation 'between'
SELECT Insert_priv FROM mysql.user WHERE Insert_priv IN ('Y','N') LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (big5_bin,COERCIBLE), (big5_bin,COERCIBLE) for operation 'in'
SELECT STRCMP(Insert_priv,'Y') FROM mysql.user LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_bin,COERCIBLE) for operation 'strcmp'
SELECT LOCATE('Y',Insert_priv) FROM mysql.user LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_bin,COERCIBLE) for operation 'locate'
SELECT FIELD(Insert_priv,'Y','N') FROM mysql.user LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (big5_bin,COERCIBLE), (big5_bin,COERCIBLE) for operation 'field'
SELECT FIND_IN_SET(Insert_priv,'Y') FROM mysql.user LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_bin,COERCIBLE) for operation 'find_in_set'
SELECT CASE Insert_priv WHEN 'Y' THEN 1 WHEN 'N' THEN 0 END FROM mysql.user LIMIT 0;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (big5_bin,COERCIBLE), (big5_bin,COERCIBLE) for operation 'case'
#
# The same checks using an own view instead of mysql.user.
# The view has exactly one row, so every query below returns
# a row, or raises an error.
#
SET NAMES big5 COLLATE big5_chinese_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_chinese_ci,COERCIBLE) for operation '<>'
# Same as above, but using BETWEEN (3-operand aggregation)
SELECT c FROM v_tailoring WHERE c BETWEEN 'A' AND 'Z';
c
Y
SELECT c FROM v_tailoring WHERE c BETWEEN 'A' AND 'Z_';
c
Y
SELECT c FROM v_tailoring WHERE c BETWEEN 'A_' AND 'Z';
c
Y
SELECT c FROM v_tailoring WHERE c BETWEEN 'A' AND 'Z+';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE) for operation 'between'
SELECT c FROM v_tailoring WHERE c BETWEEN 'A+' AND 'Z';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE) for operation 'between'
# Same as above, but using IN() (N-operand aggregation)
SELECT c FROM v_tailoring WHERE c IN ('Y','N');
c
Y
SELECT c FROM v_tailoring WHERE c NOT IN ('Y_','N');
c
Y
SELECT c FROM v_tailoring WHERE c IN ('Y','N+');
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE) for operation 'in'
SELECT c FROM v_tailoring WHERE c NOT IN ('Y+','N');
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE) for operation 'in'
# Same as above, but using STRCMP()
SELECT STRCMP(c,'Y') FROM v_tailoring;
STRCMP(c,'Y')
0
SELECT STRCMP(c,'Y_') FROM v_tailoring;
STRCMP(c,'Y_')
-1
SELECT STRCMP(c,'Y+') FROM v_tailoring;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_chinese_ci,COERCIBLE) for operation 'strcmp'
# Same as above, but using LOCATE()/POSITION()/INSTR()
SELECT LOCATE('Y',c) FROM v_tailoring;
LOCATE('Y',c)
1
SELECT LOCATE('Y_',c) FROM v_tailoring;
LOCATE('Y_',c)
0
SELECT LOCATE('Y+',c) FROM v_tailoring;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_chinese_ci,COERCIBLE) for operation 'locate'
SELECT POSITION('Y' IN c) FROM v_tailoring;
POSITION('Y' IN c)
1
SELECT POSITION('Y+' IN c) FROM v_tailoring;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_chinese_ci,COERCIBLE) for operation 'locate'
SELECT INSTR(c,'Y') FROM v_tailoring;
INSTR(c,'Y')
1
SELECT INSTR(c,'Y+') FROM v_tailoring;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_chinese_ci,COERCIBLE) for operation 'locate'
# Same as above, but using FIELD()
SELECT FIELD(c,'Y','N') FROM v_tailoring;
FIELD(c,'Y','N')
1
SELECT FIELD(c,'Y_','N') FROM v_tailoring;
FIELD(c,'Y_','N')
0
SELECT FIELD(c,'Y','N+') FROM v_tailoring;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE) for operation 'field'
SELECT FIELD(c,'Y+','N') FROM v_tailoring;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE) for operation 'field'
# Same as above, but using FIND_IN_SET()
# (a single-value haystack, so the ',' separator does not
# itself force a wider repertoire)
SELECT FIND_IN_SET(c,'Y') FROM v_tailoring;
FIND_IN_SET(c,'Y')
1
SELECT FIND_IN_SET(c,'Y_') FROM v_tailoring;
FIND_IN_SET(c,'Y_')
0
SELECT FIND_IN_SET(c,'Y+') FROM v_tailoring;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_chinese_ci,COERCIBLE) for operation 'find_in_set'
# Same as above, but using LIKE
SELECT c FROM v_tailoring WHERE c LIKE 'Y';
c
Y
SELECT c FROM v_tailoring WHERE c NOT LIKE 'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c NOT LIKE 'Y+';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_chinese_ci,COERCIBLE) for operation 'like'
# Same as above, but using RLIKE
SELECT c FROM v_tailoring WHERE c RLIKE 'Y';
c
Y
SELECT c FROM v_tailoring WHERE c NOT RLIKE 'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c RLIKE 'Y+';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_chinese_ci,COERCIBLE) for operation 'regexp'
# Same as above, but using REGEXP_INSTR()
SELECT REGEXP_INSTR(c,'Y') FROM v_tailoring;
REGEXP_INSTR(c,'Y')
1
SELECT REGEXP_INSTR(c,'Y_') FROM v_tailoring;
REGEXP_INSTR(c,'Y_')
0
SELECT REGEXP_INSTR(c,'Y+') FROM v_tailoring;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_chinese_ci,COERCIBLE) for operation 'regexp_instr'
# Same as above, but using the simple CASE operator
SELECT CASE c WHEN 'Y' THEN 1 WHEN 'N' THEN 0 END FROM v_tailoring;
CASE c WHEN 'Y' THEN 1 WHEN 'N' THEN 0 END
1
SELECT CASE c WHEN 'Y_' THEN 1 WHEN 'N' THEN 0 END FROM v_tailoring;
CASE c WHEN 'Y_' THEN 1 WHEN 'N' THEN 0 END
NULL
SELECT CASE c WHEN 'Y' THEN 1 WHEN 'N+' THEN 0 END FROM v_tailoring;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE) for operation 'case'
SELECT CASE c WHEN 'Y+' THEN 1 WHEN 'N' THEN 0 END FROM v_tailoring;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE) for operation 'case'
SET NAMES big5 COLLATE big5_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_bin,COERCIBLE) for operation '='
SELECT c FROM v_tailoring WHERE c LIKE 'Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_bin,COERCIBLE) for operation 'like'
SELECT c FROM v_tailoring WHERE c RLIKE 'Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_bin,COERCIBLE) for operation 'regexp'
SELECT REGEXP_INSTR(c,'Y') FROM v_tailoring;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_bin,COERCIBLE) for operation 'regexp_instr'
SELECT c FROM v_tailoring WHERE c BETWEEN 'A' AND 'Z';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (big5_bin,COERCIBLE), (big5_bin,COERCIBLE) for operation 'between'
SELECT c FROM v_tailoring WHERE c IN ('Y','N');
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (big5_bin,COERCIBLE), (big5_bin,COERCIBLE) for operation 'in'
SELECT STRCMP(c,'Y') FROM v_tailoring;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_bin,COERCIBLE) for operation 'strcmp'
SELECT LOCATE('Y',c) FROM v_tailoring;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_bin,COERCIBLE) for operation 'locate'
SELECT FIELD(c,'Y','N') FROM v_tailoring;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (big5_bin,COERCIBLE), (big5_bin,COERCIBLE) for operation 'field'
SELECT FIND_IN_SET(c,'Y') FROM v_tailoring;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_bin,COERCIBLE) for operation 'find_in_set'
SELECT CASE c WHEN 'Y' THEN 1 WHEN 'N' THEN 0 END FROM v_tailoring;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (big5_bin,COERCIBLE), (big5_bin,COERCIBLE) for operation 'case'
# The originally reported scenario: a view is created under latin1
# and queried under big5. The comparison must return the right rows.
SET NAMES latin1 COLLATE latin1_swedish_ci;
CREATE VIEW v1 AS SELECT 'Y' AS c1 UNION SELECT 'N';
SET NAMES big5 COLLATE big5_chinese_ci;
SELECT * FROM v1 WHERE c1='y';
c1
Y
SELECT * FROM v1 WHERE c1='Y';
c1
Y
SELECT * FROM v1 WHERE 'n'=c1;
c1
N
SELECT * FROM v1 WHERE c1='N';
c1
N
SELECT * FROM v1 WHERE c1='x';
c1
SELECT * FROM v1 WHERE c1 IN ('y','n') ORDER BY c1;
c1
N
Y
SELECT * FROM v1 WHERE c1 BETWEEN 'm' AND 'z' ORDER BY c1;
c1
N
Y
# The same view with prepared statement parameters.
# A parameter with a non-ALNUM value makes the collations incompatible.
PREPARE stmt FROM 'SELECT c1 FROM v1 WHERE c1=? ORDER BY c1';
SET @y='y', @n='N', @y_plus='Y+';
EXECUTE stmt USING @y;
c1
Y
EXECUTE stmt USING @n;
c1
N
EXECUTE stmt USING @y_plus;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_chinese_ci,COERCIBLE) for operation '='
EXECUTE stmt USING 'y';
c1
Y
EXECUTE stmt USING 'x';
c1
DEALLOCATE PREPARE stmt;
PREPARE stmt FROM 'SELECT c1 FROM v1 WHERE c1 IN (?,?) ORDER BY c1';
EXECUTE stmt USING 'y', 'n';
c1
N
Y
EXECUTE stmt USING 'y', 'Y+';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE), (big5_chinese_ci,COERCIBLE) for operation 'in'
DEALLOCATE PREPARE stmt;
EXECUTE IMMEDIATE 'SELECT c1 FROM v1 WHERE c1=?' USING 'y';
c1
Y
EXECUTE IMMEDIATE 'SELECT c1 FROM v1 WHERE c1=?' USING 'Y+';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_chinese_ci,COERCIBLE) for operation '='
DROP VIEW v1;
# Prepared statement parameters compared to a literal of another charset.
# A parameter with a non-ALNUM value makes the collations incompatible.
PREPARE stmt FROM 'SELECT _latin1''Y'' = ? AS r';
EXECUTE stmt USING @y;
r
1
EXECUTE stmt USING @n;
r
0
EXECUTE stmt USING @y_plus;
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_chinese_ci,COERCIBLE) for operation '='
DEALLOCATE PREPARE stmt;
PREPARE stmt FROM 'SELECT _latin1''Y+'' = ? AS r';
EXECUTE stmt USING 'y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_chinese_ci,COERCIBLE) for operation '='
EXECUTE stmt USING 'Y+';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_chinese_ci,COERCIBLE) for operation '='
DEALLOCATE PREPARE stmt;
EXECUTE IMMEDIATE 'SELECT _latin1''Y'' = ? AS r' USING 'y';
r
1
EXECUTE IMMEDIATE 'SELECT _latin1''Y'' = ? AS r' USING 'Y+';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (big5_chinese_ci,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -297,3 +297,311 @@ select strcmp(_big5'' collate big5_nopad_bin, _big5 0x0001050001) as c1;
--echo #
--echo # End of 10.5 tests
--echo #
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
--echo # Two different explicit COLLATE clauses are still not accepted,
--echo # whether the character sets are different or the same
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT _latin1'a' COLLATE latin1_swedish_ci = _big5'a' COLLATE big5_chinese_ci;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT _latin1'a' COLLATE latin1_german1_ci = _latin1'a' COLLATE latin1_swedish_ci;
SET NAMES big5 COLLATE big5_chinese_ci;
--disable_service_connection
--source include/ctype_tailoring_03_mysql_user_Insert_priv_last_error.inc
--echo # Same as above, but using BETWEEN (3-operand aggregation)
SELECT Insert_priv FROM mysql.user WHERE Insert_priv BETWEEN 'A' AND 'Z' LIMIT 0;
SELECT Insert_priv FROM mysql.user WHERE Insert_priv BETWEEN 'A' AND 'Z_' LIMIT 0;
SELECT Insert_priv FROM mysql.user WHERE Insert_priv BETWEEN 'A_' AND 'Z' LIMIT 0;
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT Insert_priv FROM mysql.user WHERE Insert_priv BETWEEN 'A' AND 'Z+' LIMIT 0;
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT Insert_priv FROM mysql.user WHERE Insert_priv BETWEEN 'A+' AND 'Z' LIMIT 0;
--echo # Same as above, but using IN() (N-operand aggregation)
SELECT Insert_priv FROM mysql.user WHERE Insert_priv IN ('Y','N') LIMIT 0;
SELECT Insert_priv FROM mysql.user WHERE Insert_priv IN ('Y_','N') LIMIT 0;
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT Insert_priv FROM mysql.user WHERE Insert_priv IN ('Y','N+') LIMIT 0;
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT Insert_priv FROM mysql.user WHERE Insert_priv IN ('Y+','N') LIMIT 0;
--echo # Same as above, but using STRCMP()
SELECT STRCMP(Insert_priv,'Y') FROM mysql.user LIMIT 0;
SELECT STRCMP(Insert_priv,'Y_') FROM mysql.user LIMIT 0;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT STRCMP(Insert_priv,'Y+') FROM mysql.user LIMIT 0;
--echo # Same as above, but using LOCATE()/POSITION()/INSTR()
SELECT LOCATE('Y',Insert_priv) FROM mysql.user LIMIT 0;
SELECT LOCATE('Y_',Insert_priv) FROM mysql.user LIMIT 0;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT LOCATE('Y+',Insert_priv) FROM mysql.user LIMIT 0;
SELECT POSITION('Y' IN Insert_priv) FROM mysql.user LIMIT 0;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT POSITION('Y+' IN Insert_priv) FROM mysql.user LIMIT 0;
SELECT INSTR(Insert_priv,'Y') FROM mysql.user LIMIT 0;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT INSTR(Insert_priv,'Y+') FROM mysql.user LIMIT 0;
--echo # Same as above, but using FIELD()
SELECT FIELD(Insert_priv,'Y','N') FROM mysql.user LIMIT 0;
SELECT FIELD(Insert_priv,'Y_','N') FROM mysql.user LIMIT 0;
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT FIELD(Insert_priv,'Y','N+') FROM mysql.user LIMIT 0;
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT FIELD(Insert_priv,'Y+','N') FROM mysql.user LIMIT 0;
--echo # Same as above, but using FIND_IN_SET()
--echo # (a single-value haystack, so the ',' separator does not
--echo # itself force a wider repertoire)
SELECT FIND_IN_SET(Insert_priv,'Y') FROM mysql.user LIMIT 0;
SELECT FIND_IN_SET(Insert_priv,'Y_') FROM mysql.user LIMIT 0;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT FIND_IN_SET(Insert_priv,'Y+') FROM mysql.user LIMIT 0;
--echo # Same as above, but using LIKE
SELECT Insert_priv FROM mysql.user WHERE Insert_priv LIKE 'Y' LIMIT 0;
SELECT Insert_priv FROM mysql.user WHERE Insert_priv LIKE 'Y_' LIMIT 0;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT Insert_priv FROM mysql.user WHERE Insert_priv LIKE 'Y+' LIMIT 0;
--echo # Same as above, but using RLIKE
SELECT Insert_priv FROM mysql.user WHERE Insert_priv RLIKE 'Y' LIMIT 0;
SELECT Insert_priv FROM mysql.user WHERE Insert_priv RLIKE 'Y_' LIMIT 0;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT Insert_priv FROM mysql.user WHERE Insert_priv RLIKE 'Y+' LIMIT 0;
--echo # Same as above, but using REGEXP_INSTR()
SELECT REGEXP_INSTR(Insert_priv,'Y') FROM mysql.user LIMIT 0;
SELECT REGEXP_INSTR(Insert_priv,'Y_') FROM mysql.user LIMIT 0;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT REGEXP_INSTR(Insert_priv,'Y+') FROM mysql.user LIMIT 0;
--echo # Same as above, but using MATCH ... AGAINST().
--echo # Unlike the other comparison functions above, MATCH ... AGAINST()
--echo # does not aggregate the AGAINST phrase's collation for the illegal-mix
--echo # check: Item_func_match::fix_fields() calls
--echo # agg_arg_charsets_for_comparison() on args+1 (the indexed column(s)
--echo # only), skipping args[0], which is the AGAINST phrase (key_item()).
--echo # The phrase is instead silently converted to the column's collation
--echo # (search_value), so none of the queries below raise an error, even
--echo # with a _bin column.
CREATE TABLE t1 (a VARCHAR(200) CHARACTER SET latin1 COLLATE latin1_swedish_ci,
FULLTEXT(a));
INSERT INTO t1 VALUES ('Y'),('N');
SET NAMES big5 COLLATE big5_chinese_ci;
SELECT MATCH(a) AGAINST('Y') FROM t1;
SELECT MATCH(a) AGAINST('Y_') FROM t1;
SELECT MATCH(a) AGAINST('Y+') FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(200) CHARACTER SET latin1 COLLATE latin1_bin,
FULLTEXT(a));
INSERT INTO t1 VALUES ('Y'),('N');
SELECT MATCH(a) AGAINST('Y') FROM t1;
DROP TABLE t1;
--echo # Same as above, but using the simple CASE operator
SELECT CASE Insert_priv WHEN 'Y' THEN 1 WHEN 'N' THEN 0 END FROM mysql.user LIMIT 0;
SELECT CASE Insert_priv WHEN 'Y_' THEN 1 WHEN 'N' THEN 0 END FROM mysql.user LIMIT 0;
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT CASE Insert_priv WHEN 'Y' THEN 1 WHEN 'N+' THEN 0 END FROM mysql.user LIMIT 0;
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT CASE Insert_priv WHEN 'Y+' THEN 1 WHEN 'N' THEN 0 END FROM mysql.user LIMIT 0;
SET NAMES big5 COLLATE big5_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT Insert_priv FROM mysql.user WHERE Insert_priv='Y' LIMIT 0;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT Insert_priv FROM mysql.user WHERE Insert_priv LIKE 'Y' LIMIT 0;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT Insert_priv FROM mysql.user WHERE Insert_priv RLIKE 'Y' LIMIT 0;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT REGEXP_INSTR(Insert_priv,'Y') FROM mysql.user LIMIT 0;
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT Insert_priv FROM mysql.user WHERE Insert_priv BETWEEN 'A' AND 'Z' LIMIT 0;
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT Insert_priv FROM mysql.user WHERE Insert_priv IN ('Y','N') LIMIT 0;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT STRCMP(Insert_priv,'Y') FROM mysql.user LIMIT 0;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT LOCATE('Y',Insert_priv) FROM mysql.user LIMIT 0;
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT FIELD(Insert_priv,'Y','N') FROM mysql.user LIMIT 0;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT FIND_IN_SET(Insert_priv,'Y') FROM mysql.user LIMIT 0;
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT CASE Insert_priv WHEN 'Y' THEN 1 WHEN 'N' THEN 0 END FROM mysql.user LIMIT 0;
--echo #
--echo # The same checks using an own view instead of mysql.user.
--echo # The view has exactly one row, so every query below returns
--echo # a row, or raises an error.
--echo #
--source include/ctype_tailoring_view_create.inc
SET NAMES big5 COLLATE big5_chinese_ci;
--source include/ctype_tailoring_03_probe_last_error.inc
--echo # Same as above, but using BETWEEN (3-operand aggregation)
SELECT c FROM v_tailoring WHERE c BETWEEN 'A' AND 'Z';
SELECT c FROM v_tailoring WHERE c BETWEEN 'A' AND 'Z_';
SELECT c FROM v_tailoring WHERE c BETWEEN 'A_' AND 'Z';
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT c FROM v_tailoring WHERE c BETWEEN 'A' AND 'Z+';
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT c FROM v_tailoring WHERE c BETWEEN 'A+' AND 'Z';
--echo # Same as above, but using IN() (N-operand aggregation)
SELECT c FROM v_tailoring WHERE c IN ('Y','N');
SELECT c FROM v_tailoring WHERE c NOT IN ('Y_','N');
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT c FROM v_tailoring WHERE c IN ('Y','N+');
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT c FROM v_tailoring WHERE c NOT IN ('Y+','N');
--echo # Same as above, but using STRCMP()
SELECT STRCMP(c,'Y') FROM v_tailoring;
SELECT STRCMP(c,'Y_') FROM v_tailoring;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT STRCMP(c,'Y+') FROM v_tailoring;
--echo # Same as above, but using LOCATE()/POSITION()/INSTR()
SELECT LOCATE('Y',c) FROM v_tailoring;
SELECT LOCATE('Y_',c) FROM v_tailoring;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT LOCATE('Y+',c) FROM v_tailoring;
SELECT POSITION('Y' IN c) FROM v_tailoring;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT POSITION('Y+' IN c) FROM v_tailoring;
SELECT INSTR(c,'Y') FROM v_tailoring;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT INSTR(c,'Y+') FROM v_tailoring;
--echo # Same as above, but using FIELD()
SELECT FIELD(c,'Y','N') FROM v_tailoring;
SELECT FIELD(c,'Y_','N') FROM v_tailoring;
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT FIELD(c,'Y','N+') FROM v_tailoring;
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT FIELD(c,'Y+','N') FROM v_tailoring;
--echo # Same as above, but using FIND_IN_SET()
--echo # (a single-value haystack, so the ',' separator does not
--echo # itself force a wider repertoire)
SELECT FIND_IN_SET(c,'Y') FROM v_tailoring;
SELECT FIND_IN_SET(c,'Y_') FROM v_tailoring;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT FIND_IN_SET(c,'Y+') FROM v_tailoring;
--echo # Same as above, but using LIKE
SELECT c FROM v_tailoring WHERE c LIKE 'Y';
SELECT c FROM v_tailoring WHERE c NOT LIKE 'Y_';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c NOT LIKE 'Y+';
--echo # Same as above, but using RLIKE
SELECT c FROM v_tailoring WHERE c RLIKE 'Y';
SELECT c FROM v_tailoring WHERE c NOT RLIKE 'Y_';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c RLIKE 'Y+';
--echo # Same as above, but using REGEXP_INSTR()
SELECT REGEXP_INSTR(c,'Y') FROM v_tailoring;
SELECT REGEXP_INSTR(c,'Y_') FROM v_tailoring;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT REGEXP_INSTR(c,'Y+') FROM v_tailoring;
--echo # Same as above, but using the simple CASE operator
SELECT CASE c WHEN 'Y' THEN 1 WHEN 'N' THEN 0 END FROM v_tailoring;
SELECT CASE c WHEN 'Y_' THEN 1 WHEN 'N' THEN 0 END FROM v_tailoring;
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT CASE c WHEN 'Y' THEN 1 WHEN 'N+' THEN 0 END FROM v_tailoring;
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT CASE c WHEN 'Y+' THEN 1 WHEN 'N' THEN 0 END FROM v_tailoring;
SET NAMES big5 COLLATE big5_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c LIKE 'Y';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c RLIKE 'Y';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT REGEXP_INSTR(c,'Y') FROM v_tailoring;
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT c FROM v_tailoring WHERE c BETWEEN 'A' AND 'Z';
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT c FROM v_tailoring WHERE c IN ('Y','N');
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT STRCMP(c,'Y') FROM v_tailoring;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT LOCATE('Y',c) FROM v_tailoring;
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT FIELD(c,'Y','N') FROM v_tailoring;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT FIND_IN_SET(c,'Y') FROM v_tailoring;
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT CASE c WHEN 'Y' THEN 1 WHEN 'N' THEN 0 END FROM v_tailoring;
--source include/ctype_tailoring_view_drop.inc
--echo # The originally reported scenario: a view is created under latin1
--echo # and queried under big5. The comparison must return the right rows.
SET NAMES latin1 COLLATE latin1_swedish_ci;
CREATE VIEW v1 AS SELECT 'Y' AS c1 UNION SELECT 'N';
SET NAMES big5 COLLATE big5_chinese_ci;
SELECT * FROM v1 WHERE c1='y';
SELECT * FROM v1 WHERE c1='Y';
SELECT * FROM v1 WHERE 'n'=c1;
SELECT * FROM v1 WHERE c1='N';
SELECT * FROM v1 WHERE c1='x';
SELECT * FROM v1 WHERE c1 IN ('y','n') ORDER BY c1;
SELECT * FROM v1 WHERE c1 BETWEEN 'm' AND 'z' ORDER BY c1;
--enable_service_connection
--echo # The same view with prepared statement parameters.
--echo # A parameter with a non-ALNUM value makes the collations incompatible.
PREPARE stmt FROM 'SELECT c1 FROM v1 WHERE c1=? ORDER BY c1';
SET @y='y', @n='N', @y_plus='Y+';
EXECUTE stmt USING @y;
EXECUTE stmt USING @n;
--error ER_CANT_AGGREGATE_2COLLATIONS
EXECUTE stmt USING @y_plus;
EXECUTE stmt USING 'y';
EXECUTE stmt USING 'x';
DEALLOCATE PREPARE stmt;
PREPARE stmt FROM 'SELECT c1 FROM v1 WHERE c1 IN (?,?) ORDER BY c1';
EXECUTE stmt USING 'y', 'n';
--error ER_CANT_AGGREGATE_3COLLATIONS
EXECUTE stmt USING 'y', 'Y+';
DEALLOCATE PREPARE stmt;
EXECUTE IMMEDIATE 'SELECT c1 FROM v1 WHERE c1=?' USING 'y';
--error ER_CANT_AGGREGATE_2COLLATIONS
EXECUTE IMMEDIATE 'SELECT c1 FROM v1 WHERE c1=?' USING 'Y+';
DROP VIEW v1;
--echo # Prepared statement parameters compared to a literal of another charset.
--echo # A parameter with a non-ALNUM value makes the collations incompatible.
PREPARE stmt FROM 'SELECT _latin1''Y'' = ? AS r';
EXECUTE stmt USING @y;
EXECUTE stmt USING @n;
--error ER_CANT_AGGREGATE_2COLLATIONS
EXECUTE stmt USING @y_plus;
DEALLOCATE PREPARE stmt;
PREPARE stmt FROM 'SELECT _latin1''Y+'' = ? AS r';
--error ER_CANT_AGGREGATE_2COLLATIONS
EXECUTE stmt USING 'y';
--error ER_CANT_AGGREGATE_2COLLATIONS
EXECUTE stmt USING 'Y+';
DEALLOCATE PREPARE stmt;
EXECUTE IMMEDIATE 'SELECT _latin1''Y'' = ? AS r' USING 'y';
--error ER_CANT_AGGREGATE_2COLLATIONS
EXECUTE IMMEDIATE 'SELECT _latin1''Y'' = ? AS r' USING 'Y+';
SET NAMES DEFAULT;
--echo # End of 11.8 tests

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,235 @@
--source include/have_big5.inc
--source include/have_utf32.inc
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
--disable_query_log
SET @mask='^big5';
SET @extra_collations_query=
'INSERT INTO collations VALUES'
'(''big5_chinese_ci''),(''big5_chinese_nopad_ci''),'
'(''big5_bin''),(''big5_nopad_bin'')';
--source include/ctype_tailoring_00.inc
--enable_query_log
--echo # HEX() output is only [0-9A-F], so its repertoire is
--echo # MY_REPERTOIRE_ASCII_ALNUM. It can tailoring-match a collation pair
--echo # that is incompatible on the full ASCII repertoire.
SELECT HEX('a') = _big5'61';
--echo # Item_null has the repertoire MY_REPERTOIRE_NONE, the identity element
--echo # for repertoire aggregation: a NULL operand does not widen
--echo # the repertoire of an IN()/CASE/BETWEEN aggregate...
SELECT _latin1'Y' in (NULL, _big5'Y');
--echo # ... and does not mask a genuine incompatibility either.
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT _latin1'Y+' in (NULL, _big5'Y+');
--echo # The empty string has the repertoire NONE on both sides, so it is
--echo # always compatible, regardless of collation.
SELECT _latin1'' = _big5'';
--echo #
--echo # MDEV-41246 QUOTE(), GROUP_CONCAT(), MAKE_SET() and EXPORT_SET() add
--echo # characters of their own (quotes/backslashes, the ',' separator) that
--echo # are not in their arguments' repertoire. The result's repertoire must
--echo # include them too, or illegal-mix-by-repertoire detection becomes
--echo # asymmetric.
--echo #
--echo # latin1_swedish_ci and big5_chinese_ci are compatible on the ALNUM
--echo # repertoire, but not on the wider repertoire these functions can add
--echo # (see the C_ascii1 row above).
--echo #
SELECT _latin1'a' = _big5'a';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT QUOTE(_latin1'a') = _big5'a';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT _big5'a' = QUOTE(_latin1'a');
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT (SELECT GROUP_CONCAT(_latin1'a')) = _big5'a';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT _big5'a' = (SELECT GROUP_CONCAT(_latin1'a'));
--echo # An explicit ALNUM or empty separator does not force the repertoire wider
SELECT (SELECT GROUP_CONCAT(_latin1'a' SEPARATOR 'x')) = _big5'a';
SELECT (SELECT GROUP_CONCAT(_latin1'a' SEPARATOR '')) = _big5'a';
--echo # An explicit non-ALNUM separator widens the repertoire
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT (SELECT GROUP_CONCAT(_latin1'a' SEPARATOR ',')) = _big5'a';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT (SELECT GROUP_CONCAT(_latin1'a' SEPARATOR '+')) = _big5'a';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT _big5'a' = (SELECT GROUP_CONCAT(_latin1'a' SEPARATOR ' '));
--echo # MAKE_SET() can add a ',' separator as soon as there is more than one
--echo # possible value, even when, like here, the chosen bit produces none.
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT MAKE_SET(3,_latin1'a',_latin1'b') = _big5'a,b';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT MAKE_SET(1,_latin1'a',_latin1'b') = _big5'a';
--echo # Only one possible value: no separator can ever appear.
SELECT MAKE_SET(1,_latin1'a') = _big5'a';
--echo # EXPORT_SET()'s default ',' separator is outside the ALNUM repertoire.
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT EXPORT_SET(1,_latin1'y',_latin1'n') = _big5'y';
--echo # An explicit ALNUM separator does not force the repertoire wider.
SELECT EXPORT_SET(1,_latin1'y',_latin1'n',_latin1'x',1) = _big5'y';
--echo # An explicit non-ALNUM separator is detected through normal argument
--echo # aggregation, same as for GROUP_CONCAT/MAKE_SET's hard-coded separator.
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT EXPORT_SET(1,_latin1'y',_latin1'n',_latin1',',1) = _big5'y';
--echo # LPAD()/RPAD() with no explicit pad string default to ' ', which is
--echo # outside the ALNUM repertoire.
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT LPAD(_latin1'a',3) = _big5'a';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT RPAD(_latin1'a',3) = _big5'a';
--echo # An explicit ALNUM pad string does not force the repertoire wider.
SELECT LPAD(_latin1'a',3,_latin1'x') = _big5'xxa';
--echo # An explicit non-ALNUM pad string is detected through normal argument
--echo # aggregation, same as for the default ' ' above.
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT LPAD(_latin1'a',3,_latin1'-') = _big5'--a';
--echo # JSON_OBJECTAGG() adds '{', '}', '"', ':', ',' and ' ' of its own,
--echo # which are outside the ALNUM repertoire.
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT JSON_OBJECTAGG(_latin1'a',_latin1'b') = _big5'a';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT _big5'a' = JSON_OBJECTAGG(_latin1'a',_latin1'b');
--echo # JSON_ARRAY() and JSON_OBJECT() also add '[', ']', '{', '}', '"', ':',
--echo # ',' and ' ' of their own, so the same applies to them.
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT JSON_ARRAY(_latin1'a') = _big5'a';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT _big5'a' = JSON_ARRAY(_latin1'a');
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT JSON_OBJECT(_latin1'a',_latin1'b') = _big5'a';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT _big5'a' = JSON_OBJECT(_latin1'a',_latin1'b');
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT JSON_MERGE_PRESERVE(_latin1'1',_latin1'2') = _big5'a';
--echo # JSON_ARRAY() without arguments returns '[]', which is ASCII
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT JSON_ARRAY() = _big5'a';
--echo # JSON_ARRAYAGG() already inherits the ',' repertoire from GROUP_CONCAT()
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT JSON_ARRAYAGG(_latin1'a') = _big5'a';
--echo #
--echo # DATE_FORMAT() result repertoire depends on the locale
--echo # which is actually used: the explicit third argument, or
--echo # @@lc_time_names. Locale names (e.g. of days) can be non-ASCII.
--echo # big5_chinese_ci and latin1_swedish_ci are not compatible on ASCII,
--echo # unless the DATE_FORMAT() result is allowed to be non-ASCII,
--echo # so its collation can be preferred.
--echo #
SET NAMES big5;
--echo # en_US names are ASCII
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT DATE_FORMAT('2024-01-02','%W') = _latin1'a';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT DATE_FORMAT('2024-01-02','%W','en_US') = _latin1'a';
--echo # An explicit non-ASCII locale is not ignored
SELECT DATE_FORMAT('2024-01-02','%W','ru_RU') = _latin1'a';
--echo # A non-constant locale is not known at the fixing time
SET @loc='en_US';
SELECT DATE_FORMAT('2024-01-02','%W',@loc) = _latin1'a';
--echo # The session locale is not used when the locale is passed explicitly
SET lc_time_names=ru_RU;
SELECT DATE_FORMAT('2024-01-02','%W') = _latin1'a';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT DATE_FORMAT('2024-01-02','%W','en_US') = _latin1'a';
SET lc_time_names=DEFAULT;
SET NAMES DEFAULT;
--echo #
--echo # MDEV-41246 Negative cases: the collations are still incompatible
--echo # when the strings are not ASCII only, or when a string result
--echo # function mixes arguments of different collations.
--echo #
SET NAMES latin1;
--echo # Non-ASCII literals. If only one side is non-ASCII, the ASCII side
--echo # is converted to the character set of the non-ASCII one.
SELECT _latin1 0xE9 = _big5'a';
SELECT _latin1'a' = _big5 0xA4A4;
SELECT _latin1 0xE9 IN (_big5'a', _big5'b');
--echo # If both sides are non-ASCII, no conversion is possible
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT _latin1 0xE9 = _big5 0xA4A4;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT CONCAT(_latin1'a',_latin1 0xE9) = _big5 0xA4A4;
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT _latin1 0xE9 IN (_big5 0xA4A4, _big5'b');
--echo # String result functions do not use the tailoring optimization:
--echo # the collation of the result must be calculated precisely
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT REPLACE(_latin1'abc', _big5'a', _big5'b');
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT REPLACE(_latin1'abc', _latin1'a', _big5'b');
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT SUBSTRING_INDEX(_latin1'a,b', _big5',', 1);
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT SUBSTRING_INDEX(_latin1'a,b', _big5'x', 1);
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT TRIM(_big5'a' FROM _latin1'abc');
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT GREATEST(_latin1'a', _big5'b');
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT LEAST(_latin1'a', _big5'b');
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT COALESCE(_latin1'a', _big5'b');
--echo # A non-ASCII argument makes the ASCII argument converted
SELECT COALESCE(_latin1'a', _big5 0xA4A4);
--echo # The same functions with arguments of the same collation
--echo # can be compared with a string of a compatible collation,
--echo # unless the result can contain non-ALNUM characters
SELECT COALESCE(_latin1'a', _latin1'b') = _big5'a';
SELECT GREATEST(_latin1'a', _latin1'b') = _big5'b';
SELECT REPLACE(_latin1'abc', _latin1'a', _latin1'b') = _big5'bbc';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT TRIM(_latin1' abc ') = _big5'abc';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT SUBSTRING_INDEX(_latin1'a,b', _latin1',', 1) = _big5'a';
--echo # Indexed columns. A column has a stronger derivation than a literal,
--echo # so the collation of the column is used and the index is used.
CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET latin1 COLLATE latin1_swedish_ci,
KEY(a)) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('a'),('b'),('Y'),('y'),('x');
CREATE TABLE t2 (a VARCHAR(10) CHARACTER SET big5 COLLATE big5_chinese_ci,
KEY(a)) ENGINE=MyISAM;
INSERT INTO t2 VALUES ('a'),('b'),('Y'),('y'),('x');
SET NAMES big5;
EXPLAIN SELECT * FROM t1 WHERE a='y';
SELECT * FROM t1 WHERE a='y' ORDER BY a;
EXPLAIN SELECT * FROM t1 WHERE a=_big5'Y+';
SELECT * FROM t1 WHERE a=_big5'Y+';
SET NAMES latin1;
EXPLAIN SELECT * FROM t2 WHERE a=_latin1'y';
SELECT * FROM t2 WHERE a=_latin1'y' ORDER BY a;
--echo # Two columns of different collations are still incompatible,
--echo # as they have equal derivation, and the repertoire of a column
--echo # is not limited
--error ER_CANT_AGGREGATE_2COLLATIONS
EXPLAIN SELECT * FROM t2, t1 WHERE t1.a=t2.a;
DROP TABLE t1, t2;
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -0,0 +1,56 @@
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES cp1250 COLLATE cp1250_general_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES cp1250 COLLATE cp1250_croatian_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES cp1250 COLLATE cp1250_polish_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES cp1250 COLLATE cp1250_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (cp1250_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -0,0 +1,23 @@
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES cp1250 COLLATE cp1250_general_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_01_probe.inc
SET NAMES cp1250 COLLATE cp1250_croatian_ci;
--source include/ctype_tailoring_01_probe.inc
SET NAMES cp1250 COLLATE cp1250_polish_ci;
--source include/ctype_tailoring_01_probe.inc
SET NAMES cp1250 COLLATE cp1250_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -912,3 +912,24 @@ A401
#
# End of 5.6 tests
#
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES cp1250 COLLATE cp1250_czech_cs;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (cp1250_czech_cs,COERCIBLE) for operation '='
SELECT c FROM v_tailoring WHERE c<>'Y_';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (cp1250_czech_cs,COERCIBLE) for operation '<>'
SELECT c FROM v_tailoring WHERE c<>'Y+';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (cp1250_czech_cs,COERCIBLE) for operation '<>'
SET NAMES cp1250 COLLATE cp1250_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (cp1250_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -114,3 +114,18 @@ set names cp1250 collate cp1250_czech_cs;
--echo # End of 5.6 tests
--echo #
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES cp1250 COLLATE cp1250_czech_cs;
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_02_probe_error.inc
SET NAMES cp1250 COLLATE cp1250_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -3425,3 +3425,71 @@ DROP TABLE t1;
#
# End of 10.1 tests
#
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES cp1251 COLLATE cp1251_general_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES cp1251 COLLATE cp1251_bulgarian_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES cp1251 COLLATE cp1251_ukrainian_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (cp1251_ukrainian_ci,COERCIBLE) for operation '<>'
SET NAMES cp1251 COLLATE cp1251_general_cs;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (cp1251_general_cs,COERCIBLE) for operation '='
SELECT c FROM v_tailoring WHERE c<>'Y_';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (cp1251_general_cs,COERCIBLE) for operation '<>'
SELECT c FROM v_tailoring WHERE c<>'Y+';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (cp1251_general_cs,COERCIBLE) for operation '<>'
SET NAMES cp1251 COLLATE cp1251_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (cp1251_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -143,3 +143,33 @@ DROP TABLE t1;
--echo #
--echo # End of 10.1 tests
--echo #
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES cp1251 COLLATE cp1251_general_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_01_probe.inc
SET NAMES cp1251 COLLATE cp1251_bulgarian_ci;
--source include/ctype_tailoring_01_probe.inc
SET NAMES cp1251 COLLATE cp1251_ukrainian_ci;
--source include/ctype_tailoring_03_probe_last_error.inc
SET NAMES cp1251 COLLATE cp1251_general_cs;
--source include/ctype_tailoring_02_probe_error.inc
SET NAMES cp1251 COLLATE cp1251_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -0,0 +1,24 @@
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES cp1256 COLLATE cp1256_general_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES cp1256 COLLATE cp1256_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (cp1256_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -0,0 +1,17 @@
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES cp1256 COLLATE cp1256_general_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_01_probe.inc
SET NAMES cp1256 COLLATE cp1256_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -0,0 +1,37 @@
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES cp1257 COLLATE cp1257_general_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES cp1257 COLLATE cp1257_lithuanian_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (cp1257_lithuanian_ci,COERCIBLE) for operation '='
SELECT c FROM v_tailoring WHERE c<>'Y_';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (cp1257_lithuanian_ci,COERCIBLE) for operation '<>'
SELECT c FROM v_tailoring WHERE c<>'Y+';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (cp1257_lithuanian_ci,COERCIBLE) for operation '<>'
SET NAMES cp1257 COLLATE cp1257_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (cp1257_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -0,0 +1,20 @@
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES cp1257 COLLATE cp1257_general_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_01_probe.inc
SET NAMES cp1257 COLLATE cp1257_lithuanian_ci;
--source include/ctype_tailoring_02_probe_error.inc
SET NAMES cp1257 COLLATE cp1257_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -1062,3 +1062,27 @@ _cp850'' LIKE _cp850'' ESCAPE _cp850 0xFF
#
# End of 10.2 tests
#
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES cp850 COLLATE cp850_general_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES cp850 COLLATE cp850_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (cp850_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -46,3 +46,22 @@ DELIMITER ;$$
--echo #
--echo # End of 10.2 tests
--echo #
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES cp850 COLLATE cp850_general_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_01_probe.inc
SET NAMES cp850 COLLATE cp850_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -0,0 +1,24 @@
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES cp852 COLLATE cp852_general_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES cp852 COLLATE cp852_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (cp852_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -0,0 +1,17 @@
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES cp852 COLLATE cp852_general_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_01_probe.inc
SET NAMES cp852 COLLATE cp852_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -10,3 +10,24 @@ _cp866'' LIKE _cp866'' ESCAPE _cp866 0xFF
#
# End of 10.2 tests
#
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES cp866 COLLATE cp866_general_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (cp866_general_ci,COERCIBLE) for operation '='
SELECT c FROM v_tailoring WHERE c<>'Y_';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (cp866_general_ci,COERCIBLE) for operation '<>'
SELECT c FROM v_tailoring WHERE c<>'Y+';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (cp866_general_ci,COERCIBLE) for operation '<>'
SET NAMES cp866 COLLATE cp866_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (cp866_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -12,3 +12,21 @@ SELECT _cp866'' LIKE _cp866'' ESCAPE _cp866 0xFF;
--echo #
--echo # End of 10.2 tests
--echo #
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES cp866 COLLATE cp866_general_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_02_probe_error.inc
SET NAMES cp866 COLLATE cp866_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -939,3 +939,49 @@ c1
#
# End of 10.5 tests
#
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES cp932 COLLATE cp932_japanese_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES cp932 COLLATE cp932_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (cp932_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
#
# MDEV-41246 ExtractValue() and UpdateXML() return a string, so they
# must not use the tailoring-based collation aggregation, which is only
# intended for comparison operators.
#
SET NAMES latin1;
SELECT COLLATION(ExtractValue(_cp932'<a>x</a>', _latin1'a'));
ERROR HY000: Illegal mix of collations (cp932_japanese_ci,COERCIBLE) and (latin1_swedish_ci,COERCIBLE) for operation 'extractvalue'
SELECT COLLATION(ExtractValue(_latin1'<a>x</a>', _cp932'a'));
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (cp932_japanese_ci,COERCIBLE) for operation 'extractvalue'
SELECT COLLATION(UpdateXML(_latin1'<a>x</a>', _cp932'/a', _cp932'<a>y</a>'));
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (cp932_japanese_ci,COERCIBLE), (cp932_japanese_ci,COERCIBLE) for operation 'updatexml'
SELECT COLLATION(UpdateXML(_cp932'<a>x</a>', _latin1'/a', _latin1'<a>y</a>'));
ERROR HY000: Illegal mix of collations (cp932_japanese_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'updatexml'
# Same character set arguments still work
SELECT ExtractValue(_cp932'<a>x</a>', _cp932'/a');
ExtractValue(_cp932'<a>x</a>', _cp932'/a')
x
SELECT UpdateXML(_latin1'<a>x</a>', _latin1'/a', _latin1'<a>y</a>');
UpdateXML(_latin1'<a>x</a>', _latin1'/a', _latin1'<a>y</a>')
<a>y</a>
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -80,3 +80,43 @@ select strcmp(_cp932'' collate cp932_nopad_bin, _cp932 0x0001050001) as c1;
--echo #
--echo # End of 10.5 tests
--echo #
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES cp932 COLLATE cp932_japanese_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_01_probe.inc
SET NAMES cp932 COLLATE cp932_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo #
--echo # MDEV-41246 ExtractValue() and UpdateXML() return a string, so they
--echo # must not use the tailoring-based collation aggregation, which is only
--echo # intended for comparison operators.
--echo #
SET NAMES latin1;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT COLLATION(ExtractValue(_cp932'<a>x</a>', _latin1'a'));
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT COLLATION(ExtractValue(_latin1'<a>x</a>', _cp932'a'));
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT COLLATION(UpdateXML(_latin1'<a>x</a>', _cp932'/a', _cp932'<a>y</a>'));
--error ER_CANT_AGGREGATE_3COLLATIONS
SELECT COLLATION(UpdateXML(_cp932'<a>x</a>', _latin1'/a', _latin1'<a>y</a>'));
--echo # Same character set arguments still work
SELECT ExtractValue(_cp932'<a>x</a>', _cp932'/a');
SELECT UpdateXML(_latin1'<a>x</a>', _latin1'/a', _latin1'<a>y</a>');
SET NAMES DEFAULT;
--echo # End of 11.8 tests

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,128 @@
--source include/have_cp932.inc
--source include/have_utf32.inc
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
--disable_query_log
SET @mask='^cp932';
SET @extra_collations_query=
'INSERT INTO collations VALUES'
'(''cp932_japanese_ci''),(''cp932_japanese_nopad_ci''),'
'(''cp932_bin''),(''cp932_nopad_bin'')';
--source include/ctype_tailoring_00.inc
--enable_query_log
--echo #
--echo # DATE_FORMAT() result repertoire depends on the locale
--echo # which is actually used: the explicit third argument, or
--echo # @@lc_time_names. Locale names (e.g. of days) can be non-ASCII.
--echo # cp932_japanese_ci and latin1_swedish_ci are compatible on ASCII, so
--echo # no error is expected, whatever the repertoire of the result is.
--echo #
SET NAMES cp932;
#
# Why this query does not fail with an error:
# DATE_FORMAT('2024-01-02','%W','en_US') = _latin1'a'
# (see DTCollation::aggregate() and aggregate_by_tailoring() in sql/item.cc):
#
# - Both sides are COERCIBLE, the character sets are different (cp932 and
# latin1), and none of them is a Unicode superset of the other.
# - The names of days in en_US are ASCII, so the repertoire of the left side
# is ASCII only (the format string contains '%'). The right side is
# ASCII only too (_latin1'a'). So the rule "Allow convert from ASCII" in
# left_is_superset() does not choose a winner: neither side is a superset.
# - The next step is the tailoring optimization. Both collations
# are PAD, and none of them is a UCA collation. Their tailorings on
# the cumulative ASCII repertoire are equal (ascii7_caseup_ci), as both
# collations convert lower case letters to upper case ones and sort
# all other ASCII characters in the code point order.
# So the collations are compatible on the ASCII repertoire.
# - Any of the two collations can be used for comparison.
# The algorithmically simpler one wins: latin1_swedish_ci has
# mbmaxlen 1, and cp932_japanese_ci has mbmaxlen 2. So the right side
# wins and the left side is converted to latin1. It is safe, as
# the left side is ASCII only.
#
# With a collation which is not compatible with cp932_japanese_ci on
# the ASCII repertoire, e.g. latin5_turkish_ci (it reorders ASCII letters),
# the same query fails with ER_CANT_AGGREGATE_2COLLATIONS. In
# ctype_big5_tailoring.test the partner is latin1, because big5_chinese_ci
# has no tailoring on the ASCII repertoire, so the query fails there.
#
--echo # en_US names are ASCII
SELECT DATE_FORMAT('2024-01-02','%W') = _latin1'a';
SELECT DATE_FORMAT('2024-01-02','%W','en_US') = _latin1'a';
#
# Why the collation of the left side (cp932_japanese_ci) wins in
# DATE_FORMAT('2024-01-02','%W','ru_RU') = _latin1'a'
# (see DTCollation::aggregate() and left_is_superset() in sql/item.cc):
#
# - Both sides have the same derivation: COERCIBLE (a function result
# with a literal format, and a string literal), so the derivation
# cannot decide.
# - The character sets are different (cp932 and latin1), and none of them
# is a Unicode superset of the other.
# - The right side is _latin1'a'. Its repertoire is ASCII only, so it can be
# converted to any ASCII compatible character set without data loss,
# including cp932.
# - The left side is DATE_FORMAT() with the locale ru_RU. The names of days
# in ru_RU are not ASCII, therefore the repertoire of the result
# includes MY_REPERTOIRE_EXTENDED. So it cannot be converted to latin1.
# - Therefore the rule "Allow convert from ASCII" in left_is_superset() says
# that the left side is a superset of the right side: the right side is
# ASCII only, and the left side is not. The left side wins and the right
# side is converted to cp932. The tailoring optimization is not even tried.
#
# If the repertoire of the left side was ASCII only (e.g. with the locale
# en_US), then neither side would be a superset of the other one, and the
# result would depend on the tailoring of the two collations. The result
# of this query would be the same: cp932_japanese_ci and latin1_swedish_ci
# have equal tailorings on the ASCII repertoire.
#
--echo # An explicit non-ASCII locale is not ignored.
--echo # This query does not fail with an error: the DATE_FORMAT() result is
--echo # non-ASCII, so the collation of the result is used for comparison.
--echo # Note, it would not fail even if the result was ASCII, as
--echo # cp932_japanese_ci and latin1_swedish_ci are compatible on ASCII.
SELECT DATE_FORMAT('2024-01-02','%W','ru_RU') = _latin1'a';
--echo # A non-constant locale is not known at the fixing time
SET @loc='en_US';
SELECT DATE_FORMAT('2024-01-02','%W',@loc) = _latin1'a';
--echo # The session locale is not used when the locale is passed explicitly
SET lc_time_names=ru_RU;
SELECT DATE_FORMAT('2024-01-02','%W') = _latin1'a';
SELECT DATE_FORMAT('2024-01-02','%W','en_US') = _latin1'a';
SET lc_time_names=DEFAULT;
SET NAMES DEFAULT;
--echo #
--echo # DATE_FORMAT() with cp932 and latin5. cp932_japanese_ci and
--echo # latin5_turkish_ci are not compatible on ASCII (latin5_turkish_ci
--echo # reorders ASCII letters), so unlike the latin1 queries above,
--echo # the repertoire of the DATE_FORMAT() result decides the outcome.
--echo #
SET NAMES cp932;
--echo # en_US names are ASCII: no side is a superset, and the tailorings
--echo # are not equal, so the query fails
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT DATE_FORMAT('2024-01-02','%W') = _latin5'a';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT DATE_FORMAT('2024-01-02','%W','en_US') = _latin5'a';
--echo # ru_RU names are not ASCII: the right side is ASCII only, so it
--echo # is converted to cp932, and the left side collation wins
SELECT DATE_FORMAT('2024-01-02','%W','ru_RU') = _latin5'a';
--echo # A non-constant locale is not known at the fixing time
SET @loc='en_US';
SELECT DATE_FORMAT('2024-01-02','%W',@loc) = _latin5'a';
--echo # The session locale is not used when the locale is passed explicitly
SET lc_time_names=ru_RU;
SELECT DATE_FORMAT('2024-01-02','%W') = _latin5'a';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT DATE_FORMAT('2024-01-02','%W','en_US') = _latin5'a';
SET lc_time_names=DEFAULT;
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -56,3 +56,27 @@ SET sql_mode=DEFAULT;
#
# End of 10.5 tests
#
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES dec8 COLLATE dec8_swedish_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES dec8 COLLATE dec8_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (dec8_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -13,3 +13,22 @@ SET @seq=_dec8 0xD0;
--echo #
--echo # End of 10.5 tests
--echo #
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES dec8 COLLATE dec8_swedish_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_01_probe.inc
SET NAMES dec8 COLLATE dec8_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -34833,3 +34833,27 @@ c1
#
# End of 10.5 tests
#
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES eucjpms COLLATE eucjpms_japanese_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES eucjpms COLLATE eucjpms_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (eucjpms_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -630,3 +630,22 @@ select strcmp(_eucjpms'' collate eucjpms_nopad_bin, _eucjpms 0x0001050001) as c1
--echo #
--echo # End of 10.5 tests
--echo #
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES eucjpms COLLATE eucjpms_japanese_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_01_probe.inc
SET NAMES eucjpms COLLATE eucjpms_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,18 @@
--source include/have_eucjpms.inc
--source include/have_utf32.inc
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
--disable_query_log
SET @mask='^eucjpms';
SET @extra_collations_query=
'INSERT INTO collations VALUES'
'(''eucjpms_japanese_ci''),(''eucjpms_japanese_nopad_ci''),'
'(''eucjpms_bin''),(''eucjpms_nopad_bin'')';
--source include/ctype_tailoring_00.inc
--enable_query_log
--echo # End of 11.8 tests

View File

@@ -26346,3 +26346,27 @@ c1
#
# End of 10.5 tests
#
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES euckr COLLATE euckr_korean_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES euckr COLLATE euckr_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (euckr_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -260,3 +260,22 @@ select strcmp(_euckr'' collate euckr_nopad_bin, _euckr 0x0001050001) as c1;
--echo #
--echo # End of 10.5 tests
--echo #
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES euckr COLLATE euckr_korean_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_01_probe.inc
SET NAMES euckr COLLATE euckr_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,18 @@
--source include/have_euckr.inc
--source include/have_utf32.inc
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
--disable_query_log
SET @mask='^euckr';
SET @extra_collations_query=
'INSERT INTO collations VALUES'
'(''euckr_korean_ci''),(''euckr_korean_nopad_ci''),'
'(''euckr_bin''),(''euckr_nopad_bin'')';
--source include/ctype_tailoring_00.inc
--enable_query_log
--echo # End of 11.8 tests

View File

@@ -5334,3 +5334,26 @@ c1
#
# End of 10.5 tests
#
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES gb2312 COLLATE gb2312_chinese_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (gb2312_chinese_ci,COERCIBLE) for operation '<>'
SET NAMES gb2312 COLLATE gb2312_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (gb2312_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -210,3 +210,22 @@ select strcmp(_gb2312'' collate gb2312_nopad_bin, _gb2312 0x0001050001) as c1;
--echo #
--echo # End of 10.5 tests
--echo #
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES gb2312 COLLATE gb2312_chinese_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_03_probe_last_error.inc
SET NAMES gb2312 COLLATE gb2312_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,18 @@
--source include/have_gb2312.inc
--source include/have_utf32.inc
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
--disable_query_log
SET @mask='^gb2312';
SET @extra_collations_query=
'INSERT INTO collations VALUES'
'(''gb2312_chinese_ci''),(''gb2312_chinese_nopad_ci''),'
'(''gb2312_bin''),(''gb2312_nopad_bin'')';
--source include/ctype_tailoring_00.inc
--enable_query_log
--echo # End of 11.8 tests

View File

@@ -6804,3 +6804,26 @@ strcmp(_gbk'' collate gbk_nopad_bin, _gbk 0x0001050001)
#
# End of 10.5 tests
#
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES gbk COLLATE gbk_chinese_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (gbk_chinese_ci,COERCIBLE) for operation '<>'
SET NAMES gbk COLLATE gbk_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (gbk_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -513,3 +513,22 @@ select strcmp(_gbk'' collate gbk_nopad_bin, _gbk 0x0001050001);
--echo #
--echo # End of 10.5 tests
--echo #
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES gbk COLLATE gbk_chinese_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_03_probe_last_error.inc
SET NAMES gbk COLLATE gbk_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,18 @@
--source include/have_gbk.inc
--source include/have_utf32.inc
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
--disable_query_log
SET @mask='^gbk';
SET @extra_collations_query=
'INSERT INTO collations VALUES'
'(''gbk_chinese_ci''),(''gbk_chinese_nopad_ci''),'
'(''gbk_bin''),(''gbk_nopad_bin'')';
--source include/ctype_tailoring_00.inc
--enable_query_log
--echo # End of 11.8 tests

View File

@@ -0,0 +1,23 @@
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES geostd8 COLLATE geostd8_general_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (geostd8_general_ci,COERCIBLE) for operation '<>'
SET NAMES geostd8 COLLATE geostd8_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (geostd8_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -0,0 +1,17 @@
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES geostd8 COLLATE geostd8_general_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_03_probe_last_error.inc
SET NAMES geostd8 COLLATE geostd8_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -0,0 +1,24 @@
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES greek COLLATE greek_general_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES greek COLLATE greek_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (greek_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -0,0 +1,17 @@
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES greek COLLATE greek_general_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_01_probe.inc
SET NAMES greek COLLATE greek_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -9,3 +9,27 @@ E2808E
E2808F
DROP TABLE t1;
End of 4.1 tests
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES hebrew COLLATE hebrew_general_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES hebrew COLLATE hebrew_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (hebrew_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -14,3 +14,21 @@ SELECT HEX(a) FROM t1;
DROP TABLE t1;
--echo End of 4.1 tests
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES hebrew COLLATE hebrew_general_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_01_probe.inc
SET NAMES hebrew COLLATE hebrew_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -0,0 +1,23 @@
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES hp8 COLLATE hp8_english_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (hp8_english_ci,COERCIBLE) for operation '<>'
SET NAMES hp8 COLLATE hp8_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (hp8_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -0,0 +1,17 @@
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES hp8 COLLATE hp8_english_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_03_probe_last_error.inc
SET NAMES hp8 COLLATE hp8_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -0,0 +1,24 @@
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES keybcs2 COLLATE keybcs2_general_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES keybcs2 COLLATE keybcs2_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (keybcs2_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -0,0 +1,17 @@
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES keybcs2 COLLATE keybcs2_general_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_01_probe.inc
SET NAMES keybcs2 COLLATE keybcs2_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -0,0 +1,24 @@
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES koi8r COLLATE koi8r_general_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES koi8r COLLATE koi8r_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (koi8r_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -0,0 +1,17 @@
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES koi8r COLLATE koi8r_general_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_01_probe.inc
SET NAMES koi8r COLLATE koi8r_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -0,0 +1,23 @@
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES koi8u COLLATE koi8u_general_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (koi8u_general_ci,COERCIBLE) for operation '<>'
SET NAMES koi8u COLLATE koi8u_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (koi8u_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -0,0 +1,17 @@
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES koi8u COLLATE koi8u_general_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_03_probe_last_error.inc
SET NAMES koi8u COLLATE koi8u_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -9063,3 +9063,104 @@ Warning 1292 Truncated incorrect INTEGER value: '-9223372036854775809'
DROP TABLE t1, t2;
SET @@sql_mode= @old_mode;
# End of 10.11 tests
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES latin1 COLLATE latin1_swedish_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES latin1 COLLATE latin1_danish_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES latin1 COLLATE latin1_general_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES latin1 COLLATE latin1_german1_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES latin1 COLLATE latin1_spanish_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES latin1 COLLATE latin1_bin;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -579,3 +579,32 @@ DROP TABLE t1, t2;
SET @@sql_mode= @old_mode;
--echo # End of 10.11 tests
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES latin1 COLLATE latin1_swedish_ci;
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_01_probe.inc
SET NAMES latin1 COLLATE latin1_danish_ci;
--source include/ctype_tailoring_01_probe.inc
SET NAMES latin1 COLLATE latin1_general_ci;
--source include/ctype_tailoring_01_probe.inc
SET NAMES latin1 COLLATE latin1_german1_ci;
--source include/ctype_tailoring_01_probe.inc
SET NAMES latin1 COLLATE latin1_spanish_ci;
--source include/ctype_tailoring_01_probe.inc
SET NAMES latin1 COLLATE latin1_bin;
--source include/ctype_tailoring_01_probe.inc
--source include/ctype_tailoring_view_drop.inc
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -839,3 +839,24 @@ hex(weight_string('x
#
drop database latin1_german2_ci;
use test;
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES latin1 COLLATE latin1_german2_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -189,3 +189,16 @@ select hex(weight_string('x
drop database latin1_german2_ci;
use test;
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES latin1 COLLATE latin1_german2_ci;
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_01_probe.inc
--source include/ctype_tailoring_view_drop.inc
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -844,3 +844,58 @@ DFDF9C9D9E
#
# End of 5.6 tests
#
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES latin2 COLLATE latin2_general_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES latin2 COLLATE latin2_croatian_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES latin2 COLLATE latin2_hungarian_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_hungarian_ci,COERCIBLE) for operation '<>'
SET NAMES latin2 COLLATE latin2_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -74,3 +74,28 @@ set collation_connection=latin2_bin;
--echo #
--echo # End of 5.6 tests
--echo #
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES latin2 COLLATE latin2_general_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_01_probe.inc
SET NAMES latin2 COLLATE latin2_croatian_ci;
--source include/ctype_tailoring_01_probe.inc
SET NAMES latin2 COLLATE latin2_hungarian_ci;
--source include/ctype_tailoring_03_probe_last_error.inc
SET NAMES latin2 COLLATE latin2_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -1006,3 +1006,20 @@ hex(weight_string('a' LEVEL 1,8))
#
# End of 5.6 tests
#
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES latin2 COLLATE latin2_czech_cs;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_czech_cs,COERCIBLE) for operation '='
SELECT c FROM v_tailoring WHERE c<>'Y_';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_czech_cs,COERCIBLE) for operation '<>'
SELECT c FROM v_tailoring WHERE c<>'Y+';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_czech_cs,COERCIBLE) for operation '<>'
# End of 11.8 tests

View File

@@ -248,3 +248,17 @@ set names latin2 collate latin2_czech_cs;
--echo # End of 5.6 tests
--echo #
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES latin2 COLLATE latin2_czech_cs;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_02_probe_error.inc
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
--echo # End of 11.8 tests

View File

@@ -0,0 +1,38 @@
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES latin5 COLLATE latin5_turkish_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin5_turkish_ci,COERCIBLE) for operation '='
SELECT c FROM v_tailoring WHERE c<>'Y_';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin5_turkish_ci,COERCIBLE) for operation '<>'
SELECT c FROM v_tailoring WHERE c<>'Y+';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin5_turkish_ci,COERCIBLE) for operation '<>'
SET NAMES latin5 COLLATE latin5_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin5_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
#
# MDEV-41246 LOWER() and UPPER() can convert ASCII letters to
# non-ASCII ones in Turkish collations (I -> dotless i, i -> dotted I),
# so their results are not ASCII-only and are converted to latin5
# when mixed with a latin1 string, rather than the other way round.
#
SET NAMES latin5 COLLATE latin5_turkish_ci;
SELECT HEX(LOWER('I')), LOWER('I') = _latin1'i';
HEX(LOWER('I')) LOWER('I') = _latin1'i'
FD 0
SELECT HEX(UPPER('i')), UPPER('i') = _latin1'I';
HEX(UPPER('i')) UPPER('i') = _latin1'I'
DD 0
SELECT _latin1'i' = LOWER('I');
_latin1'i' = LOWER('I')
0
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -0,0 +1,29 @@
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES latin5 COLLATE latin5_turkish_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_02_probe_error.inc
SET NAMES latin5 COLLATE latin5_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo #
--echo # MDEV-41246 LOWER() and UPPER() can convert ASCII letters to
--echo # non-ASCII ones in Turkish collations (I -> dotless i, i -> dotted I),
--echo # so their results are not ASCII-only and are converted to latin5
--echo # when mixed with a latin1 string, rather than the other way round.
--echo #
SET NAMES latin5 COLLATE latin5_turkish_ci;
SELECT HEX(LOWER('I')), LOWER('I') = _latin1'i';
SELECT HEX(UPPER('i')), UPPER('i') = _latin1'I';
SELECT _latin1'i' = LOWER('I');
SET NAMES DEFAULT;
--echo # End of 11.8 tests

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,43 @@
--source include/have_utf32.inc
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
--disable_query_log
SET @mask='^latin5';
SET @extra_collations_query=
'INSERT INTO collations VALUES'
'(''latin5_turkish_nopad_ci''),(''latin5_nopad_bin'')';
--source include/ctype_tailoring_00.inc
--enable_query_log
--echo #
--echo # DATE_FORMAT() result repertoire depends on the locale
--echo # which is actually used: the explicit third argument, or
--echo # @@lc_time_names. Locale names (e.g. of days) can be non-ASCII.
--echo # latin1 and latin5_turkish_ci are not compatible on ASCII, unless
--echo # the DATE_FORMAT() result is allowed to be non-ASCII, so its collation
--echo # can be preferred.
--echo #
SET NAMES latin1;
--echo # en_US names are ASCII
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT DATE_FORMAT('2024-01-02','%W') = _latin5'a';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT DATE_FORMAT('2024-01-02','%W','en_US') = _latin5'a';
--echo # An explicit non-ASCII locale is not ignored
SELECT DATE_FORMAT('2024-01-02','%W','ru_RU') = _latin5'a';
--echo # A non-constant locale is not known at the fixing time
SET @loc='en_US';
SELECT DATE_FORMAT('2024-01-02','%W',@loc) = _latin5'a';
--echo # The session locale is not used when the locale is passed explicitly
SET lc_time_names=ru_RU;
SELECT DATE_FORMAT('2024-01-02','%W') = _latin5'a';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT DATE_FORMAT('2024-01-02','%W','en_US') = _latin5'a';
SET lc_time_names=DEFAULT;
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -0,0 +1,34 @@
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES latin7 COLLATE latin7_general_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin7_general_ci,COERCIBLE) for operation '='
SELECT c FROM v_tailoring WHERE c<>'Y_';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin7_general_ci,COERCIBLE) for operation '<>'
SELECT c FROM v_tailoring WHERE c<>'Y+';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin7_general_ci,COERCIBLE) for operation '<>'
SET NAMES latin7 COLLATE latin7_estonian_cs;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin7_estonian_cs,COERCIBLE) for operation '='
SELECT c FROM v_tailoring WHERE c<>'Y_';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin7_estonian_cs,COERCIBLE) for operation '<>'
SELECT c FROM v_tailoring WHERE c<>'Y+';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin7_estonian_cs,COERCIBLE) for operation '<>'
SET NAMES latin7 COLLATE latin7_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin7_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -0,0 +1,20 @@
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES latin7 COLLATE latin7_general_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_02_probe_error.inc
SET NAMES latin7 COLLATE latin7_estonian_cs;
--source include/ctype_tailoring_02_probe_error.inc
SET NAMES latin7 COLLATE latin7_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -474,6 +474,7 @@ latin1_test latin1 331 1 cp1252 West European
latin1_test2 latin1 332 1 cp1252 West European
latin1_test2_cs latin1 333 1 cp1252 West European
latin1_swedish_nopad2_ci latin1 334 1 cp1252 West European
latin1_space_after_letters_ci latin1 335 1 cp1252 West European
utf8mb3_bengali_standard_ci utf8mb3 336 8
utf8mb3_bengali_traditional_ci utf8mb3 337 8
utf8mb3_implicit_weights_ci utf8mb3 338 8

View File

@@ -0,0 +1,21 @@
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES macce COLLATE macce_general_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (macce_general_ci,COERCIBLE) for operation '='
SELECT c FROM v_tailoring WHERE c<>'Y_';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (macce_general_ci,COERCIBLE) for operation '<>'
SELECT c FROM v_tailoring WHERE c<>'Y+';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (macce_general_ci,COERCIBLE) for operation '<>'
SET NAMES macce COLLATE macce_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (macce_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -0,0 +1,17 @@
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES macce COLLATE macce_general_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_02_probe_error.inc
SET NAMES macce COLLATE macce_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -0,0 +1,24 @@
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES macroman COLLATE macroman_general_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES macroman COLLATE macroman_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (macroman_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -0,0 +1,17 @@
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES macroman COLLATE macroman_general_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_01_probe.inc
SET NAMES macroman COLLATE macroman_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -19670,3 +19670,26 @@ c1
#
# End of 10.5 tests
#
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES sjis COLLATE sjis_japanese_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (sjis_japanese_ci,COERCIBLE) for operation '<>'
SET NAMES sjis COLLATE sjis_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (sjis_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -338,3 +338,22 @@ select strcmp(_sjis'' collate sjis_nopad_bin, _sjis 0x0001050001) as c1;
--echo #
--echo # End of 10.5 tests
--echo #
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES sjis COLLATE sjis_japanese_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_03_probe_last_error.inc
SET NAMES sjis COLLATE sjis_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,18 @@
--source include/have_sjis.inc
--source include/have_utf32.inc
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
--disable_query_log
SET @mask='^sjis';
SET @extra_collations_query=
'INSERT INTO collations VALUES'
'(''sjis_japanese_ci''),(''sjis_japanese_nopad_ci''),'
'(''sjis_bin''),(''sjis_nopad_bin'')';
--source include/ctype_tailoring_00.inc
--enable_query_log
--echo # End of 11.8 tests

View File

@@ -3653,3 +3653,26 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
#
# End of 10.5 tests
#
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES swe7 COLLATE swe7_swedish_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (swe7_swedish_ci,COERCIBLE) for operation '<>'
SET NAMES swe7 COLLATE swe7_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (swe7_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -71,3 +71,21 @@ EXECUTE IMMEDIATE _swe7 0x01;
--echo #
--echo # End of 10.5 tests
--echo #
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES swe7 COLLATE swe7_swedish_ci;
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_03_probe_last_error.inc
SET NAMES swe7 COLLATE swe7_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -4497,3 +4497,21 @@ DROP TABLE t1;
#
# End of 10.4 tests
#
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES tis620 COLLATE tis620_thai_ci;
# tis620_thai_ci sorts the underscore before the letters, so it is
# compatible only on the ALNUM repertoire.
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (tis620_thai_ci,COERCIBLE) for operation '<>'
SELECT c FROM v_tailoring WHERE c<>'Y+';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (tis620_thai_ci,COERCIBLE) for operation '<>'
SET NAMES tis620 COLLATE tis620_bin;
SELECT c FROM v_tailoring WHERE c='Y';
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (tis620_bin,COERCIBLE) for operation '='
SET NAMES DEFAULT;
# End of 11.8 tests

View File

@@ -254,3 +254,28 @@ DROP TABLE t1;
--echo #
--echo # End of 10.4 tests
--echo #
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES tis620 COLLATE tis620_thai_ci;
--echo # tis620_thai_ci sorts the underscore before the letters, so it is
--echo # compatible only on the ALNUM repertoire.
--disable_service_connection
--source include/ctype_tailoring_view_create.inc
SELECT c FROM v_tailoring WHERE c='Y';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c<>'Y_';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c<>'Y+';
SET NAMES tis620 COLLATE tis620_bin;
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT c FROM v_tailoring WHERE c='Y';
--source include/ctype_tailoring_view_drop.inc
--enable_service_connection
SET NAMES DEFAULT;
--echo # End of 11.8 tests

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,39 @@
--source include/have_tis620.inc
--source include/have_utf32.inc
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
--disable_query_log
SET @mask='^tis620';
SET @extra_collations_query=
'INSERT INTO collations VALUES'
'(''tis620_thai_ci''),(''tis620_thai_nopad_ci''),'
'(''tis620_bin''),(''tis620_nopad_bin'')';
--source include/ctype_tailoring_00.inc
--enable_query_log
SET NAMES tis620;
SELECT _tis620'foo' = _latin1'foo';
SET NAMES DEFAULT;
--echo #
--echo # MDEV-41246: The repertoire of IF() must include the repertoires of
--echo # both branches, not only of the winner branch (HEX(), ALNUM).
--echo # The value '1.5' has a punctuation character, so the collations
--echo # latin1_swedish_ci and tis620_thai_ci must not be mixed on it.
--echo #
SET NAMES latin1;
SELECT HEX(255) = _tis620'A';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT '1.5' = _tis620'A';
--error ER_CANT_AGGREGATE_2COLLATIONS
SELECT IF(1, 1.5, HEX(255)) = _tis620'A';
SET NAMES DEFAULT;
--echo # End of 11.8 tests

View File

@@ -6839,3 +6839,42 @@ Warning 1292 Truncated incorrect INTEGER value: '-9223372036854775809'
DROP TABLE t1;
SET @@sql_mode= @old_mode;
# End of 10.11 tests
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES utf8mb3;
SET collation_connection=ucs2_general_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES utf8mb3;
SET collation_connection=ucs2_bin;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES DEFAULT;
End of 11.8 tests

View File

@@ -1276,3 +1276,22 @@ DROP TABLE t1;
SET @@sql_mode= @old_mode;
--echo # End of 10.11 tests
--echo #
--echo # MDEV-41246 "Illegal mix of collations" on the mysql.user view
--echo #
SET NAMES utf8mb3;
SET collation_connection=ucs2_general_ci;
--source include/ctype_tailoring_view_create.inc
--source include/ctype_tailoring_01_probe.inc
SET NAMES utf8mb3;
SET collation_connection=ucs2_bin;
--source include/ctype_tailoring_01_probe.inc
--source include/ctype_tailoring_view_drop.inc
SET NAMES DEFAULT;
--echo End of 11.8 tests

View File

@@ -1166,3 +1166,110 @@ SET NAMES utf8;
#
# End of 10.9 tests
#
#
# MDEV-41246 "Illegal mix of collations" on the mysql.user view
#
SET NAMES utf8mb3;
SET collation_connection=ucs2_unicode_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES utf8mb3;
SET collation_connection=ucs2_czech_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES utf8mb3;
SET collation_connection=ucs2_uca1400_ai_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES utf8mb3;
SET collation_connection=ucs2_uca1400_ai_cs;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES utf8mb3;
SET collation_connection=ucs2_uca1400_as_ci;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES utf8mb3;
SET collation_connection=ucs2_uca1400_as_cs;
# ASCII digits
d
1
# ASCII minus, dot and digits
e
-1.5
SELECT c FROM v_tailoring WHERE c='Y';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y_';
c
Y
SELECT c FROM v_tailoring WHERE c<>'Y+';
c
Y
SET NAMES DEFAULT;
# End of 11.8 tests

Some files were not shown because too many files have changed in this diff Show More