summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-09-19 08:35:21 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2019-09-19 08:35:21 +0300
commit8887effe13ad87ba0460d4d3068fb5696f089bb0 (patch)
treeaa004a3d032e94adb89e5bbb5c68c9baef6820ef /storage
parent71e856e152c303d1beaea240a85a00fa0d447de0 (diff)
downloadmariadb-git-8887effe13ad87ba0460d4d3068fb5696f089bb0.tar.gz
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().
Diffstat (limited to 'storage')
-rw-r--r--storage/innobase/include/page0page.h14
-rw-r--r--storage/innobase/page/page0cur.cc21
-rw-r--r--storage/innobase/page/page0page.cc37
3 files changed, 21 insertions, 51 deletions
diff --git a/storage/innobase/include/page0page.h b/storage/innobase/include/page0page.h
index 2e022cddc03..3a077c9f40a 100644
--- a/storage/innobase/include/page0page.h
+++ b/storage/innobase/include/page0page.h
@@ -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
diff --git a/storage/innobase/page/page0cur.cc b/storage/innobase/page/page0cur.cc
index efd9618fad5..1e9b7a5887b 100644
--- a/storage/innobase/page/page0cur.cc
+++ b/storage/innobase/page/page0cur.cc
@@ -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
diff --git a/storage/innobase/page/page0page.cc b/storage/innobase/page/page0page.cc
index 15ce614391c..0a84a625179 100644
--- a/storage/innobase/page/page0page.cc
+++ b/storage/innobase/page/page0page.cc
@@ -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