diff options
author | Michael Widenius <monty@askmonty.org> | 2012-02-20 17:49:21 +0200 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2012-02-20 17:49:21 +0200 |
commit | 038b739c98009cf0b4b7b7c2c18421051abf79f2 (patch) | |
tree | c31b05bf35b15358f7b0a89cfd8b5b43e2901ad8 /storage/archive | |
parent | 3c07d04580fe5f28ff8bdabd1249b8123d7da76b (diff) | |
parent | ae07ec6cbf08e311e538f5149f93385e5bcaa7a6 (diff) | |
download | mariadb-git-038b739c98009cf0b4b7b7c2c18421051abf79f2.tar.gz |
Merge with MariaDB 5.1 and MySQL 5.1.61
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 deee52749e0..3ab2cb5e7ed 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); } /* |