diff --git a/mysql-test/main/ctype_utf32.result b/mysql-test/main/ctype_utf32.result index a0f760cbdc02b..4ed5ae32a7699 100644 --- a/mysql-test/main/ctype_utf32.result +++ b/mysql-test/main/ctype_utf32.result @@ -2940,3 +2940,23 @@ DROP TABLE t1; # # End of 10.2 tests # +# +# Start of 10.4 tests +# +# +# MDEV-29019 Assertion `(length % 4) == 0' failed in my_lengthsp_utf32 on SELECT +# +CREATE TABLE t (a INT); +SET collation_connection=utf32_unicode_ci; +INSERT INTO t VALUES (0); +SELECT * FROM t ORDER BY (OCT(a)); +a +0 +SELECT HEX(OCT(a)) FROM t; +HEX(OCT(a)) +00000030 +DROP TABLE t; +SET NAMES utf8; +# +# End of 10.4 tests +# diff --git a/mysql-test/main/ctype_utf32.test b/mysql-test/main/ctype_utf32.test index a62416621b874..63b6bdd65ae0b 100644 --- a/mysql-test/main/ctype_utf32.test +++ b/mysql-test/main/ctype_utf32.test @@ -1099,7 +1099,30 @@ CREATE TABLE t1 ( SHOW CREATE TABLE t1; DROP TABLE t1; ---enable_service_connection --echo # --echo # End of 10.2 tests --echo # + + +--echo # +--echo # Start of 10.4 tests +--echo # + +--echo # +--echo # MDEV-29019 Assertion `(length % 4) == 0' failed in my_lengthsp_utf32 on SELECT +--echo # + +CREATE TABLE t (a INT); +SET collation_connection=utf32_unicode_ci; +INSERT INTO t VALUES (0); +SELECT * FROM t ORDER BY (OCT(a)); +SELECT HEX(OCT(a)) FROM t; +DROP TABLE t; +SET NAMES utf8; + + +--echo # +--echo # End of 10.4 tests +--echo # + +--enable_service_connection diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index f95f47958208e..ae078dbb22fdb 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -3533,8 +3533,12 @@ String *Item_func_conv::val_str(String *str) from_base, &endptr, &err); } + uint dummy_errors; if (!(ptr= longlong2str(dec, ans, to_base)) || - str->copy(ans, (uint32) (ptr - ans), default_charset())) + (collation.collation->state & MY_CS_NONASCII) ? + str->copy(ans, (uint32) (ptr - ans), &my_charset_latin1, + collation.collation, &dummy_errors) : + str->copy(ans, (uint32) (ptr - ans), collation.collation)) { null_value= 1; return NULL;