Commit 5a21753b authored by marko's avatar marko

branches/zip: page_zip_empty_size(): New function to compute the

guaranteed free space available for inserting one record.

btr_page_get_sure_split_rec(), btr_cur_pessimistic_insert():
Use page_zip_empty_size().

btr_page_split_and_insert(): Relax a debug assertion that there should
be at least two user records on the page.  On compressed pages, we may
be able to write only one record.
parent ff0acd76
...@@ -1332,14 +1332,12 @@ btr_page_get_sure_split_rec( ...@@ -1332,14 +1332,12 @@ btr_page_get_sure_split_rec(
page_zip = buf_block_get_page_zip(buf_block_align(page)); page_zip = buf_block_get_page_zip(buf_block_align(page));
if (UNIV_LIKELY_NULL(page_zip)) { if (UNIV_LIKELY_NULL(page_zip)) {
/* Estimate the free space of an empty compressed page. /* Estimate the free space of an empty compressed page. */
The space needed for compressing the index information ulint free_space_zip = page_zip_empty_size(
is estimated. */ cursor->index->n_fields, page_zip->size);
ulint free_space_zip = page_zip->size
- PAGE_DATA - cursor->index->n_fields / 2; if (UNIV_LIKELY(free_space > (ulint) free_space_zip)) {
free_space = (ulint) free_space_zip;
if (UNIV_LIKELY(free_space > free_space_zip)) {
free_space = free_space_zip;
ut_a(insert_size <= free_space); ut_a(insert_size <= free_space);
} }
} }
...@@ -1746,7 +1744,7 @@ btr_page_split_and_insert( ...@@ -1746,7 +1744,7 @@ btr_page_split_and_insert(
ut_ad(mtr_memo_contains(mtr, buf_block_align(page), ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
MTR_MEMO_PAGE_X_FIX)); MTR_MEMO_PAGE_X_FIX));
ut_ad(page_get_n_recs(page) >= 2); ut_ad(page_get_n_recs(page) >= 1);
page_no = buf_frame_get_page_no(page); page_no = buf_frame_get_page_no(page);
......
...@@ -1341,11 +1341,9 @@ btr_cur_pessimistic_insert( ...@@ -1341,11 +1341,9 @@ btr_cur_pessimistic_insert(
} }
if (UNIV_UNLIKELY(zip_size)) { if (UNIV_UNLIKELY(zip_size)) {
/* Estimate the free space of an empty compressed page. /* Estimate the free space of an empty compressed page. */
The space needed for compressing the index information ulint free_space_zip = page_zip_empty_size(
is estimated. */ cursor->index->n_fields, zip_size);
ulint free_space_zip = zip_size
- PAGE_DATA - cursor->index->n_fields / 2;
if (UNIV_UNLIKELY(rec_get_converted_size(index, entry) if (UNIV_UNLIKELY(rec_get_converted_size(index, entry)
> free_space_zip)) { > free_space_zip)) {
......
...@@ -32,6 +32,17 @@ page_zip_rec_needs_ext( ...@@ -32,6 +32,17 @@ page_zip_rec_needs_ext(
ulint zip_size) /* in: compressed page size in bytes, or 0 */ ulint zip_size) /* in: compressed page size in bytes, or 0 */
__attribute__((const)); __attribute__((const));
/**************************************************************************
Determine the guaranteed free space on an empty page. */
ulint
page_zip_empty_size(
/*================*/
/* out: minimum payload size on the page */
ulint n_fields, /* in: number of columns in the index */
ulint zip_size) /* in: compressed page size in bytes */
__attribute__((const));
/************************************************************************** /**************************************************************************
Initialize a compressed page descriptor. */ Initialize a compressed page descriptor. */
UNIV_INLINE UNIV_INLINE
......
...@@ -52,6 +52,30 @@ static const byte supremum_extra_data[] = { ...@@ -52,6 +52,30 @@ static const byte supremum_extra_data[] = {
static const byte zero[BTR_EXTERN_FIELD_REF_SIZE] = { 0, }; static const byte zero[BTR_EXTERN_FIELD_REF_SIZE] = { 0, };
#endif #endif
/**************************************************************************
Determine the guaranteed free space on an empty page. */
ulint
page_zip_empty_size(
/*================*/
/* out: minimum payload size on the page */
ulint n_fields, /* in: number of columns in the index */
ulint zip_size) /* in: compressed page size in bytes */
{
lint size = zip_size
/* subtract the page header and the longest
uncompressed data needed for one record */
- (PAGE_DATA
+ PAGE_ZIP_DIR_SLOT_SIZE
+ DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN
+ 1/* encoded heap_no==2 in page_zip_write_rec() */
+ 1/* end of modification log */
- REC_N_NEW_EXTRA_BYTES/* omitted bytes */)
/* subtract the space for page_zip_fields_encode() */
- compressBound(2 * (n_fields + 1));
return(size > 0 ? (ulint) size : 0);
}
/***************************************************************** /*****************************************************************
Gets the size of the compressed page trailer (the dense page directory), Gets the size of the compressed page trailer (the dense page directory),
including deleted records (the free list). */ including deleted records (the free list). */
......
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