Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions mysql-test/main/column_compression.result
Original file line number Diff line number Diff line change
Expand Up @@ -3035,3 +3035,19 @@ select * from (select * from t) as t natural join (select * from t) as t1;
a b
drop tables t, t4;
# End of 10.5 tests
#
# MDEV-39450: Memory corruption: overlapping memory ranges in `Field_longstr::compress` on UPDATE of compressed column
#
CREATE TABLE t (c VARCHAR(255) COMPRESSED);
REPLACE INTO t VALUES ('abcdefghijklm');
UPDATE t SET c=RIGHT(c,10);
DROP TABLE t;
CREATE TABLE t (c VARCHAR(255) COMPRESSED);
REPLACE INTO t VALUES ('abcdefghijklm');
UPDATE t SET c=SUBSTRING(c,3);
DROP TABLE t;
CREATE TABLE t (c VARCHAR(255) COMPRESSED);
REPLACE INTO t VALUES ('abcdefghijklm');
UPDATE t SET c=MID(c,2,4);
DROP TABLE t;
# End of 10.6 tests
21 changes: 21 additions & 0 deletions mysql-test/main/column_compression.test
Original file line number Diff line number Diff line change
Expand Up @@ -573,3 +573,24 @@ select * from (select * from t) as t natural join (select * from t) as t1;
drop tables t, t4;

--echo # End of 10.5 tests

--echo #
--echo # MDEV-39450: Memory corruption: overlapping memory ranges in `Field_longstr::compress` on UPDATE of compressed column
--echo #

CREATE TABLE t (c VARCHAR(255) COMPRESSED);
REPLACE INTO t VALUES ('abcdefghijklm');
UPDATE t SET c=RIGHT(c,10);
DROP TABLE t;

CREATE TABLE t (c VARCHAR(255) COMPRESSED);
REPLACE INTO t VALUES ('abcdefghijklm');
UPDATE t SET c=SUBSTRING(c,3);
DROP TABLE t;

CREATE TABLE t (c VARCHAR(255) COMPRESSED);
REPLACE INTO t VALUES ('abcdefghijklm');
UPDATE t SET c=MID(c,2,4);
DROP TABLE t;

--echo # End of 10.6 tests
2 changes: 1 addition & 1 deletion sql/field.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8543,7 +8543,7 @@ int Field_longstr::compress(char *to, uint to_length,
/* Store uncompressed */
to[0]= 0;
if (buf_length < to_length)
memcpy(to + 1, buf, buf_length);
memmove(to + 1, buf, buf_length);
else
{
/* Storing string at blob capacity, e.g. 255 bytes string to TINYBLOB. */
Expand Down