MySQL 5.6.14 Source Code Document
|
#include "ibuf0ibuf.h"
#include "buf0buf.h"
#include "buf0rea.h"
#include "fsp0fsp.h"
#include "trx0sys.h"
#include "fil0fil.h"
#include "rem0rec.h"
#include "btr0cur.h"
#include "btr0pcur.h"
#include "btr0btr.h"
#include "row0upd.h"
#include "sync0sync.h"
#include "dict0boot.h"
#include "fut0lst.h"
#include "lock0lock.h"
#include "log0recv.h"
#include "que0que.h"
#include "srv0start.h"
#include "ha_prototypes.h"
#include "rem0cmp.h"
Go to the source code of this file.
Macros | |
#define | IBUF_BITS_PER_PAGE 4 |
#define | IBUF_BITMAP PAGE_DATA |
#define | IBUF_TABLE_NAME "SYS_IBUF_TABLE" |
#define | IBUF_REC_FIELD_SPACE 0 |
#define | IBUF_REC_FIELD_MARKER 1 |
#define | IBUF_REC_FIELD_PAGE 2 |
#define | IBUF_REC_FIELD_METADATA 3 /* the metadata field */ |
#define | IBUF_REC_FIELD_USER 4 /* first user field */ |
#define | ibuf_get_volume_buffered_count(mtr, rec, hash, size, n_recs) ibuf_get_volume_buffered_count_func(rec,hash,size,n_recs) |
#define | ibuf_get_entry_counter_low(mtr, rec, space, page_no) ibuf_get_entry_counter_low_func(rec,space,page_no) |
#define | ibuf_get_entry_counter(space, page_no, rec, mtr, exact_leaf) ibuf_get_entry_counter_func(space,page_no,rec,exact_leaf) |
Offsets to the per-page bits in the insert buffer bitmap | |
#define | IBUF_BITMAP_FREE 0 |
#define | IBUF_BITMAP_BUFFERED 2 |
#define | IBUF_BITMAP_IBUF 3 |
Variables | |
UNIV_INTERN ibuf_use_t | ibuf_use = IBUF_USE_ALL |
UNIV_INTERN ibuf_t * | ibuf = NULL |
Format of the IBUF_REC_FIELD_METADATA of an insert buffer record | |
The fourth column in the MySQL 5.5 format contains an operation type, counter, and some flags. | |
#define | IBUF_REC_INFO_SIZE 4 |
#define | IBUF_REC_OFFSET_COUNTER 0 |
#define | IBUF_REC_OFFSET_TYPE 2 |
#define | IBUF_REC_OFFSET_FLAGS 3 |
#define | IBUF_REC_COMPACT 0x1 |
#define | IBUF_MERGE_AREA 8UL |
#define | IBUF_MERGE_THRESHOLD 4 |
#define | IBUF_MAX_N_PAGES_MERGED IBUF_MERGE_AREA |
#define | IBUF_CONTRACT_ON_INSERT_NON_SYNC 0 |
#define | IBUF_CONTRACT_ON_INSERT_SYNC 5 |
#define | IBUF_CONTRACT_DO_NOT_INSERT 10 |
#define | ibuf_bitmap_page_get_bits(page, offset, zs, bit, mtr) ibuf_bitmap_page_get_bits_low(page, offset, zs, bit) |
#define | ibuf_bitmap_get_map_page(space, page_no, zip_size, mtr) |
#define | ibuf_rec_get_page_no(mtr, rec) ibuf_rec_get_page_no_func(rec) |
#define | ibuf_rec_get_space(mtr, rec) ibuf_rec_get_space_func(rec) |
#define | ibuf_rec_get_info(mtr, rec, op, comp, info_len, counter) ibuf_rec_get_info_func(rec,op,comp,info_len,counter) |
#define | ibuf_rec_get_op_type(mtr, rec) ibuf_rec_get_op_type_func(rec) |
#define | ibuf_build_entry_from_ibuf_rec(mtr, ibuf_rec, heap, pindex) ibuf_build_entry_from_ibuf_rec_func(ibuf_rec,heap,pindex) |
#define | ibuf_rec_get_volume(mtr, rec) ibuf_rec_get_volume_func(rec) |
#define | ibuf_get_merge_page_nos(contract, rec, mtr, ids, vers, pages, n_stored) ibuf_get_merge_page_nos_func(contract,rec,ids,vers,pages,n_stored) |
UNIV_INLINE void | ibuf_enter (mtr_t *mtr) |
UNIV_INLINE void | ibuf_exit (mtr_t *mtr) |
UNIV_INLINE void | ibuf_btr_pcur_commit_specify_mtr (btr_pcur_t *pcur, mtr_t *mtr) |
UNIV_INTERN void | ibuf_close (void) |
UNIV_INTERN void | ibuf_init_at_db_start (void) |
UNIV_INTERN void | ibuf_max_size_update (ulint new_val) |
UNIV_INTERN void | ibuf_bitmap_page_init (buf_block_t *block, mtr_t *mtr) |
UNIV_INTERN byte * | ibuf_parse_bitmap_init (byte *ptr, byte *end_ptr __attribute__((unused)), buf_block_t *block, mtr_t *mtr) |
UNIV_INLINE ulint | ibuf_bitmap_page_get_bits_low (const page_t *page, ulint page_no, ulint zip_size, ulint bit) |
UNIV_INLINE ulint | ibuf_bitmap_page_no_calc (ulint zip_size, ulint page_no) |
UNIV_INLINE void | ibuf_set_free_bits_low (ulint zip_size, const buf_block_t *block, ulint val, mtr_t *mtr) |
UNIV_INTERN void | ibuf_set_free_bits_func (buf_block_t *block, ulint val) |
UNIV_INTERN void | ibuf_reset_free_bits (buf_block_t *block) |
UNIV_INTERN void | ibuf_update_free_bits_low (const buf_block_t *block, ulint max_ins_size, mtr_t *mtr) |
UNIV_INTERN void | ibuf_update_free_bits_zip (buf_block_t *block, mtr_t *mtr) |
UNIV_INTERN void | ibuf_update_free_bits_for_two_pages_low (ulint zip_size, buf_block_t *block1, buf_block_t *block2, mtr_t *mtr) |
UNIV_INLINE ibool | ibuf_fixed_addr_page (ulint space, ulint zip_size, ulint page_no) |
UNIV_INTERN ibool | ibuf_page_low (ulint space, ulint zip_size, ulint page_no, const char *file, ulint line, mtr_t *mtr) |
UNIV_INTERN ulint | ibuf_rec_get_counter (const rec_t *rec) |
UNIV_INLINE ulint | ibuf_rec_get_size (const rec_t *rec, const byte *types, ulint n_fields, ulint comp) |
UNIV_INLINE ibool | ibuf_data_enough_free_for_insert (void) |
UNIV_INLINE ibool | ibuf_data_too_much_free (void) |
UNIV_INTERN void | ibuf_free_excess_pages (void) |
#define IBUF_BITMAP PAGE_DATA |
The start address for an insert buffer bitmap page bitmap
Definition at line 38 of file ibuf0ibuf.cc.
#define IBUF_BITMAP_BUFFERED 2 |
TRUE if there are buffered changes for the page
Definition at line 249 of file ibuf0ibuf.cc.
#define IBUF_BITMAP_FREE 0 |
Bits indicating the amount of free space
Definition at line 247 of file ibuf0ibuf.cc.
Gets the ibuf bitmap page where the bits describing a given file page are stored.
space | in: space id of the file page |
page_no | in: page number of the file page |
zip_size | in: compressed page size in bytes; 0 for uncompressed pages |
mtr | in: mini-transaction |
Definition at line 875 of file ibuf0ibuf.cc.
#define IBUF_BITMAP_IBUF 3 |
TRUE if page is a part of the ibuf tree, excluding the root page, or is in the free list of the ibuf
Definition at line 251 of file ibuf0ibuf.cc.
#define ibuf_bitmap_page_get_bits | ( | page, | |
offset, | |||
zs, | |||
bit, | |||
mtr | |||
) | ibuf_bitmap_page_get_bits_low(page, offset, zs, bit) |
Gets the desired bits for a given page from a bitmap page.
page | in: bitmap page |
offset | in: page whose bits to get |
zs | in: compressed page size in bytes; 0 for uncompressed pages |
bit | in: IBUF_BITMAP_FREE, IBUF_BITMAP_BUFFERED, ... |
mtr | in: mini-transaction holding an x-latch on the bitmap page |
Definition at line 692 of file ibuf0ibuf.cc.
#define IBUF_BITS_PER_PAGE 4 |
Number of bits describing a single page
Definition at line 33 of file ibuf0ibuf.cc.
#define IBUF_CONTRACT_DO_NOT_INSERT 10 |
If the combined size of the ibuf trees exceeds ibuf->max_size by
this many pages, we start to contract it synchronous contract, but do not insert
Definition at line 326 of file ibuf0ibuf.cc.
#define IBUF_CONTRACT_ON_INSERT_NON_SYNC 0 |
If the combined size of the ibuf trees exceeds ibuf->max_size by this
many pages, we start to contract it in connection to inserts there, using non-synchronous contract
Definition at line 316 of file ibuf0ibuf.cc.
#define IBUF_CONTRACT_ON_INSERT_SYNC 5 |
If the combined size of the ibuf trees exceeds ibuf->max_size by this
many pages, we start to contract it in connection to inserts there, using synchronous contract
Definition at line 321 of file ibuf0ibuf.cc.
#define IBUF_MAX_N_PAGES_MERGED IBUF_MERGE_AREA |
In ibuf_contract at most this number of pages is read to memory in one
batch, in order to merge the entries for them in the insert buffer
Definition at line 311 of file ibuf0ibuf.cc.
#define IBUF_MERGE_AREA 8UL |
The area in pages from which contract looks for page numbers for merge
Definition at line 302 of file ibuf0ibuf.cc.
#define IBUF_MERGE_THRESHOLD 4 |
Inside the merge area, pages which have at most 1 per this number less
buffered entries compared to maximum volume that can buffered for a single page are merged along with the page whose buffer became full
Definition at line 307 of file ibuf0ibuf.cc.
#define IBUF_REC_COMPACT 0x1 |
Set in IBUF_REC_OFFSET_FLAGS if the user index is in COMPACT format or later
Definition at line 286 of file ibuf0ibuf.cc.
#define IBUF_REC_FIELD_MARKER 1 |
starting with 4.1, a marker consisting of 1 byte that is 0
Definition at line 259 of file ibuf0ibuf.cc.
#define IBUF_REC_FIELD_PAGE 2 |
starting with 4.1, the page number
Definition at line 261 of file ibuf0ibuf.cc.
#define IBUF_REC_FIELD_SPACE 0 |
in the pre-4.1 format, the page number. later, the space_id
Definition at line 257 of file ibuf0ibuf.cc.
#define IBUF_REC_INFO_SIZE 4 |
Combined size of info fields at the beginning of the fourth field
Definition at line 274 of file ibuf0ibuf.cc.
#define IBUF_REC_OFFSET_COUNTER 0 |
Operation counter
Definition at line 281 of file ibuf0ibuf.cc.
#define IBUF_REC_OFFSET_FLAGS 3 |
Additional flags
Definition at line 283 of file ibuf0ibuf.cc.
#define IBUF_REC_OFFSET_TYPE 2 |
Type of operation
Definition at line 282 of file ibuf0ibuf.cc.
#define IBUF_TABLE_NAME "SYS_IBUF_TABLE" |
Table name for the insert buffer.
Definition at line 193 of file ibuf0ibuf.cc.
UNIV_INLINE ulint ibuf_bitmap_page_get_bits_low | ( | const page_t * | page, |
ulint | page_no, | ||
ulint | zip_size, | ||
ulint | bit | ||
) |
Gets the desired bits for a given page from a bitmap page.
page | in: bitmap page |
page_no | in: page whose bits to get |
zip_size | in: compressed page size in bytes; 0 for uncompressed pages |
bit | in: IBUF_BITMAP_FREE, IBUF_BITMAP_BUFFERED, ... |
Definition at line 701 of file ibuf0ibuf.cc.
UNIV_INTERN void ibuf_bitmap_page_init | ( | buf_block_t * | block, |
mtr_t * | mtr | ||
) |
Initializes an ibuf bitmap page.
block | in: bitmap page |
mtr | in: mtr |
Definition at line 620 of file ibuf0ibuf.cc.
UNIV_INLINE ulint ibuf_bitmap_page_no_calc | ( | ulint | zip_size, |
ulint | page_no | ||
) |
Calculates the bitmap page number for a given page number.
zip_size | in: compressed page size in bytes; 0 for uncompressed pages |
page_no | in: tablespace page number |
Definition at line 819 of file ibuf0ibuf.cc.
UNIV_INLINE void ibuf_btr_pcur_commit_specify_mtr | ( | btr_pcur_t * | pcur, |
mtr_t * | mtr | ||
) |
Commits an insert buffer mini-transaction and sets the persistent cursor latch mode to BTR_NO_LATCHES, that is, detaches the cursor.
pcur | in/out: persistent cursor |
mtr | in/out: mini-transaction |
Definition at line 365 of file ibuf0ibuf.cc.
UNIV_INTERN void ibuf_close | ( | void | ) |
Closes insert buffer and frees the data structures.
Definition at line 463 of file ibuf0ibuf.cc.
UNIV_INLINE ibool ibuf_data_enough_free_for_insert | ( | void | ) |
Checks if there are enough pages in the free list of the ibuf tree that we dare to start a pessimistic insert to the insert buffer.
Definition at line 2021 of file ibuf0ibuf.cc.
UNIV_INLINE ibool ibuf_data_too_much_free | ( | void | ) |
Checks if there are enough pages in the free list of the ibuf tree that we should remove them and free to the file space management.
Definition at line 2041 of file ibuf0ibuf.cc.
UNIV_INLINE void ibuf_enter | ( | mtr_t * | mtr | ) |
Sets the flag in the current mini-transaction record indicating we're inside an insert buffer routine.
mtr | in/out: mini-transaction |
Definition at line 339 of file ibuf0ibuf.cc.
UNIV_INLINE void ibuf_exit | ( | mtr_t * | mtr | ) |
Sets the flag in the current mini-transaction record indicating we're exiting an insert buffer routine.
mtr | in/out: mini-transaction |
Definition at line 352 of file ibuf0ibuf.cc.
UNIV_INLINE ibool ibuf_fixed_addr_page | ( | ulint | space, |
ulint | zip_size, | ||
ulint | page_no | ||
) |
Returns TRUE if the page is one of the fixed address ibuf pages.
space | in: space id |
zip_size | in: compressed page size in bytes; 0 for uncompressed pages |
page_no | in: page number |
Definition at line 1136 of file ibuf0ibuf.cc.
UNIV_INTERN void ibuf_free_excess_pages | ( | void | ) |
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.
Definition at line 2255 of file ibuf0ibuf.cc.
UNIV_INTERN void ibuf_init_at_db_start | ( | void | ) |
Creates the insert buffer data structure at a database startup and initializes the data structures for the insert buffer.
Definition at line 506 of file ibuf0ibuf.cc.
UNIV_INTERN void ibuf_max_size_update | ( | ulint | new_val | ) |
Updates the max_size value for ibuf.
new_val | in: new value in terms of percentage of the buffer pool size |
Definition at line 602 of file ibuf0ibuf.cc.
UNIV_INTERN ibool ibuf_page_low | ( | ulint | space, |
ulint | zip_size, | ||
ulint | page_no, | ||
const char * | file, | ||
ulint | line, | ||
mtr_t * | mtr | ||
) |
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.
space | in: space id |
zip_size | in: compressed page size in bytes, or 0 |
page_no | in: page number |
file | in: file name |
line | in: line where called |
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. |
Definition at line 1153 of file ibuf0ibuf.cc.
UNIV_INTERN byte* ibuf_parse_bitmap_init | ( | byte * | ptr, |
byte *end_ptr | __attribute__(unused), | ||
buf_block_t * | block, | ||
mtr_t * | mtr | ||
) |
Parses a redo log record of an ibuf bitmap page init.
ptr | in: buffer |
__attribute__ | in: buffer end |
block | in: block or NULL |
mtr | in: mtr or NULL |
Definition at line 657 of file ibuf0ibuf.cc.
UNIV_INTERN ulint ibuf_rec_get_counter | ( | const rec_t * | rec | ) |
Read the first two bytes from a record's fourth field (counter field in new records; something else in older records).
rec | in: ibuf record |
Definition at line 1444 of file ibuf0ibuf.cc.
UNIV_INLINE ulint ibuf_rec_get_size | ( | const rec_t * | rec, |
const byte * | types, | ||
ulint | n_fields, | ||
ulint | comp | ||
) |
Get the data size.
rec | in: ibuf record |
types | in: fields |
n_fields | in: number of fields |
comp | in: 0=ROW_FORMAT=REDUNDANT, nonzero=ROW_FORMAT=COMPACT |
Definition at line 1682 of file ibuf0ibuf.cc.
UNIV_INTERN void ibuf_reset_free_bits | ( | buf_block_t * | block | ) |
Resets the free bits of the page in the ibuf bitmap. This is done in a separate mini-transaction, hence this operation does not restrict further work to only ibuf bitmap operations, which would result if the latch to the bitmap page were kept. NOTE: The free bits in the insert 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.
block | in: index page; free bits are set to 0 if the index is a non-clustered non-unique, and page level is 0 |
Definition at line 1003 of file ibuf0ibuf.cc.
UNIV_INTERN void ibuf_set_free_bits_func | ( | buf_block_t * | block, |
ulint | val | ||
) |
Sets the free bit of the page in the ibuf bitmap. This is done in a separate mini-transaction, hence this operation does not restrict further work to only ibuf bitmap operations, which would result if the latch to the bitmap page were kept.
block | in: index page of a non-clustered index; free bit is reset if page level is 0 |
val | in: value to set: < 4 |
Definition at line 929 of file ibuf0ibuf.cc.
UNIV_INLINE void ibuf_set_free_bits_low | ( | ulint | zip_size, |
const buf_block_t * | block, | ||
ulint | val, | ||
mtr_t * | mtr | ||
) |
Sets the free bits of the page in the ibuf bitmap. This is done in a separate mini-transaction, hence this operation does not restrict further work to only ibuf bitmap operations, which would result if the latch to the bitmap page were kept.
zip_size | in: compressed page size in bytes; 0 for uncompressed pages |
block | in: index page; free bits are set if the index is non-clustered and page level is 0 |
val | in: value to set: < 4 |
mtr | in/out: mtr |
Definition at line 886 of file ibuf0ibuf.cc.
UNIV_INTERN void ibuf_update_free_bits_for_two_pages_low | ( | ulint | zip_size, |
buf_block_t * | block1, | ||
buf_block_t * | block2, | ||
mtr_t * | mtr | ||
) |
Updates the free bits for the two pages to reflect the present state. Does this in the mtr given, which means that the latching order rules 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.
zip_size | in: compressed page size in bytes; 0 for uncompressed pages |
block1 | in: index page |
block2 | in: index page |
mtr | in: mtr |
Definition at line 1104 of file ibuf0ibuf.cc.
UNIV_INTERN void ibuf_update_free_bits_low | ( | const buf_block_t * | block, |
ulint | max_ins_size, | ||
mtr_t * | mtr | ||
) |
Updates the free bits for an uncompressed page to reflect the present state. Does this in the mtr given, which means that the latching order rules virtually prevent any further operations for this OS 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.
block | in: index page |
max_ins_size | in: value of maximum insert size with reorganize before the latest operation performed to the page |
mtr | in/out: mtr |
Definition at line 1022 of file ibuf0ibuf.cc.
UNIV_INTERN void ibuf_update_free_bits_zip | ( | buf_block_t * | block, |
mtr_t * | mtr | ||
) |
Updates the free bits for a compressed page to reflect the present state. Does this in the mtr given, which means that the latching order rules virtually prevent any further operations for this OS 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.
block | in/out: index page |
mtr | in/out: mtr |
Definition at line 1060 of file ibuf0ibuf.cc.
UNIV_INTERN ibuf_t* ibuf = NULL |
The insert buffer control structure
Definition at line 204 of file ibuf0ibuf.cc.
UNIV_INTERN ibuf_use_t ibuf_use = IBUF_USE_ALL |
Operations that can currently be buffered.
Definition at line 196 of file ibuf0ibuf.cc.