Commit ac5b886f authored by marko's avatar marko

branches/zip: Fix some BLOB handling bugs.

btr_store_big_rec_extern_fields(): Assert that page_zip is non-NULL
if and only if dict_table_is_zip() holds.

btr_free_externally_stored_field(): Observe dict_table_is_zip().
Allow page_zip==NULL even if dict_table_is_zip().  Remove the
related TODO comment in row_purge_upd_exist_or_extern().

page_zip_available(): uncompressed_size already includes
PAGE_ZIP_DIR_SLOT_SIZE.

page_zip_decompress(): Remove bogus assertion d_stream.next_out == last.
Do not subtract BTR_EXTERN_FIELD_REF_SIZE from d_stream.avail_in when
decompressing records, because the records may be deleted later in
page_zip_apply_log(), and no BLOB pointers are allocated for deleted
records.
parent 36fc4c6d
...@@ -3512,6 +3512,7 @@ btr_store_big_rec_extern_fields( ...@@ -3512,6 +3512,7 @@ btr_store_big_rec_extern_fields(
space_id = buf_frame_get_space_id(rec); space_id = buf_frame_get_space_id(rec);
page_zip = buf_block_get_page_zip(buf_block_align(rec)); page_zip = buf_block_get_page_zip(buf_block_align(rec));
ut_a(!dict_table_is_zip(index->table) == !page_zip);
if (UNIV_LIKELY_NULL(page_zip)) { if (UNIV_LIKELY_NULL(page_zip)) {
int err; int err;
...@@ -3847,7 +3848,9 @@ btr_free_externally_stored_field( ...@@ -3847,7 +3848,9 @@ btr_free_externally_stored_field(
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page, SYNC_EXTERN_STORAGE); buf_page_dbg_add_level(page, SYNC_EXTERN_STORAGE);
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
if (UNIV_LIKELY_NULL(page_zip)) { if (dict_table_is_zip(index->table)) {
/* Note that page_zip will be NULL
in row_purge_upd_exist_or_extern(). */
next_page_no = mach_read_from_4(page); next_page_no = mach_read_from_4(page);
btr_page_free_low(index->tree, page, btr_page_free_low(index->tree, page,
...@@ -3859,8 +3862,10 @@ btr_free_externally_stored_field( ...@@ -3859,8 +3862,10 @@ btr_free_externally_stored_field(
mlog_write_ulint(field_ref + BTR_EXTERN_LEN + 4, mlog_write_ulint(field_ref + BTR_EXTERN_LEN + 4,
0, 0,
MLOG_4BYTES, &mtr); MLOG_4BYTES, &mtr);
page_zip_write_blob_ptr(page_zip, if (page_zip) {
page_zip_write_blob_ptr(page_zip,
rec, index, offsets, i, &mtr); rec, index, offsets, i, &mtr);
}
} else { } else {
ulint extern_len = mach_read_from_4( ulint extern_len = mach_read_from_4(
field_ref + BTR_EXTERN_LEN + 4); field_ref + BTR_EXTERN_LEN + 4);
......
...@@ -253,7 +253,7 @@ page_zip_available( ...@@ -253,7 +253,7 @@ page_zip_available(
Also the BLOB pointers will be allocated from there, but Also the BLOB pointers will be allocated from there, but
we may as well count them in the length of the record. */ we may as well count them in the length of the record. */
trailer_len += PAGE_ZIP_DIR_SLOT_SIZE + uncompressed_size; trailer_len += uncompressed_size;
} }
return(UNIV_LIKELY( return(UNIV_LIKELY(
......
...@@ -1533,11 +1533,10 @@ page_zip_decompress( ...@@ -1533,11 +1533,10 @@ page_zip_decompress(
switch (inflate(&d_stream, Z_SYNC_FLUSH)) { switch (inflate(&d_stream, Z_SYNC_FLUSH)) {
case Z_STREAM_END: case Z_STREAM_END:
/* Apparently, n_dense has grown /* Apparently, n_dense has grown
since the time the page was last compressed. */ since the time the page was last compressed.
if (UNIV_UNLIKELY(d_stream.next_out != last)) { (d_stream.next_out == last) will not hold,
/* Somehow, we got a partial record. */ in case the last record was allocated from
goto zlib_error; an originally longer space on the free list. */
}
goto zlib_done; goto zlib_done;
case Z_OK: case Z_OK:
case Z_BUF_ERROR: case Z_BUF_ERROR:
...@@ -1645,8 +1644,6 @@ page_zip_decompress( ...@@ -1645,8 +1644,6 @@ page_zip_decompress(
BTR_EXTERN_FIELD_REF_SIZE); BTR_EXTERN_FIELD_REF_SIZE);
d_stream.next_out d_stream.next_out
+= BTR_EXTERN_FIELD_REF_SIZE; += BTR_EXTERN_FIELD_REF_SIZE;
d_stream.avail_in
-= BTR_EXTERN_FIELD_REF_SIZE;
} }
} }
......
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