diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-04-09 15:57:09 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-04-09 15:57:09 +0200 |
commit | e06cb31719ce31fb1cd7944d1de86d4de9e3eca6 (patch) | |
tree | 2c740b5851514787748799604b6c724d7c4e10b9 /storage/archive | |
parent | b3e70c4ae713abeddd47b3987f898ed763fa4eca (diff) | |
download | mariadb-git-e06cb31719ce31fb1cd7944d1de86d4de9e3eca6.tar.gz |
CREATE TABLE and frm-less discovering engines.
Now CREATE TABLE does not write the frm file on disk,
if the engine can discover it
Diffstat (limited to 'storage/archive')
-rw-r--r-- | storage/archive/azio.c | 2 | ||||
-rw-r--r-- | storage/archive/azlib.h | 2 | ||||
-rw-r--r-- | storage/archive/ha_archive.cc | 22 | ||||
-rw-r--r-- | storage/archive/ha_archive.h | 2 |
4 files changed, 13 insertions, 15 deletions
diff --git a/storage/archive/azio.c b/storage/archive/azio.c index 43c418e516d..c6058af2e3d 100644 --- a/storage/archive/azio.c +++ b/storage/archive/azio.c @@ -855,7 +855,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, uchar *blob, unsigned int length) +int azwrite_frm(azio_stream *s, const uchar *blob, unsigned int length) { if (s->mode == 'r') return 1; diff --git a/storage/archive/azlib.h b/storage/archive/azlib.h index 05fc299e581..09f61afcd28 100644 --- a/storage/archive/azlib.h +++ b/storage/archive/azlib.h @@ -331,7 +331,7 @@ extern int azclose(azio_stream *file); error number (see function gzerror below). */ -extern int azwrite_frm (azio_stream *s, uchar *blob, unsigned int length); +extern int azwrite_frm (azio_stream *s, const uchar *blob, unsigned int length); extern int azread_frm (azio_stream *s, uchar *blob); extern int azwrite_comment (azio_stream *s, char *blob, unsigned int length); extern int azread_comment (azio_stream *s, char *blob); diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index 2d2ab5f285c..616af00bcc8 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -302,8 +302,7 @@ int archive_discover(handlerton *hton, THD* thd, TABLE_SHARE *share) azclose(&frm_stream); - if (!share->init_from_binary_frm_image(thd, share->normalized_path.str, - frm_ptr, frm_stream.frm_length)) + if (!share->init_from_binary_frm_image(thd, 1, frm_ptr, frm_stream.frm_length)) my_errno= 0; ret: @@ -437,7 +436,7 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, int *rc) */ if (archive_tmp.version < ARCHIVE_VERSION) *rc= HA_ERR_TABLE_NEEDS_UPGRADE; - else if (frm_compare(&archive_tmp, table_name)) + else if (frm_compare(&archive_tmp)) *rc= HA_ERR_TABLE_DEF_CHANGED; azclose(&archive_tmp); @@ -669,19 +668,19 @@ int ha_archive::frm_copy(azio_stream *src, azio_stream *dst) Compare frm blob with the on-disk frm file @param s The azio stream. - @param path A path for readfrm() @return Zero if equal, non-zero otherwise. */ -int ha_archive::frm_compare(azio_stream *s, const char *path) +int ha_archive::frm_compare(azio_stream *s) { int rc= 0; - uchar *frm_ptr= 0, *azfrm_ptr= 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 (readfrm(path, &frm_ptr, &frm_len)) + if (table->s->read_frm_image(&frm_ptr, &frm_len)) goto err; if (!(azfrm_ptr= (uchar *) my_malloc(s->frm_length, @@ -699,7 +698,7 @@ int ha_archive::frm_compare(azio_stream *s, const char *path) rc= memcmp(frm_ptr, azfrm_ptr, frm_len); err: - my_free(frm_ptr); + my_free(const_cast<uchar*>(frm_ptr)); my_free(azfrm_ptr); return rc; } @@ -721,7 +720,7 @@ int ha_archive::create(const char *name, TABLE *table_arg, char linkname[FN_REFLEN]; int error; azio_stream create_stream; /* Archive file we are working with */ - uchar *frm_ptr; + const uchar *frm_ptr; size_t frm_len; DBUG_ENTER("ha_archive::create"); @@ -784,11 +783,10 @@ int ha_archive::create(const char *name, TABLE *table_arg, /* Here is where we open up the frm and pass it to archive to store */ - readfrm(name, &frm_ptr, &frm_len); - if (frm_ptr) + if (!table_arg->s->read_frm_image(&frm_ptr, &frm_len)) { azwrite_frm(&create_stream, frm_ptr, frm_len); - my_free(frm_ptr); + my_free(const_cast<uchar*>(frm_ptr)); } if (create_info->comment.str) diff --git a/storage/archive/ha_archive.h b/storage/archive/ha_archive.h index 0723ee9bfc9..7e8d5cee47b 100644 --- a/storage/archive/ha_archive.h +++ b/storage/archive/ha_archive.h @@ -76,7 +76,7 @@ class ha_archive: public handler archive_record_buffer *create_record_buffer(unsigned int length); void destroy_record_buffer(archive_record_buffer *r); int frm_copy(azio_stream *src, azio_stream *dst); - int frm_compare(azio_stream *src, const char *path); + int frm_compare(azio_stream *src); public: ha_archive(handlerton *hton, TABLE_SHARE *table_arg); |