mirror of
https://github.com/MariaDB/server.git
synced 2025-07-21 21:22:27 +03:00
MDEV-16768: fix blob key length
The blob key length could be shorter than the length of the entire blob, for example, CREATE TABLE t1 (b BLOB, i INT, KEY(b(8))); INSERT INTO t1 VALUES (REPEAT('a',9),1); The key length is 8, while the blob length is 9. So we need to set the correct key length in Field_blob::sort_string().
This commit is contained in:
committed by
Sergei Petrunia
parent
8dda6d797a
commit
87609324e0
@ -8546,7 +8546,9 @@ void Field_blob::sort_string(uchar *to,uint length)
|
||||
Store length of blob last in blob to shorter blobs before longer blobs
|
||||
*/
|
||||
length-= packlength;
|
||||
store_bigendian(buf.length(), to + length, packlength);
|
||||
|
||||
uint key_length = MY_MIN(buf.length(), length);
|
||||
store_bigendian(key_length, to + length, packlength);
|
||||
}
|
||||
|
||||
#ifdef DBUG_ASSERT_EXISTS
|
||||
|
@ -0,0 +1,9 @@
|
||||
include/master-slave.inc
|
||||
[connection master]
|
||||
CREATE TABLE t1 (b BLOB, i INT, KEY(b(8))) ENGINE=RocksDB;
|
||||
INSERT INTO t1 VALUES (REPEAT('a',9),1);
|
||||
UPDATE t1 SET i = 2;
|
||||
connection slave;
|
||||
connection master;
|
||||
DROP TABLE t1;
|
||||
include/rpl_end.inc
|
15
storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_blob_key.test
Normal file
15
storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_blob_key.test
Normal file
@ -0,0 +1,15 @@
|
||||
--source include/have_rocksdb.inc
|
||||
--source include/have_binlog_format_row.inc
|
||||
--source include/master-slave.inc
|
||||
|
||||
CREATE TABLE t1 (b BLOB, i INT, KEY(b(8))) ENGINE=RocksDB;
|
||||
INSERT INTO t1 VALUES (REPEAT('a',9),1);
|
||||
|
||||
UPDATE t1 SET i = 2;
|
||||
|
||||
--sync_slave_with_master
|
||||
|
||||
# Cleanup
|
||||
--connection master
|
||||
DROP TABLE t1;
|
||||
--source include/rpl_end.inc
|
Reference in New Issue
Block a user