summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/archive.result7
-rw-r--r--mysql-test/t/archive.test9
-rw-r--r--storage/archive/azio.c2
3 files changed, 17 insertions, 1 deletions
diff --git a/mysql-test/r/archive.result b/mysql-test/r/archive.result
index edd49988a5f..ebd839a1fd1 100644
--- a/mysql-test/r/archive.result
+++ b/mysql-test/r/archive.result
@@ -12687,3 +12687,10 @@ CREATE TABLE t1(a VARCHAR(510)) ENGINE = ARCHIVE;
INSERT INTO t1(a) VALUES ('');
SELECT * FROM t1 ORDER BY a;
DROP TABLE t1;
+CREATE TABLE t1(a INT NOT NULL AUTO_INCREMENT, b BLOB, KEY(a)) ENGINE=archive;
+INSERT INTO t1 VALUES (NULL, NULL),(NULL, NULL);
+FLUSH TABLE t1;
+SELECT * FROM t1 ORDER BY a;
+a b
+1 NULL
+2 NULL
diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test
index a1158dbfd3b..b42c8446a32 100644
--- a/mysql-test/t/archive.test
+++ b/mysql-test/t/archive.test
@@ -1589,3 +1589,12 @@ SELECT * FROM t1 ORDER BY a;
--enable_result_log
DROP TABLE t1;
+
+#
+# BUG#31833 - ORDER BY leads to wrong result when ARCHIVE, BLOB and table
+# cache is full
+#
+CREATE TABLE t1(a INT NOT NULL AUTO_INCREMENT, b BLOB, KEY(a)) ENGINE=archive;
+INSERT INTO t1 VALUES (NULL, NULL),(NULL, NULL);
+FLUSH TABLE t1;
+SELECT * FROM t1 ORDER BY a;
diff --git a/storage/archive/azio.c b/storage/archive/azio.c
index 2cf0fe114d3..cada6c57918 100644
--- a/storage/archive/azio.c
+++ b/storage/archive/azio.c
@@ -262,7 +262,7 @@ void check_header(azio_stream *s)
if (len) s->inbuf[0] = s->stream.next_in[0];
errno = 0;
len = (uInt)my_read(s->file, (uchar *)s->inbuf + len, AZ_BUFSIZE_READ >> len, MYF(0));
- if (len == 0) s->z_err = Z_ERRNO;
+ if (len == (uInt)-1) s->z_err = Z_ERRNO;
s->stream.avail_in += len;
s->stream.next_in = s->inbuf;
if (s->stream.avail_in < 2) {