Commit f05b0766 authored by marko's avatar marko

branches/zip: Split the function page_cur_insert_rec_low().

page_cur_insert_rec_zip_reorg(): New function: Recompress or
reorganize a compressed page.

page_cur_insert_rec_zip(): New function: insert a record to
a compressed page.

page_cur_insert_rec_low(): Only handle inserts to uncompressed pages.
parent 10bb4385
......@@ -168,20 +168,35 @@ page_cur_rec_insert(
ulint* offsets,/* in/out: rec_get_offsets(rec, index) */
mtr_t* mtr); /* in: mini-transaction handle, or NULL */
/***************************************************************
Inserts a record next to page cursor. Returns pointer to inserted record if
succeed, i.e., enough space available, NULL otherwise. The record to be
inserted can be in a data tuple or as a physical record. The other parameter
must then be NULL. The cursor stays at the same position. */
Inserts a record next to page cursor on an uncompressed page.
Returns pointer to inserted record if succeed, i.e., enough
space available, NULL otherwise. The cursor stays at the same position. */
rec_t*
page_cur_insert_rec_low(
/*====================*/
/* out: pointer to record if succeed, NULL
otherwise */
rec_t* current_rec,/* in: pointer to current record after
which the new record is inserted */
dict_index_t* index, /* in: record descriptor */
rec_t* rec, /* in: pointer to a physical record */
ulint* offsets,/* in/out: rec_get_offsets(rec, index) */
mtr_t* mtr); /* in: mini-transaction handle, or NULL */
/***************************************************************
Inserts a record next to page cursor on a compressed and uncompressed
page. Returns pointer to inserted record if succeed, i.e.,
enough space available, NULL otherwise.
The cursor stays at the same position. */
rec_t*
page_cur_insert_rec_zip(
/*====================*/
/* out: pointer to record if succeed, NULL
otherwise */
rec_t** current_rec,/* in/out: pointer to current record after
which the new record is inserted */
buf_block_t* block, /* in: buffer block of *current_rec, or NULL
if the compressed page is not to be updated */
buf_block_t* block, /* in: buffer block of *current_rec */
dict_index_t* index, /* in: record descriptor */
rec_t* rec, /* in: pointer to a physical record */
ulint* offsets,/* in/out: rec_get_offsets(rec, index) */
......
......@@ -235,8 +235,14 @@ page_cur_tuple_insert(
index, tuple, ext, n_ext);
offsets = rec_get_offsets(rec, index, NULL, ULINT_UNDEFINED, &heap);
rec = page_cur_insert_rec_low(&cursor->rec, cursor->block,
index, rec, offsets, mtr);
if (buf_block_get_page_zip(cursor->block)) {
rec = page_cur_insert_rec_zip(&cursor->rec, cursor->block,
index, rec, offsets, mtr);
} else {
rec = page_cur_insert_rec_low(cursor->rec,
index, rec, offsets, mtr);
}
mem_heap_free(heap);
return(rec);
}
......@@ -257,7 +263,12 @@ page_cur_rec_insert(
ulint* offsets,/* in/out: rec_get_offsets(rec, index) */
mtr_t* mtr) /* in: mini-transaction handle, or NULL */
{
return(page_cur_insert_rec_low(&cursor->rec, cursor->block,
index, rec, offsets, mtr));
if (buf_block_get_page_zip(cursor->block)) {
return(page_cur_insert_rec_zip(&cursor->rec, cursor->block,
index, rec, offsets, mtr));
} else {
return(page_cur_insert_rec_low(cursor->rec,
index, rec, offsets, mtr));
}
}
......@@ -348,7 +348,7 @@ Write data to the uncompressed header portion of a page. The data must
already have been written to the uncompressed page.
However, the data portion of the uncompressed page may differ from
the compressed page when a record is being inserted in
page_cur_insert_rec_low(). */
page_cur_insert_rec_zip(). */
UNIV_INLINE
void
page_zip_write_header(
......@@ -369,7 +369,7 @@ page_zip_write_header(
memcpy(page_zip->data + pos, str, length);
/* The following would fail in page_cur_insert_rec_low(). */
/* The following would fail in page_cur_insert_rec_zip(). */
/* ut_ad(page_zip_validate(page_zip, str - pos)); */
if (UNIV_LIKELY_NULL(mtr)) {
......
This diff is collapsed.
......@@ -540,7 +540,7 @@ page_copy_rec_list_end_no_locks(
rec_t* ins_rec;
offsets = rec_get_offsets(cur1_rec, index, offsets,
ULINT_UNDEFINED, &heap);
ins_rec = page_cur_insert_rec_low(&cur2, NULL, index,
ins_rec = page_cur_insert_rec_low(cur2, index,
cur1_rec, offsets, mtr);
if (UNIV_UNLIKELY(!ins_rec)) {
/* Track an assertion failure reported on the mailing
......@@ -705,7 +705,7 @@ page_copy_rec_list_start(
rec_t* cur1_rec = page_cur_get_rec(&cur1);
offsets = rec_get_offsets(cur1_rec, index, offsets,
ULINT_UNDEFINED, &heap);
cur2 = page_cur_insert_rec_low(&cur2, NULL, index,
cur2 = page_cur_insert_rec_low(cur2, index,
cur1_rec, offsets, mtr);
ut_a(cur2);
......
......@@ -3247,7 +3247,7 @@ page_zip_dir_insert(
if (UNIV_LIKELY(!free_rec)) {
/* PAGE_N_RECS was already incremented
in page_cur_insert_rec_low(), but the
in page_cur_insert_rec_zip(), but the
dense directory slot at that position
contains garbage. Skip it. */
start += PAGE_ZIP_DIR_SLOT_SIZE;
......@@ -3266,7 +3266,7 @@ page_zip_dir_insert(
/* The record was allocated from the free list.
Shift the dense directory only up to that slot.
Note that in this case, n_dense is actually
off by one, because page_cur_insert_rec_low()
off by one, because page_cur_insert_rec_zip()
did not increment n_heap. */
ut_ad(rec_get_heap_no_new(rec) < n_dense + 1
+ PAGE_HEAP_NO_USER_LOW);
......
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