2005-10-27 07:29:40 +00:00
|
|
|
/******************************************************
|
|
|
|
Insert buffer
|
|
|
|
|
|
|
|
(c) 1997 Innobase Oy
|
|
|
|
|
|
|
|
Created 7/19/1997 Heikki Tuuri
|
|
|
|
*******************************************************/
|
|
|
|
|
|
|
|
#include "ibuf0ibuf.h"
|
|
|
|
|
|
|
|
#ifdef UNIV_NONINL
|
|
|
|
#include "ibuf0ibuf.ic"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "buf0buf.h"
|
|
|
|
#include "buf0rea.h"
|
|
|
|
#include "fsp0fsp.h"
|
|
|
|
#include "trx0sys.h"
|
|
|
|
#include "fil0fil.h"
|
|
|
|
#include "thr0loc.h"
|
|
|
|
#include "rem0rec.h"
|
|
|
|
#include "btr0cur.h"
|
|
|
|
#include "btr0pcur.h"
|
|
|
|
#include "btr0btr.h"
|
|
|
|
#include "sync0sync.h"
|
|
|
|
#include "dict0boot.h"
|
|
|
|
#include "fut0lst.h"
|
|
|
|
#include "lock0lock.h"
|
|
|
|
#include "log0recv.h"
|
|
|
|
#include "que0que.h"
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
/* STRUCTURE OF AN INSERT BUFFER RECORD
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
In versions < 4.1.x:
|
|
|
|
|
|
|
|
1. The first field is the page number.
|
|
|
|
2. The second field is an array which stores type info for each subsequent
|
|
|
|
field. We store the information which affects the ordering of records, and
|
|
|
|
also the physical storage size of an SQL NULL value. E.g., for CHAR(10) it
|
|
|
|
is 10 bytes.
|
|
|
|
3. Next we have the fields of the actual index record.
|
|
|
|
|
|
|
|
In versions >= 4.1.x:
|
|
|
|
|
|
|
|
Note that contary to what we planned in the 1990's, there will only be one
|
|
|
|
insert buffer tree, and that is in the system tablespace of InnoDB.
|
|
|
|
|
|
|
|
1. The first field is the space id.
|
|
|
|
2. The second field is a one-byte marker (0) which differentiates records from
|
|
|
|
the < 4.1.x storage format.
|
|
|
|
3. The third field is the page number.
|
|
|
|
4. The fourth field contains the type info, where we have also added 2 bytes to
|
|
|
|
store the charset. In the compressed table format of 5.0.x we must add more
|
|
|
|
information here so that we can build a dummy 'index' struct which 5.0.x
|
|
|
|
can use in the binary search on the index page in the ibuf merge phase.
|
|
|
|
5. The rest of the fields contain the fields of the actual index record.
|
|
|
|
|
|
|
|
In versions >= 5.0.3:
|
|
|
|
|
|
|
|
The first byte of the fourth field is an additional marker (0) if the record
|
|
|
|
is in the compact format. The presence of this marker can be detected by
|
|
|
|
looking at the length of the field modulo DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE.
|
|
|
|
|
|
|
|
The high-order bit of the character set field in the type info is the
|
|
|
|
"nullable" flag for the field. */
|
|
|
|
|
|
|
|
|
|
|
|
/* PREVENTING DEADLOCKS IN THE INSERT BUFFER SYSTEM
|
|
|
|
|
|
|
|
If an OS thread performs any operation that brings in disk pages from
|
|
|
|
non-system tablespaces into the buffer pool, or creates such a page there,
|
|
|
|
then the operation may have as a side effect an insert buffer index tree
|
|
|
|
compression. Thus, the tree latch of the insert buffer tree may be acquired
|
|
|
|
in the x-mode, and also the file space latch of the system tablespace may
|
|
|
|
be acquired in the x-mode.
|
|
|
|
|
|
|
|
Also, an insert to an index in a non-system tablespace can have the same
|
|
|
|
effect. How do we know this cannot lead to a deadlock of OS threads? There
|
|
|
|
is a problem with the i\o-handler threads: they break the latching order
|
|
|
|
because they own x-latches to pages which are on a lower level than the
|
|
|
|
insert buffer tree latch, its page latches, and the tablespace latch an
|
|
|
|
insert buffer operation can reserve.
|
|
|
|
|
|
|
|
The solution is the following: Let all the tree and page latches connected
|
|
|
|
with the insert buffer be later in the latching order than the fsp latch and
|
|
|
|
fsp page latches.
|
|
|
|
|
|
|
|
Insert buffer pages must be such that the insert buffer is never invoked
|
|
|
|
when these pages are accessed as this would result in a recursion violating
|
|
|
|
the latching order. We let a special i/o-handler thread take care of i/o to
|
|
|
|
the insert buffer pages and the ibuf bitmap pages, as well as the fsp bitmap
|
|
|
|
pages and the first inode page, which contains the inode of the ibuf tree: let
|
|
|
|
us call all these ibuf pages. To prevent deadlocks, we do not let a read-ahead
|
|
|
|
access both non-ibuf and ibuf pages.
|
|
|
|
|
|
|
|
Then an i/o-handler for the insert buffer never needs to access recursively the
|
|
|
|
insert buffer tree and thus obeys the latching order. On the other hand, other
|
|
|
|
i/o-handlers for other tablespaces may require access to the insert buffer,
|
|
|
|
but because all kinds of latches they need to access there are later in the
|
|
|
|
latching order, no violation of the latching order occurs in this case,
|
|
|
|
either.
|
|
|
|
|
|
|
|
A problem is how to grow and contract an insert buffer tree. As it is later
|
|
|
|
in the latching order than the fsp management, we have to reserve the fsp
|
|
|
|
latch first, before adding or removing pages from the insert buffer tree.
|
|
|
|
We let the insert buffer tree have its own file space management: a free
|
|
|
|
list of pages linked to the tree root. To prevent recursive using of the
|
|
|
|
insert buffer when adding pages to the tree, we must first load these pages
|
|
|
|
to memory, obtaining a latch on them, and only after that add them to the
|
|
|
|
free list of the insert buffer tree. More difficult is removing of pages
|
|
|
|
from the free list. If there is an excess of pages in the free list of the
|
|
|
|
ibuf tree, they might be needed if some thread reserves the fsp latch,
|
|
|
|
intending to allocate more file space. So we do the following: if a thread
|
|
|
|
reserves the fsp latch, we check the writer count field of the latch. If
|
|
|
|
this field has value 1, it means that the thread did not own the latch
|
|
|
|
before entering the fsp system, and the mtr of the thread contains no
|
|
|
|
modifications to the fsp pages. Now we are free to reserve the ibuf latch,
|
|
|
|
and check if there is an excess of pages in the free list. We can then, in a
|
|
|
|
separate mini-transaction, take them out of the free list and free them to
|
|
|
|
the fsp system.
|
|
|
|
|
|
|
|
To avoid deadlocks in the ibuf system, we divide file pages into three levels:
|
|
|
|
|
|
|
|
(1) non-ibuf pages,
|
|
|
|
(2) ibuf tree pages and the pages in the ibuf tree free list, and
|
|
|
|
(3) ibuf bitmap pages.
|
|
|
|
|
|
|
|
No OS thread is allowed to access higher level pages if it has latches to
|
|
|
|
lower level pages; even if the thread owns a B-tree latch it must not access
|
|
|
|
the B-tree non-leaf pages if it has latches on lower level pages. Read-ahead
|
|
|
|
is only allowed for level 1 and 2 pages. Dedicated i/o-handler threads handle
|
|
|
|
exclusively level 1 i/o. A dedicated i/o handler thread handles exclusively
|
|
|
|
level 2 i/o. However, if an OS thread does the i/o handling for itself, i.e.,
|
|
|
|
it uses synchronous aio, it can access any pages, as long as it obeys the
|
|
|
|
access order rules. */
|
|
|
|
|
|
|
|
/* Buffer pool size per the maximum insert buffer size */
|
|
|
|
#define IBUF_POOL_SIZE_PER_MAX_SIZE 2
|
|
|
|
|
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
|
|
|
/* Table name for the insert buffer. */
|
|
|
|
#define IBUF_TABLE_NAME "SYS_IBUF_TABLE"
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* The insert buffer control structure */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN ibuf_t* ibuf = NULL;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN ulint ibuf_flush_count = 0;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-02-27 11:56:38 +00:00
|
|
|
#ifdef UNIV_IBUF_COUNT_DEBUG
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Dimensions for the ibuf_count array */
|
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
|
|
|
#define IBUF_COUNT_N_SPACES 4
|
|
|
|
#define IBUF_COUNT_N_PAGES 130000
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Buffered entry counts for file pages, used in debugging */
|
2007-05-14 09:07:15 +00:00
|
|
|
static ulint ibuf_counts[IBUF_COUNT_N_SPACES][IBUF_COUNT_N_PAGES];
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-05-14 09:07:15 +00:00
|
|
|
/**********************************************************************
|
|
|
|
Checks that the indexes to ibuf_counts[][] are within limits. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
ibuf_count_check(
|
|
|
|
/*=============*/
|
|
|
|
ulint space_id, /* in: space identifier */
|
|
|
|
ulint page_no) /* in: page number */
|
|
|
|
{
|
|
|
|
if (space_id < IBUF_COUNT_N_SPACES && page_no < IBUF_COUNT_N_PAGES) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(stderr,
|
2007-10-12 08:38:49 +00:00
|
|
|
"InnoDB: UNIV_IBUF_COUNT_DEBUG limits space_id and page_no\n"
|
2007-05-14 09:07:15 +00:00
|
|
|
"InnoDB: and breaks crash recovery.\n"
|
|
|
|
"InnoDB: space_id=%lu, should be 0<=space_id<%lu\n"
|
|
|
|
"InnoDB: page_no=%lu, should be 0<=page_no<%lu\n",
|
|
|
|
(ulint) space_id, (ulint) IBUF_COUNT_N_SPACES,
|
|
|
|
(ulint) page_no, (ulint) IBUF_COUNT_N_PAGES);
|
|
|
|
ut_error;
|
|
|
|
}
|
2006-05-08 06:18:59 +00:00
|
|
|
#endif
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* The start address for an insert buffer bitmap page bitmap */
|
|
|
|
#define IBUF_BITMAP PAGE_DATA
|
|
|
|
|
|
|
|
/* Offsets in bits for the bits describing a single page in the bitmap */
|
|
|
|
#define IBUF_BITMAP_FREE 0
|
|
|
|
#define IBUF_BITMAP_BUFFERED 2
|
|
|
|
#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 */
|
|
|
|
|
|
|
|
/* Number of bits describing a single page */
|
|
|
|
#define IBUF_BITS_PER_PAGE 4
|
|
|
|
#if IBUF_BITS_PER_PAGE % 2
|
|
|
|
# error "IBUF_BITS_PER_PAGE must be an even number!"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* The mutex used to block pessimistic inserts to ibuf trees */
|
|
|
|
static mutex_t ibuf_pessimistic_insert_mutex;
|
|
|
|
|
|
|
|
/* The mutex protecting the insert buffer structs */
|
|
|
|
static mutex_t ibuf_mutex;
|
|
|
|
|
|
|
|
/* The mutex protecting the insert buffer bitmaps */
|
|
|
|
static mutex_t ibuf_bitmap_mutex;
|
|
|
|
|
|
|
|
/* The area in pages from which contract looks for page numbers for merge */
|
|
|
|
#define IBUF_MERGE_AREA 8
|
|
|
|
|
|
|
|
/* 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 */
|
|
|
|
#define IBUF_MERGE_THRESHOLD 4
|
|
|
|
|
|
|
|
/* 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 */
|
|
|
|
#define IBUF_MAX_N_PAGES_MERGED IBUF_MERGE_AREA
|
|
|
|
|
|
|
|
/* 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 */
|
|
|
|
#define IBUF_CONTRACT_ON_INSERT_NON_SYNC 0
|
|
|
|
|
|
|
|
/* Same as above, but use synchronous contract */
|
|
|
|
#define IBUF_CONTRACT_ON_INSERT_SYNC 5
|
|
|
|
|
|
|
|
/* Same as above, but no insert is done, only contract is called */
|
|
|
|
#define IBUF_CONTRACT_DO_NOT_INSERT 10
|
|
|
|
|
|
|
|
/* TODO: how to cope with drop table if there are records in the insert
|
|
|
|
buffer for the indexes of the table? Is there actually any problem,
|
|
|
|
because ibuf merge is done to a page when it is read in, and it is
|
|
|
|
still physically like the index page even if the index would have been
|
|
|
|
dropped! So, there seems to be no problem. */
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
Sets the flag in the current OS thread local storage denoting that it is
|
|
|
|
inside an insert buffer routine. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
ibuf_enter(void)
|
|
|
|
/*============*/
|
|
|
|
{
|
|
|
|
ibool* ptr;
|
|
|
|
|
|
|
|
ptr = thr_local_get_in_ibuf_field();
|
|
|
|
|
|
|
|
ut_ad(*ptr == FALSE);
|
|
|
|
|
|
|
|
*ptr = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
Sets the flag in the current OS thread local storage denoting that it is
|
|
|
|
exiting an insert buffer routine. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
ibuf_exit(void)
|
|
|
|
/*===========*/
|
|
|
|
{
|
|
|
|
ibool* ptr;
|
|
|
|
|
|
|
|
ptr = thr_local_get_in_ibuf_field();
|
|
|
|
|
|
|
|
ut_ad(*ptr == TRUE);
|
|
|
|
|
|
|
|
*ptr = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
Returns TRUE if the current OS thread is performing an insert buffer
|
|
|
|
routine. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
ibuf_inside(void)
|
|
|
|
/*=============*/
|
|
|
|
/* out: TRUE if inside an insert buffer routine: for instance,
|
|
|
|
a read-ahead of non-ibuf pages is then forbidden */
|
|
|
|
{
|
|
|
|
return(*thr_local_get_in_ibuf_field());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
Gets the ibuf header page and x-latches it. */
|
|
|
|
static
|
|
|
|
page_t*
|
|
|
|
ibuf_header_page_get(
|
|
|
|
/*=================*/
|
|
|
|
/* out: insert buffer header page */
|
|
|
|
mtr_t* mtr) /* in: mtr */
|
|
|
|
{
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_t* block;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ut_ad(!ibuf_inside());
|
|
|
|
|
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
|
|
|
block = buf_page_get(
|
|
|
|
IBUF_SPACE_ID, 0, FSP_IBUF_HEADER_PAGE_NO, RW_X_LATCH, mtr);
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_dbg_add_level(block, SYNC_IBUF_HEADER);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
return(buf_block_get_frame(block));
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
Gets the root page and x-latches it. */
|
|
|
|
static
|
|
|
|
page_t*
|
|
|
|
ibuf_tree_root_get(
|
|
|
|
/*===============*/
|
|
|
|
/* out: insert buffer tree root page */
|
|
|
|
mtr_t* mtr) /* in: mtr */
|
|
|
|
{
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_t* block;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ut_ad(ibuf_inside());
|
|
|
|
|
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
|
|
|
mtr_x_lock(dict_index_get_lock(ibuf->index), mtr);
|
|
|
|
|
|
|
|
block = buf_page_get(
|
|
|
|
IBUF_SPACE_ID, 0, FSP_IBUF_TREE_ROOT_PAGE_NO, RW_X_LATCH, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
return(buf_block_get_frame(block));
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2007-02-27 11:56:38 +00:00
|
|
|
#ifdef UNIV_IBUF_COUNT_DEBUG
|
2005-10-27 07:29:40 +00:00
|
|
|
/**********************************************************************
|
|
|
|
Gets the ibuf count for a given page. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
|
|
|
ibuf_count_get(
|
|
|
|
/*===========*/
|
|
|
|
/* out: number of entries in the insert buffer
|
|
|
|
currently buffered for this page */
|
|
|
|
ulint space, /* in: space id */
|
|
|
|
ulint page_no)/* in: page number */
|
|
|
|
{
|
2007-05-14 09:07:15 +00:00
|
|
|
ibuf_count_check(space, page_no);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-05-14 09:07:15 +00:00
|
|
|
return(ibuf_counts[space][page_no]);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
Sets the ibuf count for a given page. */
|
|
|
|
static
|
|
|
|
void
|
|
|
|
ibuf_count_set(
|
|
|
|
/*===========*/
|
|
|
|
ulint space, /* in: space id */
|
|
|
|
ulint page_no,/* in: page number */
|
|
|
|
ulint val) /* in: value to set */
|
|
|
|
{
|
2007-05-14 09:07:15 +00:00
|
|
|
ibuf_count_check(space, page_no);
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_a(val < UNIV_PAGE_SIZE);
|
|
|
|
|
2007-05-14 09:07:15 +00:00
|
|
|
ibuf_counts[space][page_no] = val;
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**********************************************************************
|
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
|
|
|
Updates the size information of the ibuf, assuming the segment size has not
|
|
|
|
changed. */
|
2005-10-27 07:29:40 +00:00
|
|
|
static
|
|
|
|
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_size_update(
|
|
|
|
/*=============*/
|
2006-10-26 08:52:14 +00:00
|
|
|
const page_t* root, /* in: ibuf tree root */
|
2005-10-27 07:29:40 +00:00
|
|
|
mtr_t* mtr) /* in: mtr */
|
|
|
|
{
|
|
|
|
ut_ad(mutex_own(&ibuf_mutex));
|
|
|
|
|
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_list_len = flst_get_len(root + PAGE_HEADER
|
2005-10-27 07:29:40 +00:00
|
|
|
+ PAGE_BTR_IBUF_FREE_LIST, mtr);
|
|
|
|
|
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->height = 1 + btr_page_get_level(root, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-08-29 09:30:31 +00:00
|
|
|
/* the '1 +' is the ibuf header page */
|
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->size = ibuf->seg_size - (1 + ibuf->free_list_len);
|
2005-10-27 07:29:40 +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
|
|
|
ibuf->empty = page_get_n_recs(root) == 0;
|
2005-10-27 07:29:40 +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
|
|
|
Creates the insert buffer data structure at a database startup and initializes
|
|
|
|
the data structures for the insert buffer. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
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
|
|
|
void
|
|
|
|
ibuf_init_at_db_start(void)
|
|
|
|
/*=======================*/
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
page_t* root;
|
|
|
|
mtr_t mtr;
|
|
|
|
dict_table_t* table;
|
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
|
|
|
mem_heap_t* heap;
|
2005-10-27 07:29:40 +00:00
|
|
|
dict_index_t* index;
|
|
|
|
ulint n_used;
|
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
|
|
|
page_t* header_page;
|
2007-12-19 14:03:39 +00:00
|
|
|
ulint error;
|
2006-02-23 19:25: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
|
|
|
ibuf = mem_alloc(sizeof(ibuf_t));
|
2005-10-27 07:29:40 +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
|
|
|
memset(ibuf, 0, sizeof(*ibuf));
|
2005-10-27 07:29:40 +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
|
|
|
/* Note that also a pessimistic delete can sometimes make a B-tree
|
|
|
|
grow in size, as the references on the upper levels of the tree can
|
|
|
|
change */
|
|
|
|
|
|
|
|
ibuf->max_size = buf_pool_get_curr_size() / UNIV_PAGE_SIZE
|
|
|
|
/ IBUF_POOL_SIZE_PER_MAX_SIZE;
|
|
|
|
|
|
|
|
mutex_create(&ibuf_pessimistic_insert_mutex,
|
|
|
|
SYNC_IBUF_PESS_INSERT_MUTEX);
|
|
|
|
|
|
|
|
mutex_create(&ibuf_mutex, SYNC_IBUF_MUTEX);
|
|
|
|
|
|
|
|
mutex_create(&ibuf_bitmap_mutex, SYNC_IBUF_BITMAP_MUTEX);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mtr_start(&mtr);
|
|
|
|
|
|
|
|
mutex_enter(&ibuf_mutex);
|
|
|
|
|
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
|
|
|
mtr_x_lock(fil_space_get_latch(IBUF_SPACE_ID, NULL), &mtr);
|
2005-10-27 07:29:40 +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
|
|
|
header_page = ibuf_header_page_get(&mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
fseg_n_reserved_pages(header_page + IBUF_HEADER + IBUF_TREE_SEG_HEADER,
|
2006-08-29 09:30:31 +00:00
|
|
|
&n_used, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
ibuf_enter();
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(n_used >= 2);
|
|
|
|
|
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->seg_size = n_used;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-10-12 11:05:22 +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
|
|
|
buf_block_t* block;
|
|
|
|
|
|
|
|
block = buf_page_get(
|
|
|
|
IBUF_SPACE_ID, 0, FSP_IBUF_TREE_ROOT_PAGE_NO,
|
2007-01-18 09:59:00 +00:00
|
|
|
RW_X_LATCH, &mtr);
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
|
2008-09-22 06:59:58 +00:00
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
root = buf_block_get_frame(block);
|
|
|
|
}
|
2005-10-27 07:29:40 +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
|
|
|
ibuf_size_update(root, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
mutex_exit(&ibuf_mutex);
|
|
|
|
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
|
|
|
|
ibuf_exit();
|
|
|
|
|
2007-01-30 09:24:18 +00:00
|
|
|
heap = mem_heap_create(450);
|
|
|
|
|
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
|
|
|
/* Use old-style record format for the insert buffer. */
|
|
|
|
table = dict_mem_table_create(IBUF_TABLE_NAME, IBUF_SPACE_ID, 1, 0);
|
2005-10-27 07:29:40 +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
|
|
|
dict_mem_table_add_col(table, heap, "DUMMY_COLUMN", DATA_BINARY, 0, 0);
|
2005-10-27 07:29:40 +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
|
|
|
table->id = ut_dulint_add(DICT_IBUF_ID_MIN, IBUF_SPACE_ID);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-30 09:24:18 +00:00
|
|
|
dict_table_add_to_cache(table, heap);
|
|
|
|
mem_heap_free(heap);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
index = dict_mem_index_create(
|
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_TABLE_NAME, "CLUST_IND",
|
|
|
|
IBUF_SPACE_ID, DICT_CLUSTERED | DICT_UNIVERSAL | DICT_IBUF, 1);
|
2005-10-27 07:29:40 +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
|
|
|
dict_mem_index_add_field(index, "DUMMY_COLUMN", 0);
|
2005-10-27 07:29:40 +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
|
|
|
index->id = ut_dulint_add(DICT_IBUF_ID_MIN, IBUF_SPACE_ID);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-12-19 14:03:39 +00:00
|
|
|
error = dict_index_add_to_cache(table, index,
|
2008-09-18 12:31:17 +00:00
|
|
|
FSP_IBUF_TREE_ROOT_PAGE_NO, FALSE);
|
2007-12-19 14:03:39 +00:00
|
|
|
ut_a(error == DB_SUCCESS);
|
2005-10-27 07:29:40 +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
|
|
|
ibuf->index = dict_table_get_first_index(table);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Initializes an ibuf bitmap page. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
ibuf_bitmap_page_init(
|
|
|
|
/*==================*/
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_t* block, /* in: bitmap page */
|
|
|
|
mtr_t* mtr) /* in: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2006-10-12 11:05:22 +00:00
|
|
|
page_t* page;
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint byte_offset;
|
2006-10-12 11:05:22 +00:00
|
|
|
ulint zip_size = buf_block_get_zip_size(block);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
ut_a(ut_is_2pow(zip_size));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
page = buf_block_get_frame(block);
|
2006-06-06 07:42:04 +00:00
|
|
|
fil_page_set_type(page, FIL_PAGE_IBUF_BITMAP);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-06-06 07:42:04 +00:00
|
|
|
/* Write all zeros to the bitmap */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-06-06 07:42:04 +00:00
|
|
|
if (!zip_size) {
|
2007-05-29 08:48:16 +00:00
|
|
|
byte_offset = UT_BITS_IN_BYTES(UNIV_PAGE_SIZE
|
|
|
|
* IBUF_BITS_PER_PAGE);
|
2006-06-06 07:42:04 +00:00
|
|
|
} else {
|
2007-05-29 08:48:16 +00:00
|
|
|
byte_offset = UT_BITS_IN_BYTES(zip_size * IBUF_BITS_PER_PAGE);
|
2006-06-06 07:42:04 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
memset(page + IBUF_BITMAP, 0, byte_offset);
|
|
|
|
|
|
|
|
/* The remaining area (up to the page trailer) is uninitialized. */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mlog_write_initial_log_record(page, MLOG_IBUF_BITMAP_INIT, mtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Parses a redo log record of an ibuf bitmap page init. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
byte*
|
|
|
|
ibuf_parse_bitmap_init(
|
|
|
|
/*===================*/
|
2006-10-19 08:27:34 +00:00
|
|
|
/* out: end of log record or NULL */
|
|
|
|
byte* ptr, /* in: buffer */
|
|
|
|
byte* end_ptr __attribute__((unused)), /* in: buffer end */
|
|
|
|
buf_block_t* block, /* in: block or NULL */
|
|
|
|
mtr_t* mtr) /* in: mtr or NULL */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ut_ad(ptr && end_ptr);
|
|
|
|
|
2006-10-19 08:27:34 +00:00
|
|
|
if (block) {
|
|
|
|
ibuf_bitmap_page_init(block, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return(ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Gets the desired bits for a given page from a bitmap page. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
ibuf_bitmap_page_get_bits(
|
|
|
|
/*======================*/
|
2006-10-26 08:52:14 +00:00
|
|
|
/* out: value of bits */
|
|
|
|
const page_t* page, /* in: bitmap page */
|
|
|
|
ulint page_no,/* in: page whose bits to get */
|
|
|
|
ulint zip_size,/* in: compressed page size in bytes;
|
|
|
|
0 for uncompressed pages */
|
|
|
|
ulint bit, /* in: IBUF_BITMAP_FREE,
|
|
|
|
IBUF_BITMAP_BUFFERED, ... */
|
|
|
|
mtr_t* mtr __attribute__((unused)))
|
|
|
|
/* in: mtr containing an
|
|
|
|
x-latch to the bitmap page */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ulint byte_offset;
|
|
|
|
ulint bit_offset;
|
|
|
|
ulint map_byte;
|
|
|
|
ulint value;
|
|
|
|
|
|
|
|
ut_ad(bit < IBUF_BITS_PER_PAGE);
|
2006-02-17 14:19:39 +00:00
|
|
|
#if IBUF_BITS_PER_PAGE % 2
|
|
|
|
# error "IBUF_BITS_PER_PAGE % 2 != 0"
|
|
|
|
#endif
|
2006-06-07 11:23:21 +00:00
|
|
|
ut_ad(ut_is_2pow(zip_size));
|
2006-10-09 19:36:58 +00:00
|
|
|
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-06-06 07:42:04 +00:00
|
|
|
if (!zip_size) {
|
|
|
|
bit_offset = (page_no % UNIV_PAGE_SIZE) * IBUF_BITS_PER_PAGE
|
2006-09-21 08:01:50 +00:00
|
|
|
+ bit;
|
2006-06-06 07:42:04 +00:00
|
|
|
} else {
|
|
|
|
bit_offset = (page_no & (zip_size - 1)) * IBUF_BITS_PER_PAGE
|
2006-09-21 08:01:50 +00:00
|
|
|
+ bit;
|
2006-06-06 07:42:04 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
byte_offset = bit_offset / 8;
|
|
|
|
bit_offset = bit_offset % 8;
|
|
|
|
|
|
|
|
ut_ad(byte_offset + IBUF_BITMAP < UNIV_PAGE_SIZE);
|
|
|
|
|
|
|
|
map_byte = mach_read_from_1(page + IBUF_BITMAP + byte_offset);
|
|
|
|
|
|
|
|
value = ut_bit_get_nth(map_byte, bit_offset);
|
|
|
|
|
|
|
|
if (bit == IBUF_BITMAP_FREE) {
|
|
|
|
ut_ad(bit_offset + 1 < 8);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
value = value * 2 + ut_bit_get_nth(map_byte, bit_offset + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Sets the desired bit for a given page in a bitmap page. */
|
|
|
|
static
|
|
|
|
void
|
|
|
|
ibuf_bitmap_page_set_bits(
|
|
|
|
/*======================*/
|
|
|
|
page_t* page, /* in: bitmap page */
|
|
|
|
ulint page_no,/* in: page whose bits to set */
|
2006-06-06 07:42:04 +00:00
|
|
|
ulint zip_size,/* in: compressed page size in bytes;
|
|
|
|
0 for uncompressed pages */
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint bit, /* in: IBUF_BITMAP_FREE, IBUF_BITMAP_BUFFERED, ... */
|
|
|
|
ulint val, /* in: value to set */
|
|
|
|
mtr_t* mtr) /* in: mtr containing an x-latch to the bitmap page */
|
|
|
|
{
|
|
|
|
ulint byte_offset;
|
|
|
|
ulint bit_offset;
|
|
|
|
ulint map_byte;
|
|
|
|
|
|
|
|
ut_ad(bit < IBUF_BITS_PER_PAGE);
|
2006-02-17 14:19:39 +00:00
|
|
|
#if IBUF_BITS_PER_PAGE % 2
|
|
|
|
# error "IBUF_BITS_PER_PAGE % 2 != 0"
|
|
|
|
#endif
|
2006-06-07 11:23:21 +00:00
|
|
|
ut_ad(ut_is_2pow(zip_size));
|
2006-10-09 19:36:58 +00:00
|
|
|
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX));
|
2007-02-27 11:56:38 +00:00
|
|
|
#ifdef UNIV_IBUF_COUNT_DEBUG
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_a((bit != IBUF_BITMAP_BUFFERED) || (val != FALSE)
|
2006-10-12 07:02:36 +00:00
|
|
|
|| (0 == ibuf_count_get(page_get_space_id(page),
|
2006-08-29 09:30:31 +00:00
|
|
|
page_no)));
|
2005-10-27 07:29:40 +00:00
|
|
|
#endif
|
2006-06-06 07:42:04 +00:00
|
|
|
if (!zip_size) {
|
|
|
|
bit_offset = (page_no % UNIV_PAGE_SIZE) * IBUF_BITS_PER_PAGE
|
2006-09-21 08:01:50 +00:00
|
|
|
+ bit;
|
2006-06-06 07:42:04 +00:00
|
|
|
} else {
|
|
|
|
bit_offset = (page_no & (zip_size - 1)) * IBUF_BITS_PER_PAGE
|
2006-09-21 08:01:50 +00:00
|
|
|
+ bit;
|
2006-06-06 07:42:04 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
byte_offset = bit_offset / 8;
|
|
|
|
bit_offset = bit_offset % 8;
|
|
|
|
|
|
|
|
ut_ad(byte_offset + IBUF_BITMAP < UNIV_PAGE_SIZE);
|
|
|
|
|
|
|
|
map_byte = mach_read_from_1(page + IBUF_BITMAP + byte_offset);
|
|
|
|
|
|
|
|
if (bit == IBUF_BITMAP_FREE) {
|
|
|
|
ut_ad(bit_offset + 1 < 8);
|
|
|
|
ut_ad(val <= 3);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
map_byte = ut_bit_set_nth(map_byte, bit_offset, val / 2);
|
|
|
|
map_byte = ut_bit_set_nth(map_byte, bit_offset + 1, val % 2);
|
|
|
|
} else {
|
|
|
|
ut_ad(val <= 1);
|
|
|
|
map_byte = ut_bit_set_nth(map_byte, bit_offset, val);
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mlog_write_ulint(page + IBUF_BITMAP + byte_offset, map_byte,
|
2006-08-29 09:30:31 +00:00
|
|
|
MLOG_1BYTE, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Calculates the bitmap page number for a given page number. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
ibuf_bitmap_page_no_calc(
|
|
|
|
/*=====================*/
|
|
|
|
/* out: the bitmap page number where
|
|
|
|
the file page is mapped */
|
2006-06-06 07:42:04 +00:00
|
|
|
ulint zip_size, /* in: compressed page size in bytes;
|
|
|
|
0 for uncompressed pages */
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint page_no) /* in: tablespace page number */
|
|
|
|
{
|
2006-06-07 11:23:21 +00:00
|
|
|
ut_ad(ut_is_2pow(zip_size));
|
2006-06-06 07:42:04 +00:00
|
|
|
|
|
|
|
if (!zip_size) {
|
|
|
|
return(FSP_IBUF_BITMAP_OFFSET
|
2006-08-29 09:30:31 +00:00
|
|
|
+ (page_no & ~(UNIV_PAGE_SIZE - 1)));
|
2006-06-06 07:42:04 +00:00
|
|
|
} else {
|
|
|
|
return(FSP_IBUF_BITMAP_OFFSET
|
2006-08-29 09:30:31 +00:00
|
|
|
+ (page_no & ~(zip_size - 1)));
|
2006-06-06 07:42:04 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Gets the ibuf bitmap page where the bits describing a given file page are
|
|
|
|
stored. */
|
|
|
|
static
|
|
|
|
page_t*
|
|
|
|
ibuf_bitmap_get_map_page(
|
|
|
|
/*=====================*/
|
|
|
|
/* out: bitmap page where the file page is mapped,
|
|
|
|
that is, the bitmap page containing the descriptor
|
|
|
|
bits for the file page; the bitmap page is
|
|
|
|
x-latched */
|
|
|
|
ulint space, /* in: space id of the file page */
|
|
|
|
ulint page_no,/* in: page number of the file page */
|
2006-06-06 07:42:04 +00:00
|
|
|
ulint zip_size,/* in: compressed page size in bytes;
|
|
|
|
0 for uncompressed pages */
|
2005-10-27 07:29:40 +00:00
|
|
|
mtr_t* mtr) /* in: mtr */
|
|
|
|
{
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_t* block;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
block = buf_page_get(space, zip_size,
|
2006-10-12 11:05:22 +00:00
|
|
|
ibuf_bitmap_page_no_calc(zip_size, page_no),
|
|
|
|
RW_X_LATCH, mtr);
|
|
|
|
buf_block_dbg_add_level(block, SYNC_IBUF_BITMAP);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
return(buf_block_get_frame(block));
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
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. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
ibuf_set_free_bits_low(
|
|
|
|
/*===================*/
|
2007-10-12 13:25:12 +00:00
|
|
|
ulint zip_size,/* in: compressed page size in bytes;
|
|
|
|
0 for uncompressed pages */
|
|
|
|
const buf_block_t* block, /* in: index page; free bits are set if
|
|
|
|
the index is non-clustered and page
|
|
|
|
level is 0 */
|
|
|
|
ulint val, /* in: value to set: < 4 */
|
|
|
|
mtr_t* mtr) /* in/out: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
page_t* bitmap_page;
|
2006-06-06 07:42:04 +00:00
|
|
|
ulint space;
|
|
|
|
ulint page_no;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-10-13 09:15:17 +00:00
|
|
|
if (!page_is_leaf(buf_block_get_frame(block))) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-10-13 09:15:17 +00:00
|
|
|
space = buf_block_get_space(block);
|
|
|
|
page_no = buf_block_get_page_no(block);
|
2006-06-06 07:42:04 +00:00
|
|
|
bitmap_page = ibuf_bitmap_get_map_page(space, page_no, zip_size, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
#ifdef UNIV_IBUF_DEBUG
|
2006-08-29 09:30:31 +00:00
|
|
|
# if 0
|
|
|
|
fprintf(stderr,
|
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
|
|
|
"Setting space %lu page %lu free bits to %lu should be %lu\n",
|
|
|
|
space, page_no, val,
|
|
|
|
ibuf_index_page_calc_free(zip_size, block));
|
2006-08-29 09:30:31 +00:00
|
|
|
# endif
|
2006-02-23 19:25:29 +00:00
|
|
|
|
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
|
|
|
ut_a(val <= ibuf_index_page_calc_free(zip_size, block));
|
2006-08-29 09:30:31 +00:00
|
|
|
#endif /* UNIV_IBUF_DEBUG */
|
2006-06-06 07:42:04 +00:00
|
|
|
ibuf_bitmap_page_set_bits(bitmap_page, page_no, zip_size,
|
2006-08-29 09:30:31 +00:00
|
|
|
IBUF_BITMAP_FREE, val, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
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. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
2007-03-01 11:33:26 +00:00
|
|
|
ibuf_set_free_bits_func(
|
|
|
|
/*====================*/
|
2007-05-06 12:39:46 +00:00
|
|
|
buf_block_t* block, /* in: index page of a non-clustered index;
|
|
|
|
free bit is reset if page level is 0 */
|
2007-03-01 11:33:26 +00:00
|
|
|
#ifdef UNIV_IBUF_DEBUG
|
|
|
|
ulint max_val,/* in: ULINT_UNDEFINED or a maximum
|
2006-10-13 07:45:52 +00:00
|
|
|
value which the bits must have before
|
|
|
|
setting; this is for debugging */
|
2007-03-01 11:33:26 +00:00
|
|
|
#endif /* UNIV_IBUF_DEBUG */
|
|
|
|
ulint val) /* in: value to set: < 4 */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
mtr_t mtr;
|
2006-10-13 07:45:52 +00:00
|
|
|
page_t* page;
|
2005-10-27 07:29:40 +00:00
|
|
|
page_t* bitmap_page;
|
2006-06-06 07:42:04 +00:00
|
|
|
ulint space;
|
|
|
|
ulint page_no;
|
|
|
|
ulint zip_size;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-10-13 07:45:52 +00:00
|
|
|
page = buf_block_get_frame(block);
|
|
|
|
|
2006-04-04 10:42:05 +00:00
|
|
|
if (!page_is_leaf(page)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mtr_start(&mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-10-13 07:45:52 +00:00
|
|
|
space = buf_block_get_space(block);
|
|
|
|
page_no = buf_block_get_page_no(block);
|
|
|
|
zip_size = buf_block_get_zip_size(block);
|
2006-06-06 07:42:04 +00:00
|
|
|
bitmap_page = ibuf_bitmap_get_map_page(space, page_no, zip_size, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
#ifdef UNIV_IBUF_DEBUG
|
2007-03-01 11:33:26 +00:00
|
|
|
if (max_val != ULINT_UNDEFINED) {
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint old_val;
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
old_val = ibuf_bitmap_page_get_bits(
|
|
|
|
bitmap_page, page_no, zip_size,
|
|
|
|
IBUF_BITMAP_FREE, &mtr);
|
2006-08-29 09:30:31 +00:00
|
|
|
# if 0
|
2005-10-27 07:29:40 +00:00
|
|
|
if (old_val != max_val) {
|
2006-08-29 09:30:31 +00:00
|
|
|
fprintf(stderr,
|
|
|
|
"Ibuf: page %lu old val %lu max val %lu\n",
|
2006-10-12 07:02:36 +00:00
|
|
|
page_get_page_no(page),
|
2006-08-29 09:30:31 +00:00
|
|
|
old_val, max_val);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
2006-08-29 09:30:31 +00:00
|
|
|
# endif
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ut_a(old_val <= max_val);
|
|
|
|
}
|
2006-08-29 09:30:31 +00:00
|
|
|
# if 0
|
|
|
|
fprintf(stderr, "Setting page no %lu free bits to %lu should be %lu\n",
|
2006-10-12 07:02:36 +00:00
|
|
|
page_get_page_no(page), val,
|
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
|
|
|
ibuf_index_page_calc_free(zip_size, block));
|
2006-08-29 09:30:31 +00:00
|
|
|
# endif
|
2005-10-27 07:29:40 +00:00
|
|
|
|
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
|
|
|
ut_a(val <= ibuf_index_page_calc_free(zip_size, block));
|
2007-03-01 11:33:26 +00:00
|
|
|
#endif /* UNIV_IBUF_DEBUG */
|
2006-06-06 07:42:04 +00:00
|
|
|
ibuf_bitmap_page_set_bits(bitmap_page, page_no, zip_size,
|
2006-08-29 09:30:31 +00:00
|
|
|
IBUF_BITMAP_FREE, val, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
mtr_commit(&mtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
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-06 14:17:36 +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(
|
|
|
|
/*=================*/
|
2006-10-13 07:45:52 +00:00
|
|
|
buf_block_t* block) /* in: index page; free bits are set to 0
|
|
|
|
if the index is a non-clustered
|
|
|
|
non-unique, and page level is 0 */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2007-05-06 12:39:46 +00:00
|
|
|
ibuf_set_free_bits(block, 0, ULINT_UNDEFINED);
|
2005-10-27 07:29:40 +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-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
ibuf_update_free_bits_low(
|
|
|
|
/*======================*/
|
2007-10-12 13:25:12 +00:00
|
|
|
const buf_block_t* block, /* in: index page */
|
|
|
|
ulint max_ins_size, /* in: value of
|
|
|
|
maximum insert size
|
|
|
|
with reorganize before
|
|
|
|
the latest operation
|
|
|
|
performed to the page */
|
|
|
|
mtr_t* mtr) /* in/out: mtr */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ulint before;
|
|
|
|
ulint after;
|
|
|
|
|
2007-10-12 13:25:12 +00:00
|
|
|
ut_a(!buf_block_get_page_zip(block));
|
|
|
|
|
|
|
|
before = ibuf_index_page_calc_free_bits(0, max_ins_size);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-10-12 13:25:12 +00:00
|
|
|
after = ibuf_index_page_calc_free(0, block);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-10-12 13:25:12 +00:00
|
|
|
/* This approach cannot be used on compressed pages, since the
|
|
|
|
computed value of "before" often does not match the current
|
|
|
|
state of the bitmap. This is because the free space may
|
|
|
|
increase or decrease when a compressed page is reorganized. */
|
2005-10-27 07:29:40 +00:00
|
|
|
if (before != after) {
|
2007-10-12 13:25:12 +00:00
|
|
|
ibuf_set_free_bits_low(0, block, after, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-12 13:25:12 +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-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2007-10-12 13:25:12 +00:00
|
|
|
void
|
|
|
|
ibuf_update_free_bits_zip(
|
|
|
|
/*======================*/
|
2008-02-25 14:01:15 +00:00
|
|
|
buf_block_t* block, /* in/out: index page */
|
|
|
|
mtr_t* mtr) /* in/out: mtr */
|
2007-10-12 13:25:12 +00:00
|
|
|
{
|
|
|
|
page_t* bitmap_page;
|
|
|
|
ulint space;
|
|
|
|
ulint page_no;
|
|
|
|
ulint zip_size;
|
|
|
|
ulint after;
|
|
|
|
|
|
|
|
space = buf_block_get_space(block);
|
|
|
|
page_no = buf_block_get_page_no(block);
|
|
|
|
zip_size = buf_block_get_zip_size(block);
|
|
|
|
|
|
|
|
ut_a(page_is_leaf(buf_block_get_frame(block)));
|
|
|
|
ut_a(zip_size);
|
|
|
|
|
|
|
|
bitmap_page = ibuf_bitmap_get_map_page(space, page_no, zip_size, mtr);
|
|
|
|
|
|
|
|
after = ibuf_index_page_calc_free_zip(zip_size, block);
|
2008-02-25 14:01:15 +00:00
|
|
|
|
|
|
|
if (after == 0) {
|
|
|
|
/* We move the page to the front of the buffer pool LRU list:
|
|
|
|
the purpose of this is to prevent those pages to which we
|
|
|
|
cannot make inserts using the insert buffer from slipping
|
|
|
|
out of the buffer pool */
|
|
|
|
|
|
|
|
buf_page_make_young(&block->page);
|
|
|
|
}
|
|
|
|
|
2007-10-12 13:25:12 +00:00
|
|
|
ibuf_bitmap_page_set_bits(bitmap_page, page_no, zip_size,
|
|
|
|
IBUF_BITMAP_FREE, after, mtr);
|
|
|
|
}
|
|
|
|
|
2005-10-27 07:29:40 +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-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
ibuf_update_free_bits_for_two_pages_low(
|
|
|
|
/*====================================*/
|
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
|
|
|
ulint zip_size,/* in: compressed page size in bytes;
|
|
|
|
0 for uncompressed pages */
|
2006-10-13 09:15:17 +00:00
|
|
|
buf_block_t* block1, /* in: index page */
|
|
|
|
buf_block_t* block2, /* in: index page */
|
2005-10-27 07:29:40 +00:00
|
|
|
mtr_t* mtr) /* in: mtr */
|
|
|
|
{
|
|
|
|
ulint state;
|
|
|
|
|
|
|
|
/* As we have to x-latch two random bitmap pages, we have to acquire
|
|
|
|
the bitmap mutex to prevent a deadlock with a similar operation
|
|
|
|
performed by another OS thread. */
|
|
|
|
|
|
|
|
mutex_enter(&ibuf_bitmap_mutex);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
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
|
|
|
state = ibuf_index_page_calc_free(zip_size, block1);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-05-06 12:39:46 +00:00
|
|
|
ibuf_set_free_bits_low(zip_size, block1, state, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
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
|
|
|
state = ibuf_index_page_calc_free(zip_size, block2);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2007-05-06 12:39:46 +00:00
|
|
|
ibuf_set_free_bits_low(zip_size, block2, state, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mutex_exit(&ibuf_bitmap_mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
Returns TRUE if the page is one of the fixed address ibuf pages. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
|
|
|
ibuf_fixed_addr_page(
|
|
|
|
/*=================*/
|
|
|
|
/* out: TRUE if a fixed address ibuf i/o page */
|
2006-06-05 09:04:19 +00:00
|
|
|
ulint space, /* in: space id */
|
2006-06-06 07:42:04 +00:00
|
|
|
ulint zip_size,/* in: compressed page size in bytes;
|
|
|
|
0 for uncompressed pages */
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint page_no)/* in: page number */
|
|
|
|
{
|
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
|
|
|
return((space == IBUF_SPACE_ID && page_no == IBUF_TREE_ROOT_PAGE_NO)
|
2006-08-29 09:30:31 +00:00
|
|
|
|| ibuf_bitmap_page(zip_size, page_no));
|
2005-10-27 07:29:40 +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.
|
|
|
|
Must not be called when recv_no_ibuf_operations==TRUE. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
ibuf_page(
|
|
|
|
/*======*/
|
|
|
|
/* out: TRUE if level 2 or level 3 page */
|
|
|
|
ulint space, /* in: space id */
|
2006-10-19 11:07:50 +00:00
|
|
|
ulint zip_size,/* in: compressed page size in bytes, or 0 */
|
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
|
|
|
ulint page_no,/* in: page number */
|
|
|
|
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. */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ibool ret;
|
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
|
|
|
mtr_t local_mtr;
|
|
|
|
page_t* bitmap_page;
|
2005-10-27 07:29:40 +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
|
|
|
ut_ad(!recv_no_ibuf_operations);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-06-06 07:42:04 +00:00
|
|
|
if (ibuf_fixed_addr_page(space, zip_size, page_no)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
return(TRUE);
|
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
|
|
|
} else if (space != IBUF_SPACE_ID) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
ut_ad(fil_space_get_type(IBUF_SPACE_ID) == FIL_TABLESPACE);
|
2005-10-27 07:29:40 +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
|
|
|
if (mtr == NULL) {
|
|
|
|
mtr = &local_mtr;
|
|
|
|
mtr_start(mtr);
|
|
|
|
}
|
2005-10-27 07:29:40 +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
|
|
|
bitmap_page = ibuf_bitmap_get_map_page(space, page_no, zip_size, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-06-06 07:42:04 +00:00
|
|
|
ret = ibuf_bitmap_page_get_bits(bitmap_page, page_no, zip_size,
|
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_BITMAP_IBUF, mtr);
|
2005-10-27 07:29:40 +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
|
|
|
if (mtr == &local_mtr) {
|
|
|
|
mtr_commit(mtr);
|
2005-10-27 07:29:40 +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
|
|
|
return(ret);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Returns the page number field of an ibuf record. */
|
|
|
|
static
|
|
|
|
ulint
|
|
|
|
ibuf_rec_get_page_no(
|
|
|
|
/*=================*/
|
2006-10-26 08:52:14 +00:00
|
|
|
/* out: page number */
|
|
|
|
const rec_t* rec) /* in: ibuf record */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2006-10-26 08:52:14 +00:00
|
|
|
const byte* field;
|
|
|
|
ulint len;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ut_ad(ibuf_inside());
|
|
|
|
ut_ad(rec_get_n_fields_old(rec) > 2);
|
|
|
|
|
|
|
|
field = rec_get_nth_field_old(rec, 1, &len);
|
|
|
|
|
|
|
|
if (len == 1) {
|
|
|
|
/* This is of the >= 4.1.x record format */
|
|
|
|
ut_a(trx_sys_multiple_tablespace_format);
|
|
|
|
|
|
|
|
field = rec_get_nth_field_old(rec, 2, &len);
|
|
|
|
} else {
|
|
|
|
ut_a(trx_doublewrite_must_reset_space_ids);
|
|
|
|
ut_a(!trx_sys_multiple_tablespace_format);
|
|
|
|
|
|
|
|
field = rec_get_nth_field_old(rec, 0, &len);
|
|
|
|
}
|
|
|
|
|
|
|
|
ut_a(len == 4);
|
|
|
|
|
|
|
|
return(mach_read_from_4(field));
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Returns the space id field of an ibuf record. For < 4.1.x format records
|
|
|
|
returns 0. */
|
|
|
|
static
|
|
|
|
ulint
|
|
|
|
ibuf_rec_get_space(
|
|
|
|
/*===============*/
|
2006-10-26 08:52:14 +00:00
|
|
|
/* out: space id */
|
|
|
|
const rec_t* rec) /* in: ibuf record */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2006-10-26 08:52:14 +00:00
|
|
|
const byte* field;
|
|
|
|
ulint len;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ut_ad(ibuf_inside());
|
|
|
|
ut_ad(rec_get_n_fields_old(rec) > 2);
|
|
|
|
|
|
|
|
field = rec_get_nth_field_old(rec, 1, &len);
|
|
|
|
|
|
|
|
if (len == 1) {
|
|
|
|
/* This is of the >= 4.1.x record format */
|
|
|
|
|
|
|
|
ut_a(trx_sys_multiple_tablespace_format);
|
|
|
|
field = rec_get_nth_field_old(rec, 0, &len);
|
|
|
|
ut_a(len == 4);
|
|
|
|
|
|
|
|
return(mach_read_from_4(field));
|
|
|
|
}
|
|
|
|
|
|
|
|
ut_a(trx_doublewrite_must_reset_space_ids);
|
|
|
|
ut_a(!trx_sys_multiple_tablespace_format);
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Creates a dummy index for inserting a record to a non-clustered index.
|
|
|
|
*/
|
|
|
|
static
|
|
|
|
dict_index_t*
|
|
|
|
ibuf_dummy_index_create(
|
|
|
|
/*====================*/
|
|
|
|
/* out: dummy index */
|
|
|
|
ulint n, /* in: number of fields */
|
|
|
|
ibool comp) /* in: TRUE=use compact record format */
|
|
|
|
{
|
|
|
|
dict_table_t* table;
|
|
|
|
dict_index_t* index;
|
2006-02-27 09:33:26 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
table = dict_mem_table_create("IBUF_DUMMY",
|
2006-08-29 09:30:31 +00:00
|
|
|
DICT_HDR_SPACE, n,
|
|
|
|
comp ? DICT_TF_COMPACT : 0);
|
2006-02-27 09:33:26 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
index = dict_mem_index_create("IBUF_DUMMY", "IBUF_DUMMY",
|
2006-08-29 09:30:31 +00:00
|
|
|
DICT_HDR_SPACE, 0, n);
|
2006-02-27 09:33:26 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
index->table = table;
|
2006-02-27 09:33:26 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* avoid ut_ad(index->cached) in dict_index_get_n_unique_in_tree */
|
|
|
|
index->cached = TRUE;
|
2006-02-27 09:33:26 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
return(index);
|
|
|
|
}
|
|
|
|
/************************************************************************
|
|
|
|
Add a column to the dummy index */
|
|
|
|
static
|
|
|
|
void
|
|
|
|
ibuf_dummy_index_add_col(
|
2006-02-23 19:25:29 +00:00
|
|
|
/*=====================*/
|
2005-10-27 07:29:40 +00:00
|
|
|
dict_index_t* index, /* in: dummy index */
|
2006-10-17 12:24:13 +00:00
|
|
|
const dtype_t* type, /* in: the data type of the column */
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint len) /* in: length of the column */
|
|
|
|
{
|
|
|
|
ulint i = index->table->n_def;
|
2007-01-30 09:24:18 +00:00
|
|
|
dict_mem_table_add_col(index->table, NULL, NULL,
|
2006-08-29 09:30:31 +00:00
|
|
|
dtype_get_mtype(type),
|
|
|
|
dtype_get_prtype(type),
|
2006-09-19 10:14:07 +00:00
|
|
|
dtype_get_len(type));
|
2006-10-19 07:27:26 +00:00
|
|
|
dict_index_add_col(index, index->table,
|
2006-08-29 09:30:31 +00:00
|
|
|
dict_table_get_nth_col(index->table, i), len);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
/************************************************************************
|
|
|
|
Deallocates a dummy index for inserting a record to a non-clustered index.
|
|
|
|
*/
|
|
|
|
static
|
|
|
|
void
|
|
|
|
ibuf_dummy_index_free(
|
2006-02-23 19:25:29 +00:00
|
|
|
/*==================*/
|
2005-10-27 07:29:40 +00:00
|
|
|
dict_index_t* index) /* in: dummy index */
|
|
|
|
{
|
|
|
|
dict_table_t* table = index->table;
|
2006-04-12 09:32:17 +00:00
|
|
|
|
|
|
|
dict_mem_index_free(index);
|
|
|
|
dict_mem_table_free(table);
|
2005-10-27 07:29:40 +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
|
|
|
/*************************************************************************
|
|
|
|
Builds the entry to insert into a non-clustered index when we have the
|
|
|
|
corresponding record in an ibuf index. */
|
|
|
|
UNIV_INLINE
|
|
|
|
dtuple_t*
|
|
|
|
ibuf_build_entry_pre_4_1_x(
|
|
|
|
/*=======================*/
|
|
|
|
/* out, own: entry to insert to
|
|
|
|
a non-clustered index; NOTE that
|
|
|
|
as we copy pointers to fields in
|
|
|
|
ibuf_rec, the caller must hold a
|
|
|
|
latch to the ibuf_rec page as long
|
|
|
|
as the entry is used! */
|
|
|
|
const rec_t* ibuf_rec, /* in: record in an insert buffer */
|
|
|
|
mem_heap_t* heap, /* in: heap where built */
|
|
|
|
dict_index_t** pindex) /* out, own: dummy index that
|
|
|
|
describes the entry */
|
|
|
|
{
|
|
|
|
ulint i;
|
|
|
|
ulint len;
|
|
|
|
const byte* types;
|
|
|
|
dtuple_t* tuple;
|
|
|
|
ulint n_fields;
|
|
|
|
|
|
|
|
ut_a(trx_doublewrite_must_reset_space_ids);
|
|
|
|
ut_a(!trx_sys_multiple_tablespace_format);
|
|
|
|
|
|
|
|
n_fields = rec_get_n_fields_old(ibuf_rec) - 2;
|
|
|
|
tuple = dtuple_create(heap, n_fields);
|
|
|
|
types = rec_get_nth_field_old(ibuf_rec, 1, &len);
|
|
|
|
|
|
|
|
ut_a(len == n_fields * DATA_ORDER_NULL_TYPE_BUF_SIZE);
|
|
|
|
|
|
|
|
for (i = 0; i < n_fields; i++) {
|
|
|
|
const byte* data;
|
|
|
|
dfield_t* field;
|
|
|
|
|
|
|
|
field = dtuple_get_nth_field(tuple, i);
|
|
|
|
|
|
|
|
data = rec_get_nth_field_old(ibuf_rec, i + 2, &len);
|
|
|
|
|
|
|
|
dfield_set_data(field, data, len);
|
|
|
|
|
|
|
|
dtype_read_for_order_and_null_size(
|
|
|
|
dfield_get_type(field),
|
|
|
|
types + i * DATA_ORDER_NULL_TYPE_BUF_SIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
*pindex = ibuf_dummy_index_create(n_fields, FALSE);
|
|
|
|
|
|
|
|
return(tuple);
|
|
|
|
}
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/*************************************************************************
|
|
|
|
Builds the entry to insert into a non-clustered index when we have the
|
|
|
|
corresponding record in an ibuf index. */
|
|
|
|
static
|
|
|
|
dtuple_t*
|
|
|
|
ibuf_build_entry_from_ibuf_rec(
|
|
|
|
/*===========================*/
|
|
|
|
/* out, own: entry to insert to
|
|
|
|
a non-clustered index; NOTE that
|
|
|
|
as we copy pointers to fields in
|
|
|
|
ibuf_rec, the caller must hold a
|
|
|
|
latch to the ibuf_rec page as long
|
|
|
|
as the entry is used! */
|
2006-10-26 08:52:14 +00:00
|
|
|
const rec_t* ibuf_rec, /* in: record in an insert buffer */
|
2005-10-27 07:29:40 +00:00
|
|
|
mem_heap_t* heap, /* in: heap where built */
|
|
|
|
dict_index_t** pindex) /* out, own: dummy index that
|
|
|
|
describes the entry */
|
|
|
|
{
|
|
|
|
dtuple_t* tuple;
|
|
|
|
dfield_t* field;
|
|
|
|
ulint n_fields;
|
2006-10-26 08:52:14 +00:00
|
|
|
const byte* types;
|
2005-10-27 07:29:40 +00:00
|
|
|
const byte* data;
|
|
|
|
ulint len;
|
|
|
|
ulint i;
|
|
|
|
dict_index_t* index;
|
|
|
|
|
|
|
|
data = rec_get_nth_field_old(ibuf_rec, 1, &len);
|
|
|
|
|
|
|
|
if (len > 1) {
|
|
|
|
/* This a < 4.1.x format record */
|
|
|
|
|
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
|
|
|
return(ibuf_build_entry_pre_4_1_x(ibuf_rec, heap, pindex));
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* This a >= 4.1.x format record */
|
|
|
|
|
|
|
|
ut_a(trx_sys_multiple_tablespace_format);
|
|
|
|
ut_a(*data == 0);
|
|
|
|
ut_a(rec_get_n_fields_old(ibuf_rec) > 4);
|
|
|
|
|
|
|
|
n_fields = rec_get_n_fields_old(ibuf_rec) - 4;
|
|
|
|
|
|
|
|
tuple = dtuple_create(heap, n_fields);
|
|
|
|
|
|
|
|
types = rec_get_nth_field_old(ibuf_rec, 3, &len);
|
|
|
|
|
|
|
|
ut_a(len % DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE <= 1);
|
2006-09-19 10:14:07 +00:00
|
|
|
index = ibuf_dummy_index_create(
|
|
|
|
n_fields, len % DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if (len % DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE) {
|
|
|
|
/* compact record format */
|
|
|
|
len--;
|
|
|
|
ut_a(*types == 0);
|
|
|
|
types++;
|
|
|
|
}
|
|
|
|
|
|
|
|
ut_a(len == n_fields * DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE);
|
|
|
|
|
|
|
|
for (i = 0; i < n_fields; i++) {
|
2006-10-19 07:27:26 +00:00
|
|
|
field = dtuple_get_nth_field(tuple, i);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
data = rec_get_nth_field_old(ibuf_rec, i + 4, &len);
|
|
|
|
|
|
|
|
dfield_set_data(field, data, len);
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
dtype_new_read_for_order_and_null_size(
|
2006-10-19 07:27:26 +00:00
|
|
|
dfield_get_type(field),
|
2006-09-19 10:14:07 +00:00
|
|
|
types + i * DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ibuf_dummy_index_add_col(index, dfield_get_type(field), len);
|
|
|
|
}
|
|
|
|
|
2007-11-28 11:22:25 +00:00
|
|
|
/* Prevent an ut_ad() failure in page_zip_write_rec() by
|
|
|
|
adding system columns to the dummy table pointed to by the
|
|
|
|
dummy secondary index. The insert buffer is only used for
|
|
|
|
secondary indexes, whose records never contain any system
|
|
|
|
columns, such as DB_TRX_ID. */
|
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
|
|
|
ut_d(dict_table_add_system_columns(index->table, index->table->heap));
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
*pindex = index;
|
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
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
return(tuple);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Returns the space taken by a stored non-clustered index entry if converted to
|
|
|
|
an index record. */
|
|
|
|
static
|
|
|
|
ulint
|
|
|
|
ibuf_rec_get_volume(
|
|
|
|
/*================*/
|
2006-10-26 08:52:14 +00:00
|
|
|
/* out: size of index record in bytes
|
|
|
|
+ an upper limit of the space taken in the
|
|
|
|
page directory */
|
|
|
|
const rec_t* ibuf_rec)/* in: ibuf record */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2006-10-26 08:52:14 +00:00
|
|
|
dtype_t dtype;
|
|
|
|
ibool new_format = FALSE;
|
|
|
|
ulint data_size = 0;
|
|
|
|
ulint n_fields;
|
|
|
|
const byte* types;
|
|
|
|
const byte* data;
|
|
|
|
ulint len;
|
|
|
|
ulint i;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ut_ad(ibuf_inside());
|
|
|
|
ut_ad(rec_get_n_fields_old(ibuf_rec) > 2);
|
|
|
|
|
|
|
|
data = rec_get_nth_field_old(ibuf_rec, 1, &len);
|
|
|
|
|
|
|
|
if (len > 1) {
|
|
|
|
/* < 4.1.x format record */
|
|
|
|
|
|
|
|
ut_a(trx_doublewrite_must_reset_space_ids);
|
|
|
|
ut_a(!trx_sys_multiple_tablespace_format);
|
|
|
|
|
|
|
|
n_fields = rec_get_n_fields_old(ibuf_rec) - 2;
|
|
|
|
|
|
|
|
types = rec_get_nth_field_old(ibuf_rec, 1, &len);
|
|
|
|
|
|
|
|
ut_ad(len == n_fields * DATA_ORDER_NULL_TYPE_BUF_SIZE);
|
|
|
|
} else {
|
|
|
|
/* >= 4.1.x format record */
|
|
|
|
|
|
|
|
ut_a(trx_sys_multiple_tablespace_format);
|
|
|
|
ut_a(*data == 0);
|
|
|
|
|
|
|
|
types = rec_get_nth_field_old(ibuf_rec, 3, &len);
|
|
|
|
|
|
|
|
ut_a(len % DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE <= 1);
|
|
|
|
if (len % DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE) {
|
|
|
|
/* compact record format */
|
|
|
|
ulint volume;
|
|
|
|
dict_index_t* dummy_index;
|
|
|
|
mem_heap_t* heap = mem_heap_create(500);
|
2006-09-19 10:14:07 +00:00
|
|
|
dtuple_t* entry = ibuf_build_entry_from_ibuf_rec(
|
|
|
|
ibuf_rec, heap, &dummy_index);
|
branches/zip: Make merge sort handle externally stored columns.
Some things still fail in innodb-index.test, and there seems to be
a race condition (data dictionary lock wait) when running with --valgrind.
dfield_t: Add an "external storage" flag, dfield->ext.
dfield_is_null(), dfield_is_ext(), dfield_set_ext(), dfield_set_null():
New functions.
dfield_copy(), dfield_copy_data(): Add const qualifiers, fix in/out comments.
data_write_sql_null(): Use memset().
big_rec_field_t: Replace byte* data with const void* data.
ut_ulint_sort(): Remove.
upd_field_t: Remove extern_storage.
upd_node_t: Replace ext_vec, n_ext_vec with n_ext.
row_merge_copy_blobs(): New function.
row_ins_index_entry(): Add the parameter "ibool foreign" for suppressing
foreign key checks during fast index creation or when inserting into
secondary indexes.
btr_page_insert_fits(): Add const qualifiers.
btr_cur_add_ext(), upd_ext_vec_contains(): Remove.
dfield_print_also_hex(), dfield_print(): Replace if...else if with switch.
Observe dfield_is_ext().
2007-06-21 09:43:15 +00:00
|
|
|
volume = rec_get_converted_size(dummy_index, entry, 0);
|
2005-10-27 07:29:40 +00:00
|
|
|
ibuf_dummy_index_free(dummy_index);
|
|
|
|
mem_heap_free(heap);
|
|
|
|
return(volume + page_dir_calc_reserved_space(1));
|
|
|
|
}
|
|
|
|
|
|
|
|
n_fields = rec_get_n_fields_old(ibuf_rec) - 4;
|
|
|
|
|
|
|
|
new_format = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < n_fields; i++) {
|
|
|
|
if (new_format) {
|
|
|
|
data = rec_get_nth_field_old(ibuf_rec, i + 4, &len);
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
dtype_new_read_for_order_and_null_size(
|
|
|
|
&dtype, types + i
|
|
|
|
* DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE);
|
2005-10-27 07:29:40 +00:00
|
|
|
} else {
|
|
|
|
data = rec_get_nth_field_old(ibuf_rec, i + 2, &len);
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
dtype_read_for_order_and_null_size(
|
|
|
|
&dtype, types + i
|
|
|
|
* DATA_ORDER_NULL_TYPE_BUF_SIZE);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (len == UNIV_SQL_NULL) {
|
|
|
|
data_size += dtype_get_sql_null_size(&dtype);
|
|
|
|
} else {
|
|
|
|
data_size += len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
branches/zip: dtuple_convert_big_rec(): Do not store anything locally
of externally stored columns, and fix bugs introduced in r873. (Bug #22496)
btr_page_get_sure_split_rec(), btr_page_insert_fits(),
rec_get_converted_size(), rec_convert_dtuple_to_rec(),
rec_convert_dtuple_to_rec_old(), rec_convert_dtuple_to_rec_new():
Add parameters ext and n_ext. Flag external fields during the
conversion.
rec_set_field_extern_bits(), rec_set_field_extern_bits_new(),
rec_offs_set_nth_extern(), rec_set_nth_field_extern_bit_old():
Remove. The bits are set by rec_convert_dtuple_to_rec().
page_cur_insert_rec_low(): Remove the parameters ext and n_ext.
btr_cur_add_ext(): New utility function for updating and sorting ext[].
Low-level functions now expect the array to be in ascending order
for performance reasons. Used in btr_cur_optimistic_insert(),
btr_cur_pessimistic_insert(), and btr_cur_pessimistic_update().
btr_cur_optimistic_insert(): Remove some defensive code, because we cannot
compute the added parameters of rec_get_converted_size().
btr_push_update_extern_fields(): Sort the array. Require the array to
be twice the maximum usage, so that ut_ulint_sort() can be used.
dtuple_convert_big_rec(): Allocate new space for the BLOB pointer,
to avoid overwriting prefix indexes to the same column. Adapt
dtuple_convert_back_big_rec().
row_build_index_entry(): Fetch the columns also for prefix indexes of
the clustered index.
page_zip_apply_log(), page_zip_decompress_clust(): Allow externally
stored fields to lack a locally stored part.
2006-09-29 10:40:42 +00:00
|
|
|
return(data_size + rec_get_converted_extra_size(data_size, n_fields, 0)
|
2006-08-29 09:30:31 +00:00
|
|
|
+ page_dir_calc_reserved_space(1));
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Builds the tuple to insert to an ibuf tree when we have an entry for a
|
|
|
|
non-clustered index. */
|
|
|
|
static
|
|
|
|
dtuple_t*
|
|
|
|
ibuf_entry_build(
|
|
|
|
/*=============*/
|
|
|
|
/* out, own: entry to insert into an ibuf
|
|
|
|
index tree; NOTE that the original entry
|
|
|
|
must be kept because we copy pointers to its
|
|
|
|
fields */
|
2006-09-12 07:29:57 +00:00
|
|
|
dict_index_t* index, /* in: non-clustered index */
|
2006-10-20 08:30:07 +00:00
|
|
|
const dtuple_t* entry, /* in: entry for a non-clustered index */
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint space, /* in: space id */
|
|
|
|
ulint page_no,/* in: index page number where entry should
|
|
|
|
be inserted */
|
|
|
|
mem_heap_t* heap) /* in: heap into which to build */
|
|
|
|
{
|
|
|
|
dtuple_t* tuple;
|
|
|
|
dfield_t* field;
|
2006-10-17 12:24:13 +00:00
|
|
|
const dfield_t* entry_field;
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint n_fields;
|
|
|
|
byte* buf;
|
|
|
|
byte* buf2;
|
|
|
|
ulint i;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Starting from 4.1.x, we have to build a tuple whose
|
|
|
|
(1) first field is the space id,
|
|
|
|
(2) the second field a single marker byte (0) to tell that this
|
|
|
|
is a new format record,
|
|
|
|
(3) the third contains the page number, and
|
|
|
|
(4) the fourth contains the relevent type information of each data
|
|
|
|
field; the length of this field % DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE is
|
2006-08-29 09:30:31 +00:00
|
|
|
(a) 0 for b-trees in the old format, and
|
|
|
|
(b) 1 for b-trees in the compact format, the first byte of the field
|
|
|
|
being the marker (0);
|
2005-10-27 07:29:40 +00:00
|
|
|
(5) and the rest of the fields are copied from entry. All fields
|
|
|
|
in the tuple are ordered like the type binary in our insert buffer
|
|
|
|
tree. */
|
|
|
|
|
|
|
|
n_fields = dtuple_get_n_fields(entry);
|
|
|
|
|
|
|
|
tuple = dtuple_create(heap, n_fields + 4);
|
|
|
|
|
|
|
|
/* Store the space id in tuple */
|
|
|
|
|
2006-10-19 07:27:26 +00:00
|
|
|
field = dtuple_get_nth_field(tuple, 0);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
buf = mem_heap_alloc(heap, 4);
|
|
|
|
|
|
|
|
mach_write_to_4(buf, space);
|
|
|
|
|
|
|
|
dfield_set_data(field, buf, 4);
|
|
|
|
|
|
|
|
/* Store the marker byte field in tuple */
|
|
|
|
|
2006-10-19 07:27:26 +00:00
|
|
|
field = dtuple_get_nth_field(tuple, 1);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
buf = mem_heap_alloc(heap, 1);
|
|
|
|
|
|
|
|
/* We set the marker byte zero */
|
|
|
|
|
|
|
|
mach_write_to_1(buf, 0);
|
|
|
|
|
|
|
|
dfield_set_data(field, buf, 1);
|
|
|
|
|
|
|
|
/* Store the page number in tuple */
|
|
|
|
|
2006-10-19 07:27:26 +00:00
|
|
|
field = dtuple_get_nth_field(tuple, 2);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
buf = mem_heap_alloc(heap, 4);
|
|
|
|
|
|
|
|
mach_write_to_4(buf, page_no);
|
|
|
|
|
|
|
|
dfield_set_data(field, buf, 4);
|
|
|
|
|
|
|
|
/* Store the type info in buf2, and add the fields from entry to
|
|
|
|
tuple */
|
|
|
|
buf2 = mem_heap_alloc(heap, n_fields
|
2006-08-29 09:30:31 +00:00
|
|
|
* DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE
|
2006-09-12 07:29:57 +00:00
|
|
|
+ dict_table_is_comp(index->table));
|
|
|
|
if (dict_table_is_comp(index->table)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
*buf2++ = 0; /* write the compact format indicator */
|
|
|
|
}
|
|
|
|
for (i = 0; i < n_fields; i++) {
|
2007-06-06 11:07:37 +00:00
|
|
|
ulint fixed_len;
|
|
|
|
const dict_field_t* ifield;
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* We add 4 below because we have the 4 extra fields at the
|
|
|
|
start of an ibuf record */
|
|
|
|
|
2006-10-19 07:27:26 +00:00
|
|
|
field = dtuple_get_nth_field(tuple, i + 4);
|
2005-10-27 07:29:40 +00:00
|
|
|
entry_field = dtuple_get_nth_field(entry, i);
|
|
|
|
dfield_copy(field, entry_field);
|
|
|
|
|
2007-06-06 11:07:37 +00:00
|
|
|
ifield = dict_index_get_nth_field(index, i);
|
|
|
|
/* Prefix index columns of fixed-length columns are of
|
|
|
|
fixed length. However, in the function call below,
|
|
|
|
dfield_get_type(entry_field) contains the fixed length
|
|
|
|
of the column in the clustered index. Replace it with
|
|
|
|
the fixed length of the secondary index column. */
|
|
|
|
fixed_len = ifield->fixed_len;
|
|
|
|
|
|
|
|
#ifdef UNIV_DEBUG
|
|
|
|
if (fixed_len) {
|
|
|
|
/* dict_index_add_col() should guarantee these */
|
2007-10-23 06:46:12 +00:00
|
|
|
ut_ad(fixed_len <= (ulint)
|
|
|
|
dfield_get_type(entry_field)->len);
|
2007-06-06 11:07:37 +00:00
|
|
|
if (ifield->prefix_len) {
|
|
|
|
ut_ad(ifield->prefix_len == fixed_len);
|
|
|
|
} else {
|
2007-10-23 06:46:12 +00:00
|
|
|
ut_ad(fixed_len == (ulint)
|
|
|
|
dfield_get_type(entry_field)->len);
|
2007-06-06 11:07:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* UNIV_DEBUG */
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
dtype_new_store_for_order_and_null_size(
|
|
|
|
buf2 + i * DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE,
|
2007-06-06 11:07:37 +00:00
|
|
|
dfield_get_type(entry_field), fixed_len);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Store the type info in buf2 to field 3 of tuple */
|
|
|
|
|
2006-10-19 07:27:26 +00:00
|
|
|
field = dtuple_get_nth_field(tuple, 3);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-12 07:29:57 +00:00
|
|
|
if (dict_table_is_comp(index->table)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
buf2--;
|
|
|
|
}
|
|
|
|
|
|
|
|
dfield_set_data(field, buf2, n_fields
|
2006-08-29 09:30:31 +00:00
|
|
|
* DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE
|
2006-09-12 07:29:57 +00:00
|
|
|
+ dict_table_is_comp(index->table));
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Set all the types in the new tuple binary */
|
|
|
|
|
|
|
|
dtuple_set_types_binary(tuple, n_fields + 4);
|
|
|
|
|
|
|
|
return(tuple);
|
2006-02-23 19:25:29 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Builds a search tuple used to search buffered inserts for an index page.
|
|
|
|
This is for < 4.1.x format records */
|
|
|
|
static
|
|
|
|
dtuple_t*
|
|
|
|
ibuf_search_tuple_build(
|
|
|
|
/*====================*/
|
|
|
|
/* out, own: search tuple */
|
|
|
|
ulint space, /* in: space id */
|
|
|
|
ulint page_no,/* in: index page number */
|
|
|
|
mem_heap_t* heap) /* in: heap into which to build */
|
|
|
|
{
|
|
|
|
dtuple_t* tuple;
|
|
|
|
dfield_t* field;
|
|
|
|
byte* buf;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_a(space == 0);
|
|
|
|
ut_a(trx_doublewrite_must_reset_space_ids);
|
|
|
|
ut_a(!trx_sys_multiple_tablespace_format);
|
|
|
|
|
|
|
|
tuple = dtuple_create(heap, 1);
|
|
|
|
|
|
|
|
/* Store the page number in tuple */
|
|
|
|
|
2006-10-19 07:27:26 +00:00
|
|
|
field = dtuple_get_nth_field(tuple, 0);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
buf = mem_heap_alloc(heap, 4);
|
|
|
|
|
|
|
|
mach_write_to_4(buf, page_no);
|
|
|
|
|
|
|
|
dfield_set_data(field, buf, 4);
|
|
|
|
|
|
|
|
dtuple_set_types_binary(tuple, 1);
|
|
|
|
|
|
|
|
return(tuple);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Builds a search tuple used to search buffered inserts for an index page.
|
|
|
|
This is for >= 4.1.x format records. */
|
|
|
|
static
|
|
|
|
dtuple_t*
|
|
|
|
ibuf_new_search_tuple_build(
|
|
|
|
/*========================*/
|
|
|
|
/* out, own: search tuple */
|
|
|
|
ulint space, /* in: space id */
|
|
|
|
ulint page_no,/* in: index page number */
|
|
|
|
mem_heap_t* heap) /* in: heap into which to build */
|
|
|
|
{
|
|
|
|
dtuple_t* tuple;
|
|
|
|
dfield_t* field;
|
|
|
|
byte* buf;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_a(trx_sys_multiple_tablespace_format);
|
|
|
|
|
|
|
|
tuple = dtuple_create(heap, 3);
|
|
|
|
|
|
|
|
/* Store the space id in tuple */
|
|
|
|
|
2006-10-19 07:27:26 +00:00
|
|
|
field = dtuple_get_nth_field(tuple, 0);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
buf = mem_heap_alloc(heap, 4);
|
|
|
|
|
|
|
|
mach_write_to_4(buf, space);
|
|
|
|
|
|
|
|
dfield_set_data(field, buf, 4);
|
|
|
|
|
|
|
|
/* Store the new format record marker byte */
|
|
|
|
|
2006-10-19 07:27:26 +00:00
|
|
|
field = dtuple_get_nth_field(tuple, 1);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
buf = mem_heap_alloc(heap, 1);
|
|
|
|
|
|
|
|
mach_write_to_1(buf, 0);
|
|
|
|
|
|
|
|
dfield_set_data(field, buf, 1);
|
|
|
|
|
|
|
|
/* Store the page number in tuple */
|
|
|
|
|
2006-10-19 07:27:26 +00:00
|
|
|
field = dtuple_get_nth_field(tuple, 2);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
buf = mem_heap_alloc(heap, 4);
|
|
|
|
|
|
|
|
mach_write_to_4(buf, page_no);
|
|
|
|
|
|
|
|
dfield_set_data(field, buf, 4);
|
|
|
|
|
|
|
|
dtuple_set_types_binary(tuple, 3);
|
|
|
|
|
|
|
|
return(tuple);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
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. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
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_data_enough_free_for_insert(void)
|
|
|
|
/*==================================*/
|
2005-10-27 07:29:40 +00:00
|
|
|
/* out: TRUE if enough free pages in list */
|
|
|
|
{
|
|
|
|
ut_ad(mutex_own(&ibuf_mutex));
|
|
|
|
|
|
|
|
/* We want a big margin of free pages, because a B-tree can sometimes
|
|
|
|
grow in size also if records are deleted from it, as the node pointers
|
|
|
|
can change, and we must make sure that we are able to delete the
|
|
|
|
inserts buffered for pages that we read to the buffer pool, without
|
|
|
|
any risk of running out of free space in the insert buffer. */
|
|
|
|
|
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
|
|
|
return(ibuf->free_list_len >= (ibuf->size / 2) + 3 * ibuf->height);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
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. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
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_data_too_much_free(void)
|
|
|
|
/*=========================*/
|
2005-10-27 07:29:40 +00:00
|
|
|
/* out: TRUE if enough free pages in list */
|
|
|
|
{
|
|
|
|
ut_ad(mutex_own(&ibuf_mutex));
|
|
|
|
|
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
|
|
|
return(ibuf->free_list_len >= 3 + (ibuf->size / 2) + 3 * ibuf->height);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Allocates a new page from the ibuf file segment and adds it to the free
|
|
|
|
list. */
|
|
|
|
static
|
|
|
|
ulint
|
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_add_free_page(void)
|
|
|
|
/*====================*/
|
2005-10-27 07:29:40 +00:00
|
|
|
/* out: DB_SUCCESS, or DB_STRONG_FAIL
|
|
|
|
if no space left */
|
|
|
|
{
|
|
|
|
mtr_t mtr;
|
|
|
|
page_t* header_page;
|
branches/zip: Implement the configuration parameter and settable global
variable innodb_file_format. Implement file format version stamping of
*.ibd files and SYS_TABLES.TYPE.
This change breaks introduces an incompatible change for for
compressed tables. We can do this, as we have not released yet.
innodb-zip.test: Add tests for stricter KEY_BLOCK_SIZE and ROW_FORMAT
checks.
DICT_TF_COMPRESSED_MASK, DICT_TF_COMPRESSED_SHIFT: Replace with
DICT_TF_ZSSIZE_MASK, DICT_TF_ZSSIZE_SHIFT.
DICT_TF_FORMAT_MASK, DICT_TF_FORMAT_SHIFT, DICT_TF_FORMAT_51,
DICT_TF_FORMAT_ZIP: File format version, stored in table->flags,
in the .ibd file header, and in SYS_TABLES.TYPE.
dict_create_sys_tables_tuple(): Write the table flags to SYS_TABLES.TYPE
if the format is at least DICT_TF_FORMAT_ZIP. For old formats
(DICT_TF_FORMAT_51), write DICT_TABLE_ORDINARY as the table type.
DB_TABLE_ZIP_NO_IBD: Remove the error code. The error handling is done
in ha_innodb.cc; as a failsafe measure, dict_build_table_def_step() will
silently clear the compression and format flags instead of returning this
error.
dict_mem_table_create(): Assert that no extra bits are set in the flags.
dict_sys_tables_get_zip_size(): Rename to dict_sys_tables_get_flags().
Check all flag bits, and return ULINT_UNDEFINED if the combination is
unsupported.
dict_boot(): Document the SYS_TABLES columns N_COLS and TYPE.
dict_table_get_format(), dict_table_set_format(),
dict_table_flags_to_zip_size(): New accessors to table->flags.
dtuple_convert_big_rec(): Introduce the auxiliary variables
local_len, local_prefix_len. Store a 768-byte prefix locally
if the file format is less than DICT_TF_FORMAT_ZIP.
dtuple_convert_back_big_rec(): Restore the columns.
srv_file_format: New variable: innodb_file_format.
fil_create_new_single_table_tablespace(): Replace the parameter zip_size
with table->flags.
fil_open_single_table_tablespace(): Replace the parameter zip_size_in_k
with table->flags. Check the flags.
fil_space_struct, fil_space_create(), fil_op_write_log():
Replace zip_size with flags.
fil_node_open_file(): Note a TODO item for InnoDB Hot Backup.
Check that the tablespace flags match.
fil_space_get_zip_size(): Rename to fil_space_get_flags(). Add a
wrapper for fil_space_get_zip_size().
fsp_header_get_flags(): New function.
fsp_header_init_fields(): Replace zip_size with flags.
FSP_SPACE_FLAGS: New name for the tablespace flags. This field used
to be called FSP_PAGE_ZIP_SIZE, or FSP_LOWEST_NO_WRITE. It has always
been written as 0 in MySQL/InnoDB versions 4.1 to 5.1.
MLOG_ZIP_FILE_CREATE: Rename to MLOG_FILE_CREATE2. Add a 32-bit
parameter for the tablespace flags.
ha_innobase::create(): Check the table attributes ROW_FORMAT and
KEY_BLOCK_SIZE. Issue errors if they are inappropriate, or warnings
if the inherited attributes (in ALTER TABLE) will be ignored.
PAGE_ZIP_MIN_SIZE_SHIFT: New constant: the 2-logarithm of PAGE_ZIP_MIN_SIZE.
2008-03-10 11:05:32 +00:00
|
|
|
ulint flags;
|
2007-01-18 09:59:00 +00:00
|
|
|
ulint zip_size;
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint page_no;
|
|
|
|
page_t* page;
|
|
|
|
page_t* root;
|
|
|
|
page_t* bitmap_page;
|
|
|
|
|
|
|
|
mtr_start(&mtr);
|
|
|
|
|
|
|
|
/* Acquire the fsp latch before the ibuf header, obeying the latching
|
|
|
|
order */
|
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
|
|
|
mtr_x_lock(fil_space_get_latch(IBUF_SPACE_ID, &flags), &mtr);
|
branches/zip: Implement the configuration parameter and settable global
variable innodb_file_format. Implement file format version stamping of
*.ibd files and SYS_TABLES.TYPE.
This change breaks introduces an incompatible change for for
compressed tables. We can do this, as we have not released yet.
innodb-zip.test: Add tests for stricter KEY_BLOCK_SIZE and ROW_FORMAT
checks.
DICT_TF_COMPRESSED_MASK, DICT_TF_COMPRESSED_SHIFT: Replace with
DICT_TF_ZSSIZE_MASK, DICT_TF_ZSSIZE_SHIFT.
DICT_TF_FORMAT_MASK, DICT_TF_FORMAT_SHIFT, DICT_TF_FORMAT_51,
DICT_TF_FORMAT_ZIP: File format version, stored in table->flags,
in the .ibd file header, and in SYS_TABLES.TYPE.
dict_create_sys_tables_tuple(): Write the table flags to SYS_TABLES.TYPE
if the format is at least DICT_TF_FORMAT_ZIP. For old formats
(DICT_TF_FORMAT_51), write DICT_TABLE_ORDINARY as the table type.
DB_TABLE_ZIP_NO_IBD: Remove the error code. The error handling is done
in ha_innodb.cc; as a failsafe measure, dict_build_table_def_step() will
silently clear the compression and format flags instead of returning this
error.
dict_mem_table_create(): Assert that no extra bits are set in the flags.
dict_sys_tables_get_zip_size(): Rename to dict_sys_tables_get_flags().
Check all flag bits, and return ULINT_UNDEFINED if the combination is
unsupported.
dict_boot(): Document the SYS_TABLES columns N_COLS and TYPE.
dict_table_get_format(), dict_table_set_format(),
dict_table_flags_to_zip_size(): New accessors to table->flags.
dtuple_convert_big_rec(): Introduce the auxiliary variables
local_len, local_prefix_len. Store a 768-byte prefix locally
if the file format is less than DICT_TF_FORMAT_ZIP.
dtuple_convert_back_big_rec(): Restore the columns.
srv_file_format: New variable: innodb_file_format.
fil_create_new_single_table_tablespace(): Replace the parameter zip_size
with table->flags.
fil_open_single_table_tablespace(): Replace the parameter zip_size_in_k
with table->flags. Check the flags.
fil_space_struct, fil_space_create(), fil_op_write_log():
Replace zip_size with flags.
fil_node_open_file(): Note a TODO item for InnoDB Hot Backup.
Check that the tablespace flags match.
fil_space_get_zip_size(): Rename to fil_space_get_flags(). Add a
wrapper for fil_space_get_zip_size().
fsp_header_get_flags(): New function.
fsp_header_init_fields(): Replace zip_size with flags.
FSP_SPACE_FLAGS: New name for the tablespace flags. This field used
to be called FSP_PAGE_ZIP_SIZE, or FSP_LOWEST_NO_WRITE. It has always
been written as 0 in MySQL/InnoDB versions 4.1 to 5.1.
MLOG_ZIP_FILE_CREATE: Rename to MLOG_FILE_CREATE2. Add a 32-bit
parameter for the tablespace flags.
ha_innobase::create(): Check the table attributes ROW_FORMAT and
KEY_BLOCK_SIZE. Issue errors if they are inappropriate, or warnings
if the inherited attributes (in ALTER TABLE) will be ignored.
PAGE_ZIP_MIN_SIZE_SHIFT: New constant: the 2-logarithm of PAGE_ZIP_MIN_SIZE.
2008-03-10 11:05:32 +00:00
|
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
2006-02-23 19:25: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
|
|
|
header_page = ibuf_header_page_get(&mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Allocate a new page: NOTE that if the page has been a part of a
|
|
|
|
non-clustered index which has subsequently been dropped, then the
|
|
|
|
page may have buffered inserts in the insert buffer, and these
|
|
|
|
should be deleted from there. These get deleted when the page
|
|
|
|
allocation creates the page in buffer. Thus the call below may end
|
|
|
|
up calling the insert buffer routines and, as we yet have no latches
|
|
|
|
to insert buffer tree pages, these routines can run without a risk
|
|
|
|
of a deadlock. This is the reason why we created a special ibuf
|
|
|
|
header page apart from the 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
|
|
|
page_no = fseg_alloc_free_page(
|
|
|
|
header_page + IBUF_HEADER + IBUF_TREE_SEG_HEADER, 0, FSP_UP,
|
|
|
|
&mtr);
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (page_no == FIL_NULL) {
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
|
|
|
|
return(DB_STRONG_FAIL);
|
|
|
|
}
|
|
|
|
|
2006-10-12 11:05:22 +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
|
|
|
buf_block_t* block;
|
|
|
|
|
|
|
|
block = buf_page_get(
|
|
|
|
IBUF_SPACE_ID, 0, page_no, RW_X_LATCH, &mtr);
|
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_dbg_add_level(block, SYNC_TREE_NODE_NEW);
|
2008-09-22 06:59:58 +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
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
page = buf_block_get_frame(block);
|
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ibuf_enter();
|
|
|
|
|
|
|
|
mutex_enter(&ibuf_mutex);
|
|
|
|
|
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
|
|
|
root = ibuf_tree_root_get(&mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Add the page to the free list and update the ibuf size data */
|
|
|
|
|
|
|
|
flst_add_last(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST,
|
2006-08-29 09:30:31 +00:00
|
|
|
page + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
mlog_write_ulint(page + FIL_PAGE_TYPE, FIL_PAGE_IBUF_FREE_LIST,
|
2006-08-29 09:30:31 +00:00
|
|
|
MLOG_2BYTES, &mtr);
|
2005-10-27 07:29:40 +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
|
|
|
ibuf->seg_size++;
|
|
|
|
ibuf->free_list_len++;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Set the bit indicating that this page is now an ibuf tree page
|
|
|
|
(level 2 page) */
|
|
|
|
|
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
|
|
|
bitmap_page = ibuf_bitmap_get_map_page(
|
|
|
|
IBUF_SPACE_ID, page_no, zip_size, &mtr);
|
|
|
|
|
|
|
|
ibuf_bitmap_page_set_bits(
|
|
|
|
bitmap_page, page_no, zip_size, IBUF_BITMAP_IBUF, TRUE, &mtr);
|
2006-06-06 07:42:04 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mtr_commit(&mtr);
|
|
|
|
|
|
|
|
mutex_exit(&ibuf_mutex);
|
|
|
|
|
|
|
|
ibuf_exit();
|
|
|
|
|
|
|
|
return(DB_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Removes a page from the free list and frees it to the fsp system. */
|
|
|
|
static
|
|
|
|
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_remove_free_page(void)
|
|
|
|
/*=======================*/
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
mtr_t mtr;
|
|
|
|
mtr_t mtr2;
|
|
|
|
page_t* header_page;
|
branches/zip: Implement the configuration parameter and settable global
variable innodb_file_format. Implement file format version stamping of
*.ibd files and SYS_TABLES.TYPE.
This change breaks introduces an incompatible change for for
compressed tables. We can do this, as we have not released yet.
innodb-zip.test: Add tests for stricter KEY_BLOCK_SIZE and ROW_FORMAT
checks.
DICT_TF_COMPRESSED_MASK, DICT_TF_COMPRESSED_SHIFT: Replace with
DICT_TF_ZSSIZE_MASK, DICT_TF_ZSSIZE_SHIFT.
DICT_TF_FORMAT_MASK, DICT_TF_FORMAT_SHIFT, DICT_TF_FORMAT_51,
DICT_TF_FORMAT_ZIP: File format version, stored in table->flags,
in the .ibd file header, and in SYS_TABLES.TYPE.
dict_create_sys_tables_tuple(): Write the table flags to SYS_TABLES.TYPE
if the format is at least DICT_TF_FORMAT_ZIP. For old formats
(DICT_TF_FORMAT_51), write DICT_TABLE_ORDINARY as the table type.
DB_TABLE_ZIP_NO_IBD: Remove the error code. The error handling is done
in ha_innodb.cc; as a failsafe measure, dict_build_table_def_step() will
silently clear the compression and format flags instead of returning this
error.
dict_mem_table_create(): Assert that no extra bits are set in the flags.
dict_sys_tables_get_zip_size(): Rename to dict_sys_tables_get_flags().
Check all flag bits, and return ULINT_UNDEFINED if the combination is
unsupported.
dict_boot(): Document the SYS_TABLES columns N_COLS and TYPE.
dict_table_get_format(), dict_table_set_format(),
dict_table_flags_to_zip_size(): New accessors to table->flags.
dtuple_convert_big_rec(): Introduce the auxiliary variables
local_len, local_prefix_len. Store a 768-byte prefix locally
if the file format is less than DICT_TF_FORMAT_ZIP.
dtuple_convert_back_big_rec(): Restore the columns.
srv_file_format: New variable: innodb_file_format.
fil_create_new_single_table_tablespace(): Replace the parameter zip_size
with table->flags.
fil_open_single_table_tablespace(): Replace the parameter zip_size_in_k
with table->flags. Check the flags.
fil_space_struct, fil_space_create(), fil_op_write_log():
Replace zip_size with flags.
fil_node_open_file(): Note a TODO item for InnoDB Hot Backup.
Check that the tablespace flags match.
fil_space_get_zip_size(): Rename to fil_space_get_flags(). Add a
wrapper for fil_space_get_zip_size().
fsp_header_get_flags(): New function.
fsp_header_init_fields(): Replace zip_size with flags.
FSP_SPACE_FLAGS: New name for the tablespace flags. This field used
to be called FSP_PAGE_ZIP_SIZE, or FSP_LOWEST_NO_WRITE. It has always
been written as 0 in MySQL/InnoDB versions 4.1 to 5.1.
MLOG_ZIP_FILE_CREATE: Rename to MLOG_FILE_CREATE2. Add a 32-bit
parameter for the tablespace flags.
ha_innobase::create(): Check the table attributes ROW_FORMAT and
KEY_BLOCK_SIZE. Issue errors if they are inappropriate, or warnings
if the inherited attributes (in ALTER TABLE) will be ignored.
PAGE_ZIP_MIN_SIZE_SHIFT: New constant: the 2-logarithm of PAGE_ZIP_MIN_SIZE.
2008-03-10 11:05:32 +00:00
|
|
|
ulint flags;
|
2007-01-18 09:59:00 +00:00
|
|
|
ulint zip_size;
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint page_no;
|
|
|
|
page_t* page;
|
|
|
|
page_t* root;
|
|
|
|
page_t* bitmap_page;
|
|
|
|
|
|
|
|
mtr_start(&mtr);
|
|
|
|
|
|
|
|
/* Acquire the fsp latch before the ibuf header, obeying the latching
|
|
|
|
order */
|
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
|
|
|
mtr_x_lock(fil_space_get_latch(IBUF_SPACE_ID, &flags), &mtr);
|
branches/zip: Implement the configuration parameter and settable global
variable innodb_file_format. Implement file format version stamping of
*.ibd files and SYS_TABLES.TYPE.
This change breaks introduces an incompatible change for for
compressed tables. We can do this, as we have not released yet.
innodb-zip.test: Add tests for stricter KEY_BLOCK_SIZE and ROW_FORMAT
checks.
DICT_TF_COMPRESSED_MASK, DICT_TF_COMPRESSED_SHIFT: Replace with
DICT_TF_ZSSIZE_MASK, DICT_TF_ZSSIZE_SHIFT.
DICT_TF_FORMAT_MASK, DICT_TF_FORMAT_SHIFT, DICT_TF_FORMAT_51,
DICT_TF_FORMAT_ZIP: File format version, stored in table->flags,
in the .ibd file header, and in SYS_TABLES.TYPE.
dict_create_sys_tables_tuple(): Write the table flags to SYS_TABLES.TYPE
if the format is at least DICT_TF_FORMAT_ZIP. For old formats
(DICT_TF_FORMAT_51), write DICT_TABLE_ORDINARY as the table type.
DB_TABLE_ZIP_NO_IBD: Remove the error code. The error handling is done
in ha_innodb.cc; as a failsafe measure, dict_build_table_def_step() will
silently clear the compression and format flags instead of returning this
error.
dict_mem_table_create(): Assert that no extra bits are set in the flags.
dict_sys_tables_get_zip_size(): Rename to dict_sys_tables_get_flags().
Check all flag bits, and return ULINT_UNDEFINED if the combination is
unsupported.
dict_boot(): Document the SYS_TABLES columns N_COLS and TYPE.
dict_table_get_format(), dict_table_set_format(),
dict_table_flags_to_zip_size(): New accessors to table->flags.
dtuple_convert_big_rec(): Introduce the auxiliary variables
local_len, local_prefix_len. Store a 768-byte prefix locally
if the file format is less than DICT_TF_FORMAT_ZIP.
dtuple_convert_back_big_rec(): Restore the columns.
srv_file_format: New variable: innodb_file_format.
fil_create_new_single_table_tablespace(): Replace the parameter zip_size
with table->flags.
fil_open_single_table_tablespace(): Replace the parameter zip_size_in_k
with table->flags. Check the flags.
fil_space_struct, fil_space_create(), fil_op_write_log():
Replace zip_size with flags.
fil_node_open_file(): Note a TODO item for InnoDB Hot Backup.
Check that the tablespace flags match.
fil_space_get_zip_size(): Rename to fil_space_get_flags(). Add a
wrapper for fil_space_get_zip_size().
fsp_header_get_flags(): New function.
fsp_header_init_fields(): Replace zip_size with flags.
FSP_SPACE_FLAGS: New name for the tablespace flags. This field used
to be called FSP_PAGE_ZIP_SIZE, or FSP_LOWEST_NO_WRITE. It has always
been written as 0 in MySQL/InnoDB versions 4.1 to 5.1.
MLOG_ZIP_FILE_CREATE: Rename to MLOG_FILE_CREATE2. Add a 32-bit
parameter for the tablespace flags.
ha_innobase::create(): Check the table attributes ROW_FORMAT and
KEY_BLOCK_SIZE. Issue errors if they are inappropriate, or warnings
if the inherited attributes (in ALTER TABLE) will be ignored.
PAGE_ZIP_MIN_SIZE_SHIFT: New constant: the 2-logarithm of PAGE_ZIP_MIN_SIZE.
2008-03-10 11:05:32 +00:00
|
|
|
zip_size = dict_table_flags_to_zip_size(flags);
|
2006-02-23 19:25: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
|
|
|
header_page = ibuf_header_page_get(&mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Prevent pessimistic inserts to insert buffer trees for a while */
|
|
|
|
mutex_enter(&ibuf_pessimistic_insert_mutex);
|
|
|
|
|
|
|
|
ibuf_enter();
|
|
|
|
|
|
|
|
mutex_enter(&ibuf_mutex);
|
|
|
|
|
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
|
|
|
if (!ibuf_data_too_much_free()) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mutex_exit(&ibuf_mutex);
|
|
|
|
|
|
|
|
ibuf_exit();
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mutex_exit(&ibuf_pessimistic_insert_mutex);
|
|
|
|
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mtr_start(&mtr2);
|
2006-02-23 19:25: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
|
|
|
root = ibuf_tree_root_get(&mtr2);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
page_no = flst_get_last(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST,
|
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
|
|
|
&mtr2).page;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* NOTE that we must release the latch on the ibuf tree root
|
|
|
|
because in fseg_free_page we access level 1 pages, and the root
|
|
|
|
is a level 2 page. */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mtr_commit(&mtr2);
|
|
|
|
mutex_exit(&ibuf_mutex);
|
|
|
|
|
|
|
|
ibuf_exit();
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Since pessimistic inserts were prevented, we know that the
|
|
|
|
page is still in the free list. NOTE that also deletes may take
|
|
|
|
pages from the free list, but they take them from the start, and
|
|
|
|
the free list was so long that they cannot have taken the last
|
|
|
|
page from it. */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
fseg_free_page(header_page + IBUF_HEADER + IBUF_TREE_SEG_HEADER,
|
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_SPACE_ID, page_no, &mtr);
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
#ifdef UNIV_DEBUG_FILE_ACCESSES
|
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
|
|
|
buf_page_reset_file_page_was_freed(IBUF_SPACE_ID, page_no);
|
2005-10-27 07:29:40 +00:00
|
|
|
#endif
|
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
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ibuf_enter();
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mutex_enter(&ibuf_mutex);
|
|
|
|
|
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
|
|
|
root = ibuf_tree_root_get(&mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ut_ad(page_no == flst_get_last(root + PAGE_HEADER
|
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
|
|
|
+ PAGE_BTR_IBUF_FREE_LIST, &mtr).page);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-10-12 11:05:22 +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
|
|
|
buf_block_t* block;
|
|
|
|
|
|
|
|
block = buf_page_get(
|
|
|
|
IBUF_SPACE_ID, 0, page_no, RW_X_LATCH, &mtr);
|
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
|
2008-09-22 06:59:58 +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
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
page = buf_block_get_frame(block);
|
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Remove the page from the free list and update the ibuf size data */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
flst_remove(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST,
|
2006-08-29 09:30:31 +00:00
|
|
|
page + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, &mtr);
|
2005-10-27 07:29:40 +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
|
|
|
ibuf->seg_size--;
|
|
|
|
ibuf->free_list_len--;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mutex_exit(&ibuf_pessimistic_insert_mutex);
|
|
|
|
|
|
|
|
/* Set the bit indicating that this page is no more an ibuf tree page
|
|
|
|
(level 2 page) */
|
|
|
|
|
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
|
|
|
bitmap_page = ibuf_bitmap_get_map_page(
|
|
|
|
IBUF_SPACE_ID, page_no, zip_size, &mtr);
|
|
|
|
|
|
|
|
ibuf_bitmap_page_set_bits(
|
|
|
|
bitmap_page, page_no, zip_size, IBUF_BITMAP_IBUF, FALSE, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
#ifdef UNIV_DEBUG_FILE_ACCESSES
|
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
|
|
|
buf_page_set_file_page_was_freed(IBUF_SPACE_ID, page_no);
|
2005-10-27 07:29:40 +00:00
|
|
|
#endif
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
|
|
|
|
mutex_exit(&ibuf_mutex);
|
|
|
|
|
|
|
|
ibuf_exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
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-06 14:17:36 +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)
|
|
|
|
/*========================*/
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
ulint i;
|
|
|
|
|
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
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
|
|
|
ut_ad(rw_lock_own(fil_space_get_latch(IBUF_SPACE_ID, NULL),
|
|
|
|
RW_LOCK_EX));
|
2005-10-27 07:29:40 +00:00
|
|
|
#endif /* UNIV_SYNC_DEBUG */
|
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
|
|
|
|
|
|
|
ut_ad(rw_lock_get_x_lock_count(
|
|
|
|
fil_space_get_latch(IBUF_SPACE_ID, NULL)) == 1);
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(!ibuf_inside());
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* NOTE: We require that the thread did not own the latch before,
|
|
|
|
because then we know that we can obey the correct latching order
|
|
|
|
for ibuf latches */
|
|
|
|
|
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
|
|
|
if (!ibuf) {
|
|
|
|
/* Not yet initialized; not sure if this is possible, but
|
|
|
|
does no harm to check for it. */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free at most a few pages at a time, so that we do not delay the
|
|
|
|
requested service too much */
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
|
|
|
|
mutex_enter(&ibuf_mutex);
|
|
|
|
|
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
|
|
|
if (!ibuf_data_too_much_free()) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mutex_exit(&ibuf_mutex);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mutex_exit(&ibuf_mutex);
|
|
|
|
|
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_remove_free_page();
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Reads page numbers from a leaf in an ibuf tree. */
|
|
|
|
static
|
|
|
|
ulint
|
|
|
|
ibuf_get_merge_page_nos(
|
|
|
|
/*====================*/
|
|
|
|
/* out: a lower limit for the combined volume
|
|
|
|
of records which will be merged */
|
|
|
|
ibool contract,/* in: TRUE if this function is called to
|
|
|
|
contract the tree, FALSE if this is called
|
|
|
|
when a single page becomes full and we look
|
|
|
|
if it pays to read also nearby pages */
|
|
|
|
rec_t* rec, /* in: record from which we read up and down
|
|
|
|
in the chain of records */
|
|
|
|
ulint* space_ids,/* in/out: space id's of the pages */
|
2008-03-17 14:19:04 +00:00
|
|
|
ib_int64_t* space_versions,/* in/out: tablespace version
|
2005-10-27 07:29:40 +00:00
|
|
|
timestamps; used to prevent reading in old
|
|
|
|
pages after DISCARD + IMPORT tablespace */
|
|
|
|
ulint* page_nos,/* in/out: buffer for at least
|
|
|
|
IBUF_MAX_N_PAGES_MERGED many page numbers;
|
|
|
|
the page numbers are in an ascending order */
|
|
|
|
ulint* n_stored)/* out: number of page numbers stored to
|
|
|
|
page_nos in this function */
|
|
|
|
{
|
|
|
|
ulint prev_page_no;
|
|
|
|
ulint prev_space_id;
|
|
|
|
ulint first_page_no;
|
|
|
|
ulint first_space_id;
|
|
|
|
ulint rec_page_no;
|
|
|
|
ulint rec_space_id;
|
|
|
|
ulint sum_volumes;
|
|
|
|
ulint volume_for_page;
|
|
|
|
ulint rec_volume;
|
|
|
|
ulint limit;
|
|
|
|
ulint n_pages;
|
|
|
|
|
|
|
|
*n_stored = 0;
|
|
|
|
|
|
|
|
limit = ut_min(IBUF_MAX_N_PAGES_MERGED, buf_pool->curr_size / 4);
|
|
|
|
|
|
|
|
if (page_rec_is_supremum(rec)) {
|
|
|
|
|
|
|
|
rec = page_rec_get_prev(rec);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (page_rec_is_infimum(rec)) {
|
|
|
|
|
|
|
|
rec = page_rec_get_next(rec);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (page_rec_is_supremum(rec)) {
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
first_page_no = ibuf_rec_get_page_no(rec);
|
|
|
|
first_space_id = ibuf_rec_get_space(rec);
|
|
|
|
n_pages = 0;
|
|
|
|
prev_page_no = 0;
|
|
|
|
prev_space_id = 0;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Go backwards from the first rec until we reach the border of the
|
|
|
|
'merge area', or the page start or the limit of storeable pages is
|
|
|
|
reached */
|
|
|
|
|
|
|
|
while (!page_rec_is_infimum(rec) && UNIV_LIKELY(n_pages < limit)) {
|
|
|
|
|
|
|
|
rec_page_no = ibuf_rec_get_page_no(rec);
|
|
|
|
rec_space_id = ibuf_rec_get_space(rec);
|
|
|
|
|
|
|
|
if (rec_space_id != first_space_id
|
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
|
|
|
|| (rec_page_no / IBUF_MERGE_AREA)
|
|
|
|
!= (first_page_no / IBUF_MERGE_AREA)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
break;
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (rec_page_no != prev_page_no
|
2006-08-29 09:30:31 +00:00
|
|
|
|| rec_space_id != prev_space_id) {
|
2005-10-27 07:29:40 +00:00
|
|
|
n_pages++;
|
|
|
|
}
|
|
|
|
|
|
|
|
prev_page_no = rec_page_no;
|
|
|
|
prev_space_id = rec_space_id;
|
|
|
|
|
|
|
|
rec = page_rec_get_prev(rec);
|
|
|
|
}
|
|
|
|
|
|
|
|
rec = page_rec_get_next(rec);
|
|
|
|
|
|
|
|
/* At the loop start there is no prev page; we mark this with a pair
|
|
|
|
of space id, page no (0, 0) for which there can never be entries in
|
|
|
|
the insert buffer */
|
|
|
|
|
|
|
|
prev_page_no = 0;
|
|
|
|
prev_space_id = 0;
|
|
|
|
sum_volumes = 0;
|
|
|
|
volume_for_page = 0;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
while (*n_stored < limit) {
|
|
|
|
if (page_rec_is_supremum(rec)) {
|
|
|
|
/* When no more records available, mark this with
|
|
|
|
another 'impossible' pair of space id, page no */
|
|
|
|
rec_page_no = 1;
|
|
|
|
rec_space_id = 0;
|
|
|
|
} else {
|
|
|
|
rec_page_no = ibuf_rec_get_page_no(rec);
|
|
|
|
rec_space_id = ibuf_rec_get_space(rec);
|
|
|
|
ut_ad(rec_page_no > IBUF_TREE_ROOT_PAGE_NO);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef UNIV_IBUF_DEBUG
|
|
|
|
ut_a(*n_stored < IBUF_MAX_N_PAGES_MERGED);
|
|
|
|
#endif
|
|
|
|
if ((rec_space_id != prev_space_id
|
2006-08-29 09:30:31 +00:00
|
|
|
|| rec_page_no != prev_page_no)
|
|
|
|
&& (prev_space_id != 0 || prev_page_no != 0)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if ((prev_page_no == first_page_no
|
2006-08-29 09:30:31 +00:00
|
|
|
&& prev_space_id == first_space_id)
|
|
|
|
|| contract
|
|
|
|
|| (volume_for_page
|
|
|
|
> ((IBUF_MERGE_THRESHOLD - 1)
|
|
|
|
* 4 * UNIV_PAGE_SIZE
|
|
|
|
/ IBUF_PAGE_SIZE_PER_FREE_SPACE)
|
|
|
|
/ IBUF_MERGE_THRESHOLD)) {
|
2006-02-23 19:25:29 +00:00
|
|
|
|
|
|
|
space_ids[*n_stored] = prev_space_id;
|
2005-10-27 07:29:40 +00:00
|
|
|
space_versions[*n_stored]
|
2006-08-29 09:30:31 +00:00
|
|
|
= fil_space_get_version(prev_space_id);
|
2005-10-27 07:29:40 +00:00
|
|
|
page_nos[*n_stored] = prev_page_no;
|
|
|
|
|
|
|
|
(*n_stored)++;
|
|
|
|
|
|
|
|
sum_volumes += volume_for_page;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rec_space_id != first_space_id
|
2006-08-29 09:30:31 +00:00
|
|
|
|| rec_page_no / IBUF_MERGE_AREA
|
|
|
|
!= first_page_no / IBUF_MERGE_AREA) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
break;
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
volume_for_page = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rec_page_no == 1 && rec_space_id == 0) {
|
|
|
|
/* Supremum record */
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
rec_volume = ibuf_rec_get_volume(rec);
|
|
|
|
|
|
|
|
volume_for_page += rec_volume;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
prev_page_no = rec_page_no;
|
|
|
|
prev_space_id = rec_space_id;
|
|
|
|
|
|
|
|
rec = page_rec_get_next(rec);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef UNIV_IBUF_DEBUG
|
|
|
|
ut_a(*n_stored <= IBUF_MAX_N_PAGES_MERGED);
|
|
|
|
#endif
|
2006-08-29 09:30:31 +00:00
|
|
|
#if 0
|
|
|
|
fprintf(stderr, "Ibuf merge batch %lu pages %lu volume\n",
|
|
|
|
*n_stored, sum_volumes);
|
|
|
|
#endif
|
2005-10-27 07:29:40 +00:00
|
|
|
return(sum_volumes);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Contracts insert buffer trees by reading pages to the buffer pool. */
|
|
|
|
static
|
|
|
|
ulint
|
|
|
|
ibuf_contract_ext(
|
|
|
|
/*==============*/
|
|
|
|
/* out: 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 */
|
|
|
|
ulint* n_pages,/* out: number of pages to which merged */
|
|
|
|
ibool sync) /* in: TRUE if the caller wants to wait for the
|
|
|
|
issued read with the highest tablespace address
|
|
|
|
to complete */
|
|
|
|
{
|
|
|
|
btr_pcur_t pcur;
|
|
|
|
ulint page_nos[IBUF_MAX_N_PAGES_MERGED];
|
|
|
|
ulint space_ids[IBUF_MAX_N_PAGES_MERGED];
|
2008-03-17 14:19:04 +00:00
|
|
|
ib_int64_t space_versions[IBUF_MAX_N_PAGES_MERGED];
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint n_stored;
|
|
|
|
ulint sum_sizes;
|
|
|
|
mtr_t mtr;
|
|
|
|
|
|
|
|
*n_pages = 0;
|
|
|
|
ut_ad(!ibuf_inside());
|
|
|
|
|
|
|
|
mutex_enter(&ibuf_mutex);
|
|
|
|
|
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
|
|
|
if (ibuf->empty) {
|
|
|
|
mutex_exit(&ibuf_mutex);
|
2006-02-23 19:25: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
|
|
|
return(0);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mtr_start(&mtr);
|
|
|
|
|
|
|
|
ibuf_enter();
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Open a cursor to a randomly chosen leaf of the tree, at a random
|
|
|
|
position within the leaf */
|
|
|
|
|
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
|
|
|
btr_pcur_open_at_rnd_pos(ibuf->index, BTR_SEARCH_LEAF, &pcur, &mtr);
|
2005-10-27 07:29:40 +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
|
|
|
if (page_get_n_recs(btr_pcur_get_page(&pcur)) == 0) {
|
|
|
|
/* When the ibuf tree is emptied completely, the last record
|
|
|
|
is removed using an optimistic delete and ibuf_size_update
|
|
|
|
is not called, causing ibuf->empty to remain FALSE. If we do
|
|
|
|
not reset it to TRUE here then database shutdown will hang
|
|
|
|
in the loop in ibuf_contract_for_n_pages. */
|
2005-10-27 07:29:40 +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
|
|
|
ibuf->empty = TRUE;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
ibuf_exit();
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
mtr_commit(&mtr);
|
|
|
|
btr_pcur_close(&pcur);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
mutex_exit(&ibuf_mutex);
|
|
|
|
|
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
|
|
|
return(0);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mutex_exit(&ibuf_mutex);
|
|
|
|
|
|
|
|
sum_sizes = ibuf_get_merge_page_nos(TRUE, btr_pcur_get_rec(&pcur),
|
2006-08-29 09:30:31 +00:00
|
|
|
space_ids, space_versions,
|
|
|
|
page_nos, &n_stored);
|
|
|
|
#if 0 /* defined UNIV_IBUF_DEBUG */
|
|
|
|
fprintf(stderr, "Ibuf contract sync %lu pages %lu volume %lu\n",
|
|
|
|
sync, n_stored, sum_sizes);
|
2005-10-27 07:29:40 +00:00
|
|
|
#endif
|
|
|
|
ibuf_exit();
|
|
|
|
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
btr_pcur_close(&pcur);
|
|
|
|
|
|
|
|
buf_read_ibuf_merge_pages(sync, space_ids, space_versions, page_nos,
|
2006-08-29 09:30:31 +00:00
|
|
|
n_stored);
|
2005-10-27 07:29:40 +00:00
|
|
|
*n_pages = n_stored;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
return(sum_sizes + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Contracts insert buffer trees by reading pages to the buffer pool. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
|
|
|
ibuf_contract(
|
|
|
|
/*==========*/
|
|
|
|
/* out: 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 */
|
|
|
|
ibool sync) /* in: TRUE if the caller wants to wait for the
|
|
|
|
issued read with the highest tablespace address
|
|
|
|
to complete */
|
|
|
|
{
|
|
|
|
ulint n_pages;
|
|
|
|
|
|
|
|
return(ibuf_contract_ext(&n_pages, sync));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Contracts insert buffer trees by reading pages to the buffer pool. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
|
|
|
ibuf_contract_for_n_pages(
|
|
|
|
/*======================*/
|
|
|
|
/* out: 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 */
|
|
|
|
ibool sync, /* in: TRUE if the caller wants to wait for the
|
|
|
|
issued read with the highest tablespace address
|
|
|
|
to complete */
|
|
|
|
ulint n_pages)/* in: try to read at least this many pages to
|
|
|
|
the buffer pool and merge the ibuf contents to
|
|
|
|
them */
|
|
|
|
{
|
|
|
|
ulint sum_bytes = 0;
|
2006-02-23 19:25:29 +00:00
|
|
|
ulint sum_pages = 0;
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint n_bytes;
|
|
|
|
ulint n_pag2;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
while (sum_pages < n_pages) {
|
|
|
|
n_bytes = ibuf_contract_ext(&n_pag2, sync);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (n_bytes == 0) {
|
|
|
|
return(sum_bytes);
|
|
|
|
}
|
|
|
|
|
|
|
|
sum_bytes += n_bytes;
|
|
|
|
sum_pages += n_pag2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return(sum_bytes);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Contract insert buffer trees after insert if they are too big. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
ibuf_contract_after_insert(
|
|
|
|
/*=======================*/
|
|
|
|
ulint entry_size) /* in: size of a record which was inserted
|
|
|
|
into an ibuf tree */
|
|
|
|
{
|
|
|
|
ibool sync;
|
|
|
|
ulint sum_sizes;
|
|
|
|
ulint size;
|
|
|
|
|
|
|
|
mutex_enter(&ibuf_mutex);
|
|
|
|
|
|
|
|
if (ibuf->size < ibuf->max_size + IBUF_CONTRACT_ON_INSERT_NON_SYNC) {
|
|
|
|
mutex_exit(&ibuf_mutex);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sync = FALSE;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (ibuf->size >= ibuf->max_size + IBUF_CONTRACT_ON_INSERT_SYNC) {
|
|
|
|
|
|
|
|
sync = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
mutex_exit(&ibuf_mutex);
|
|
|
|
|
|
|
|
/* Contract at least entry_size many bytes */
|
|
|
|
sum_sizes = 0;
|
|
|
|
size = 1;
|
|
|
|
|
|
|
|
while ((size > 0) && (sum_sizes < entry_size)) {
|
|
|
|
|
|
|
|
size = ibuf_contract(sync);
|
|
|
|
sum_sizes += size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Gets an upper limit for the combined size of entries buffered in the insert
|
|
|
|
buffer for a given page. */
|
2008-10-23 08:37:42 +00:00
|
|
|
static
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
|
|
|
ibuf_get_volume_buffered(
|
|
|
|
/*=====================*/
|
|
|
|
/* out: upper limit for the volume of
|
|
|
|
buffered inserts for the index page, in bytes;
|
|
|
|
we may also return UNIV_PAGE_SIZE, if the
|
|
|
|
entries for the index page span on several
|
|
|
|
pages in the insert buffer */
|
|
|
|
btr_pcur_t* pcur, /* in: pcur positioned at a place in an
|
|
|
|
insert buffer tree where we would insert an
|
|
|
|
entry for the index page whose number is
|
|
|
|
page_no, latch mode has to be BTR_MODIFY_PREV
|
|
|
|
or BTR_MODIFY_TREE */
|
|
|
|
ulint space, /* in: space id */
|
|
|
|
ulint page_no,/* in: page number of an index page */
|
|
|
|
mtr_t* mtr) /* in: mtr */
|
|
|
|
{
|
|
|
|
ulint volume;
|
|
|
|
rec_t* rec;
|
|
|
|
page_t* page;
|
|
|
|
ulint prev_page_no;
|
|
|
|
page_t* prev_page;
|
|
|
|
ulint next_page_no;
|
|
|
|
page_t* next_page;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_a(trx_sys_multiple_tablespace_format);
|
|
|
|
|
|
|
|
ut_ad((pcur->latch_mode == BTR_MODIFY_PREV)
|
2006-08-29 09:30:31 +00:00
|
|
|
|| (pcur->latch_mode == BTR_MODIFY_TREE));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Count the volume of records earlier in the alphabetical order than
|
|
|
|
pcur */
|
|
|
|
|
|
|
|
volume = 0;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
rec = btr_pcur_get_rec(pcur);
|
2006-10-09 16:22:47 +00:00
|
|
|
page = page_align(rec);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if (page_rec_is_supremum(rec)) {
|
|
|
|
rec = page_rec_get_prev(rec);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
if (page_rec_is_infimum(rec)) {
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (page_no != ibuf_rec_get_page_no(rec)
|
2006-08-29 09:30:31 +00:00
|
|
|
|| space != ibuf_rec_get_space(rec)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
goto count_later;
|
|
|
|
}
|
|
|
|
|
|
|
|
volume += ibuf_rec_get_volume(rec);
|
|
|
|
|
|
|
|
rec = page_rec_get_prev(rec);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Look at the previous page */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
prev_page_no = btr_page_get_prev(page, mtr);
|
|
|
|
|
|
|
|
if (prev_page_no == FIL_NULL) {
|
|
|
|
|
|
|
|
goto count_later;
|
|
|
|
}
|
|
|
|
|
2006-10-12 11:05:22 +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
|
|
|
buf_block_t* block;
|
|
|
|
|
|
|
|
block = buf_page_get(
|
|
|
|
IBUF_SPACE_ID, 0, prev_page_no, RW_X_LATCH, mtr);
|
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
|
2008-09-22 06:59:58 +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
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
prev_page = buf_block_get_frame(block);
|
|
|
|
}
|
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
|
|
|
|
2006-05-11 17:00:43 +00:00
|
|
|
#ifdef UNIV_BTR_DEBUG
|
|
|
|
ut_a(btr_page_get_next(prev_page, mtr)
|
2006-10-12 07:02:36 +00:00
|
|
|
== page_get_page_no(page));
|
2006-05-11 17:00:43 +00:00
|
|
|
#endif /* UNIV_BTR_DEBUG */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
rec = page_get_supremum_rec(prev_page);
|
|
|
|
rec = page_rec_get_prev(rec);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
for (;;) {
|
|
|
|
if (page_rec_is_infimum(rec)) {
|
|
|
|
|
|
|
|
/* We cannot go to yet a previous page, because we
|
|
|
|
do not have the x-latch on it, and cannot acquire one
|
|
|
|
because of the latching order: we have to give up */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
return(UNIV_PAGE_SIZE);
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (page_no != ibuf_rec_get_page_no(rec)
|
2006-08-29 09:30:31 +00:00
|
|
|
|| space != ibuf_rec_get_space(rec)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
goto count_later;
|
|
|
|
}
|
|
|
|
|
|
|
|
volume += ibuf_rec_get_volume(rec);
|
|
|
|
|
|
|
|
rec = page_rec_get_prev(rec);
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
count_later:
|
|
|
|
rec = btr_pcur_get_rec(pcur);
|
|
|
|
|
|
|
|
if (!page_rec_is_supremum(rec)) {
|
|
|
|
rec = page_rec_get_next(rec);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
if (page_rec_is_supremum(rec)) {
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (page_no != ibuf_rec_get_page_no(rec)
|
2006-08-29 09:30:31 +00:00
|
|
|
|| space != ibuf_rec_get_space(rec)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
return(volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
volume += ibuf_rec_get_volume(rec);
|
|
|
|
|
|
|
|
rec = page_rec_get_next(rec);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Look at the next page */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
next_page_no = btr_page_get_next(page, mtr);
|
|
|
|
|
|
|
|
if (next_page_no == FIL_NULL) {
|
|
|
|
|
|
|
|
return(volume);
|
|
|
|
}
|
|
|
|
|
2006-10-12 11:05:22 +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
|
|
|
buf_block_t* block;
|
|
|
|
|
|
|
|
block = buf_page_get(
|
|
|
|
IBUF_SPACE_ID, 0, next_page_no, RW_X_LATCH, mtr);
|
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
|
2008-09-22 06:59:58 +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
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
next_page = buf_block_get_frame(block);
|
|
|
|
}
|
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
|
|
|
|
2006-05-11 17:00:43 +00:00
|
|
|
#ifdef UNIV_BTR_DEBUG
|
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
|
|
|
ut_a(btr_page_get_prev(next_page, mtr) == page_get_page_no(page));
|
2006-05-11 17:00:43 +00:00
|
|
|
#endif /* UNIV_BTR_DEBUG */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
rec = page_get_infimum_rec(next_page);
|
|
|
|
rec = page_rec_get_next(rec);
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
if (page_rec_is_supremum(rec)) {
|
|
|
|
|
|
|
|
/* We give up */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
return(UNIV_PAGE_SIZE);
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (page_no != ibuf_rec_get_page_no(rec)
|
2006-08-29 09:30:31 +00:00
|
|
|
|| space != ibuf_rec_get_space(rec)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
return(volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
volume += ibuf_rec_get_volume(rec);
|
|
|
|
|
|
|
|
rec = page_rec_get_next(rec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Reads the biggest tablespace id from the high end of the insert buffer
|
|
|
|
tree and updates the counter in fil_system. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
ibuf_update_max_tablespace_id(void)
|
|
|
|
/*===============================*/
|
|
|
|
{
|
|
|
|
ulint max_space_id;
|
2006-10-26 08:52:14 +00:00
|
|
|
const rec_t* rec;
|
|
|
|
const byte* field;
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint len;
|
|
|
|
btr_pcur_t pcur;
|
|
|
|
mtr_t mtr;
|
|
|
|
|
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
|
|
|
ut_a(!dict_table_is_comp(ibuf->index->table));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ibuf_enter();
|
|
|
|
|
|
|
|
mtr_start(&mtr);
|
|
|
|
|
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
|
|
|
btr_pcur_open_at_index_side(
|
|
|
|
FALSE, ibuf->index, BTR_SEARCH_LEAF, &pcur, TRUE, &mtr);
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
btr_pcur_move_to_prev(&pcur, &mtr);
|
|
|
|
|
2007-10-22 08:16:35 +00:00
|
|
|
if (btr_pcur_is_before_first_on_page(&pcur)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
/* The tree is empty */
|
|
|
|
|
|
|
|
max_space_id = 0;
|
|
|
|
} else {
|
|
|
|
rec = btr_pcur_get_rec(&pcur);
|
|
|
|
|
|
|
|
field = rec_get_nth_field_old(rec, 0, &len);
|
|
|
|
|
|
|
|
ut_a(len == 4);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
max_space_id = mach_read_from_4(field);
|
|
|
|
}
|
|
|
|
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
ibuf_exit();
|
|
|
|
|
|
|
|
/* printf("Maximum space id in insert buffer %lu\n", max_space_id); */
|
|
|
|
|
|
|
|
fil_set_max_space_id_if_bigger(max_space_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Makes an index insert to the insert buffer, instead of directly to the disk
|
|
|
|
page, if this is possible. */
|
|
|
|
static
|
|
|
|
ulint
|
|
|
|
ibuf_insert_low(
|
|
|
|
/*============*/
|
|
|
|
/* out: DB_SUCCESS, DB_FAIL, DB_STRONG_FAIL */
|
|
|
|
ulint mode, /* in: BTR_MODIFY_PREV or BTR_MODIFY_TREE */
|
2006-10-20 08:30:07 +00:00
|
|
|
const dtuple_t* entry, /* in: index entry to insert */
|
2007-10-12 10:48:35 +00:00
|
|
|
ulint entry_size,
|
|
|
|
/* in: rec_get_converted_size(index, entry) */
|
2005-10-27 07:29:40 +00:00
|
|
|
dict_index_t* index, /* in: index where to insert; must not be
|
|
|
|
unique or clustered */
|
|
|
|
ulint space, /* in: space id where to insert */
|
2006-10-19 11:07:50 +00:00
|
|
|
ulint zip_size,/* in: compressed page size in bytes, or 0 */
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint page_no,/* in: page number where to insert */
|
|
|
|
que_thr_t* thr) /* in: query thread */
|
|
|
|
{
|
|
|
|
big_rec_t* dummy_big_rec;
|
|
|
|
btr_pcur_t pcur;
|
|
|
|
btr_cur_t* cursor;
|
|
|
|
dtuple_t* ibuf_entry;
|
|
|
|
mem_heap_t* heap;
|
|
|
|
ulint buffered;
|
|
|
|
rec_t* ins_rec;
|
|
|
|
ibool old_bit_value;
|
|
|
|
page_t* bitmap_page;
|
|
|
|
page_t* root;
|
|
|
|
ulint err;
|
|
|
|
ibool do_merge;
|
|
|
|
ulint space_ids[IBUF_MAX_N_PAGES_MERGED];
|
2008-03-17 14:19:04 +00:00
|
|
|
ib_int64_t space_versions[IBUF_MAX_N_PAGES_MERGED];
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint page_nos[IBUF_MAX_N_PAGES_MERGED];
|
|
|
|
ulint n_stored;
|
|
|
|
ulint bits;
|
|
|
|
mtr_t mtr;
|
|
|
|
mtr_t bitmap_mtr;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-03-09 17:26:02 +00:00
|
|
|
ut_a(!dict_index_is_clust(index));
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(dtuple_check_typed(entry));
|
2007-10-12 08:38:49 +00:00
|
|
|
ut_ad(ut_is_2pow(zip_size));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ut_a(trx_sys_multiple_tablespace_format);
|
|
|
|
|
|
|
|
do_merge = FALSE;
|
|
|
|
|
|
|
|
mutex_enter(&ibuf_mutex);
|
|
|
|
|
|
|
|
if (ibuf->size >= ibuf->max_size + IBUF_CONTRACT_DO_NOT_INSERT) {
|
|
|
|
/* Insert buffer is now too big, contract it but do not try
|
|
|
|
to insert */
|
|
|
|
|
|
|
|
mutex_exit(&ibuf_mutex);
|
|
|
|
|
|
|
|
#ifdef UNIV_IBUF_DEBUG
|
|
|
|
fputs("Ibuf too big\n", stderr);
|
2006-02-23 19:25:29 +00:00
|
|
|
#endif
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Use synchronous contract (== TRUE) */
|
|
|
|
ibuf_contract(TRUE);
|
|
|
|
|
|
|
|
return(DB_STRONG_FAIL);
|
|
|
|
}
|
|
|
|
|
|
|
|
mutex_exit(&ibuf_mutex);
|
|
|
|
|
|
|
|
if (mode == BTR_MODIFY_TREE) {
|
|
|
|
mutex_enter(&ibuf_pessimistic_insert_mutex);
|
|
|
|
|
|
|
|
ibuf_enter();
|
|
|
|
|
|
|
|
mutex_enter(&ibuf_mutex);
|
|
|
|
|
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
|
|
|
while (!ibuf_data_enough_free_for_insert()) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mutex_exit(&ibuf_mutex);
|
|
|
|
|
|
|
|
ibuf_exit();
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mutex_exit(&ibuf_pessimistic_insert_mutex);
|
|
|
|
|
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
|
|
|
err = ibuf_add_free_page();
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if (err == DB_STRONG_FAIL) {
|
|
|
|
|
|
|
|
return(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
mutex_enter(&ibuf_pessimistic_insert_mutex);
|
|
|
|
|
|
|
|
ibuf_enter();
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mutex_enter(&ibuf_mutex);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ibuf_enter();
|
|
|
|
}
|
|
|
|
|
|
|
|
heap = mem_heap_create(512);
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
/* Build the entry which contains the space id and the page number as
|
2005-10-27 07:29:40 +00:00
|
|
|
the first fields and the type information for other fields, and which
|
|
|
|
will be inserted to the insert buffer. */
|
|
|
|
|
2006-09-12 07:29:57 +00:00
|
|
|
ibuf_entry = ibuf_entry_build(index, entry, space, page_no, heap);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Open a cursor to the insert buffer tree to calculate if we can add
|
|
|
|
the new entry to it without exceeding the free space limit for the
|
|
|
|
page. */
|
|
|
|
|
|
|
|
mtr_start(&mtr);
|
|
|
|
|
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
|
|
|
btr_pcur_open(ibuf->index, ibuf_entry, PAGE_CUR_LE, mode, &pcur, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Find out the volume of already buffered inserts for the same index
|
|
|
|
page */
|
|
|
|
buffered = ibuf_get_volume_buffered(&pcur, space, page_no, &mtr);
|
|
|
|
|
2007-02-27 11:56:38 +00:00
|
|
|
#ifdef UNIV_IBUF_COUNT_DEBUG
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_a((buffered == 0) || ibuf_count_get(space, page_no));
|
|
|
|
#endif
|
2006-02-23 19:25:29 +00:00
|
|
|
mtr_start(&bitmap_mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
bitmap_page = ibuf_bitmap_get_map_page(space, page_no,
|
|
|
|
zip_size, &bitmap_mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* We check if the index page is suitable for buffered entries */
|
|
|
|
|
|
|
|
if (buf_page_peek(space, page_no)
|
2006-08-29 09:30:31 +00:00
|
|
|
|| lock_rec_expl_exist_on_page(space, page_no)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
err = DB_STRONG_FAIL;
|
|
|
|
|
|
|
|
mtr_commit(&bitmap_mtr);
|
|
|
|
|
|
|
|
goto function_exit;
|
|
|
|
}
|
|
|
|
|
2006-06-06 07:42:04 +00:00
|
|
|
bits = ibuf_bitmap_page_get_bits(bitmap_page, page_no, zip_size,
|
2006-08-29 09:30:31 +00:00
|
|
|
IBUF_BITMAP_FREE, &bitmap_mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if (buffered + entry_size + page_dir_calc_reserved_space(1)
|
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
|
|
|
> ibuf_index_page_calc_free_from_bits(zip_size, bits)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
mtr_commit(&bitmap_mtr);
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
/* It may not fit */
|
2005-10-27 07:29:40 +00:00
|
|
|
err = DB_STRONG_FAIL;
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
do_merge = TRUE;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ibuf_get_merge_page_nos(FALSE, btr_pcur_get_rec(&pcur),
|
|
|
|
space_ids, space_versions,
|
|
|
|
page_nos, &n_stored);
|
|
|
|
goto function_exit;
|
2006-02-23 19:25:29 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Set the bitmap bit denoting that the insert buffer contains
|
|
|
|
buffered entries for this index page, if the bit is not set yet */
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
old_bit_value = ibuf_bitmap_page_get_bits(
|
|
|
|
bitmap_page, page_no, zip_size,
|
|
|
|
IBUF_BITMAP_BUFFERED, &bitmap_mtr);
|
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
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (!old_bit_value) {
|
2006-06-06 07:42:04 +00:00
|
|
|
ibuf_bitmap_page_set_bits(bitmap_page, page_no, zip_size,
|
2006-08-29 09:30:31 +00:00
|
|
|
IBUF_BITMAP_BUFFERED, TRUE,
|
|
|
|
&bitmap_mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mtr_commit(&bitmap_mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
cursor = btr_pcur_get_btr_cur(&pcur);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (mode == BTR_MODIFY_PREV) {
|
|
|
|
err = btr_cur_optimistic_insert(BTR_NO_LOCKING_FLAG, cursor,
|
|
|
|
ibuf_entry, &ins_rec,
|
branches/zip: Make merge sort handle externally stored columns.
Some things still fail in innodb-index.test, and there seems to be
a race condition (data dictionary lock wait) when running with --valgrind.
dfield_t: Add an "external storage" flag, dfield->ext.
dfield_is_null(), dfield_is_ext(), dfield_set_ext(), dfield_set_null():
New functions.
dfield_copy(), dfield_copy_data(): Add const qualifiers, fix in/out comments.
data_write_sql_null(): Use memset().
big_rec_field_t: Replace byte* data with const void* data.
ut_ulint_sort(): Remove.
upd_field_t: Remove extern_storage.
upd_node_t: Replace ext_vec, n_ext_vec with n_ext.
row_merge_copy_blobs(): New function.
row_ins_index_entry(): Add the parameter "ibool foreign" for suppressing
foreign key checks during fast index creation or when inserting into
secondary indexes.
btr_page_insert_fits(): Add const qualifiers.
btr_cur_add_ext(), upd_ext_vec_contains(): Remove.
dfield_print_also_hex(), dfield_print(): Replace if...else if with switch.
Observe dfield_is_ext().
2007-06-21 09:43:15 +00:00
|
|
|
&dummy_big_rec, 0, thr, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (err == DB_SUCCESS) {
|
|
|
|
/* Update the page max trx id field */
|
2006-10-23 18:26:10 +00:00
|
|
|
page_update_max_trx_id(btr_cur_get_block(cursor), NULL,
|
2006-08-29 09:30:31 +00:00
|
|
|
thr_get_trx(thr)->id);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ut_ad(mode == BTR_MODIFY_TREE);
|
|
|
|
|
|
|
|
/* We acquire an x-latch to the root page before the insert,
|
|
|
|
because a pessimistic insert releases the tree x-latch,
|
|
|
|
which would cause the x-latching of the root after that to
|
|
|
|
break the latching order. */
|
2006-02-23 19:25: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
|
|
|
root = ibuf_tree_root_get(&mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
err = btr_cur_pessimistic_insert(BTR_NO_LOCKING_FLAG
|
|
|
|
| BTR_NO_UNDO_LOG_FLAG,
|
2006-08-29 09:30:31 +00:00
|
|
|
cursor,
|
|
|
|
ibuf_entry, &ins_rec,
|
branches/zip: Make merge sort handle externally stored columns.
Some things still fail in innodb-index.test, and there seems to be
a race condition (data dictionary lock wait) when running with --valgrind.
dfield_t: Add an "external storage" flag, dfield->ext.
dfield_is_null(), dfield_is_ext(), dfield_set_ext(), dfield_set_null():
New functions.
dfield_copy(), dfield_copy_data(): Add const qualifiers, fix in/out comments.
data_write_sql_null(): Use memset().
big_rec_field_t: Replace byte* data with const void* data.
ut_ulint_sort(): Remove.
upd_field_t: Remove extern_storage.
upd_node_t: Replace ext_vec, n_ext_vec with n_ext.
row_merge_copy_blobs(): New function.
row_ins_index_entry(): Add the parameter "ibool foreign" for suppressing
foreign key checks during fast index creation or when inserting into
secondary indexes.
btr_page_insert_fits(): Add const qualifiers.
btr_cur_add_ext(), upd_ext_vec_contains(): Remove.
dfield_print_also_hex(), dfield_print(): Replace if...else if with switch.
Observe dfield_is_ext().
2007-06-21 09:43:15 +00:00
|
|
|
&dummy_big_rec, 0, thr, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (err == DB_SUCCESS) {
|
|
|
|
/* Update the page max trx id field */
|
2006-10-23 18:26:10 +00:00
|
|
|
page_update_max_trx_id(btr_cur_get_block(cursor), NULL,
|
2006-08-29 09:30:31 +00:00
|
|
|
thr_get_trx(thr)->id);
|
2005-10-27 07:29:40 +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
|
|
|
ibuf_size_update(root, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function_exit:
|
2007-02-27 11:56:38 +00:00
|
|
|
#ifdef UNIV_IBUF_COUNT_DEBUG
|
2005-10-27 07:29:40 +00:00
|
|
|
if (err == DB_SUCCESS) {
|
2006-08-29 09:30:31 +00:00
|
|
|
fprintf(stderr,
|
|
|
|
"Incrementing ibuf count of space %lu page %lu\n"
|
|
|
|
"from %lu by 1\n", space, page_no,
|
|
|
|
ibuf_count_get(space, page_no));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ibuf_count_set(space, page_no,
|
2006-08-29 09:30:31 +00:00
|
|
|
ibuf_count_get(space, page_no) + 1);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
#endif
|
2006-02-23 19:25:29 +00:00
|
|
|
if (mode == BTR_MODIFY_TREE) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mutex_exit(&ibuf_mutex);
|
|
|
|
mutex_exit(&ibuf_pessimistic_insert_mutex);
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mtr_commit(&mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
btr_pcur_close(&pcur);
|
2005-10-27 07:29:40 +00:00
|
|
|
ibuf_exit();
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
mem_heap_free(heap);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if (err == DB_SUCCESS) {
|
2008-10-21 06:16:45 +00:00
|
|
|
mutex_enter(&ibuf_mutex);
|
|
|
|
|
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->empty = FALSE;
|
|
|
|
ibuf->n_inserts++;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2008-10-21 06:16:45 +00:00
|
|
|
mutex_exit(&ibuf_mutex);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2008-10-21 07:04:06 +00:00
|
|
|
if (mode == BTR_MODIFY_TREE) {
|
|
|
|
ibuf_contract_after_insert(entry_size);
|
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (do_merge) {
|
|
|
|
#ifdef UNIV_IBUF_DEBUG
|
|
|
|
ut_a(n_stored <= IBUF_MAX_N_PAGES_MERGED);
|
|
|
|
#endif
|
|
|
|
buf_read_ibuf_merge_pages(FALSE, space_ids, space_versions,
|
2006-08-29 09:30:31 +00:00
|
|
|
page_nos, n_stored);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
return(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
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
|
|
|
|
or unique. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
ibuf_insert(
|
|
|
|
/*========*/
|
|
|
|
/* out: TRUE if success */
|
2006-10-20 08:30:07 +00:00
|
|
|
const dtuple_t* entry, /* in: index entry to insert */
|
2005-10-27 07:29:40 +00:00
|
|
|
dict_index_t* index, /* in: index where to insert */
|
|
|
|
ulint space, /* in: space id where to insert */
|
2006-10-19 11:07:50 +00:00
|
|
|
ulint zip_size,/* in: compressed page size in bytes, or 0 */
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint page_no,/* in: page number where to insert */
|
|
|
|
que_thr_t* thr) /* in: query thread */
|
|
|
|
{
|
|
|
|
ulint err;
|
2007-10-12 10:48:35 +00:00
|
|
|
ulint entry_size;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ut_a(trx_sys_multiple_tablespace_format);
|
|
|
|
ut_ad(dtuple_check_typed(entry));
|
2007-10-12 08:38:49 +00:00
|
|
|
ut_ad(ut_is_2pow(zip_size));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-03-09 17:26:02 +00:00
|
|
|
ut_a(!dict_index_is_clust(index));
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2007-10-12 10:48:35 +00:00
|
|
|
entry_size = rec_get_converted_size(index, entry, 0);
|
|
|
|
|
|
|
|
if (entry_size
|
2006-08-29 09:30:31 +00:00
|
|
|
>= (page_get_free_space_of_empty(dict_table_is_comp(index->table))
|
|
|
|
/ 2)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
return(FALSE);
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2007-10-12 10:48:35 +00:00
|
|
|
err = ibuf_insert_low(BTR_MODIFY_PREV, entry, entry_size,
|
|
|
|
index, space, zip_size, page_no, thr);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (err == DB_FAIL) {
|
2007-10-12 10:48:35 +00:00
|
|
|
err = ibuf_insert_low(BTR_MODIFY_TREE, entry, entry_size,
|
|
|
|
index, space, zip_size, page_no, thr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (err == DB_SUCCESS) {
|
|
|
|
#ifdef UNIV_IBUF_DEBUG
|
|
|
|
/* fprintf(stderr, "Ibuf insert for page no %lu of index %s\n",
|
2006-08-29 09:30:31 +00:00
|
|
|
page_no, index->name); */
|
2005-10-27 07:29:40 +00:00
|
|
|
#endif
|
|
|
|
return(TRUE);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
ut_a(err == DB_STRONG_FAIL);
|
|
|
|
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/************************************************************************
|
|
|
|
During merge, inserts to an index page a secondary index entry extracted
|
|
|
|
from the insert buffer. */
|
|
|
|
static
|
|
|
|
void
|
|
|
|
ibuf_insert_to_index_page(
|
|
|
|
/*======================*/
|
|
|
|
dtuple_t* entry, /* in: buffered entry to insert */
|
2006-10-18 11:39:31 +00:00
|
|
|
buf_block_t* block, /* in/out: index page where the buffered entry
|
2005-10-27 07:29:40 +00:00
|
|
|
should be placed */
|
|
|
|
dict_index_t* index, /* in: record descriptor */
|
|
|
|
mtr_t* mtr) /* in: mtr */
|
|
|
|
{
|
|
|
|
page_cur_t page_cur;
|
|
|
|
ulint low_match;
|
2006-10-18 11:39:31 +00:00
|
|
|
page_t* page = buf_block_get_frame(block);
|
2005-10-27 07:29:40 +00:00
|
|
|
rec_t* rec;
|
|
|
|
page_t* bitmap_page;
|
|
|
|
ulint old_bits;
|
|
|
|
|
|
|
|
ut_ad(ibuf_inside());
|
|
|
|
ut_ad(dtuple_check_typed(entry));
|
|
|
|
|
2006-02-27 09:33:26 +00:00
|
|
|
if (UNIV_UNLIKELY(dict_table_is_comp(index->table)
|
2006-08-29 09:30:31 +00:00
|
|
|
!= (ibool)!!page_is_comp(page))) {
|
|
|
|
fputs("InnoDB: Trying to insert a record from"
|
|
|
|
" the insert buffer to an index page\n"
|
|
|
|
"InnoDB: but the 'compact' flag does not match!\n",
|
|
|
|
stderr);
|
2005-10-27 07:29:40 +00:00
|
|
|
goto dump;
|
|
|
|
}
|
|
|
|
|
|
|
|
rec = page_rec_get_next(page_get_infimum_rec(page));
|
|
|
|
|
|
|
|
if (UNIV_UNLIKELY(rec_get_n_fields(rec, index)
|
2006-08-29 09:30:31 +00:00
|
|
|
!= dtuple_get_n_fields(entry))) {
|
|
|
|
fputs("InnoDB: Trying to insert a record from"
|
|
|
|
" the insert buffer to an index page\n"
|
|
|
|
"InnoDB: but the number of fields does not match!\n",
|
|
|
|
stderr);
|
|
|
|
dump:
|
2006-05-02 11:44:39 +00:00
|
|
|
buf_page_print(page, 0);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
dtuple_print(stderr, entry);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-08-29 09:30:31 +00:00
|
|
|
fputs("InnoDB: The table where where"
|
|
|
|
" this index record belongs\n"
|
|
|
|
"InnoDB: is now probably corrupt."
|
|
|
|
" Please run CHECK TABLE on\n"
|
|
|
|
"InnoDB: your tables.\n"
|
|
|
|
"InnoDB: Submit a detailed bug report to"
|
|
|
|
" http://bugs.mysql.com!\n", stderr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-10-20 12:45:53 +00:00
|
|
|
low_match = page_cur_search(block, index, entry,
|
2006-08-29 09:30:31 +00:00
|
|
|
PAGE_CUR_LE, &page_cur);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (low_match == dtuple_get_n_fields(entry)) {
|
2007-11-29 12:23:48 +00:00
|
|
|
page_zip_des_t* page_zip;
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
rec = page_cur_get_rec(&page_cur);
|
2007-11-29 12:23:48 +00:00
|
|
|
page_zip = buf_block_get_page_zip(block);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2007-11-29 12:23:48 +00:00
|
|
|
btr_cur_del_unmark_for_ibuf(rec, page_zip, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
} else {
|
branches/zip: Make merge sort handle externally stored columns.
Some things still fail in innodb-index.test, and there seems to be
a race condition (data dictionary lock wait) when running with --valgrind.
dfield_t: Add an "external storage" flag, dfield->ext.
dfield_is_null(), dfield_is_ext(), dfield_set_ext(), dfield_set_null():
New functions.
dfield_copy(), dfield_copy_data(): Add const qualifiers, fix in/out comments.
data_write_sql_null(): Use memset().
big_rec_field_t: Replace byte* data with const void* data.
ut_ulint_sort(): Remove.
upd_field_t: Remove extern_storage.
upd_node_t: Replace ext_vec, n_ext_vec with n_ext.
row_merge_copy_blobs(): New function.
row_ins_index_entry(): Add the parameter "ibool foreign" for suppressing
foreign key checks during fast index creation or when inserting into
secondary indexes.
btr_page_insert_fits(): Add const qualifiers.
btr_cur_add_ext(), upd_ext_vec_contains(): Remove.
dfield_print_also_hex(), dfield_print(): Replace if...else if with switch.
Observe dfield_is_ext().
2007-06-21 09:43:15 +00:00
|
|
|
rec = page_cur_tuple_insert(&page_cur, entry, index, 0, mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2007-02-20 15:01:47 +00:00
|
|
|
if (UNIV_LIKELY(rec != NULL)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If the record did not fit, reorganize */
|
|
|
|
|
|
|
|
btr_page_reorganize(block, index, mtr);
|
|
|
|
page_cur_search(block, index, entry, PAGE_CUR_LE, &page_cur);
|
|
|
|
|
|
|
|
/* This time the record must fit */
|
|
|
|
if (UNIV_UNLIKELY
|
|
|
|
(!page_cur_tuple_insert(&page_cur, entry, index,
|
branches/zip: Make merge sort handle externally stored columns.
Some things still fail in innodb-index.test, and there seems to be
a race condition (data dictionary lock wait) when running with --valgrind.
dfield_t: Add an "external storage" flag, dfield->ext.
dfield_is_null(), dfield_is_ext(), dfield_set_ext(), dfield_set_null():
New functions.
dfield_copy(), dfield_copy_data(): Add const qualifiers, fix in/out comments.
data_write_sql_null(): Use memset().
big_rec_field_t: Replace byte* data with const void* data.
ut_ulint_sort(): Remove.
upd_field_t: Remove extern_storage.
upd_node_t: Replace ext_vec, n_ext_vec with n_ext.
row_merge_copy_blobs(): New function.
row_ins_index_entry(): Add the parameter "ibool foreign" for suppressing
foreign key checks during fast index creation or when inserting into
secondary indexes.
btr_page_insert_fits(): Add const qualifiers.
btr_cur_add_ext(), upd_ext_vec_contains(): Remove.
dfield_print_also_hex(), dfield_print(): Replace if...else if with switch.
Observe dfield_is_ext().
2007-06-21 09:43:15 +00:00
|
|
|
0, mtr))) {
|
2007-02-20 15:01:47 +00:00
|
|
|
ulint space;
|
|
|
|
ulint page_no;
|
|
|
|
ulint zip_size;
|
|
|
|
|
|
|
|
ut_print_timestamp(stderr);
|
|
|
|
|
|
|
|
fprintf(stderr,
|
2007-10-12 08:38:49 +00:00
|
|
|
" InnoDB: Error: Insert buffer insert"
|
2007-02-20 15:01:47 +00:00
|
|
|
" fails; page free %lu,"
|
|
|
|
" dtuple size %lu\n",
|
|
|
|
(ulong) page_get_max_insert_size(
|
|
|
|
page, 1),
|
|
|
|
(ulong) rec_get_converted_size(
|
branches/zip: Make merge sort handle externally stored columns.
Some things still fail in innodb-index.test, and there seems to be
a race condition (data dictionary lock wait) when running with --valgrind.
dfield_t: Add an "external storage" flag, dfield->ext.
dfield_is_null(), dfield_is_ext(), dfield_set_ext(), dfield_set_null():
New functions.
dfield_copy(), dfield_copy_data(): Add const qualifiers, fix in/out comments.
data_write_sql_null(): Use memset().
big_rec_field_t: Replace byte* data with const void* data.
ut_ulint_sort(): Remove.
upd_field_t: Remove extern_storage.
upd_node_t: Replace ext_vec, n_ext_vec with n_ext.
row_merge_copy_blobs(): New function.
row_ins_index_entry(): Add the parameter "ibool foreign" for suppressing
foreign key checks during fast index creation or when inserting into
secondary indexes.
btr_page_insert_fits(): Add const qualifiers.
btr_cur_add_ext(), upd_ext_vec_contains(): Remove.
dfield_print_also_hex(), dfield_print(): Replace if...else if with switch.
Observe dfield_is_ext().
2007-06-21 09:43:15 +00:00
|
|
|
index, entry, 0));
|
2007-02-20 15:01:47 +00:00
|
|
|
fputs("InnoDB: Cannot insert index record ",
|
|
|
|
stderr);
|
|
|
|
dtuple_print(stderr, entry);
|
|
|
|
fputs("\nInnoDB: The table where"
|
|
|
|
" this index record belongs\n"
|
|
|
|
"InnoDB: is now probably corrupt."
|
|
|
|
" Please run CHECK TABLE on\n"
|
|
|
|
"InnoDB: that table.\n", stderr);
|
|
|
|
|
|
|
|
space = page_get_space_id(page);
|
|
|
|
zip_size = buf_block_get_zip_size(block);
|
|
|
|
page_no = page_get_page_no(page);
|
|
|
|
|
|
|
|
bitmap_page = ibuf_bitmap_get_map_page(
|
|
|
|
space, page_no, zip_size, mtr);
|
|
|
|
old_bits = ibuf_bitmap_page_get_bits(
|
|
|
|
bitmap_page, page_no, zip_size,
|
|
|
|
IBUF_BITMAP_FREE, mtr);
|
|
|
|
|
2007-10-12 08:38:49 +00:00
|
|
|
fprintf(stderr,
|
|
|
|
"InnoDB: space %lu, page %lu,"
|
|
|
|
" zip_size %lu, bitmap bits %lu\n",
|
|
|
|
(ulong) space, (ulong) page_no,
|
|
|
|
(ulong) zip_size, (ulong) old_bits);
|
2007-02-20 15:01:47 +00:00
|
|
|
|
|
|
|
fputs("InnoDB: Submit a detailed bug report"
|
|
|
|
" to http://bugs.mysql.com\n", stderr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Deletes from ibuf the record on which pcur is positioned. If we have to
|
|
|
|
resort to a pessimistic delete, this function commits mtr and closes
|
|
|
|
the cursor. */
|
|
|
|
static
|
|
|
|
ibool
|
|
|
|
ibuf_delete_rec(
|
|
|
|
/*============*/
|
|
|
|
/* out: TRUE if mtr was committed and pcur
|
|
|
|
closed in this operation */
|
|
|
|
ulint space, /* in: space id */
|
|
|
|
ulint page_no,/* in: index page number where the record
|
|
|
|
should belong */
|
|
|
|
btr_pcur_t* pcur, /* in: pcur positioned on the record to
|
|
|
|
delete, having latch mode BTR_MODIFY_LEAF */
|
2006-10-26 08:52:14 +00:00
|
|
|
const dtuple_t* search_tuple,
|
2005-10-27 07:29:40 +00:00
|
|
|
/* in: search tuple for entries of page_no */
|
|
|
|
mtr_t* mtr) /* in: mtr */
|
|
|
|
{
|
|
|
|
ibool success;
|
|
|
|
page_t* root;
|
|
|
|
ulint err;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(ibuf_inside());
|
2008-10-21 06:18:57 +00:00
|
|
|
ut_ad(page_rec_is_user_rec(btr_pcur_get_rec(pcur)));
|
|
|
|
ut_ad(ibuf_rec_get_page_no(btr_pcur_get_rec(pcur)) == page_no);
|
|
|
|
ut_ad(ibuf_rec_get_space(btr_pcur_get_rec(pcur)) == space);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
success = btr_cur_optimistic_delete(btr_pcur_get_btr_cur(pcur), mtr);
|
|
|
|
|
|
|
|
if (success) {
|
2007-02-27 11:56:38 +00:00
|
|
|
#ifdef UNIV_IBUF_COUNT_DEBUG
|
2006-08-29 09:30:31 +00:00
|
|
|
fprintf(stderr,
|
|
|
|
"Decrementing ibuf count of space %lu page %lu\n"
|
|
|
|
"from %lu by 1\n", space, page_no,
|
|
|
|
ibuf_count_get(space, page_no));
|
2005-10-27 07:29:40 +00:00
|
|
|
ibuf_count_set(space, page_no,
|
2006-08-29 09:30:31 +00:00
|
|
|
ibuf_count_get(space, page_no) - 1);
|
2005-10-27 07:29:40 +00:00
|
|
|
#endif
|
|
|
|
return(FALSE);
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2008-10-21 06:18:57 +00:00
|
|
|
ut_ad(page_rec_is_user_rec(btr_pcur_get_rec(pcur)));
|
|
|
|
ut_ad(ibuf_rec_get_page_no(btr_pcur_get_rec(pcur)) == page_no);
|
|
|
|
ut_ad(ibuf_rec_get_space(btr_pcur_get_rec(pcur)) == space);
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* We have to resort to a pessimistic delete from ibuf */
|
|
|
|
btr_pcur_store_position(pcur, mtr);
|
|
|
|
|
|
|
|
btr_pcur_commit_specify_mtr(pcur, mtr);
|
|
|
|
|
|
|
|
mutex_enter(&ibuf_mutex);
|
|
|
|
|
|
|
|
mtr_start(mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
success = btr_pcur_restore_position(BTR_MODIFY_TREE, pcur, mtr);
|
|
|
|
|
|
|
|
if (!success) {
|
2008-10-23 19:25:43 +00:00
|
|
|
if (fil_space_get_flags(space) == ULINT_UNDEFINED) {
|
|
|
|
/* The tablespace has been dropped. It is possible
|
|
|
|
that another thread has deleted the insert buffer
|
|
|
|
entry. Do not complain. */
|
2008-12-22 13:41:47 +00:00
|
|
|
goto commit_and_exit;
|
2008-10-23 19:25:43 +00:00
|
|
|
}
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
fprintf(stderr,
|
2006-08-29 09:30:31 +00:00
|
|
|
"InnoDB: ERROR: Submit the output to"
|
|
|
|
" http://bugs.mysql.com\n"
|
|
|
|
"InnoDB: ibuf cursor restoration fails!\n"
|
|
|
|
"InnoDB: ibuf record inserted to page %lu\n",
|
|
|
|
(ulong) page_no);
|
2005-10-27 07:29:40 +00:00
|
|
|
fflush(stderr);
|
|
|
|
|
|
|
|
rec_print_old(stderr, btr_pcur_get_rec(pcur));
|
|
|
|
rec_print_old(stderr, pcur->old_rec);
|
|
|
|
dtuple_print(stderr, search_tuple);
|
|
|
|
|
|
|
|
rec_print_old(stderr,
|
2006-08-29 09:30:31 +00:00
|
|
|
page_rec_get_next(btr_pcur_get_rec(pcur)));
|
2005-10-27 07:29:40 +00:00
|
|
|
fflush(stderr);
|
|
|
|
|
|
|
|
btr_pcur_commit_specify_mtr(pcur, mtr);
|
|
|
|
|
|
|
|
fputs("InnoDB: Validating insert buffer tree:\n", stderr);
|
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
|
|
|
if (!btr_validate_index(ibuf->index, NULL)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(stderr, "InnoDB: ibuf tree ok\n");
|
|
|
|
fflush(stderr);
|
|
|
|
|
2008-10-23 19:25:43 +00:00
|
|
|
goto func_exit;
|
2005-10-27 07:29:40 +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
|
|
|
root = ibuf_tree_root_get(mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
btr_cur_pessimistic_delete(&err, TRUE, btr_pcur_get_btr_cur(pcur),
|
branches/zip: In the rollback of incomplete transactions after crash
recovery, tolerate clustered index records whose externally stored
columns have not been written. This should remove the assertion failures
that were reported as Mantis issue#58, issue#62, issue#64.
trx_is_recv(): New function: TRUE if this transaction is rolling back
an incomplete transaction in crash recovery.
enum trx_rbmode: Rollback modes: no rollback, normal rollback, crash recovery.
btr_cur_pessimistic_delete(), btr_free_externally_stored_field(),
btr_rec_free_externally_stored_fields():
Replace the ibool parameter with enum trx_rbmode.
btr_free_externally_stored_field(): If field_ref is zero, return
but assert ut_a(rbmode == RB_RECOVERY). Unless InnoDB has crashed
while inserting a clustered index record, field_ref should not be zero.
btr_rec_free_updated_extern_fields(): Add the parameter enum trx_rbmode.
btr_cur_pessimistic_update(): Pass the rbmode parameter to
btr_rec_free_updated_extern_fields().
row_undo_ins(), row_undo_mod_upd_del_sec(): If row_build_index_entry()
fails, assert trx_is_recv() and skip this secondary index.
row_undo_mod_upd_del_sec(): Empty the heap at the end of each loop
iteration in order to conserve memory and to reduce the number of
low-level memory allocations.
2008-08-06 08:48:34 +00:00
|
|
|
RB_NONE, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_a(err == DB_SUCCESS);
|
|
|
|
|
2007-02-27 11:56:38 +00:00
|
|
|
#ifdef UNIV_IBUF_COUNT_DEBUG
|
2005-10-27 07:29:40 +00:00
|
|
|
ibuf_count_set(space, page_no, ibuf_count_get(space, page_no) - 1);
|
|
|
|
#endif
|
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_size_update(root, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2008-12-22 13:41:47 +00:00
|
|
|
commit_and_exit:
|
2005-10-27 07:29:40 +00:00
|
|
|
btr_pcur_commit_specify_mtr(pcur, mtr);
|
|
|
|
|
2008-10-23 19:25:43 +00:00
|
|
|
func_exit:
|
2005-10-27 07:29:40 +00:00
|
|
|
btr_pcur_close(pcur);
|
|
|
|
|
|
|
|
mutex_exit(&ibuf_mutex);
|
|
|
|
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
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-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
ibuf_merge_or_delete_for_page(
|
|
|
|
/*==========================*/
|
2006-10-19 08:27:34 +00:00
|
|
|
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 */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
mem_heap_t* heap;
|
|
|
|
btr_pcur_t pcur;
|
|
|
|
dtuple_t* search_tuple;
|
|
|
|
ulint n_inserts;
|
|
|
|
#ifdef UNIV_IBUF_DEBUG
|
|
|
|
ulint volume;
|
|
|
|
#endif
|
2006-08-01 10:11:04 +00:00
|
|
|
page_zip_des_t* page_zip = NULL;
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool tablespace_being_deleted = FALSE;
|
|
|
|
ibool corruption_noticed = FALSE;
|
|
|
|
mtr_t mtr;
|
|
|
|
|
2006-11-24 12:49:59 +00:00
|
|
|
ut_ad(!block || buf_block_get_space(block) == space);
|
|
|
|
ut_ad(!block || buf_block_get_page_no(block) == page_no);
|
2006-10-19 08:27:34 +00:00
|
|
|
ut_ad(!block || buf_block_get_zip_size(block) == zip_size);
|
|
|
|
|
2008-12-08 12:14:01 +00:00
|
|
|
if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE
|
2008-12-11 15:08:14 +00:00
|
|
|
|| trx_sys_hdr_page(space, page_no)) {
|
|
|
|
return;
|
|
|
|
}
|
2006-06-06 07:42:04 +00:00
|
|
|
|
2008-12-11 15:08:14 +00:00
|
|
|
/* We cannot refer to zip_size in the following, because
|
|
|
|
zip_size is passed as ULINT_UNDEFINED (it is unknown) when
|
|
|
|
buf_read_ibuf_merge_pages() is merging (discarding) changes
|
|
|
|
for a dropped tablespace. When block != NULL or
|
|
|
|
update_ibuf_bitmap is specified, the zip_size must be known.
|
|
|
|
That is why we will repeat the check below, with zip_size in
|
|
|
|
place of 0. Passing zip_size as 0 assumes that the
|
|
|
|
uncompressed page size always is a power-of-2 multiple of the
|
|
|
|
compressed page size. */
|
|
|
|
|
|
|
|
if (ibuf_fixed_addr_page(space, 0, page_no)
|
|
|
|
|| fsp_descr_page(0, page_no)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-02-28 11:08:59 +00:00
|
|
|
if (UNIV_LIKELY(update_ibuf_bitmap)) {
|
2008-12-11 15:08:14 +00:00
|
|
|
ut_a(ut_is_2pow(zip_size));
|
|
|
|
|
|
|
|
if (ibuf_fixed_addr_page(space, zip_size, page_no)
|
|
|
|
|| fsp_descr_page(zip_size, page_no)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* If the following returns FALSE, we get the counter
|
|
|
|
incremented, and must decrement it when we leave this
|
|
|
|
function. When the counter is > 0, that prevents tablespace
|
|
|
|
from being dropped. */
|
|
|
|
|
|
|
|
tablespace_being_deleted = fil_inc_pending_ibuf_merges(space);
|
|
|
|
|
2007-02-28 11:08:59 +00:00
|
|
|
if (UNIV_UNLIKELY(tablespace_being_deleted)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Do not try to read the bitmap page from space;
|
|
|
|
just delete the ibuf records for the page */
|
|
|
|
|
2006-10-19 08:27:34 +00:00
|
|
|
block = NULL;
|
2005-10-27 07:29:40 +00:00
|
|
|
update_ibuf_bitmap = FALSE;
|
2006-09-22 11:30:03 +00:00
|
|
|
} else {
|
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
|
|
|
page_t* bitmap_page;
|
|
|
|
|
2006-09-22 11:30:03 +00:00
|
|
|
mtr_start(&mtr);
|
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
|
|
|
|
|
|
|
bitmap_page = ibuf_bitmap_get_map_page(
|
|
|
|
space, page_no, zip_size, &mtr);
|
2006-09-22 11:30:03 +00:00
|
|
|
|
|
|
|
if (!ibuf_bitmap_page_get_bits(bitmap_page, page_no,
|
|
|
|
zip_size,
|
|
|
|
IBUF_BITMAP_BUFFERED,
|
|
|
|
&mtr)) {
|
|
|
|
/* No inserts buffered for this page */
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
|
|
|
|
if (!tablespace_being_deleted) {
|
|
|
|
fil_decr_pending_ibuf_merges(space);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mtr_commit(&mtr);
|
2005-10-27 07:29:40 +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
|
|
|
} else if (block
|
|
|
|
&& (ibuf_fixed_addr_page(space, zip_size, page_no)
|
|
|
|
|| fsp_descr_page(zip_size, page_no))) {
|
2006-09-21 08:01:50 +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
|
|
|
return;
|
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ibuf_enter();
|
|
|
|
|
|
|
|
heap = mem_heap_create(512);
|
|
|
|
|
|
|
|
if (!trx_sys_multiple_tablespace_format) {
|
|
|
|
ut_a(trx_doublewrite_must_reset_space_ids);
|
2006-02-23 19:25:29 +00:00
|
|
|
search_tuple = ibuf_search_tuple_build(space, page_no, heap);
|
2005-10-27 07:29:40 +00:00
|
|
|
} else {
|
2006-02-23 19:25:29 +00:00
|
|
|
search_tuple = ibuf_new_search_tuple_build(space, page_no,
|
2006-08-29 09:30:31 +00:00
|
|
|
heap);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-10-19 08:27:34 +00:00
|
|
|
if (block) {
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Move the ownership of the x-latch on the page to this OS
|
|
|
|
thread, so that we can acquire a second x-latch on it. This
|
|
|
|
is needed for the insert operations to the index page to pass
|
|
|
|
the debug checks. */
|
|
|
|
|
|
|
|
rw_lock_x_lock_move_ownership(&(block->lock));
|
2006-10-12 11:05:22 +00:00
|
|
|
page_zip = buf_block_get_page_zip(block);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-11-01 09:20:22 +00:00
|
|
|
if (UNIV_UNLIKELY(fil_page_get_type(block->frame)
|
2008-09-24 09:30:32 +00:00
|
|
|
!= FIL_PAGE_INDEX)
|
|
|
|
|| UNIV_UNLIKELY(!page_is_leaf(block->frame))) {
|
2005-10-27 07:29:40 +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
|
|
|
page_t* bitmap_page;
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
corruption_noticed = TRUE;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_print_timestamp(stderr);
|
|
|
|
|
|
|
|
mtr_start(&mtr);
|
|
|
|
|
2006-02-27 09:33:26 +00:00
|
|
|
fputs(" InnoDB: Dump of the ibuf bitmap page:\n",
|
2006-08-29 09:30:31 +00:00
|
|
|
stderr);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
bitmap_page = ibuf_bitmap_get_map_page(space, page_no,
|
|
|
|
zip_size, &mtr);
|
2006-05-02 11:44:39 +00:00
|
|
|
buf_page_print(bitmap_page, 0);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mtr_commit(&mtr);
|
|
|
|
|
|
|
|
fputs("\nInnoDB: Dump of the page:\n", stderr);
|
|
|
|
|
2006-11-01 09:20:22 +00:00
|
|
|
buf_page_print(block->frame, 0);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
fprintf(stderr,
|
2006-08-29 09:30:31 +00:00
|
|
|
"InnoDB: Error: corruption in the tablespace."
|
|
|
|
" Bitmap shows insert\n"
|
|
|
|
"InnoDB: buffer records to page n:o %lu"
|
|
|
|
" though the page\n"
|
|
|
|
"InnoDB: type is %lu, which is"
|
2008-09-24 09:30:32 +00:00
|
|
|
" not an index leaf page!\n"
|
2006-08-29 09:30:31 +00:00
|
|
|
"InnoDB: We try to resolve the problem"
|
|
|
|
" by skipping the insert buffer\n"
|
|
|
|
"InnoDB: merge for this page."
|
|
|
|
" Please run CHECK TABLE on your tables\n"
|
|
|
|
"InnoDB: to determine if they are corrupt"
|
|
|
|
" after this.\n\n"
|
|
|
|
"InnoDB: Please submit a detailed bug report"
|
|
|
|
" to http://bugs.mysql.com\n\n",
|
2005-10-27 07:29:40 +00:00
|
|
|
(ulong) page_no,
|
2006-10-19 08:27:34 +00:00
|
|
|
(ulong)
|
2006-11-01 09:20:22 +00:00
|
|
|
fil_page_get_type(block->frame));
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
n_inserts = 0;
|
|
|
|
#ifdef UNIV_IBUF_DEBUG
|
|
|
|
volume = 0;
|
|
|
|
#endif
|
|
|
|
loop:
|
|
|
|
mtr_start(&mtr);
|
|
|
|
|
2006-10-19 08:27:34 +00:00
|
|
|
if (block) {
|
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
|
|
|
ibool success;
|
|
|
|
|
|
|
|
success = buf_page_get_known_nowait(
|
|
|
|
RW_X_LATCH, block,
|
|
|
|
BUF_KEEP_OLD, __FILE__, __LINE__, &mtr);
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_a(success);
|
2008-09-22 06:59:58 +00:00
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Position pcur in the insert buffer at the first entry for this
|
|
|
|
index page */
|
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
|
|
|
btr_pcur_open_on_user_rec(
|
|
|
|
ibuf->index, search_tuple, PAGE_CUR_GE, BTR_MODIFY_LEAF,
|
|
|
|
&pcur, &mtr);
|
|
|
|
|
2007-10-22 08:16:35 +00:00
|
|
|
if (!btr_pcur_is_on_user_rec(&pcur)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(btr_pcur_is_after_last_in_tree(&pcur, &mtr));
|
|
|
|
|
|
|
|
goto reset_bit;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;;) {
|
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
|
|
|
rec_t* rec;
|
|
|
|
|
2007-10-22 08:16:35 +00:00
|
|
|
ut_ad(btr_pcur_is_on_user_rec(&pcur));
|
2005-10-27 07:29:40 +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
|
|
|
rec = btr_pcur_get_rec(&pcur);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Check if the entry is for this index page */
|
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
|
|
|
if (ibuf_rec_get_page_no(rec) != page_no
|
|
|
|
|| ibuf_rec_get_space(rec) != space) {
|
|
|
|
|
2006-10-19 08:27:34 +00:00
|
|
|
if (block) {
|
|
|
|
page_header_reset_last_insert(
|
2006-11-01 09:20:22 +00:00
|
|
|
block->frame, page_zip, &mtr);
|
2005-10-27 07:29:40 +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
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
goto reset_bit;
|
|
|
|
}
|
|
|
|
|
2006-08-01 10:11:04 +00:00
|
|
|
if (UNIV_UNLIKELY(corruption_noticed)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
fputs("InnoDB: Discarding record\n ", stderr);
|
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
|
|
|
rec_print_old(stderr, rec);
|
branches/zip: Document and obey the rules for modifying the free bits in
the insert buffer bitmap.
ibuf_set_free_bits_func(): Never disable redo logging.
ibuf_update_free_bits_zip(): Remove.
btr_page_reorganize_low(), page_zip_reorganize(): Do not update the insert
buffer bitmap. Instead, document that callers will have to take care of it,
and adapt the callers.
btr_compress(): On error, reset the insert buffer free bits.
btr_cur_insert_if_possible(): Do not modify the insert buffer bitmap.
btr_compress(), btr_cur_optimistic_insert(): On compressed pages,
reset the insert buffer bitmap. Document why.
btr_cur_update_alloc_zip(): Document why it is necessary and sufficient
to reset the insert buffer free bits.
btr_cur_update_in_place(), btr_cur_optimistic_update(),
btr_cur_pessimistic_update(): Update the free bits in the same
mini-transaction. Document that the mini-transaction must be
committed before latching any further pages. Verify that this
is the case in all execution paths.
row_ins_sec_index_entry_by_modify(), row_ins_clust_index_entry_by_modify(),
row_undo_mod_clust_low(): Because these functions call
btr_cur_update_in_place(), btr_cur_optimistic_update(), or
btr_cur_pessimistic_update(), document that the mini-transaction must be
committed before latching any further pages. Verify that this is the case
in all execution paths.
2007-05-16 09:23:53 +00:00
|
|
|
fputs("\nInnoDB: from the insert buffer!\n\n", stderr);
|
2006-10-19 08:27:34 +00:00
|
|
|
} else if (block) {
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Now we have at pcur a record which should be
|
|
|
|
inserted to the index page; NOTE that the call below
|
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
|
|
|
copies pointers to fields in rec, and we must
|
|
|
|
keep the latch to the rec page until the
|
2005-10-27 07:29:40 +00:00
|
|
|
insertion is finished! */
|
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
|
|
|
dtuple_t* entry;
|
|
|
|
dulint max_trx_id;
|
2005-10-27 07:29:40 +00:00
|
|
|
dict_index_t* dummy_index;
|
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
|
|
|
|
|
|
|
max_trx_id = page_get_max_trx_id(page_align(rec));
|
2006-10-23 18:26:10 +00:00
|
|
|
page_update_max_trx_id(block, page_zip, max_trx_id);
|
2005-11-11 21:18:42 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
entry = ibuf_build_entry_from_ibuf_rec(
|
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
|
|
|
rec, heap, &dummy_index);
|
2005-10-27 07:29:40 +00:00
|
|
|
#ifdef UNIV_IBUF_DEBUG
|
branches/zip: Make merge sort handle externally stored columns.
Some things still fail in innodb-index.test, and there seems to be
a race condition (data dictionary lock wait) when running with --valgrind.
dfield_t: Add an "external storage" flag, dfield->ext.
dfield_is_null(), dfield_is_ext(), dfield_set_ext(), dfield_set_null():
New functions.
dfield_copy(), dfield_copy_data(): Add const qualifiers, fix in/out comments.
data_write_sql_null(): Use memset().
big_rec_field_t: Replace byte* data with const void* data.
ut_ulint_sort(): Remove.
upd_field_t: Remove extern_storage.
upd_node_t: Replace ext_vec, n_ext_vec with n_ext.
row_merge_copy_blobs(): New function.
row_ins_index_entry(): Add the parameter "ibool foreign" for suppressing
foreign key checks during fast index creation or when inserting into
secondary indexes.
btr_page_insert_fits(): Add const qualifiers.
btr_cur_add_ext(), upd_ext_vec_contains(): Remove.
dfield_print_also_hex(), dfield_print(): Replace if...else if with switch.
Observe dfield_is_ext().
2007-06-21 09:43:15 +00:00
|
|
|
volume += rec_get_converted_size(dummy_index, entry, 0)
|
2006-08-29 09:30:31 +00:00
|
|
|
+ page_dir_calc_reserved_space(1);
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_a(volume <= 4 * UNIV_PAGE_SIZE
|
2006-08-29 09:30:31 +00:00
|
|
|
/ IBUF_PAGE_SIZE_PER_FREE_SPACE);
|
2005-10-27 07:29:40 +00:00
|
|
|
#endif
|
2006-10-18 11:39:31 +00:00
|
|
|
ibuf_insert_to_index_page(entry, block,
|
2006-08-29 09:30:31 +00:00
|
|
|
dummy_index, &mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
ibuf_dummy_index_free(dummy_index);
|
|
|
|
}
|
|
|
|
|
|
|
|
n_inserts++;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Delete the record from ibuf */
|
|
|
|
if (ibuf_delete_rec(space, page_no, &pcur, search_tuple,
|
2006-08-29 09:30:31 +00:00
|
|
|
&mtr)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Deletion was pessimistic and mtr was committed:
|
|
|
|
we start from the beginning again */
|
|
|
|
|
|
|
|
goto loop;
|
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
|
|
|
} else if (btr_pcur_is_after_last_on_page(&pcur)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
mtr_commit(&mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
btr_pcur_close(&pcur);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
goto loop;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
reset_bit:
|
2007-02-27 11:56:38 +00:00
|
|
|
#ifdef UNIV_IBUF_COUNT_DEBUG
|
2005-10-27 07:29:40 +00:00
|
|
|
if (ibuf_count_get(space, page_no) > 0) {
|
|
|
|
/* btr_print_tree(ibuf_data->index->tree, 100);
|
|
|
|
ibuf_print(); */
|
|
|
|
}
|
|
|
|
#endif
|
2007-02-28 11:08:59 +00:00
|
|
|
if (UNIV_LIKELY(update_ibuf_bitmap)) {
|
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
|
|
|
page_t* bitmap_page;
|
|
|
|
|
|
|
|
bitmap_page = ibuf_bitmap_get_map_page(
|
|
|
|
space, page_no, zip_size, &mtr);
|
|
|
|
|
|
|
|
ibuf_bitmap_page_set_bits(
|
|
|
|
bitmap_page, page_no, zip_size,
|
|
|
|
IBUF_BITMAP_BUFFERED, FALSE, &mtr);
|
|
|
|
|
2006-10-19 08:27:34 +00:00
|
|
|
if (block) {
|
2006-09-21 08:01:50 +00:00
|
|
|
ulint old_bits = ibuf_bitmap_page_get_bits(
|
|
|
|
bitmap_page, page_no, zip_size,
|
|
|
|
IBUF_BITMAP_FREE, &mtr);
|
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
|
|
|
|
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
|
|
|
ulint new_bits = ibuf_index_page_calc_free(
|
|
|
|
zip_size, block);
|
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
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (old_bits != new_bits) {
|
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_bitmap_page_set_bits(
|
|
|
|
bitmap_page, page_no, zip_size,
|
|
|
|
IBUF_BITMAP_FREE, new_bits, &mtr);
|
2005-10-27 07:29:40 +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
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mtr_commit(&mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
btr_pcur_close(&pcur);
|
2005-10-27 07:29:40 +00:00
|
|
|
mem_heap_free(heap);
|
|
|
|
|
|
|
|
/* Protect our statistics keeping from race conditions */
|
|
|
|
mutex_enter(&ibuf_mutex);
|
|
|
|
|
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->n_merges++;
|
|
|
|
ibuf->n_merged_recs += n_inserts;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mutex_exit(&ibuf_mutex);
|
|
|
|
|
|
|
|
if (update_ibuf_bitmap && !tablespace_being_deleted) {
|
|
|
|
|
|
|
|
fil_decr_pending_ibuf_merges(space);
|
|
|
|
}
|
|
|
|
|
|
|
|
ibuf_exit();
|
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
|
|
|
|
2007-02-27 11:56:38 +00:00
|
|
|
#ifdef UNIV_IBUF_COUNT_DEBUG
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_a(ibuf_count_get(space, page_no) == 0);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
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-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
ibuf_delete_for_discarded_space(
|
|
|
|
/*============================*/
|
|
|
|
ulint space) /* in: space id */
|
|
|
|
{
|
|
|
|
mem_heap_t* heap;
|
|
|
|
btr_pcur_t pcur;
|
|
|
|
dtuple_t* search_tuple;
|
|
|
|
rec_t* ibuf_rec;
|
|
|
|
ulint page_no;
|
|
|
|
ibool closed;
|
|
|
|
ulint n_inserts;
|
|
|
|
mtr_t mtr;
|
|
|
|
|
|
|
|
heap = mem_heap_create(512);
|
|
|
|
|
|
|
|
/* Use page number 0 to build the search tuple so that we get the
|
|
|
|
cursor positioned at the first entry for this space id */
|
|
|
|
|
|
|
|
search_tuple = ibuf_new_search_tuple_build(space, 0, heap);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
n_inserts = 0;
|
|
|
|
loop:
|
|
|
|
ibuf_enter();
|
|
|
|
|
|
|
|
mtr_start(&mtr);
|
|
|
|
|
|
|
|
/* Position pcur in the insert buffer at the first entry for the
|
|
|
|
space */
|
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
|
|
|
btr_pcur_open_on_user_rec(
|
|
|
|
ibuf->index, search_tuple, PAGE_CUR_GE, BTR_MODIFY_LEAF,
|
|
|
|
&pcur, &mtr);
|
|
|
|
|
2007-10-22 08:16:35 +00:00
|
|
|
if (!btr_pcur_is_on_user_rec(&pcur)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(btr_pcur_is_after_last_in_tree(&pcur, &mtr));
|
|
|
|
|
|
|
|
goto leave_loop;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;;) {
|
2007-10-22 08:16:35 +00:00
|
|
|
ut_ad(btr_pcur_is_on_user_rec(&pcur));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ibuf_rec = btr_pcur_get_rec(&pcur);
|
|
|
|
|
|
|
|
/* Check if the entry is for this space */
|
|
|
|
if (ibuf_rec_get_space(ibuf_rec) != space) {
|
|
|
|
|
|
|
|
goto leave_loop;
|
|
|
|
}
|
|
|
|
|
|
|
|
page_no = ibuf_rec_get_page_no(ibuf_rec);
|
|
|
|
|
|
|
|
n_inserts++;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Delete the record from ibuf */
|
|
|
|
closed = ibuf_delete_rec(space, page_no, &pcur, search_tuple,
|
2006-08-29 09:30:31 +00:00
|
|
|
&mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (closed) {
|
|
|
|
/* Deletion was pessimistic and mtr was committed:
|
|
|
|
we start from the beginning again */
|
|
|
|
|
|
|
|
ibuf_exit();
|
|
|
|
|
|
|
|
goto loop;
|
|
|
|
}
|
|
|
|
|
2007-10-22 08:16:35 +00:00
|
|
|
if (btr_pcur_is_after_last_on_page(&pcur)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
mtr_commit(&mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
btr_pcur_close(&pcur);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ibuf_exit();
|
|
|
|
|
|
|
|
goto loop;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
leave_loop:
|
|
|
|
mtr_commit(&mtr);
|
2006-02-23 19:25:29 +00:00
|
|
|
btr_pcur_close(&pcur);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Protect our statistics keeping from race conditions */
|
|
|
|
mutex_enter(&ibuf_mutex);
|
|
|
|
|
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->n_merges++;
|
|
|
|
ibuf->n_merged_recs += n_inserts;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mutex_exit(&ibuf_mutex);
|
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
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ibuf_exit();
|
|
|
|
|
|
|
|
mem_heap_free(heap);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
Looks if the insert buffer is empty. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
ibuf_is_empty(void)
|
|
|
|
/*===============*/
|
|
|
|
/* out: TRUE if empty */
|
|
|
|
{
|
|
|
|
ibool is_empty;
|
2006-10-26 08:52:14 +00:00
|
|
|
const page_t* root;
|
2005-10-27 07:29:40 +00:00
|
|
|
mtr_t mtr;
|
|
|
|
|
|
|
|
ibuf_enter();
|
|
|
|
|
|
|
|
mutex_enter(&ibuf_mutex);
|
|
|
|
|
|
|
|
mtr_start(&mtr);
|
|
|
|
|
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
|
|
|
root = ibuf_tree_root_get(&mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if (page_get_n_recs(root) == 0) {
|
|
|
|
|
|
|
|
is_empty = TRUE;
|
|
|
|
|
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
|
|
|
if (ibuf->empty == FALSE) {
|
2005-10-27 07:29:40 +00:00
|
|
|
fprintf(stderr,
|
2006-08-29 09:30:31 +00:00
|
|
|
"InnoDB: Warning: insert buffer tree is empty"
|
|
|
|
" but the data struct does not\n"
|
|
|
|
"InnoDB: know it. This condition is legal"
|
|
|
|
" if the master thread has not yet\n"
|
|
|
|
"InnoDB: run to completion.\n");
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
} else {
|
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
|
|
|
ut_a(ibuf->empty == FALSE);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
is_empty = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
|
|
|
|
mutex_exit(&ibuf_mutex);
|
|
|
|
|
|
|
|
ibuf_exit();
|
|
|
|
|
|
|
|
return(is_empty);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
Prints info of ibuf. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
ibuf_print(
|
|
|
|
/*=======*/
|
|
|
|
FILE* file) /* in: file where to print */
|
|
|
|
{
|
2007-02-27 11:56:38 +00:00
|
|
|
#ifdef UNIV_IBUF_COUNT_DEBUG
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint i;
|
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
|
|
|
ulint j;
|
2005-10-27 07:29:40 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
mutex_enter(&ibuf_mutex);
|
|
|
|
|
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
|
|
|
fprintf(file,
|
|
|
|
"Ibuf: size %lu, free list len %lu, seg size %lu,\n"
|
|
|
|
"%lu inserts, %lu merged recs, %lu merges\n",
|
|
|
|
(ulong) ibuf->size,
|
|
|
|
(ulong) ibuf->free_list_len,
|
|
|
|
(ulong) ibuf->seg_size,
|
|
|
|
(ulong) ibuf->n_inserts,
|
|
|
|
(ulong) ibuf->n_merged_recs,
|
|
|
|
(ulong) ibuf->n_merges);
|
2007-02-27 11:56:38 +00:00
|
|
|
#ifdef UNIV_IBUF_COUNT_DEBUG
|
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
|
|
|
for (i = 0; i < IBUF_COUNT_N_SPACES; i++) {
|
|
|
|
for (j = 0; j < IBUF_COUNT_N_PAGES; j++) {
|
|
|
|
ulint count = ibuf_count_get(i, j);
|
2005-10-27 07:29:40 +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
|
|
|
if (count > 0) {
|
2005-10-27 07:29:40 +00:00
|
|
|
fprintf(stderr,
|
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 count for space/page %lu/%lu"
|
|
|
|
" is %lu\n",
|
|
|
|
(ulong) i, (ulong) j, (ulong) count);
|
2005-10-27 07:29:40 +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
|
|
|
#endif /* UNIV_IBUF_COUNT_DEBUG */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mutex_exit(&ibuf_mutex);
|
|
|
|
}
|