Commit 62db6d6b authored by marko's avatar marko

branches/zip: Update the insert buffer free bits when recompressing

a page during update-in-place.

page_zip_alloc(): Rename to btr_cur_update_alloc_zip().
Invoke ibuf_update_free_bits_if_full().
parent 0f792cb2
...@@ -1627,6 +1627,48 @@ func_exit: ...@@ -1627,6 +1627,48 @@ func_exit:
return(ptr); return(ptr);
} }
/*****************************************************************
See if there is enough place in the page modification log to log
an update-in-place. */
static
ibool
btr_cur_update_alloc_zip(
/*=====================*/
/* out: TRUE if enough place */
page_zip_des_t* page_zip,/* in/out: compressed page */
buf_block_t* block, /* in/out: buffer page */
dict_index_t* index, /* in: the index corresponding to the block */
ulint length, /* in: size needed */
mtr_t* mtr) /* in: mini-transaction */
{
ut_a(page_zip == buf_block_get_page_zip(block));
ut_ad(page_zip);
if (page_zip_available(page_zip, dict_index_is_clust(index),
length, 0)) {
return(TRUE);
}
if (!page_zip->m_nonempty) {
/* The page has been freshly compressed, so
recompressing it will not help. */
return(FALSE);
}
if (!page_zip_compress(page_zip, buf_block_get_frame(block),
index, mtr)) {
/* Unable to compress the page */
return(FALSE);
}
/* Update the free bits in the insert buffer. */
ibuf_update_free_bits_if_full(index, buf_block_get_zip_size(block),
block, UNIV_PAGE_SIZE, ULINT_UNDEFINED);
return(page_zip_available(page_zip, dict_index_is_clust(index),
length, 0));
}
/***************************************************************** /*****************************************************************
Updates a record when the update causes no size changes in its fields. Updates a record when the update causes no size changes in its fields.
We assume here that the ordering fields of the record do not change. */ We assume here that the ordering fields of the record do not change. */
...@@ -1671,14 +1713,12 @@ btr_cur_update_in_place( ...@@ -1671,14 +1713,12 @@ btr_cur_update_in_place(
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
block = btr_cur_get_block(cursor); block = btr_cur_get_block(cursor);
page_zip = buf_block_get_page_zip(block);
/* Check that enough space is available on the compressed page. */ /* Check that enough space is available on the compressed page. */
page_zip = buf_block_get_page_zip(block);
if (UNIV_LIKELY_NULL(page_zip) if (UNIV_LIKELY_NULL(page_zip)
&& UNIV_UNLIKELY(!page_zip_alloc(page_zip, && !btr_cur_update_alloc_zip(page_zip, block, index,
buf_block_get_frame(block), rec_offs_size(offsets), mtr)) {
index, rec_offs_size(offsets),
0, mtr))) {
return(DB_ZIP_OVERFLOW); return(DB_ZIP_OVERFLOW);
} }
...@@ -1848,7 +1888,8 @@ btr_cur_optimistic_update( ...@@ -1848,7 +1888,8 @@ btr_cur_optimistic_update(
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
if (UNIV_LIKELY_NULL(page_zip) if (UNIV_LIKELY_NULL(page_zip)
&& !page_zip_alloc(page_zip, page, index, new_rec_size, 0, mtr)) { && !btr_cur_update_alloc_zip(page_zip, block, index,
new_rec_size, mtr)) {
mem_heap_free(heap); mem_heap_free(heap);
return(DB_ZIP_OVERFLOW); return(DB_ZIP_OVERFLOW);
......
...@@ -160,24 +160,6 @@ page_zip_available( ...@@ -160,24 +160,6 @@ page_zip_available(
the heap */ the heap */
__attribute__((warn_unused_result, nonnull, pure)); __attribute__((warn_unused_result, nonnull, pure));
/**************************************************************************
Ensure that enough space is available in the modification log.
If not, try to compress the page. */
UNIV_INLINE
ibool
page_zip_alloc(
/*===========*/
/* out: TRUE if enough space is available */
page_zip_des_t* page_zip,/* in/out: compressed page;
will only be modified if compression is needed
and successful */
const page_t* page, /* in: uncompressed page */
dict_index_t* index, /* in: index of the B-tree node */
ulint length, /* in: combined size of the record */
ulint create, /* in: nonzero=add the record to the heap */
mtr_t* mtr) /* in: mini-transaction, or NULL */
__attribute__((warn_unused_result, nonnull(1,2,3)));
/************************************************************************** /**************************************************************************
Write data to the uncompressed header portion of a page. The data must Write data to the uncompressed header portion of a page. The data must
already have been written to the uncompressed page. */ already have been written to the uncompressed page. */
......
...@@ -323,49 +323,6 @@ page_zip_des_init( ...@@ -323,49 +323,6 @@ page_zip_des_init(
memset(page_zip, 0, sizeof *page_zip); memset(page_zip, 0, sizeof *page_zip);
} }
/**************************************************************************
Ensure that enough space is available in the modification log.
If not, try to compress the page. */
UNIV_INLINE
ibool
page_zip_alloc(
/*===========*/
/* out: TRUE if enough space is available */
page_zip_des_t* page_zip,/* in/out: compressed page;
will only be modified if compression is needed
and successful */
const page_t* page, /* in: uncompressed page */
dict_index_t* index, /* in: index of the B-tree node */
ulint length, /* in: combined size of the record */
ulint create, /* in: nonzero=add the record to the heap */
mtr_t* mtr) /* in: mini-transaction, or NULL */
{
ut_ad(page_is_comp(page));
#ifdef UNIV_ZIP_DEBUG
ut_a(page_zip_validate(page_zip, page));
#endif /* UNIV_ZIP_DEBUG */
if (page_zip_available(page_zip, dict_index_is_clust(index),
length, create)) {
return(TRUE);
}
if (!page_zip->m_nonempty) {
/* The page has been freshly compressed, so
recompressing it will not help. */
return(FALSE);
}
if (!page_zip_compress(page_zip, page, index, mtr)) {
/* Unable to compress the page */
return(FALSE);
}
/* Check if there is enough space available after compression. */
return(page_zip_available(page_zip, dict_index_is_clust(index),
length, create));
}
/************************************************************************** /**************************************************************************
Write a log record of writing to the uncompressed header portion of a page. */ Write a log record of writing to the uncompressed header portion of a page. */
......
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