Commit 7828aadd authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-33318 ORDER BY COLLATE improperly applied to non-character columns

when changing charset from latin1 to utf8, adjust max_length accordingly
parent 67abdb9f
......@@ -772,3 +772,27 @@ string
#
# End of 10.2 tests
#
#
# MDEV-33318 ORDER BY COLLATE improperly applied to non-character columns
#
set names utf8;
create table t1 (ts datetime);
insert t1 values ('2024-01-26 21:37:54'), ('2024-01-26 21:37:54'),
('2024-01-26 21:37:54'), ('2024-01-26 21:37:54'),
('2024-01-26 21:37:58'), ('2024-01-26 21:37:58'),
('2024-01-26 21:37:58'), ('2024-01-26 21:38:02'),
('2024-01-26 21:38:02'), ('2024-01-26 21:38:02');
select * from t1 order by ts collate utf8_bin;
ts
2024-01-26 21:37:54
2024-01-26 21:37:54
2024-01-26 21:37:54
2024-01-26 21:37:54
2024-01-26 21:37:58
2024-01-26 21:37:58
2024-01-26 21:37:58
2024-01-26 21:38:02
2024-01-26 21:38:02
2024-01-26 21:38:02
drop table t1;
# End of 10.6 tests
......@@ -357,3 +357,18 @@ SELECT COLUMN_GET(COLUMN_CREATE(0, 'string'),0 AS CHAR CHARACTER SET latin1 COLL
--echo #
--echo # End of 10.2 tests
--echo #
--echo #
--echo # MDEV-33318 ORDER BY COLLATE improperly applied to non-character columns
--echo #
set names utf8;
create table t1 (ts datetime);
insert t1 values ('2024-01-26 21:37:54'), ('2024-01-26 21:37:54'),
('2024-01-26 21:37:54'), ('2024-01-26 21:37:54'),
('2024-01-26 21:37:58'), ('2024-01-26 21:37:58'),
('2024-01-26 21:37:58'), ('2024-01-26 21:38:02'),
('2024-01-26 21:38:02'), ('2024-01-26 21:38:02');
select * from t1 order by ts collate utf8_bin;
drop table t1;
--echo # End of 10.6 tests
......@@ -3590,7 +3590,9 @@ bool Item_func_set_collation::fix_length_and_dec()
}
collation.set(m_set_collation, DERIVATION_EXPLICIT,
args[0]->collation.repertoire);
max_length= args[0]->max_length;
ulonglong max_char_length= (ulonglong) args[0]->max_char_length();
fix_char_length_ulonglong(max_char_length * collation.collation->mbmaxlen);
return FALSE;
}
......
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