summaryrefslogtreecommitdiff
path: root/storage/archive
diff options
context:
space:
mode:
authorunknown <svoj@mysql.com/june.mysql.com>2007-11-23 17:51:12 +0400
committerunknown <svoj@mysql.com/june.mysql.com>2007-11-23 17:51:12 +0400
commit13ce2d7778d42a55a51350517c11b87fef90d9cd (patch)
tree0c286bb63584bb4040541a38cf5d11b305692351 /storage/archive
parent6cc8a820d3ad135bed4fd569ae6d43cc56181944 (diff)
downloadmariadb-git-13ce2d7778d42a55a51350517c11b87fef90d9cd.tar.gz
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: A test case for BUG#31833. mysql-test/t/archive.test: A test case for BUG#31833. storage/archive/azio.c: 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.
Diffstat (limited to 'storage/archive')
-rw-r--r--storage/archive/azio.c2
1 files changed, 1 insertions, 1 deletions
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) {