Commit f137c038 authored by marko's avatar marko

branches/zip: Improve the clearing of deleted records. Try to support

operations on BLOB columns.  There are some bugs in the code, because
test-insert and a few other tests fail.

page_mem_free(): Add parameter index.  Decrement PAGE_N_RECS here.
Move some operations to page_zip_dir_delete().

page_zip_clear_rec(): Make this a static function.

page_zip_dir_delete(): Add parameters index and offsets.
Decrement PAGE_N_RECS and clear info_bits and n_owned.

page_zip_get_n_prev_extern(): Correct the synopsis and the algorithm.
Add parameter page_zip.  Search the records in heap_no order instead
of collation order.

page_zip_compress(), page_zip_decompress(): Only copy BLOB pointers
and increment n_blobs for records that have not been deleted.

page_zip_clear_rec(): Clear trx_id and roll_ptr on the compressed page.

page_zip_dir_delete(): Decrement PAGE_N_RECS.  Shift the array of
BLOB pointers.  Call page_zip_clear_rec().

page_zip_dir_add_slot(): Shift the array of BLOB pointers to make
space of roll_ptr and trx_id.

page_cur_delete_rec(): Do not decrement PAGE_N_RECS or call
page_zip_clear_rec(), as page_mem_free() already does it.
parent cd7583af
......@@ -604,6 +604,7 @@ page_mem_free(
page_zip_des_t* page_zip,/* in/out: compressed page with at least
6 bytes available, or NULL */
rec_t* rec, /* in: pointer to the (origin of) record */
dict_index_t* index, /* in: index of rec */
const ulint* offsets);/* in: array returned by rec_get_offsets() */
/**************************************************************
The index page creation function. */
......
......@@ -909,33 +909,29 @@ page_mem_free(
page_zip_des_t* page_zip,/* in/out: compressed page with at least
6 bytes available, or NULL */
rec_t* rec, /* in: pointer to the (origin of) record */
dict_index_t* index, /* in: index of rec */
const ulint* offsets)/* in: array returned by rec_get_offsets() */
{
rec_t* free;
ulint garbage;
ut_ad(rec_offs_validate(rec, NULL, offsets));
ut_ad(!rec_offs_comp(offsets) == !page_rec_is_comp(rec));
ut_ad(rec_offs_validate(rec, index, offsets));
free = page_header_get_ptr(page, PAGE_FREE);
page_rec_set_next(rec, free);
page_header_set_ptr(page, page_zip, PAGE_FREE, rec);
if (UNIV_LIKELY_NULL(page_zip)) {
ut_ad(rec_offs_comp(offsets));
/* The compression algorithm expects info_bits and n_owned
to be 0 for deleted records. */
rec[-REC_N_NEW_EXTRA_BYTES] = 0; /* info_bits and n_owned */
/* Update the dense page directory. */
page_zip_dir_delete(page_zip, rec, free);
}
garbage = page_header_get_field(page, PAGE_GARBAGE);
page_header_set_field(page, page_zip, PAGE_GARBAGE,
garbage + rec_offs_size(offsets));
if (UNIV_LIKELY_NULL(page_zip)) {
page_zip_dir_delete(page_zip, rec, index, offsets, free);
} else {
page_header_set_field(page, page_zip, PAGE_N_RECS,
(ulint)(page_get_n_recs(page) - 1));
}
}
#ifdef UNIV_MATERIALIZE
......
......@@ -53,19 +53,6 @@ page_zip_write(
ulint length) /* in: length of the data */
__attribute__((nonnull));
/**************************************************************************
Clear a record on the uncompressed and compressed page, if possible. */
void
page_zip_clear_rec(
/*===============*/
page_zip_des_t* page_zip,/* in/out: compressed page */
byte* rec, /* in: record to clear */
dict_index_t* index, /* in: index of rec */
const ulint* offsets,/* in: rec_get_offsets(rec, index) */
mtr_t* mtr) /* in: mini-transaction */
__attribute__((nonnull));
/**************************************************************************
Write data to the uncompressed header portion of a page. The data must
already have been written to the uncompressed page. */
......@@ -110,9 +97,11 @@ void
page_zip_dir_delete(
/*================*/
page_zip_des_t* page_zip,/* in/out: compressed page */
const byte* rec, /* in: deleted record */
byte* rec, /* in: deleted record */
dict_index_t* index, /* in: index of rec */
const ulint* offsets,/* in: rec_get_offsets(rec) */
const byte* free) /* in: previous start of the free list */
__attribute__((nonnull(1,2)));
__attribute__((nonnull(1,2,3,4)));
/**************************************************************************
Add a slot to the dense page directory. */
......
......@@ -161,19 +161,6 @@ page_zip_write_trx_id_and_roll_ptr(
dulint roll_ptr)/* in: roll_ptr */
__attribute__((nonnull));
/**************************************************************************
Clear a record on the uncompressed and compressed page, if possible. */
void
page_zip_clear_rec(
/*===============*/
page_zip_des_t* page_zip,/* in/out: compressed page */
byte* rec, /* in/out: record to clear */
dict_index_t* index, /* in: index of rec */
const ulint* offsets,/* in: rec_get_offsets(rec, index) */
mtr_t* mtr) /* in: mini-transaction */
__attribute__((nonnull));
/**************************************************************************
Populate the dense page directory on the compressed page
from the sparse directory on the uncompressed row_format=compact page. */
......@@ -216,9 +203,11 @@ void
page_zip_dir_delete(
/*================*/
page_zip_des_t* page_zip,/* in/out: compressed page */
const byte* rec, /* in: deleted record */
byte* rec, /* in: deleted record */
dict_index_t* index, /* in: index of rec */
const ulint* offsets,/* in: rec_get_offsets(rec) */
const byte* free) /* in: previous start of the free list */
__attribute__((nonnull(1,2)));
__attribute__((nonnull(1,2,3,4)));
/**************************************************************************
Add a slot to the dense page directory. */
......
......@@ -1535,18 +1535,7 @@ page_cur_delete_rec(
page_dir_slot_set_n_owned(cur_dir_slot, page_zip, cur_n_owned - 1);
/* 6. Free the memory occupied by the record */
page_mem_free(page, page_zip, current_rec, offsets);
page_header_set_field(page, page_zip, PAGE_N_RECS,
(ulint)(page_get_n_recs(page) - 1));
if (UNIV_LIKELY_NULL(page_zip)) {
/* Clear the data bytes of the deleted record in order
to improve the compression ratio of the page. The fixed extra
bytes of the record, which will be omitted from the
stream compression algorithm, cannot be cleared, because
page_mem_alloc() needs them in order to determine the size
of the deleted record. */
page_zip_clear_rec(page_zip, rec, index, offsets, mtr);
}
page_mem_free(page, page_zip, current_rec, index, offsets);
/* 7. Now we have decremented the number of owned records of the slot.
If the number drops below PAGE_DIR_SLOT_MIN_N_OWNED, we balance the
......
This diff is collapsed.
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