Below is the list of changes that have just been committed into a local
5.1 repository of svoj. When svoj does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-11-23 17:51:12+04:00, svoj@stripped +3 -0
BUG#31833 - ORDER BY leads to wrong result when ARCHIVE, BLOB and
table cache is full
After reading last record from freshly opened archive table
(e.g. after flush table, or if there is no room in table cache),
the table is reported as crashed.
The problem was that azio wrongly invalidated azio_stream when it
meets EOF.
mysql-test/r/archive.result@stripped, 2007-11-23 17:50:36+04:00, svoj@stripped +7 -0
A test case for BUG#31833.
mysql-test/t/archive.test@stripped, 2007-11-23 17:50:36+04:00, svoj@stripped +9 -0
A test case for BUG#31833.
storage/archive/azio.c@stripped, 2007-11-23 17:50:36+04:00, svoj@stripped +1 -1
After azread() successfuly read and inflated data, it calls
check_header() function. According to the comment it is done
to detect concatenated .az files.
When we read last record, there are no more bytes left at the
current offset, all further my_read() calls will return 0. In
this case check_header() wrongly sets s->z_err to Z_ERRNO,
indicating that azio_stream is broken.
Following is original condition from gzio:
len = (uInt)fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file);
if (len == 0 && ferror(s->file)) s->z_err = Z_ERRNO;
As fread() returns 0 on both EOF and error, the condition states:
Invalidate gzio_stream if we got an error from last fread().
Applied the same logic to azio.
Note that a test case contains FLUSH TABLE t1 prior to SELECT. It is
needed because azio doesn't flush buffers immediately. Thus we may
azread() last record from in-memory buffer. When we read from
in-memory buffer, EOF is detected by different branch of code in
azread() and we never enter check_header() in this case.
diff -Nrup a/mysql-test/r/archive.result b/mysql-test/r/archive.result
--- a/mysql-test/r/archive.result 2007-10-28 01:27:44 +05:00
+++ b/mysql-test/r/archive.result 2007-11-23 17:50:36 +04:00
@@ -12687,3 +12687,10 @@ CREATE TABLE t1(a VARCHAR(510)) ENGINE =
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 -Nrup a/mysql-test/t/archive.test b/mysql-test/t/archive.test
--- a/mysql-test/t/archive.test 2007-10-28 01:27:44 +05:00
+++ b/mysql-test/t/archive.test 2007-11-23 17:50:36 +04:00
@@ -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 -Nrup a/storage/archive/azio.c b/storage/archive/azio.c
--- a/storage/archive/azio.c 2007-10-28 01:27:44 +05:00
+++ b/storage/archive/azio.c 2007-11-23 17:50:36 +04:00
@@ -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) {
| Thread |
|---|
| • bk commit into 5.1 tree (svoj:1.2641) BUG#31833 | Sergey Vojtovich | 23 Nov |