summaryrefslogtreecommitdiff
path: root/storage/archive
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2010-09-11 20:43:48 +0200
committerSergei Golubchik <sergii@pisem.net>2010-09-11 20:43:48 +0200
commita3d80d952d7b99680ca4a3a89e128ecc0d490c10 (patch)
tree0d72ee69e037cdd09618ddb53652dd1b220890dc /storage/archive
parentec06ba24553d2d83b3a6a6bc4d8150910b01ee7c (diff)
parent966661c8cc75dd7d540a5fe40b4d893c40e91d26 (diff)
downloadmariadb-git-a3d80d952d7b99680ca4a3a89e128ecc0d490c10.tar.gz
merge with 5.1
Diffstat (limited to 'storage/archive')
-rw-r--r--storage/archive/Makefile.am6
-rw-r--r--storage/archive/azio.c11
-rw-r--r--storage/archive/ha_archive.cc42
-rw-r--r--storage/archive/ha_archive.h3
4 files changed, 47 insertions, 15 deletions
diff --git a/storage/archive/Makefile.am b/storage/archive/Makefile.am
index d092f091798..254c95bf68b 100644
--- a/storage/archive/Makefile.am
+++ b/storage/archive/Makefile.am
@@ -36,14 +36,14 @@ noinst_PROGRAMS = archive_test archive_reader
EXTRA_LTLIBRARIES = ha_archive.la
pkgplugin_LTLIBRARIES = @plugin_archive_shared_target@
ha_archive_la_LDFLAGS = -module -rpath $(pkgplugindir)
-ha_archive_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
-ha_archive_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
+ha_archive_la_CXXFLAGS= -shared $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN
+ha_archive_la_CFLAGS = -shared $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
ha_archive_la_SOURCES = ha_archive.cc azio.c
EXTRA_LIBRARIES = libarchive.a
noinst_LIBRARIES = @plugin_archive_static_target@
-libarchive_a_CXXFLAGS = $(AM_CFLAGS)
+libarchive_a_CXXFLAGS = $(AM_CXXFLAGS)
libarchive_a_CFLAGS = $(AM_CFLAGS)
libarchive_a_SOURCES = ha_archive.cc azio.c
diff --git a/storage/archive/azio.c b/storage/archive/azio.c
index a24350dd454..fc54d98ab15 100644
--- a/storage/archive/azio.c
+++ b/storage/archive/azio.c
@@ -150,6 +150,17 @@ int az_open (azio_stream *s, const char *path, int Flags, File fd)
}
else
{
+ /* Reset values in case of old version of archive file */
+ s->rows= 0;
+ s->forced_flushes= 0;
+ s->shortest_row= 0;
+ s->longest_row= 0;
+ s->auto_increment= 0;
+ s->check_point= 0;
+ s->comment_start_pos= 0;
+ s->comment_length= 0;
+ s->frm_start_pos= 0;
+ s->frm_length= 0;
check_header(s); /* skip the .az header */
}
diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc
index 922db30c9d9..f3f5788360a 100644
--- a/storage/archive/ha_archive.cc
+++ b/storage/archive/ha_archive.cc
@@ -293,7 +293,7 @@ int ha_archive::read_data_header(azio_stream *file_to_read)
DBUG_PRINT("ha_archive", ("Version %u", data_buffer[1]));
if ((data_buffer[0] != (uchar)ARCHIVE_CHECK_HEADER) &&
- (data_buffer[1] != (uchar)ARCHIVE_VERSION))
+ (data_buffer[1] == 1 || data_buffer[1] == 2))
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
DBUG_RETURN(0);
@@ -360,9 +360,19 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, int *rc)
my_free(share, MYF(0));
DBUG_RETURN(NULL);
}
- stats.auto_increment_value= archive_tmp.auto_increment + 1;
- share->rows_recorded= (ha_rows)archive_tmp.rows;
- share->crashed= archive_tmp.dirty;
+ share->version= archive_tmp.version;
+ if (archive_tmp.version == ARCHIVE_VERSION)
+ {
+ stats.auto_increment_value= archive_tmp.auto_increment + 1;
+ share->rows_recorded= (ha_rows)archive_tmp.rows;
+ share->crashed= archive_tmp.dirty;
+ }
+ else
+ {
+ /* Used by repair */
+ share->rows_recorded= ~(ha_rows) 0;
+ stats.auto_increment_value= 0;
+ }
/*
If archive version is less than 3, It should be upgraded before
use.
@@ -512,10 +522,19 @@ int ha_archive::open(const char *name, int mode, uint open_options)
case 0:
break;
case HA_ERR_CRASHED_ON_USAGE:
+ DBUG_PRINT("ha_archive", ("archive table was crashed"));
if (open_options & HA_OPEN_FOR_REPAIR)
+ {
+ rc= 0;
break;
+ }
/* fall through */
case HA_ERR_TABLE_NEEDS_UPGRADE:
+ if (open_options & HA_OPEN_FOR_REPAIR)
+ {
+ rc= 0;
+ break;
+ }
free_share();
/* fall through */
default:
@@ -535,13 +554,6 @@ int ha_archive::open(const char *name, int mode, uint open_options)
thr_lock_data_init(&share->lock, &lock, NULL);
- DBUG_PRINT("ha_archive", ("archive table was crashed %s",
- rc == HA_ERR_CRASHED_ON_USAGE ? "yes" : "no"));
- if (rc == HA_ERR_CRASHED_ON_USAGE && open_options & HA_OPEN_FOR_REPAIR)
- {
- DBUG_RETURN(0);
- }
-
DBUG_RETURN(rc);
}
@@ -1267,6 +1279,14 @@ int ha_archive::rnd_pos(uchar * buf, uchar *pos)
DBUG_RETURN(get_row(&archive, buf));
}
+int ha_archive::check_for_upgrade(HA_CHECK_OPT *check_opt)
+{
+ if (share->version < ARCHIVE_VERSION)
+ return HA_ADMIN_NEEDS_ALTER;
+ return 0;
+}
+
+
/*
This method repairs the meta file. It does this by walking the datafile and
rewriting the meta file. If EXTENDED repair is requested, we attempt to
diff --git a/storage/archive/ha_archive.h b/storage/archive/ha_archive.h
index ab630ed22fd..653a13b242d 100644
--- a/storage/archive/ha_archive.h
+++ b/storage/archive/ha_archive.h
@@ -35,7 +35,7 @@ typedef struct st_archive_record_buffer {
typedef struct st_archive_share {
char *table_name;
char data_file_name[FN_REFLEN];
- uint table_name_length,use_count;
+ uint table_name_length,use_count, version;
pthread_mutex_t mutex;
THR_LOCK lock;
azio_stream archive_write; /* Archive file we are working with */
@@ -133,6 +133,7 @@ public:
int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info);
int optimize(THD* thd, HA_CHECK_OPT* check_opt);
int repair(THD* thd, HA_CHECK_OPT* check_opt);
+ int check_for_upgrade(HA_CHECK_OPT *check_opt);
void start_bulk_insert(ha_rows rows);
int end_bulk_insert();
enum row_type get_row_type() const