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.
parent 491e471f
CREATE TABLE t1(a BLOB) ENGINE=ARCHIVE;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
DROP TABLE t1;
This diff is collapsed.
...@@ -205,7 +205,7 @@ bool archive_db_init() ...@@ -205,7 +205,7 @@ bool archive_db_init()
else else
{ {
zoffset_size= 2 << ((zlibCompileFlags() >> 6) & 3); zoffset_size= 2 << ((zlibCompileFlags() >> 6) & 3);
switch (sizeof(z_off_t)) { switch (zoffset_size) {
case 2: case 2:
max_zfile_size= INT_MAX16; max_zfile_size= INT_MAX16;
break; break;
...@@ -676,6 +676,7 @@ int ha_archive::real_write_row(byte *buf, gzFile writer) ...@@ -676,6 +676,7 @@ int ha_archive::real_write_row(byte *buf, gzFile writer)
total_row_length+= ((Field_blob*) table->field[*ptr])->get_length(); total_row_length+= ((Field_blob*) table->field[*ptr])->get_length();
if (share->approx_file_size > max_zfile_size - total_row_length) if (share->approx_file_size > max_zfile_size - total_row_length)
{ {
gzflush(writer, Z_SYNC_FLUSH);
info(HA_STATUS_TIME); info(HA_STATUS_TIME);
share->approx_file_size= (ulong) data_file_length; share->approx_file_size= (ulong) data_file_length;
if (share->approx_file_size > max_zfile_size - total_row_length) if (share->approx_file_size > max_zfile_size - total_row_length)
......
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