Commit 0fa7fe90 authored by Ashish Agarwal's avatar Ashish Agarwal

BUG#11751793 - 42784: Merge from mysql-5.1 to mysql-5.5

parents e065b124 a00f87bf
...@@ -1689,13 +1689,15 @@ int ha_archive::check(THD* thd, HA_CHECK_OPT* check_opt) ...@@ -1689,13 +1689,15 @@ int ha_archive::check(THD* thd, HA_CHECK_OPT* check_opt)
{ {
int rc= 0; int rc= 0;
const char *old_proc_info; const char *old_proc_info;
ha_rows count= share->rows_recorded; ha_rows count;
DBUG_ENTER("ha_archive::check"); DBUG_ENTER("ha_archive::check");
old_proc_info= thd_proc_info(thd, "Checking table"); old_proc_info= thd_proc_info(thd, "Checking table");
/* Flush any waiting data */
mysql_mutex_lock(&share->mutex); 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); mysql_mutex_unlock(&share->mutex);
if (init_archive_reader()) if (init_archive_reader())
...@@ -1705,18 +1707,34 @@ int ha_archive::check(THD* thd, HA_CHECK_OPT* check_opt) ...@@ -1705,18 +1707,34 @@ int ha_archive::check(THD* thd, HA_CHECK_OPT* check_opt)
start of the file. start of the file.
*/ */
read_data_header(&archive); 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]))) while (!(rc= get_row(&archive, table->record[0])))
count--; count--;
mysql_mutex_unlock(&share->mutex);
thd_proc_info(thd, old_proc_info);
if ((rc && rc != HA_ERR_END_OF_FILE) || count) if ((rc && rc != HA_ERR_END_OF_FILE) || count)
{ goto error;
share->crashed= FALSE;
DBUG_RETURN(HA_ADMIN_CORRUPT);
}
thd_proc_info(thd, old_proc_info);
DBUG_RETURN(HA_ADMIN_OK); DBUG_RETURN(HA_ADMIN_OK);
error:
thd_proc_info(thd, old_proc_info);
share->crashed= FALSE;
DBUG_RETURN(HA_ADMIN_CORRUPT);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment