summaryrefslogtreecommitdiff
path: root/storage/archive
diff options
context:
space:
mode:
authorunknown <knielsen@knielsen-hq.org>2010-01-30 10:00:14 +0100
committerunknown <knielsen@knielsen-hq.org>2010-01-30 10:00:14 +0100
commite8631758fe6bac6b13187f372809366792920cd7 (patch)
treeb4e7251729b81216e6d66d5bf8dee7d7c315cc26 /storage/archive
parentacb7de23306ce0b311344d679e8c63160ad32a49 (diff)
parente9bce6c9d4bde35306b845e22e9b5ada69c4512f (diff)
downloadmariadb-git-e8631758fe6bac6b13187f372809366792920cd7.tar.gz
Automerge from main into MariaDB 5.1.42 release branch.
Diffstat (limited to 'storage/archive')
-rwxr-xr-x[-rw-r--r--]storage/archive/CMakeLists.txt3
-rw-r--r--storage/archive/azio.c18
-rw-r--r--storage/archive/ha_archive.cc16
3 files changed, 32 insertions, 5 deletions
diff --git a/storage/archive/CMakeLists.txt b/storage/archive/CMakeLists.txt
index ce4d92d3f99..f4492c3ce77 100644..100755
--- a/storage/archive/CMakeLists.txt
+++ b/storage/archive/CMakeLists.txt
@@ -13,6 +13,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
+SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
+
INCLUDE("${PROJECT_SOURCE_DIR}/storage/mysql_storage_engine.cmake")
SET(ARCHIVE_SOURCES azio.c ha_archive.cc ha_archive.h)
MYSQL_STORAGE_ENGINE(ARCHIVE)
diff --git a/storage/archive/azio.c b/storage/archive/azio.c
index b6d66fc0739..a24350dd454 100644
--- a/storage/archive/azio.c
+++ b/storage/archive/azio.c
@@ -71,7 +71,8 @@ int az_open (azio_stream *s, const char *path, int Flags, File fd)
s->transparent = 0;
s->mode = 'r';
s->version = (unsigned char)az_magic[1]; /* this needs to be a define to version */
- s->version = (unsigned char)az_magic[2]; /* minor version */
+ s->minor_version= (unsigned char) az_magic[2]; /* minor version */
+ s->dirty= AZ_STATE_CLEAN;
/*
We do our own version of append by nature.
@@ -354,10 +355,19 @@ void read_header(azio_stream *s, unsigned char *buffer)
s->comment_length= (unsigned int)uint4korr(buffer + AZ_COMMENT_LENGTH_POS);
s->dirty= (unsigned int)buffer[AZ_DIRTY_POS];
}
- else
+ else if (buffer[0] == gz_magic[0] && buffer[1] == gz_magic[1])
{
- DBUG_ASSERT(buffer[0] == az_magic[0] && buffer[1] == az_magic[1]);
- return;
+ /*
+ Set version number to previous version (2).
+ */
+ s->version= (unsigned char) 2;
+ } else {
+ /*
+ Unknown version.
+ Most probably due to a corrupt archive.
+ */
+ s->dirty= AZ_STATE_DIRTY;
+ s->z_err= Z_VERSION_ERROR;
}
}
diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc
index ed6ff18f980..5b67782a868 100644
--- a/storage/archive/ha_archive.cc
+++ b/storage/archive/ha_archive.cc
@@ -360,6 +360,12 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, int *rc)
stats.auto_increment_value= archive_tmp.auto_increment + 1;
share->rows_recorded= (ha_rows)archive_tmp.rows;
share->crashed= archive_tmp.dirty;
+ /*
+ If archive version is less than 3, It should be upgraded before
+ use.
+ */
+ if (archive_tmp.version < ARCHIVE_VERSION)
+ *rc= HA_ERR_TABLE_NEEDS_UPGRADE;
azclose(&archive_tmp);
VOID(my_hash_insert(&archive_open_tables, (uchar*) share));
@@ -491,7 +497,15 @@ int ha_archive::open(const char *name, int mode, uint open_options)
(open_options & HA_OPEN_FOR_REPAIR) ? "yes" : "no"));
share= get_share(name, &rc);
- if (rc == HA_ERR_CRASHED_ON_USAGE && !(open_options & HA_OPEN_FOR_REPAIR))
+ /*
+ Allow open on crashed table in repair mode only.
+ Block open on 5.0 ARCHIVE table. Though we have almost all
+ routines to access these tables, they were not well tested.
+ For now we have to refuse to open such table to avoid
+ potential data loss.
+ */
+ if ((rc == HA_ERR_CRASHED_ON_USAGE && !(open_options & HA_OPEN_FOR_REPAIR))
+ || rc == HA_ERR_TABLE_NEEDS_UPGRADE)
{
/* purecov: begin inspected */
free_share();