Commit bb200599 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-24584 Selecting INT column with COLLATE utf8mb4_general_ci throws an error

parent 5cae401b
......@@ -6473,5 +6473,24 @@ CAST(_ucs2 0x0061E0030062 AS INT)
Warnings:
Warning 1292 Truncated incorrect INTEGER value: 'ab'
#
# MDEV-24584 Selecting INT column with COLLATE utf8mb4_general_ci throws an error
#
SET NAMES utf8, collation_connection=ucs2_general_ci;
SELECT 1 COLLATE ucs2_general_ci;
1 COLLATE ucs2_general_ci
1
SELECT 1 COLLATE ucs2_bin;
1 COLLATE ucs2_bin
1
SELECT HEX(1 COLLATE ucs2_general_ci);
HEX(1 COLLATE ucs2_general_ci)
0031
SELECT HEX(1 COLLATE ucs2_bin);
HEX(1 COLLATE ucs2_bin)
0031
SELECT 1 COLLATE latin1_swedish_ci;
ERROR 42000: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'ucs2'
SET NAMES utf8;
#
# End of 10.5 tests
#
......@@ -1146,6 +1146,19 @@ SELECT CAST(_ucs2 0x0061DFFF0062 AS INT);
SELECT CAST(_ucs2 0x0061D7000062 AS INT);
SELECT CAST(_ucs2 0x0061E0030062 AS INT);
--echo #
--echo # MDEV-24584 Selecting INT column with COLLATE utf8mb4_general_ci throws an error
--echo #
SET NAMES utf8, collation_connection=ucs2_general_ci;
SELECT 1 COLLATE ucs2_general_ci;
SELECT 1 COLLATE ucs2_bin;
SELECT HEX(1 COLLATE ucs2_general_ci);
SELECT HEX(1 COLLATE ucs2_bin);
--error ER_COLLATION_CHARSET_MISMATCH
SELECT 1 COLLATE latin1_swedish_ci;
SET NAMES utf8;
--echo #
--echo # End of 10.5 tests
--echo #
......@@ -4149,3 +4149,21 @@ c
#
# End of 10.2 tests
#
#
# Start of 10.5 tests
#
#
# MDEV-24584 Selecting INT column with COLLATE utf8mb4_general_ci throws an error
#
SET NAMES utf8mb4;
SELECT 1 COLLATE utf8mb4_general_ci;
1 COLLATE utf8mb4_general_ci
1
SELECT 1 COLLATE utf8mb4_bin;
1 COLLATE utf8mb4_bin
1
SELECT 1 COLLATE latin1_swedish_ci;
ERROR 42000: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8mb4'
#
# End of 10.5 tests
#
......@@ -2043,3 +2043,22 @@ EXECUTE IMMEDIATE 'SELECT ''😎'' AS c';
--echo #
--echo # End of 10.2 tests
--echo #
--echo #
--echo # Start of 10.5 tests
--echo #
--echo #
--echo # MDEV-24584 Selecting INT column with COLLATE utf8mb4_general_ci throws an error
--echo #
SET NAMES utf8mb4;
SELECT 1 COLLATE utf8mb4_general_ci;
SELECT 1 COLLATE utf8mb4_bin;
--error ER_COLLATION_CHARSET_MISMATCH
SELECT 1 COLLATE latin1_swedish_ci;
--echo #
--echo # End of 10.5 tests
--echo #
......@@ -3552,10 +3552,12 @@ String *Item_func_set_collation::val_str(String *str)
bool Item_func_set_collation::fix_length_and_dec()
{
if (!my_charset_same(args[0]->collation.collation, m_set_collation))
if (agg_arg_charsets_for_string_result(collation, args, 1))
return true;
if (!my_charset_same(collation.collation, m_set_collation))
{
my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0),
m_set_collation->name, args[0]->collation.collation->csname);
m_set_collation->name, collation.collation->csname);
return TRUE;
}
collation.set(m_set_collation, DERIVATION_EXPLICIT,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment