Commit 8887effe authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-12353 preparation: page_mem_alloc_heap()

Define the function in the same compilation unit as its only callers
page_cur_insert_rec_low() and page_cur_insert_rec_zip().
parent 71e856e1
......@@ -943,20 +943,6 @@ page_mem_alloc_free(
rec_t* next_rec,/*!< in: pointer to the new head of the
free record list */
ulint need); /*!< in: number of bytes allocated */
/************************************************************//**
Allocates a block of memory from the heap of an index page.
@return pointer to start of allocated buffer, or NULL if allocation fails */
byte*
page_mem_alloc_heap(
/*================*/
page_t* page, /*!< in/out: index page */
page_zip_des_t* page_zip,/*!< in/out: compressed page with enough
space available for inserting the record,
or NULL */
ulint need, /*!< in: total number of bytes needed */
ulint* heap_no);/*!< out: this contains the heap number
of the allocated record
if allocation succeeds */
/** Read the PAGE_DIRECTION field from a byte.
@param[in] ptr pointer to PAGE_DIRECTION_B
......
......@@ -1355,6 +1355,27 @@ static void page_dir_balance_slot(page_t* page, page_zip_des_t* page_zip,
page_dir_slot_set_n_owned(up_slot, page_zip, up_n_owned - 1);
}
/** Allocate space for inserting an index record.
@param[in,out] page index page
@param[in,out] page_zip ROW_FORMAT=COMPRESSED page, or NULL
@param[in] need number of bytes needed
@param[out] heap_no record heap number
@return pointer to the start of the allocated buffer
@retval NULL if allocation fails */
static byte* page_mem_alloc_heap(page_t* page, page_zip_des_t* page_zip,
ulint need, ulint* heap_no)
{
if (need > page_get_max_insert_size(page, 1)) {
return NULL;
}
byte* top = page_header_get_ptr(page, PAGE_HEAP_TOP);
page_header_set_ptr(page, page_zip, PAGE_HEAP_TOP, top + need);
*heap_no = page_dir_get_n_heap(page);
page_dir_set_n_heap(page, page_zip, 1 + *heap_no);
return top;
}
/***********************************************************//**
Inserts a record next to page cursor on an uncompressed page.
Returns pointer to inserted record if succeed, i.e., enough
......
......@@ -250,43 +250,6 @@ page_set_autoinc(
}
}
/************************************************************//**
Allocates a block of memory from the heap of an index page.
@return pointer to start of allocated buffer, or NULL if allocation fails */
byte*
page_mem_alloc_heap(
/*================*/
page_t* page, /*!< in/out: index page */
page_zip_des_t* page_zip,/*!< in/out: compressed page with enough
space available for inserting the record,
or NULL */
ulint need, /*!< in: total number of bytes needed */
ulint* heap_no)/*!< out: this contains the heap number
of the allocated record
if allocation succeeds */
{
byte* block;
ulint avl_space;
ut_ad(page && heap_no);
avl_space = page_get_max_insert_size(page, 1);
if (avl_space >= need) {
block = page_header_get_ptr(page, PAGE_HEAP_TOP);
page_header_set_ptr(page, page_zip, PAGE_HEAP_TOP,
block + need);
*heap_no = page_dir_get_n_heap(page);
page_dir_set_n_heap(page, page_zip, 1 + *heap_no);
return(block);
}
return(NULL);
}
/**********************************************************//**
Writes a log record of page creation. */
UNIV_INLINE
......
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