Skip to content

Commit 6fb94c3

Browse files
committed
MDEV-11320: MariaRocks: rocksdb.type_text_indexes fails
Backport the fix for BUG#81810 from facebook/mysql-5.6 tree. Added the original testcase. rocksdb.type_text_indexes still fails due to another problem.
1 parent 3876f46 commit 6fb94c3

File tree

4 files changed

+68
-2
lines changed

4 files changed

+68
-2
lines changed

mysql-test/r/ctype_collate.result

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,3 +719,38 @@ DROP FUNCTION getText;
719719
DROP DATABASE test1;
720720
USE test;
721721
SET NAMES latin1;
722+
#
723+
# MDEV-11320, MySQL BUG#81810: Inconsistent sort order for blob/text between InnoDB and filesort
724+
#
725+
CREATE TABLE t1 (
726+
b LONGTEXT CHARACTER SET "latin1" COLLATE "latin1_bin",
727+
KEY b (b(32))
728+
);
729+
INSERT INTO t1 (b) VALUES ('a'), (_binary 0x1), (_binary 0x0), ('');
730+
drop table t1;
731+
CREATE TABLE t1 (
732+
b LONGTEXT CHARACTER SET "latin1" COLLATE "latin1_bin",
733+
PRIMARY KEY b (b(32))
734+
);
735+
INSERT INTO t1 (b) VALUES ('a'), (_binary 0x1), (_binary 0x0), ('');
736+
explain
737+
select hex(b) from t1 force index (PRIMARY) where b<'zzz';
738+
id select_type table type possible_keys key key_len ref rows Extra
739+
1 SIMPLE t1 range PRIMARY PRIMARY 34 NULL 4 Using where
740+
select hex(b) from t1 force index (PRIMARY) where b<'zzz';
741+
hex(b)
742+
00
743+
01
744+
745+
61
746+
explain
747+
select hex(b) from t1 where b<'zzz' order by b;
748+
id select_type table type possible_keys key key_len ref rows Extra
749+
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 4 Using where; Using filesort
750+
select hex(b) from t1 where b<'zzz' order by b;
751+
hex(b)
752+
00
753+
01
754+
755+
61
756+
drop table t1;

mysql-test/r/myisam.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1108,8 +1108,8 @@ length(c1) c1
11081108
0
11091109
SELECT DISTINCT length(c1), c1 FROM t1 ORDER BY c1;
11101110
length(c1) c1
1111-
0
11121111
2 A
1112+
0
11131113
2 B
11141114
DROP TABLE t1;
11151115
End of 4.1 tests

mysql-test/t/ctype_collate.test

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,34 @@ DROP FUNCTION getText;
308308
DROP DATABASE test1;
309309
USE test;
310310
SET NAMES latin1;
311+
312+
--echo #
313+
--echo # MDEV-11320, MySQL BUG#81810: Inconsistent sort order for blob/text between InnoDB and filesort
314+
--echo #
315+
316+
CREATE TABLE t1 (
317+
b LONGTEXT CHARACTER SET "latin1" COLLATE "latin1_bin",
318+
KEY b (b(32))
319+
);
320+
INSERT INTO t1 (b) VALUES ('a'), (_binary 0x1), (_binary 0x0), ('');
321+
322+
323+
drop table t1;
324+
325+
CREATE TABLE t1 (
326+
b LONGTEXT CHARACTER SET "latin1" COLLATE "latin1_bin",
327+
PRIMARY KEY b (b(32))
328+
);
329+
330+
INSERT INTO t1 (b) VALUES ('a'), (_binary 0x1), (_binary 0x0), ('');
331+
332+
explain
333+
select hex(b) from t1 force index (PRIMARY) where b<'zzz';
334+
select hex(b) from t1 force index (PRIMARY) where b<'zzz';
335+
336+
explain
337+
select hex(b) from t1 where b<'zzz' order by b;
338+
select hex(b) from t1 where b<'zzz' order by b;
339+
340+
drop table t1;
341+

sql/field.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8259,7 +8259,7 @@ void Field_blob::sort_string(uchar *to,uint length)
82598259
uchar *blob;
82608260
uint blob_length=get_length();
82618261

8262-
if (!blob_length)
8262+
if (!blob_length && field_charset->pad_char == 0)
82638263
bzero(to,length);
82648264
else
82658265
{

0 commit comments

Comments
 (0)