diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-04-09 16:18:33 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-04-09 16:18:33 +0200 |
commit | 02c712aa546df8d6e9c285e6adc95309925673e3 (patch) | |
tree | 8d6654dac2666dcd738db1f10dbd919610087795 /storage/archive | |
parent | f6168bb67bb5cab0584809c876c674a92051b5d1 (diff) | |
download | mariadb-git-02c712aa546df8d6e9c285e6adc95309925673e3.tar.gz |
* frm extra2 segment.
* persistent table versions in the extra2
* ha_archive::frm_compare using TABLE_SHARE::tabledef_version
* distinguish between "important" and "optional" extra2 frm values
* write engine-defined attributes (aka "table options") to extra2, not to extra,
but still read from the old location, if they're found there.
Diffstat (limited to 'storage/archive')
-rw-r--r-- | storage/archive/azio.c | 18 | ||||
-rw-r--r-- | storage/archive/azlib.h | 3 | ||||
-rw-r--r-- | storage/archive/ha_archive.cc | 31 |
3 files changed, 26 insertions, 26 deletions
diff --git a/storage/archive/azio.c b/storage/archive/azio.c index c6058af2e3d..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]) { diff --git a/storage/archive/azlib.h b/storage/archive/azlib.h index 09f61afcd28..2971705b2f1 100644 --- a/storage/archive/azlib.h +++ b/storage/archive/azlib.h @@ -198,6 +198,7 @@ extern "C" { #define AZ_BUFSIZE_READ 32768 #define AZ_BUFSIZE_WRITE 16384 +#define AZ_FRMVER_LEN 16 /* same as MY_UUID_SIZE in 10.0.2 */ typedef struct azio_stream { z_stream stream; @@ -227,6 +228,8 @@ typedef struct azio_stream { unsigned char dirty; /* State of file */ unsigned int frm_start_pos; /* Position for start of FRM */ unsigned int frm_length; /* Position for start of FRM */ + unsigned char frmver[AZ_FRMVER_LEN]; + unsigned int frmver_length; unsigned int comment_start_pos; /* Position for start of comment */ unsigned int comment_length; /* Position for start of comment */ } azio_stream; diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index 515ebf8cf3d..9f164da3359 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -673,33 +673,12 @@ int ha_archive::frm_copy(azio_stream *src, azio_stream *dst) int ha_archive::frm_compare(azio_stream *s) { - int rc= 0; - const uchar *frm_ptr= 0; - uchar *azfrm_ptr= 0; - size_t frm_len; - - /* no frm = no discovery. perhaps it's a partitioned table */ - if (table->s->read_frm_image(&frm_ptr, &frm_len)) - goto err; - - if (!(azfrm_ptr= (uchar *) my_malloc(s->frm_length, - MYF(MY_THREAD_SPECIFIC | MY_WME)))) - goto err; - - rc= 1; + if (!s->frmver_length) + return 0; // Old pre-10.0 archive table. Never rediscover. - if (frm_len != s->frm_length) - goto err; - - if (azread_frm(s, azfrm_ptr)) - goto err; - - rc= memcmp(frm_ptr, azfrm_ptr, frm_len); - -err: - my_free(const_cast<uchar*>(frm_ptr)); - my_free(azfrm_ptr); - return rc; + LEX_CUSTRING *ver= &table->s->tabledef_version; + return ver->length != s->frmver_length || + memcmp(ver->str, s->frmver, ver->length); } |