2009-02-17 09:10:18 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
|
|
|
|
Copyright (c) 1997, 2009, Innobase Oy. All Rights Reserved.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU General Public License as published by the Free Software
|
|
|
|
Foundation; version 2 of the License.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
|
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
|
|
Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/**************************************************//**
|
|
|
|
@file include/ibuf0ibuf.h
|
2005-10-27 07:29:40 +00:00
|
|
|
Insert buffer
|
|
|
|
|
|
|
|
Created 7/19/1997 Heikki Tuuri
|
|
|
|
*******************************************************/
|
|
|
|
|
|
|
|
#ifndef ibuf0ibuf_h
|
|
|
|
#define ibuf0ibuf_h
|
|
|
|
|
|
|
|
#include "univ.i"
|
|
|
|
|
|
|
|
#include "mtr0mtr.h"
|
2009-03-23 14:21:34 +00:00
|
|
|
#include "dict0mem.h"
|
2005-10-27 07:29:40 +00:00
|
|
|
#include "fsp0fsp.h"
|
|
|
|
|
2009-03-23 14:21:34 +00:00
|
|
|
#ifndef UNIV_HOTBACKUP
|
|
|
|
# include "ibuf0types.h"
|
|
|
|
|
2009-01-30 10:58:56 +00:00
|
|
|
/** Combinations of operations that can be buffered. Because the enum
|
|
|
|
values are used for indexing innobase_change_buffering_values[], they
|
|
|
|
should start at 0 and there should not be any gaps. */
|
2009-01-29 09:27:09 +00:00
|
|
|
typedef enum {
|
|
|
|
IBUF_USE_NONE = 0,
|
2009-01-30 10:58:56 +00:00
|
|
|
IBUF_USE_INSERT, /* insert */
|
|
|
|
|
|
|
|
IBUF_USE_COUNT /* number of entries in ibuf_use_t */
|
2009-01-29 09:27:09 +00:00
|
|
|
} ibuf_use_t;
|
|
|
|
|
|
|
|
/** Operations that can currently be buffered. */
|
|
|
|
extern ibuf_use_t ibuf_use;
|
|
|
|
|
|
|
|
/** The insert buffer control structure */
|
|
|
|
extern ibuf_t* ibuf;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2008-09-04 07:47:49 +00:00
|
|
|
/* The purpose of the insert buffer is to reduce random disk access.
|
|
|
|
When we wish to insert a record into a non-unique secondary index and
|
|
|
|
the B-tree leaf page where the record belongs to is not in the buffer
|
|
|
|
pool, we insert the record into the insert buffer B-tree, indexed by
|
|
|
|
(space_id, page_no). When the page is eventually read into the buffer
|
|
|
|
pool, we look up the insert buffer B-tree for any modifications to the
|
|
|
|
page, and apply these upon the completion of the read operation. This
|
|
|
|
is called the insert buffer merge. */
|
|
|
|
|
|
|
|
/* The insert buffer merge must always succeed. To guarantee this,
|
|
|
|
the insert buffer subsystem keeps track of the free space in pages for
|
|
|
|
which it can buffer operations. Two bits per page in the insert
|
|
|
|
buffer bitmap indicate the available space in coarse increments. 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. It is unsafe to increment the bits in a
|
|
|
|
separately committed mini-transaction, because in crash recovery, the
|
|
|
|
free bits could momentarily be set too high. */
|
|
|
|
|
2009-05-25 09:52:29 +00:00
|
|
|
/******************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Creates the insert buffer data structure at a database startup and
|
|
|
|
initializes the data structures for the insert buffer of each tablespace. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
ibuf_init_at_db_start(void);
|
|
|
|
/*=======================*/
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Reads the biggest tablespace id from the high end of the insert buffer
|
|
|
|
tree and updates the counter in fil_system. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
ibuf_update_max_tablespace_id(void);
|
|
|
|
/*===============================*/
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Initializes an ibuf bitmap page. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
ibuf_bitmap_page_init(
|
|
|
|
/*==================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_block_t* block, /*!< in: bitmap page */
|
|
|
|
mtr_t* mtr); /*!< in: mtr */
|
2009-05-25 09:52:29 +00:00
|
|
|
/************************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Resets the free bits of the page in the ibuf bitmap. This is done in a
|
2008-09-04 07:47:49 +00:00
|
|
|
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. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
2007-05-06 12:39:46 +00:00
|
|
|
ibuf_reset_free_bits(
|
|
|
|
/*=================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_block_t* block); /*!< in: index page; free bits are set to 0
|
2006-10-13 07:45:52 +00:00
|
|
|
if the index is a non-clustered
|
|
|
|
non-unique, and page level is 0 */
|
2009-05-25 09:52:29 +00:00
|
|
|
/************************************************************************//**
|
2007-10-12 13:25:12 +00:00
|
|
|
Updates the free bits of an uncompressed page in the ibuf bitmap if
|
2008-09-04 07:47:49 +00:00
|
|
|
there is not enough free on the page any more. This is done in a
|
2007-10-12 13:25:12 +00:00
|
|
|
separate mini-transaction, hence this operation does not restrict
|
|
|
|
further work to only ibuf bitmap operations, which would result if the
|
2008-09-04 07:47:49 +00:00
|
|
|
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
|
|
|
|
unsafe to increment the bits in a separately committed
|
|
|
|
mini-transaction, because in crash recovery, the free bits could
|
|
|
|
momentarily be set too high. It is only safe to use this function for
|
|
|
|
decrementing the free bits. Should more free space become available,
|
|
|
|
we must not update the free bits here, because that would break crash
|
|
|
|
recovery. */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
ibuf_update_free_bits_if_full(
|
|
|
|
/*==========================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_block_t* block, /*!< in: index page to which we have added new
|
2005-10-27 07:29:40 +00:00
|
|
|
records; the free bits are updated if the
|
|
|
|
index is non-clustered and non-unique and
|
|
|
|
the page level is 0, and the page becomes
|
|
|
|
fuller */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint max_ins_size,/*!< in: value of maximum insert size with
|
2005-10-27 07:29:40 +00:00
|
|
|
reorganize before the latest operation
|
|
|
|
performed to the page */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint increase);/*!< in: upper limit for the additional space
|
2005-10-27 07:29:40 +00:00
|
|
|
used in the latest operation, if known, or
|
|
|
|
ULINT_UNDEFINED */
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2008-09-04 07:47:49 +00:00
|
|
|
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. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
ibuf_update_free_bits_low(
|
|
|
|
/*======================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
const buf_block_t* block, /*!< in: index page */
|
|
|
|
ulint max_ins_size, /*!< in: value of
|
2007-10-12 13:25:12 +00:00
|
|
|
maximum insert size
|
|
|
|
with reorganize before
|
|
|
|
the latest operation
|
|
|
|
performed to the page */
|
2009-05-25 05:30:14 +00:00
|
|
|
mtr_t* mtr); /*!< in/out: mtr */
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2008-09-04 07:47:49 +00:00
|
|
|
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. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2007-10-12 13:25:12 +00:00
|
|
|
void
|
|
|
|
ibuf_update_free_bits_zip(
|
|
|
|
/*======================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_block_t* block, /*!< in/out: index page */
|
|
|
|
mtr_t* mtr); /*!< in/out: mtr */
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2008-09-04 07:47:49 +00:00
|
|
|
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. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
ibuf_update_free_bits_for_two_pages_low(
|
|
|
|
/*====================================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes;
|
branches/zip: Enable the insert buffer on compressed tablespaces.
page_zip_max_ins_size(): New function.
btr_cur_optimistic_insert(), btr_cur_optimistic_delete(),
btr_page_split_and_insert(), btr_compress(): Do not update the
ibuf free bits for non-leaf pages or pages belonging to a clustered index.
The insert buffer only covers operations on leaf pages of secondary indexes.
For pages covered by the insert buffer, limit the max_ins_size to
page_zip_max_ins_size().
buf_page_get_gen(): Merge the insert buffer after decompressing the page.
buf_page_io_complete(): Relax the assertion about ibuf_count. For
compressed-only pages, the insert buffer merge takes place
in buf_page_get_gen().
ibuf_index_page_calc_free_bits(), ibuf_index_page_calc_free_from_bits(),
ibuf_index_page_calc_free(), ibuf_update_free_bits_if_full(),
ibuf_update_free_bits_low(), ibuf_update_free_bits_for_two_pages_low(),
ibuf_set_free_bits_low(): Add the parameter zip_size. Limit the maximum
insert size to page_zip_max_ins_size().
2007-02-19 20:32:06 +00:00
|
|
|
0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_block_t* block1, /*!< in: index page */
|
|
|
|
buf_block_t* block2, /*!< in: index page */
|
|
|
|
mtr_t* mtr); /*!< in: mtr */
|
2009-05-25 09:52:29 +00:00
|
|
|
/**********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
A basic partial test if an insert to the insert buffer could be possible and
|
|
|
|
recommended. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
|
|
|
ibuf_should_try(
|
|
|
|
/*============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
dict_index_t* index, /*!< in: index where to insert */
|
|
|
|
ulint ignore_sec_unique); /*!< in: if != 0, we should
|
2005-10-27 07:29:40 +00:00
|
|
|
ignore UNIQUE constraint on
|
|
|
|
a secondary index when we
|
|
|
|
decide */
|
2009-05-25 09:52:29 +00:00
|
|
|
/******************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Returns TRUE if the current OS thread is performing an insert buffer
|
2009-05-25 05:30:14 +00:00
|
|
|
routine.
|
2009-05-25 08:09:45 +00:00
|
|
|
|
|
|
|
For instance, a read-ahead of non-ibuf pages is forbidden by threads
|
|
|
|
that are executing an insert buffer routine.
|
|
|
|
@return TRUE if inside an insert buffer routine */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
ibuf_inside(void);
|
|
|
|
/*=============*/
|
2009-05-25 09:52:29 +00:00
|
|
|
/***********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Checks if a page address is an ibuf bitmap page (level 3 page) address.
|
|
|
|
@return TRUE if a bitmap page */
|
2005-10-27 07:29:40 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
|
|
|
ibuf_bitmap_page(
|
|
|
|
/*=============*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes;
|
2006-06-05 09:04:19 +00:00
|
|
|
0 for uncompressed pages */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint page_no);/*!< in: page number */
|
2009-05-25 09:52:29 +00:00
|
|
|
/***********************************************************************//**
|
branches/zip: Clean up the insert buffer subsystem.
Originally, there were provisions in InnoDB for multiple insert buffer
B-trees, apparently one for each tablespace.
When Heikki implemented innodb_file_per_table (multiple InnoDB
tablespaces) in MySQL 4.1, he made the insert buffer live only in the
system tablespace (space 0) but left the provisions in the code.
When Osku Salerma implemented delete buffering, he also cleaned up the
insert buffer subsystem so that only one insert buffer B-tree exists.
This patch applies the clean-up to the InnoDB Plugin.
Having a separate patch of the insert buffer clean-up should help us
better compare the essential changes of the InnoDB Plugin and InnoDB+
and to track down bugs that are specific to InnoDB+.
IBUF_SPACE_ID: New constant, defined as 0.
ibuf_data_t: Remove.
ibuf_t: Add the applicable fields from ibuf_data_t. There is only one
insert buffer tree from now on.
ibuf_page_low(), ibuf_page(): Merge to a single function ibuf_page().
fil_space_t: Remove ibuf_data.
fil_space_get_ibuf_data(): Remove. There is only one ibuf_data, for
space IBUF_SPACE_ID.
fil_ibuf_init_at_db_start(): Remove.
ibuf_init_at_db_start(): Fuse with ibuf_data_init_for_space().
ibuf_validate_low(): Remove. There is only one ibuf tree.
ibuf_free_excess_pages(), ibuf_header_page_get(),
ibuf_free_excess_pages(): Remove the parameter space, which was always
0.
ibuf_tree_root_get(): Remove the parameters space and data. There is
only one ibuf tree, for space IBUF_SPACE_ID.
ibuf_data_sizes_update(): Rename to ibuf_size_update(), and remove the
parameter data. There is only one ibuf data struct.
ibuf_build_entry_pre_4_1_x(): New function, refactored from
ibuf_build_entry_from_ibuf_rec().
ibuf_data_enough_free_for_insert(), ibuf_data_too_much_free(): Remove
the parameter data. There is only one insert buffer tree.
ibuf_add_free_page(), ibuf_remove_free_page(): Remove the parameters
space and data. There is only one insert buffer tree.
ibuf_get_merge_page_nos(): Add parenthesis, to reduce diffs to
branches/innodb+.
ibuf_contract_ext(): Do not pick an insert buffer tree at random.
There is only one.
ibuf_print(): Print the single insert buffer tree.
rb://19 approved by Heikki on IM
2008-12-12 14:08:23 +00:00
|
|
|
Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages.
|
2009-05-25 05:30:14 +00:00
|
|
|
Must not be called when recv_no_ibuf_operations==TRUE.
|
|
|
|
@return TRUE if level 2 or level 3 page */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
ibuf_page(
|
|
|
|
/*======*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint zip_size,/*!< in: compressed page size in bytes, or 0 */
|
|
|
|
ulint page_no,/*!< in: page number */
|
|
|
|
mtr_t* mtr); /*!< in: mtr which will contain an x-latch to the
|
2005-10-27 07:29:40 +00:00
|
|
|
bitmap page if the page is not one of the fixed
|
branches/zip: Clean up the insert buffer subsystem.
Originally, there were provisions in InnoDB for multiple insert buffer
B-trees, apparently one for each tablespace.
When Heikki implemented innodb_file_per_table (multiple InnoDB
tablespaces) in MySQL 4.1, he made the insert buffer live only in the
system tablespace (space 0) but left the provisions in the code.
When Osku Salerma implemented delete buffering, he also cleaned up the
insert buffer subsystem so that only one insert buffer B-tree exists.
This patch applies the clean-up to the InnoDB Plugin.
Having a separate patch of the insert buffer clean-up should help us
better compare the essential changes of the InnoDB Plugin and InnoDB+
and to track down bugs that are specific to InnoDB+.
IBUF_SPACE_ID: New constant, defined as 0.
ibuf_data_t: Remove.
ibuf_t: Add the applicable fields from ibuf_data_t. There is only one
insert buffer tree from now on.
ibuf_page_low(), ibuf_page(): Merge to a single function ibuf_page().
fil_space_t: Remove ibuf_data.
fil_space_get_ibuf_data(): Remove. There is only one ibuf_data, for
space IBUF_SPACE_ID.
fil_ibuf_init_at_db_start(): Remove.
ibuf_init_at_db_start(): Fuse with ibuf_data_init_for_space().
ibuf_validate_low(): Remove. There is only one ibuf tree.
ibuf_free_excess_pages(), ibuf_header_page_get(),
ibuf_free_excess_pages(): Remove the parameter space, which was always
0.
ibuf_tree_root_get(): Remove the parameters space and data. There is
only one ibuf tree, for space IBUF_SPACE_ID.
ibuf_data_sizes_update(): Rename to ibuf_size_update(), and remove the
parameter data. There is only one ibuf data struct.
ibuf_build_entry_pre_4_1_x(): New function, refactored from
ibuf_build_entry_from_ibuf_rec().
ibuf_data_enough_free_for_insert(), ibuf_data_too_much_free(): Remove
the parameter data. There is only one insert buffer tree.
ibuf_add_free_page(), ibuf_remove_free_page(): Remove the parameters
space and data. There is only one insert buffer tree.
ibuf_get_merge_page_nos(): Add parenthesis, to reduce diffs to
branches/innodb+.
ibuf_contract_ext(): Do not pick an insert buffer tree at random.
There is only one.
ibuf_print(): Print the single insert buffer tree.
rb://19 approved by Heikki on IM
2008-12-12 14:08:23 +00:00
|
|
|
address ibuf pages, or NULL, in which case a new
|
|
|
|
transaction is created. */
|
2009-05-25 09:52:29 +00:00
|
|
|
/***********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
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
|
2006-02-23 19:25:29 +00:00
|
|
|
file segment, and the thread did not own the fsp latch before this call. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
branches/zip: Clean up the insert buffer subsystem.
Originally, there were provisions in InnoDB for multiple insert buffer
B-trees, apparently one for each tablespace.
When Heikki implemented innodb_file_per_table (multiple InnoDB
tablespaces) in MySQL 4.1, he made the insert buffer live only in the
system tablespace (space 0) but left the provisions in the code.
When Osku Salerma implemented delete buffering, he also cleaned up the
insert buffer subsystem so that only one insert buffer B-tree exists.
This patch applies the clean-up to the InnoDB Plugin.
Having a separate patch of the insert buffer clean-up should help us
better compare the essential changes of the InnoDB Plugin and InnoDB+
and to track down bugs that are specific to InnoDB+.
IBUF_SPACE_ID: New constant, defined as 0.
ibuf_data_t: Remove.
ibuf_t: Add the applicable fields from ibuf_data_t. There is only one
insert buffer tree from now on.
ibuf_page_low(), ibuf_page(): Merge to a single function ibuf_page().
fil_space_t: Remove ibuf_data.
fil_space_get_ibuf_data(): Remove. There is only one ibuf_data, for
space IBUF_SPACE_ID.
fil_ibuf_init_at_db_start(): Remove.
ibuf_init_at_db_start(): Fuse with ibuf_data_init_for_space().
ibuf_validate_low(): Remove. There is only one ibuf tree.
ibuf_free_excess_pages(), ibuf_header_page_get(),
ibuf_free_excess_pages(): Remove the parameter space, which was always
0.
ibuf_tree_root_get(): Remove the parameters space and data. There is
only one ibuf tree, for space IBUF_SPACE_ID.
ibuf_data_sizes_update(): Rename to ibuf_size_update(), and remove the
parameter data. There is only one ibuf data struct.
ibuf_build_entry_pre_4_1_x(): New function, refactored from
ibuf_build_entry_from_ibuf_rec().
ibuf_data_enough_free_for_insert(), ibuf_data_too_much_free(): Remove
the parameter data. There is only one insert buffer tree.
ibuf_add_free_page(), ibuf_remove_free_page(): Remove the parameters
space and data. There is only one insert buffer tree.
ibuf_get_merge_page_nos(): Add parenthesis, to reduce diffs to
branches/innodb+.
ibuf_contract_ext(): Do not pick an insert buffer tree at random.
There is only one.
ibuf_print(): Print the single insert buffer tree.
rb://19 approved by Heikki on IM
2008-12-12 14:08:23 +00:00
|
|
|
ibuf_free_excess_pages(void);
|
|
|
|
/*========================*/
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Makes an index insert to the insert buffer, instead of directly to the disk
|
|
|
|
page, if this is possible. Does not do insert if the index is clustered
|
2009-05-25 05:30:14 +00:00
|
|
|
or unique.
|
|
|
|
@return TRUE if success */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
ibuf_insert(
|
|
|
|
/*========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
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 */
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
When an index page is read from a disk to the buffer pool, this function
|
|
|
|
inserts to the page the possible index entries buffered in the insert buffer.
|
|
|
|
The entries are deleted 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. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
ibuf_merge_or_delete_for_page(
|
|
|
|
/*==========================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
buf_block_t* block, /*!< in: if page has been read from
|
2006-10-19 08:27:34 +00:00
|
|
|
disk, pointer to the page x-latched,
|
|
|
|
else NULL */
|
2009-05-25 05:30:14 +00:00
|
|
|
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,
|
2006-10-19 08:27:34 +00:00
|
|
|
or 0 */
|
2009-05-25 05:30:14 +00:00
|
|
|
ibool update_ibuf_bitmap);/*!< in: normally this is set
|
2006-10-19 08:27:34 +00:00
|
|
|
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 */
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
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! */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
ibuf_delete_for_discarded_space(
|
|
|
|
/*============================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space); /*!< in: space id */
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Contracts insert buffer trees by reading pages to the buffer pool.
|
2009-05-25 08:09:45 +00:00
|
|
|
@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 */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
|
|
|
ibuf_contract(
|
|
|
|
/*==========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ibool sync); /*!< in: TRUE if the caller wants to wait for the
|
2005-10-27 07:29:40 +00:00
|
|
|
issued read with the highest tablespace address
|
|
|
|
to complete */
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Contracts insert buffer trees by reading pages to the buffer pool.
|
2009-05-25 08:09:45 +00:00
|
|
|
@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 */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
|
|
|
ibuf_contract_for_n_pages(
|
|
|
|
/*======================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ibool sync, /*!< in: TRUE if the caller wants to wait for the
|
2005-10-27 07:29:40 +00:00
|
|
|
issued read with the highest tablespace address
|
|
|
|
to complete */
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint n_pages);/*!< in: try to read at least this many pages to
|
2005-10-27 07:29:40 +00:00
|
|
|
the buffer pool and merge the ibuf contents to
|
|
|
|
them */
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
2009-05-25 09:52:29 +00:00
|
|
|
/*********************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Parses a redo log record of an ibuf bitmap page init.
|
|
|
|
@return end of log record or NULL */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
byte*
|
|
|
|
ibuf_parse_bitmap_init(
|
|
|
|
/*===================*/
|
2009-05-25 05:30:14 +00:00
|
|
|
byte* ptr, /*!< in: buffer */
|
|
|
|
byte* end_ptr,/*!< in: buffer end */
|
|
|
|
buf_block_t* block, /*!< in: block or NULL */
|
|
|
|
mtr_t* mtr); /*!< in: mtr or NULL */
|
2009-03-23 14:21:34 +00:00
|
|
|
#ifndef UNIV_HOTBACKUP
|
2007-02-27 11:56:38 +00:00
|
|
|
#ifdef UNIV_IBUF_COUNT_DEBUG
|
2009-05-25 09:52:29 +00:00
|
|
|
/******************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Gets the ibuf count for a given page.
|
2009-05-25 08:09:45 +00:00
|
|
|
@return number of entries in the insert buffer currently buffered for
|
|
|
|
this page */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
|
|
|
ibuf_count_get(
|
|
|
|
/*===========*/
|
2009-05-25 05:30:14 +00:00
|
|
|
ulint space, /*!< in: space id */
|
|
|
|
ulint page_no);/*!< in: page number */
|
2006-05-08 06:18:59 +00:00
|
|
|
#endif
|
2009-05-25 09:52:29 +00:00
|
|
|
/******************************************************************//**
|
2009-05-25 05:30:14 +00:00
|
|
|
Looks if the insert buffer is empty.
|
|
|
|
@return TRUE if empty */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
ibuf_is_empty(void);
|
|
|
|
/*===============*/
|
2009-05-25 09:52:29 +00:00
|
|
|
/******************************************************************//**
|
2005-10-27 07:29:40 +00:00
|
|
|
Prints info of ibuf. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
ibuf_print(
|
|
|
|
/*=======*/
|
2009-05-25 05:30:14 +00:00
|
|
|
FILE* file); /*!< in: file where to print */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
#define IBUF_HEADER_PAGE_NO FSP_IBUF_HEADER_PAGE_NO
|
|
|
|
#define IBUF_TREE_ROOT_PAGE_NO FSP_IBUF_TREE_ROOT_PAGE_NO
|
|
|
|
|
2009-03-23 14:21:34 +00:00
|
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* The ibuf header page currently contains only the file segment header
|
|
|
|
for the file segment from which the pages for the ibuf tree are allocated */
|
|
|
|
#define IBUF_HEADER PAGE_DATA
|
|
|
|
#define IBUF_TREE_SEG_HEADER 0 /* fseg header for ibuf tree */
|
|
|
|
|
branches/zip: Clean up the insert buffer subsystem.
Originally, there were provisions in InnoDB for multiple insert buffer
B-trees, apparently one for each tablespace.
When Heikki implemented innodb_file_per_table (multiple InnoDB
tablespaces) in MySQL 4.1, he made the insert buffer live only in the
system tablespace (space 0) but left the provisions in the code.
When Osku Salerma implemented delete buffering, he also cleaned up the
insert buffer subsystem so that only one insert buffer B-tree exists.
This patch applies the clean-up to the InnoDB Plugin.
Having a separate patch of the insert buffer clean-up should help us
better compare the essential changes of the InnoDB Plugin and InnoDB+
and to track down bugs that are specific to InnoDB+.
IBUF_SPACE_ID: New constant, defined as 0.
ibuf_data_t: Remove.
ibuf_t: Add the applicable fields from ibuf_data_t. There is only one
insert buffer tree from now on.
ibuf_page_low(), ibuf_page(): Merge to a single function ibuf_page().
fil_space_t: Remove ibuf_data.
fil_space_get_ibuf_data(): Remove. There is only one ibuf_data, for
space IBUF_SPACE_ID.
fil_ibuf_init_at_db_start(): Remove.
ibuf_init_at_db_start(): Fuse with ibuf_data_init_for_space().
ibuf_validate_low(): Remove. There is only one ibuf tree.
ibuf_free_excess_pages(), ibuf_header_page_get(),
ibuf_free_excess_pages(): Remove the parameter space, which was always
0.
ibuf_tree_root_get(): Remove the parameters space and data. There is
only one ibuf tree, for space IBUF_SPACE_ID.
ibuf_data_sizes_update(): Rename to ibuf_size_update(), and remove the
parameter data. There is only one ibuf data struct.
ibuf_build_entry_pre_4_1_x(): New function, refactored from
ibuf_build_entry_from_ibuf_rec().
ibuf_data_enough_free_for_insert(), ibuf_data_too_much_free(): Remove
the parameter data. There is only one insert buffer tree.
ibuf_add_free_page(), ibuf_remove_free_page(): Remove the parameters
space and data. There is only one insert buffer tree.
ibuf_get_merge_page_nos(): Add parenthesis, to reduce diffs to
branches/innodb+.
ibuf_contract_ext(): Do not pick an insert buffer tree at random.
There is only one.
ibuf_print(): Print the single insert buffer tree.
rb://19 approved by Heikki on IM
2008-12-12 14:08:23 +00:00
|
|
|
/* The insert buffer tree itself is always located in space 0. */
|
|
|
|
#define IBUF_SPACE_ID 0
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
#ifndef UNIV_NONINL
|
|
|
|
#include "ibuf0ibuf.ic"
|
|
|
|
#endif
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
#endif
|