diff options
author | Michael Widenius <monty@askmonty.org> | 2012-02-21 01:58:50 +0200 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2012-02-21 01:58:50 +0200 |
commit | 15c5a2686f6367d5a280813ad96ef86bd0ee0fc0 (patch) | |
tree | a1e008c4e92b63efa9cea54ed5ab837fa2b7e229 /storage/archive | |
parent | 84a3767c1912c34e79cde72a51e4cf69d235587e (diff) | |
parent | 522b289607ce10ff3e44fdf8035ae1c29bffe4f4 (diff) | |
download | mariadb-git-15c5a2686f6367d5a280813ad96ef86bd0ee0fc0.tar.gz |
Merge with MariaDB 5.2
Diffstat (limited to 'storage/archive')
-rw-r--r-- | storage/archive/ha_archive.cc | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index 0474fb61a7c..0549ba2d978 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -773,6 +773,7 @@ uint32 ha_archive::max_row_length(const uchar *buf) ptr != end ; ptr++) { + if (!table->field[*ptr]->is_null()) length += 2 + ((Field_blob*)table->field[*ptr])->get_length(); } @@ -1620,13 +1621,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 */ pthread_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); pthread_mutex_unlock(&share->mutex); if (init_archive_reader()) @@ -1639,18 +1642,34 @@ int ha_archive::check(THD* thd, HA_CHECK_OPT* check_opt) DBUG_RETURN(errno); 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. + */ + pthread_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); + pthread_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); } /* |