Commit f2204447 authored by marko's avatar marko

branches/zip: Minor fixes

Restore page_zip_clear_rec() to the global scope.
Invoke it in page_delete_rec_list_end().

Add debug assertions to page0zip.c to guard against overwriting data
on the compressed page.
parent f137c038
......@@ -162,6 +162,18 @@ page_zip_write_trx_id_and_roll_ptr(
__attribute__((nonnull));
/**************************************************************************
Clear an area 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(1,2,3,4)));
/**************************************************************************
Populate the dense page directory on the compressed page
from the sparse directory on the uncompressed row_format=compact page. */
void
......
......@@ -855,15 +855,8 @@ page_delete_rec_list_end(
ULINT_UNDEFINED, &heap);
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
extra bytes of the record cannot be
cleared, because page_mem_alloc()
needs them in order to determine the
size of the deleted record. */
memset(rec2, 0, rec_offs_data_size(offsets));
page_zip_clear_rec(page_zip,
rec2, index, offsets, NULL);
}
s = rec_offs_size(offsets);
......
......@@ -44,6 +44,11 @@ static const byte supremum_extra_data[] = {
0x65, 0x6d, 0x75, 0x6d /* "supremum" */
};
#ifdef UNIV_DEBUG
/* Array of zeros, used for debug assertions */
static const byte zero[BTR_EXTERN_FIELD_REF_SIZE] = { 0, };
#endif
/*****************************************************************
Gets the size of the compressed page trailer (the dense page directory),
including deleted records (the free list). */
......@@ -1892,8 +1897,10 @@ page_zip_write_rec(
if (UNIV_UNLIKELY(heap_no - 1 >= 64)) {
*data++ = 0x80 | (heap_no - 1) >> 7;
ut_ad(!*data);
}
*data++ = (heap_no - 1) << 1;
ut_ad(!*data);
{
const byte* start = rec_get_start((rec_t*) rec, offsets);
......@@ -1906,6 +1913,7 @@ page_zip_write_rec(
while (b != start) {
*data++ = *--b;
ut_ad(!*data);
}
}
......@@ -1964,6 +1972,10 @@ page_zip_write_rec(
if (create) {
page_zip->n_blobs += n_ext;
ut_ad(!memcmp(ext_end - n_ext
* BTR_EXTERN_FIELD_REF_SIZE,
zero,
BTR_EXTERN_FIELD_REF_SIZE));
memmove(ext_end - n_ext
* BTR_EXTERN_FIELD_REF_SIZE,
ext_end,
......@@ -1992,12 +2004,18 @@ page_zip_write_rec(
ut_ad(len == DATA_ROLL_PTR_LEN);
/* Log the preceding fields. */
ut_ad(!memcmp(data, zero,
ut_min(src - start, sizeof zero)));
memcpy(data, start, src - start);
data += src - start;
start = src + (DATA_TRX_ID_LEN
+ DATA_ROLL_PTR_LEN);
/* Store trx_id and roll_ptr separately. */
ut_ad(!memcmp(storage
- (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN)
* (heap_no - 1), zero,
DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN));
memcpy(storage
- (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN)
* (heap_no - 1),
......@@ -2011,6 +2029,8 @@ page_zip_write_rec(
ut_ad(len > BTR_EXTERN_FIELD_REF_SIZE);
src += len - BTR_EXTERN_FIELD_REF_SIZE;
ut_ad(!memcmp(data, zero,
ut_min(src - start, sizeof zero)));
memcpy(data, start, src - start);
data += src - start;
start = src + BTR_EXTERN_FIELD_REF_SIZE;
......@@ -2018,6 +2038,8 @@ page_zip_write_rec(
/* Store the BLOB pointer separately. */
externs -= BTR_EXTERN_FIELD_REF_SIZE;
ut_ad(data < externs);
ut_ad(!memcmp(externs, zero,
BTR_EXTERN_FIELD_REF_SIZE));
memcpy(externs, src,
BTR_EXTERN_FIELD_REF_SIZE);
}
......@@ -2026,6 +2048,7 @@ page_zip_write_rec(
/* Log the last bytes of the record. */
len = rec_get_end((rec_t*) rec, offsets) - start;
ut_ad(!memcmp(data, zero, ut_min(len, sizeof zero)));
memcpy(data, start, len);
data += len;
} else {
......@@ -2040,10 +2063,15 @@ page_zip_write_rec(
len = rec_offs_data_size(offsets) - REC_NODE_PTR_SIZE;
ut_ad(data + len < storage - REC_NODE_PTR_SIZE
* (page_dir_get_n_heap(page) - 2));
ut_ad(!memcmp(data, zero, ut_min(len, sizeof zero)));
memcpy(data, rec, len);
data += len;
/* Copy the node pointer to the uncompressed area. */
ut_ad(!memcmp(storage - REC_NODE_PTR_SIZE
* (heap_no - 1),
zero,
REC_NODE_PTR_SIZE));
memcpy(storage - REC_NODE_PTR_SIZE
* (heap_no - 1),
rec + len,
......@@ -2235,7 +2263,7 @@ page_zip_write_trx_id_and_roll_ptr(
/**************************************************************************
Clear an area on the uncompressed and compressed page, if possible. */
static
void
page_zip_clear_rec(
/*===============*/
......@@ -2283,6 +2311,7 @@ page_zip_clear_rec(
ut_ad(!*data);
if (UNIV_UNLIKELY(heap_no - 1 >= 64)) {
*data++ = 0x80 | (heap_no - 1) >> 7;
ut_ad(!*data);
}
*data++ = (heap_no - 1) << 1 | 1;
ut_ad(!*data);
......@@ -2497,12 +2526,18 @@ page_zip_dir_add_slot(
* (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN);
externs = stored
- page_zip->n_blobs * BTR_EXTERN_FIELD_REF_SIZE;
ut_ad(!memcmp(zero, externs - (PAGE_ZIP_DIR_SLOT_SIZE
+ DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN),
PAGE_ZIP_DIR_SLOT_SIZE
+ DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN));
memmove(externs - (PAGE_ZIP_DIR_SLOT_SIZE
+ DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN),
externs, stored - externs);
} else {
stored = dir
- page_zip->n_blobs * BTR_EXTERN_FIELD_REF_SIZE;
ut_ad(!memcmp(zero, stored - PAGE_ZIP_DIR_SLOT_SIZE,
PAGE_ZIP_DIR_SLOT_SIZE));
}
/* Move the uncompressed area backwards to make space
......
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