diff options
author | unknown <brian@zim.(none)> | 2006-08-14 03:29:17 -0700 |
---|---|---|
committer | unknown <brian@zim.(none)> | 2006-08-14 03:29:17 -0700 |
commit | ba8be73946c35852cf296c2d30bbf2a0fe06f87f (patch) | |
tree | bc2caebf2da50b2545ebd2d4d83e7e9f758fa6d3 /sql/ha_archive.cc | |
parent | 6071b686b179d1fcc96cd6ccce940d62bd509c70 (diff) | |
download | mariadb-git-ba8be73946c35852cf296c2d30bbf2a0fe06f87f.tar.gz |
Fix for bug#20648 We introduce a new field method for knowing "real size", and we now in archive null unused bits of a row to null before writing.
sql/field.cc:
data_length for field needs to be calculated directly.
sql/field.h:
The new method data_length() returns the "real" length of the field.
sql/ha_archive.cc:
Before a write_row() archive nulls space beyond the size of the row in varchars to make sure that compression only sees NULL.
Diffstat (limited to 'sql/ha_archive.cc')
-rw-r--r-- | sql/ha_archive.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/sql/ha_archive.cc b/sql/ha_archive.cc index 3885defb4d5..0fb0bc9f791 100644 --- a/sql/ha_archive.cc +++ b/sql/ha_archive.cc @@ -710,6 +710,28 @@ int ha_archive::write_row(byte *buf) if (init_archive_writer()) DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); + /* + Varchar structures are constant in size but are not cleaned up request + to request. The following sets all unused space to null to improve + compression. + */ + for (Field **field=table->field ; *field ; field++) + { + DBUG_PRINT("archive",("Pack is %d\n", (*field)->pack_length())); + DBUG_PRINT("archive",("MyPack is %d\n", (*field)->data_length((char*) buf + (*field)->offset()))); + if ((*field)->real_type() == MYSQL_TYPE_VARCHAR) + { + uint actual_length= (*field)->data_length((char*) buf + (*field)->offset()); + uint offset= (*field)->offset() + actual_length + + (actual_length > 255 ? 2 : 1); + DBUG_PRINT("archive",("Offset is %d -> %d\n", actual_length, offset)); + /* + if ((*field)->pack_length() + (*field)->offset() != offset) + bzero(buf + offset, (size_t)((*field)->pack_length() + (actual_length > 255 ? 2 : 1) - (*field)->data_length)); + */ + } + } + share->rows_recorded++; rc= real_write_row(buf, share->archive_write); pthread_mutex_unlock(&share->mutex); |