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 Item_func_compress::val_str() from 2003, not a recent change. MySQL 5.5 to 9.1 give the same result.
SET @save_max_allowed_packet= @@global.max_allowed_packet; |
SET GLOBAL max_allowed_packet= 1073741824; |
--connect (con1,localhost,root)
|
SET @c= COMPRESS(REPEAT('a',1073741824)); |
--let $l= query_get_value(SELECT LENGTH(UNCOMPRESS(@c)) AS l, l, 1)
|
if ($l != 1073741824) |
{
|
--die UNCOMPRESS did not give back the 1073741824 byte string that COMPRESS was given, the result length is $l |
}
|
--disconnect con1
|
--connection default
|
SET GLOBAL max_allowed_packet= @save_max_allowed_packet; |
Leads to:
|
CS 13.1.2 87e62ca17270e163a6d41b3fc8d6f4d440f1bb88 (Optimized, Clang 22.1.8-20260622) Build 05/10/2026 |
mysqltest: At line 8: UNCOMPRESS did not give back the 1073741824 byte string that COMPRESS was given, the result length is NULL
|
In the client, with max_allowed_packet at 1073741824:
|
CS 13.1.2 87e62ca17270e163a6d41b3fc8d6f4d440f1bb88 (Optimized, Clang 22.1.8-20260622) Build 05/10/2026 |
SELECT UNCOMPRESSED_LENGTH(COMPRESS(REPEAT('a',1073741823))) AS at_1073741823;
|
at_1073741823
|
1073741823
|
|
|
SELECT UNCOMPRESSED_LENGTH(COMPRESS(REPEAT('a',1073741824))) AS at_1073741824;
|
at_1073741824
|
0
|
|
|
SELECT LENGTH(UNCOMPRESS(COMPRESS(REPEAT('a',1073741824)))) AS uncompress_len;
|
uncompress_len
|
NULL
|
|
|
SHOW WARNINGS;
|
Level Code Message
|
Warning 1258 ZLIB: Not enough room in the output buffer (probably, length of uncompressed data was corrupted)
|
COMPRESS() itself gives no warning. With one byte less, UNCOMPRESS() gives the string back.
From the code it seems that Item_func_compress::val_str() writes the source length into the first four bytes masked with 0x3FFFFFFF, so 1073741824 is stored as 0. Item_func_uncompressed_length::val_int() reads it back with the same mask, and Item_func_uncompress::val_str() uses it as the size of the output buffer.
Attachments
Issue Links
- relates to
-
MDEV-36718 max_allowed_packet affects the outcome of UNCOMPRESS call on non-compressed argument
-
- Closed
-
-
MDEV-40798 Compress Result Metadata Uint32 Wrap
-
- Confirmed
-