summaryrefslogtreecommitdiff
path: root/storage/archive/azio.c
diff options
context:
space:
mode:
Diffstat (limited to 'storage/archive/azio.c')
-rw-r--r--storage/archive/azio.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/storage/archive/azio.c b/storage/archive/azio.c
index 92d7ad70344..4519d15cefc 100644
--- a/storage/archive/azio.c
+++ b/storage/archive/azio.c
@@ -364,6 +364,8 @@ void read_header(azio_stream *s, unsigned char *buffer)
{
if (buffer[0] == az_magic[0] && buffer[1] == az_magic[1])
{
+ uchar tmp[AZ_FRMVER_LEN + 2];
+
s->version= (unsigned int)buffer[AZ_VERSION_POS];
s->minor_version= (unsigned int)buffer[AZ_MINOR_VERSION_POS];
s->block_size= 1024 * buffer[AZ_BLOCK_POS];
@@ -379,6 +381,22 @@ void read_header(azio_stream *s, unsigned char *buffer)
s->comment_start_pos= (unsigned int)uint4korr(buffer + AZ_COMMENT_POS);
s->comment_length= (unsigned int)uint4korr(buffer + AZ_COMMENT_LENGTH_POS);
s->dirty= (unsigned int)buffer[AZ_DIRTY_POS];
+
+ /*
+ we'll hard-code the current frm format for now, to avoid
+ changing archive table versions.
+ */
+ if (s->frm_length == 0 ||
+ my_pread(s->file, tmp, sizeof(tmp), s->frm_start_pos + 64, MYF(MY_NABP)) ||
+ tmp[0] != 0 || tmp[1] != AZ_FRMVER_LEN)
+ {
+ s->frmver_length= 0;
+ }
+ else
+ {
+ s->frmver_length= tmp[1];
+ memcpy(s->frmver, tmp+2, s->frmver_length);
+ }
}
else if (buffer[0] == gz_magic[0] && buffer[1] == gz_magic[1])
{
@@ -855,7 +873,7 @@ int azclose (azio_stream *s)
Though this was added to support MySQL's FRM file, anything can be
stored in this location.
*/
-int azwrite_frm(azio_stream *s, char *blob, unsigned int length)
+int azwrite_frm(azio_stream *s, const uchar *blob, unsigned int length)
{
if (s->mode == 'r')
return 1;
@@ -867,7 +885,7 @@ int azwrite_frm(azio_stream *s, char *blob, unsigned int length)
s->frm_length= length;
s->start+= length;
- if (my_pwrite(s->file, (uchar*) blob, s->frm_length,
+ if (my_pwrite(s->file, 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))
@@ -876,9 +894,9 @@ int azwrite_frm(azio_stream *s, char *blob, unsigned int length)
return 0;
}
-int azread_frm(azio_stream *s, char *blob)
+int azread_frm(azio_stream *s, uchar *blob)
{
- return my_pread(s->file, (uchar*) blob, s->frm_length,
+ return my_pread(s->file, blob, s->frm_length,
s->frm_start_pos, MYF(MY_NABP)) ? 1 : 0;
}