Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.11, 11.4, 11.8, 12.3, 13.1, 13.2, 13.3
Description
Likely cause: old code in my_strnncoll_binary() and my_strnncoll_8bit_bin(), not a recent change. CS 10.11 and ES 10.6 have it too.
# @b holds 2147483648 bytes 'a' and one byte 'b' |
--perl
|
open(my $f, ">", "$ENV{MYSQLTEST_VARDIR}/tmp/t1.txt") or die; |
my $s= "a" x 1048576; |
print $f $s for 1..2048; |
print $f "b"; |
close($f); |
EOF
|
CREATE TABLE t1 (a INT); |
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
--eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/t1.txt' INTO TABLE t1 CHARACTER SET binary (@b) SET a=1
|
--remove_file $MYSQLTEST_VARDIR/tmp/t1.txt
|
--let $r= query_get_value(SELECT @b > '' AS r, r, 1)
|
if ($r != 1) |
{
|
--die A 2147483649 byte binary string did not compare as greater than the empty string |
}
|
DROP TABLE t1; |
Leads to:
|
CS 13.1.2 87e62ca17270e163a6d41b3fc8d6f4d440f1bb88 (Optimized, Clang 22.1.8-20260622) Build 05/10/2026 |
mysqltest: At line 16: A 2147483649 byte binary string did not compare as greater than the empty string
|
The @b value is 2147483649 bytes, so it should compare as greater than the empty string. More forms, in the client:
- SELECT @b > '': 0, and STRCMP(@b,''): -1
- with a 3221225472 byte value, SELECT @b > 'a': 0, and STRCMP(@b,'a'): -1
- the same bytes in a latin1 user variable: 1, the expected answer
None of these give a warning.
MySQL 5.5, 5.6, 8.0 and 9.1 give the same results, 0 and -1.
From the code it seems that my_strnncoll_binary() and my_strnncoll_8bit_bin() return the length difference as an int when one string is a prefix of the other. Here the difference is 2147483649, so the int is negative and the longer string reads as the smaller one.
Attachments
Issue Links
- relates to
-
MDEV-42479 SIGSEGV in my_instr_bin on LOCATE with a start position over 2147483647, and 0 returned where the string matches
-
- Open
-
-
MDEV-42518 SIGSEGV in Item_func_like::turboBM_matches on LIKE over a 2 GB string, and 0 returned where the string matches
-
- Open
-