summaryrefslogtreecommitdiff
path: root/storage/archive
diff options
context:
space:
mode:
authorAshish Agarwal <ashish.y.agarwal@oracle.com>2011-11-23 18:50:29 +0530
committerAshish Agarwal <ashish.y.agarwal@oracle.com>2011-11-23 18:50:29 +0530
commit0fa7fe90b4b2bfe9bbdb4527d3b57a697362e558 (patch)
treef59ab307dd6a2c16e07b03af06e7b1e9c3e69c0d /storage/archive
parente065b124fd30d2f471b731238f4d71c4780c5c0d (diff)
parenta00f87bf155fda703ffd314e5d8166583db92d93 (diff)
downloadmariadb-git-0fa7fe90b4b2bfe9bbdb4527d3b57a697362e558.tar.gz
BUG#11751793 - 42784: Merge from mysql-5.1 to mysql-5.5
Diffstat (limited to 'storage/archive')
-rw-r--r--storage/archive/ha_archive.cc36
1 files changed, 27 insertions, 9 deletions
diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc
index b6947688768..7b943139c24 100644
--- a/storage/archive/ha_archive.cc
+++ b/storage/archive/ha_archive.cc
@@ -1689,13 +1689,15 @@ int ha_archive::check(THD* thd, HA_CHECK_OPT* check_opt)
{
int rc= 0;
const char *old_proc_info;
- ha_rows count= share->rows_recorded;
+ ha_rows count;
DBUG_ENTER("ha_archive::check");
old_proc_info= thd_proc_info(thd, "Checking table");
- /* Flush any waiting data */
mysql_mutex_lock(&share->mutex);
- azflush(&(share->archive_write), Z_SYNC_FLUSH);
+ count= share->rows_recorded;
+ /* Flush any waiting data */
+ if (share->archive_write_open)
+ azflush(&(share->archive_write), Z_SYNC_FLUSH);
mysql_mutex_unlock(&share->mutex);
if (init_archive_reader())
@@ -1705,18 +1707,34 @@ int ha_archive::check(THD* thd, HA_CHECK_OPT* check_opt)
start of the file.
*/
read_data_header(&archive);
+ for (ha_rows cur_count= count; cur_count; cur_count--)
+ {
+ if ((rc= get_row(&archive, table->record[0])))
+ goto error;
+ }
+ /*
+ Now read records that may have been inserted concurrently.
+ Acquire share->mutex so tail of the table is not modified by
+ concurrent writers.
+ */
+ mysql_mutex_lock(&share->mutex);
+ count= share->rows_recorded - count;
+ if (share->archive_write_open)
+ azflush(&(share->archive_write), Z_SYNC_FLUSH);
while (!(rc= get_row(&archive, table->record[0])))
count--;
-
- thd_proc_info(thd, old_proc_info);
+ mysql_mutex_unlock(&share->mutex);
if ((rc && rc != HA_ERR_END_OF_FILE) || count)
- {
- share->crashed= FALSE;
- DBUG_RETURN(HA_ADMIN_CORRUPT);
- }
+ goto error;
+ thd_proc_info(thd, old_proc_info);
DBUG_RETURN(HA_ADMIN_OK);
+
+error:
+ thd_proc_info(thd, old_proc_info);
+ share->crashed= FALSE;
+ DBUG_RETURN(HA_ADMIN_CORRUPT);
}
/*