summaryrefslogtreecommitdiff
path: root/storage/archive/azio.c
diff options
context:
space:
mode:
authorDavi Arnaut <davi.arnaut@oracle.com>2010-07-26 12:54:20 -0300
committerDavi Arnaut <davi.arnaut@oracle.com>2010-07-26 12:54:20 -0300
commite4cbcaf942796e5ba1f865485ea56c3903cf2fb8 (patch)
tree7351d5d892130fe6f95d96337a08097268d2e199 /storage/archive/azio.c
parent0a8021610d08718c614c3cd62332a6b4a8c2cabc (diff)
downloadmariadb-git-e4cbcaf942796e5ba1f865485ea56c3903cf2fb8.tar.gz
Bug#45377: ARCHIVE tables aren't discoverable after OPTIMIZE
The problem was that the optimize method of the ARCHIVE storage engine was not preserving the FRM embedded in the ARZ file when rewriting the ARZ file for optimization. The ARCHIVE engine stores the FRM in the ARZ file so it can be transferred from machine to machine without also copying the FRM -- the engine restores the embedded FRM during discovery. The solution is to copy over the FRM when rewriting the ARZ file. In addition, some initial error checking is performed to ensure garbage is not copied over. mysql-test/t/archive.test: Add test case for Bug#45377. storage/archive/azio.c: Add error checking to ensure that the I/O operations are successful. storage/archive/ha_archive.cc: Copy over the embedded FRM.
Diffstat (limited to 'storage/archive/azio.c')
-rw-r--r--storage/archive/azio.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/storage/archive/azio.c b/storage/archive/azio.c
index c1dd6e6f38c..1e2753027dc 100644
--- a/storage/archive/azio.c
+++ b/storage/archive/azio.c
@@ -31,7 +31,7 @@ int az_open(azio_stream *s, const char *path, int Flags, File fd);
int do_flush(azio_stream *file, int flush);
int get_byte(azio_stream *s);
void check_header(azio_stream *s);
-void write_header(azio_stream *s);
+int write_header(azio_stream *s);
int destroy(azio_stream *s);
void putLong(File file, uLong x);
uLong getLong(azio_stream *s);
@@ -155,7 +155,7 @@ int az_open (azio_stream *s, const char *path, int Flags, File fd)
}
-void write_header(azio_stream *s)
+int write_header(azio_stream *s)
{
char buffer[AZHEADER_SIZE + AZMETA_BUFFER_SIZE];
char *ptr= buffer;
@@ -191,8 +191,8 @@ void write_header(azio_stream *s)
*(ptr + AZ_DIRTY_POS)= (unsigned char)s->dirty; /* Start of Data Block Index Block */
/* Always begin at the begining, and end there as well */
- my_pwrite(s->file, (uchar*) buffer, AZHEADER_SIZE + AZMETA_BUFFER_SIZE, 0,
- MYF(0));
+ return my_pwrite(s->file, (uchar*) buffer, AZHEADER_SIZE + AZMETA_BUFFER_SIZE,
+ 0, MYF(MY_NABP)) ? 1 : 0;
}
/* ===========================================================================
@@ -838,19 +838,19 @@ int azwrite_frm(azio_stream *s, char *blob, unsigned int length)
s->frm_length= length;
s->start+= length;
- my_pwrite(s->file, (uchar*) blob, s->frm_length, s->frm_start_pos, MYF(0));
-
- write_header(s);
- my_seek(s->file, 0, MY_SEEK_END, MYF(0));
+ if (my_pwrite(s->file, (uchar*) blob, s->frm_length,
+ s->frm_start_pos, MYF(MY_NABP)) ||
+ write_header(s) ||
+ (my_seek(s->file, 0, MY_SEEK_END, MYF(0)) == MY_FILEPOS_ERROR))
+ return 1;
return 0;
}
int azread_frm(azio_stream *s, char *blob)
{
- my_pread(s->file, (uchar*) blob, s->frm_length, s->frm_start_pos, MYF(0));
-
- return 0;
+ return my_pread(s->file, (uchar*) blob, s->frm_length,
+ s->frm_start_pos, MYF(MY_NABP)) ? 1 : 0;
}