summaryrefslogtreecommitdiff
path: root/storage/innobase/include/ibuf0ibuf.h
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/include/ibuf0ibuf.h')
-rw-r--r--storage/innobase/include/ibuf0ibuf.h199
1 files changed, 95 insertions, 104 deletions
diff --git a/storage/innobase/include/ibuf0ibuf.h b/storage/innobase/include/ibuf0ibuf.h
index 09c48822b9f..c4d83833fb7 100644
--- a/storage/innobase/include/ibuf0ibuf.h
+++ b/storage/innobase/include/ibuf0ibuf.h
@@ -94,13 +94,11 @@ free bits could momentarily be set too high. */
/******************************************************************//**
Creates the insert buffer data structure at a database startup.
@return DB_SUCCESS or failure */
-UNIV_INTERN
dberr_t
ibuf_init_at_db_start(void);
/*=======================*/
/*********************************************************************//**
Updates the max_size value for ibuf. */
-UNIV_INTERN
void
ibuf_max_size_update(
/*=================*/
@@ -109,7 +107,6 @@ ibuf_max_size_update(
/*********************************************************************//**
Reads the biggest tablespace id from the high end of the insert buffer
tree and updates the counter in fil_system. */
-UNIV_INTERN
void
ibuf_update_max_tablespace_id(void);
/*===============================*/
@@ -131,7 +128,6 @@ ibuf_mtr_commit(
MY_ATTRIBUTE((nonnull));
/*********************************************************************//**
Initializes an ibuf bitmap page. */
-UNIV_INTERN
void
ibuf_bitmap_page_init(
/*==================*/
@@ -146,7 +142,6 @@ buffer bitmap must never exceed the free space on a page. It is safe
to decrement or reset the bits in the bitmap in a mini-transaction
that is committed before the mini-transaction that affects the free
space. */
-UNIV_INTERN
void
ibuf_reset_free_bits(
/*=================*/
@@ -189,7 +184,6 @@ thread until mtr is committed. NOTE: The free bits in the insert
buffer bitmap must never exceed the free space on a page. It is safe
to set the free bits in the same mini-transaction that updated the
page. */
-UNIV_INTERN
void
ibuf_update_free_bits_low(
/*======================*/
@@ -208,7 +202,6 @@ thread until mtr is committed. NOTE: The free bits in the insert
buffer bitmap must never exceed the free space on a page. It is safe
to set the free bits in the same mini-transaction that updated the
page. */
-UNIV_INTERN
void
ibuf_update_free_bits_zip(
/*======================*/
@@ -221,12 +214,9 @@ virtually prevent any further operations until mtr is committed.
NOTE: The free bits in the insert buffer bitmap must never exceed the
free space on a page. It is safe to set the free bits in the same
mini-transaction that updated the pages. */
-UNIV_INTERN
void
ibuf_update_free_bits_for_two_pages_low(
/*====================================*/
- ulint zip_size,/*!< in: compressed page size in bytes;
- 0 for uncompressed pages */
buf_block_t* block1, /*!< in: index page */
buf_block_t* block2, /*!< in: index page */
mtr_t* mtr); /*!< in: mtr */
@@ -255,113 +245,115 @@ ibuf_inside(
/*========*/
const mtr_t* mtr) /*!< in: mini-transaction */
MY_ATTRIBUTE((nonnull, pure));
-/***********************************************************************//**
-Checks if a page address is an ibuf bitmap page (level 3 page) address.
-@return TRUE if a bitmap page */
+
+/** Checks if a page address is an ibuf bitmap page (level 3 page) address.
+@param[in] page_id page id
+@param[in] page_size page size
+@return TRUE if a bitmap page */
UNIV_INLINE
ibool
ibuf_bitmap_page(
-/*=============*/
- ulint zip_size,/*!< in: compressed page size in bytes;
- 0 for uncompressed pages */
- ulint page_no);/*!< in: page number */
-/***********************************************************************//**
-Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages.
-Must not be called when recv_no_ibuf_operations==TRUE.
-@return TRUE if level 2 or level 3 page */
-UNIV_INTERN
+ const page_id_t& page_id,
+ const page_size_t& page_size);
+
+/** Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages.
+Must not be called when recv_no_ibuf_operations==true.
+@param[in] page_id page id
+@param[in] page_size page size
+@param[in] x_latch FALSE if relaxed check (avoid latching the
+bitmap page)
+@param[in] file file name
+@param[in] line line where called
+@param[in,out] mtr mtr which will contain an x-latch to the
+bitmap page if the page is not one of the fixed address ibuf pages, or NULL,
+in which case a new transaction is created.
+@return TRUE if level 2 or level 3 page */
ibool
ibuf_page_low(
-/*==========*/
- ulint space, /*!< in: space id */
- ulint zip_size,/*!< in: compressed page size in bytes, or 0 */
- ulint page_no,/*!< in: page number */
+ const page_id_t& page_id,
+ const page_size_t& page_size,
#ifdef UNIV_DEBUG
- ibool x_latch,/*!< in: FALSE if relaxed check
- (avoid latching the bitmap page) */
+ ibool x_latch,
#endif /* UNIV_DEBUG */
- const char* file, /*!< in: file name */
- ulint line, /*!< in: line where called */
- mtr_t* mtr) /*!< in: mtr which will contain an
- x-latch to the bitmap page if the page
- is not one of the fixed address ibuf
- pages, or NULL, in which case a new
- transaction is created. */
+ const char* file,
+ ulint line,
+ mtr_t* mtr)
MY_ATTRIBUTE((warn_unused_result));
+
#ifdef UNIV_DEBUG
-/** Checks if a page is a level 2 or 3 page in the ibuf hierarchy of
-pages. Must not be called when recv_no_ibuf_operations==TRUE.
-@param space tablespace identifier
-@param zip_size compressed page size in bytes, or 0
-@param page_no page number
-@param mtr mini-transaction or NULL
+
+/** Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages.
+Must not be called when recv_no_ibuf_operations==true.
+@param[in] page_id tablespace/page identifier
+@param[in] page_size page size
+@param[in,out] mtr mini-transaction or NULL
@return TRUE if level 2 or level 3 page */
-# define ibuf_page(space, zip_size, page_no, mtr) \
- ibuf_page_low(space, zip_size, page_no, TRUE, __FILE__, __LINE__, mtr)
+# define ibuf_page(page_id, page_size, mtr) \
+ ibuf_page_low(page_id, page_size, TRUE, __FILE__, __LINE__, mtr)
+
#else /* UVIV_DEBUG */
-/** Checks if a page is a level 2 or 3 page in the ibuf hierarchy of
-pages. Must not be called when recv_no_ibuf_operations==TRUE.
-@param space tablespace identifier
-@param zip_size compressed page size in bytes, or 0
-@param page_no page number
-@param mtr mini-transaction or NULL
+
+/** Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages.
+Must not be called when recv_no_ibuf_operations==true.
+@param[in] page_id tablespace/page identifier
+@param[in] page_size page size
+@param[in,out] mtr mini-transaction or NULL
@return TRUE if level 2 or level 3 page */
-# define ibuf_page(space, zip_size, page_no, mtr) \
- ibuf_page_low(space, zip_size, page_no, __FILE__, __LINE__, mtr)
+# define ibuf_page(page_id, page_size, mtr) \
+ ibuf_page_low(page_id, page_size, __FILE__, __LINE__, mtr)
+
#endif /* UVIV_DEBUG */
/***********************************************************************//**
Frees excess pages from the ibuf free list. This function is called when an OS
thread calls fsp services to allocate a new file segment, or a new page to a
file segment, and the thread did not own the fsp latch before this call. */
-UNIV_INTERN
void
ibuf_free_excess_pages(void);
/*========================*/
-/*********************************************************************//**
-Buffer an operation in the insert/delete buffer, instead of doing it
+
+/** Buffer an operation in the insert/delete buffer, instead of doing it
directly to the disk page, if this is possible. Does not do it if the index
is clustered or unique.
-@return TRUE if success */
-UNIV_INTERN
+@param[in] op operation type
+@param[in] entry index entry to insert
+@param[in,out] index index where to insert
+@param[in] page_id page id where to insert
+@param[in] page_size page size
+@param[in,out] thr query thread
+@return TRUE if success */
ibool
ibuf_insert(
-/*========*/
- ibuf_op_t op, /*!< in: operation type */
- const dtuple_t* entry, /*!< in: index entry to insert */
- dict_index_t* index, /*!< in: index where to insert */
- ulint space, /*!< in: space id where to insert */
- ulint zip_size,/*!< in: compressed page size in bytes, or 0 */
- ulint page_no,/*!< in: page number where to insert */
- que_thr_t* thr); /*!< in: query thread */
-/*********************************************************************//**
-When an index page is read from a disk to the buffer pool, this function
+ ibuf_op_t op,
+ const dtuple_t* entry,
+ dict_index_t* index,
+ const page_id_t& page_id,
+ const page_size_t& page_size,
+ que_thr_t* thr);
+
+/** When an index page is read from a disk to the buffer pool, this function
applies any buffered operations to the page and deletes the entries from the
insert buffer. If the page is not read, but created in the buffer pool, this
function deletes its buffered entries from the insert buffer; there can
exist entries for such a page if the page belonged to an index which
-subsequently was dropped. */
-UNIV_INTERN
+subsequently was dropped.
+@param[in,out] block if page has been read from disk,
+pointer to the page x-latched, else NULL
+@param[in] page_id page id of the index page
+@param[in] update_ibuf_bitmap normally this is set to TRUE, but
+if we have deleted or are deleting the tablespace, then we naturally do not
+want to update a non-existent bitmap page */
void
ibuf_merge_or_delete_for_page(
-/*==========================*/
- buf_block_t* block, /*!< in: if page has been read from
- disk, pointer to the page x-latched,
- else NULL */
- ulint space, /*!< in: space id of the index page */
- ulint page_no,/*!< in: page number of the index page */
- ulint zip_size,/*!< in: compressed page size in bytes,
- or 0 */
- ibool update_ibuf_bitmap);/*!< in: normally this is set
- to TRUE, but if we have deleted or are
- deleting the tablespace, then we
- naturally do not want to update a
- non-existent bitmap page */
+ buf_block_t* block,
+ const page_id_t& page_id,
+ const page_size_t* page_size,
+ ibool update_ibuf_bitmap);
+
/*********************************************************************//**
Deletes all entries in the insert buffer for a given space id. This is used
in DISCARD TABLESPACE and IMPORT TABLESPACE.
NOTE: this does not update the page free bitmaps in the space. The space will
become CORRUPT when you call this function! */
-UNIV_INTERN
void
ibuf_delete_for_discarded_space(
/*============================*/
@@ -370,17 +362,15 @@ ibuf_delete_for_discarded_space(
@param[in] full If true, do a full contraction based
on PCT_IO(100). If false, the size of contract batch is determined
based on the current size of the change buffer.
+@param[in] space_id tablespace for which to contract, or
+ULINT_UNDEFINED to contract for all tablespaces
@return a lower limit for the combined size in bytes of entries which
will be merged from ibuf trees to the pages read, 0 if ibuf is
empty */
-UNIV_INTERN
ulint
ibuf_merge_in_background(
- bool full); /*!< in: TRUE if the caller wants to
- do a full contract based on PCT_IO(100).
- If FALSE then the size of contract
- batch is determined based on the
- current size of the ibuf tree. */
+ bool full,
+ ulint space_id);
/** Contracts insert buffer trees by reading pages referring to space_id
to the buffer pool.
@@ -394,8 +384,7 @@ ibuf_merge_space(
#endif /* !UNIV_HOTBACKUP */
/*********************************************************************//**
Parses a redo log record of an ibuf bitmap page init.
-@return end of log record or NULL */
-UNIV_INTERN
+@return end of log record or NULL */
byte*
ibuf_parse_bitmap_init(
/*===================*/
@@ -405,27 +394,24 @@ ibuf_parse_bitmap_init(
mtr_t* mtr); /*!< in: mtr or NULL */
#ifndef UNIV_HOTBACKUP
#ifdef UNIV_IBUF_COUNT_DEBUG
-/******************************************************************//**
-Gets the ibuf count for a given page.
+
+/** Gets the ibuf count for a given page.
+@param[in] page_id page id
@return number of entries in the insert buffer currently buffered for
this page */
-UNIV_INTERN
ulint
ibuf_count_get(
-/*===========*/
- ulint space, /*!< in: space id */
- ulint page_no);/*!< in: page number */
+ const page_id_t& page_id);
+
#endif
/******************************************************************//**
Looks if the insert buffer is empty.
-@return true if empty */
-UNIV_INTERN
+@return true if empty */
bool
ibuf_is_empty(void);
/*===============*/
/******************************************************************//**
Prints info of ibuf. */
-UNIV_INTERN
void
ibuf_print(
/*=======*/
@@ -433,15 +419,13 @@ ibuf_print(
/********************************************************************
Read the first two bytes from a record's fourth field (counter field in new
records; something else in older records).
-@return "counter" field, or ULINT_UNDEFINED if for some reason it can't be read */
-UNIV_INTERN
+@return "counter" field, or ULINT_UNDEFINED if for some reason it can't be read */
ulint
ibuf_rec_get_counter(
/*=================*/
const rec_t* rec); /*!< in: ibuf record */
/******************************************************************//**
Closes insert buffer and frees the data structures. */
-UNIV_INTERN
void
ibuf_close(void);
/*============*/
@@ -449,7 +433,6 @@ ibuf_close(void);
/******************************************************************//**
Checks the insert buffer bitmaps on IMPORT TABLESPACE.
@return DB_SUCCESS or error code */
-UNIV_INTERN
dberr_t
ibuf_check_bitmap_on_import(
/*========================*/
@@ -457,6 +440,14 @@ ibuf_check_bitmap_on_import(
ulint space_id) /*!< in: tablespace identifier */
MY_ATTRIBUTE((nonnull, warn_unused_result));
+/** Updates free bits and buffered bits for bulk loaded page.
+@param[in] block index page
+@param]in] reset flag if reset free val */
+void
+ibuf_set_bitmap_for_bulk_load(
+ buf_block_t* block,
+ bool reset);
+
#define IBUF_HEADER_PAGE_NO FSP_IBUF_HEADER_PAGE_NO
#define IBUF_TREE_ROOT_PAGE_NO FSP_IBUF_TREE_ROOT_PAGE_NO
@@ -468,7 +459,7 @@ for the file segment from which the pages for the ibuf tree are allocated */
#define IBUF_TREE_SEG_HEADER 0 /* fseg header for ibuf tree */
/* The insert buffer tree itself is always located in space 0. */
-#define IBUF_SPACE_ID 0
+#define IBUF_SPACE_ID static_cast<ulint>(0)
#ifndef UNIV_NONINL
#include "ibuf0ibuf.ic"