summaryrefslogtreecommitdiff
path: root/sql/ha_archive.cc
diff options
context:
space:
mode:
authorunknown <svoj@mysql.com/april.(none)>2007-06-24 19:44:54 +0500
committerunknown <svoj@mysql.com/april.(none)>2007-06-24 19:44:54 +0500
commitb3b8d5165d76de270532120dd8ce2a216308c0bd (patch)
tree2599305b8941711b1310c6fd4145bf4ba5c6b034 /sql/ha_archive.cc
parent4831826c694d5169764eb75fb246c0cb6f0f7a99 (diff)
downloadmariadb-git-b3b8d5165d76de270532120dd8ce2a216308c0bd.tar.gz
BUG#15787 - MySQL crashes when archive table exceeds 2GB
Max compressed file size was calculated incorretly causing server crash on INSERT. With this patch we use proper max file size provided by zlib. Affects 5.0 only. sql/ha_archive.cc: When calculating max compressed file size, use the real offset size that is provided by zlib, instead of sizeof(z_off_t), which may be different from actual offset size. When we're about to write and the data file is almost full flush gzio buffer to get accurate real file size. mysql-test/r/archive-big.result: New BitKeeper file ``mysql-test/r/archive-big.result'' mysql-test/t/archive-big.test: New BitKeeper file ``mysql-test/t/archive-big.test''
Diffstat (limited to 'sql/ha_archive.cc')
-rw-r--r--sql/ha_archive.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/sql/ha_archive.cc b/sql/ha_archive.cc
index e2a2211259f..6e18f2e1e01 100644
--- a/sql/ha_archive.cc
+++ b/sql/ha_archive.cc
@@ -205,7 +205,7 @@ bool archive_db_init()
else
{
zoffset_size= 2 << ((zlibCompileFlags() >> 6) & 3);
- switch (sizeof(z_off_t)) {
+ switch (zoffset_size) {
case 2:
max_zfile_size= INT_MAX16;
break;
@@ -676,6 +676,7 @@ int ha_archive::real_write_row(byte *buf, gzFile writer)
total_row_length+= ((Field_blob*) table->field[*ptr])->get_length();
if (share->approx_file_size > max_zfile_size - total_row_length)
{
+ gzflush(writer, Z_SYNC_FLUSH);
info(HA_STATUS_TIME);
share->approx_file_size= (ulong) data_file_length;
if (share->approx_file_size > max_zfile_size - total_row_length)