2005-10-27 07:29:40 +00:00
|
|
|
/************************************************************************
|
|
|
|
The index tree adaptive search
|
|
|
|
|
|
|
|
(c) 1996 Innobase Oy
|
|
|
|
|
|
|
|
Created 2/17/1996 Heikki Tuuri
|
|
|
|
*************************************************************************/
|
|
|
|
|
branches/innodb+: Merge revisions 4072:4150 from branches/zip:
------------------------------------------------------------------------
r4074 | vasil | 2009-01-31 08:05:24 +0200 (Sat, 31 Jan 2009) | 4 lines
branches/zip:
Adjust the failing patch patches/information_schema.diff.
------------------------------------------------------------------------
r4076 | vasil | 2009-02-02 09:32:04 +0200 (Mon, 02 Feb 2009) | 4 lines
branches/zip:
Add ChangeLog entry for the change in r4072.
------------------------------------------------------------------------
r4077 | marko | 2009-02-02 10:48:05 +0200 (Mon, 02 Feb 2009) | 2 lines
branches/zip: innobase_start_or_create_for_mysql(): Remove a factual error
in the function comment. Parameters are not read from a file "srv_init".
------------------------------------------------------------------------
r4081 | marko | 2009-02-02 14:28:17 +0200 (Mon, 02 Feb 2009) | 4 lines
branches/zip: Enclose some backup functions in #ifdef UNIV_HOTBACKUP.
recv_read_cp_info_for_backup(), recv_scan_log_seg_for_backup():
These functions are only called by InnoDB Hot Backup.
------------------------------------------------------------------------
r4082 | vasil | 2009-02-02 18:24:08 +0200 (Mon, 02 Feb 2009) | 10 lines
branches/zip:
Fix a mysql-test failure in innodb-zip:
main.innodb-zip [ fail ]
Test ended at 2009-02-02 18:13:25
CURRENT_TEST: main.innodb-zip
mysqltest: At line 160: Found line beginning with -- that didn't contain a valid mysqltest command, check your syntax or use # if you intended to write a comment
------------------------------------------------------------------------
r4083 | vasil | 2009-02-02 18:33:20 +0200 (Mon, 02 Feb 2009) | 6 lines
branches/zip:
Fix the failing innodb-zip test to restore the environment as it was before
the test execution because a newly added feature in the mysql-test framework
does check for this.
------------------------------------------------------------------------
r4088 | calvin | 2009-02-03 02:35:56 +0200 (Tue, 03 Feb 2009) | 8 lines
branches/zip: fix a compiler error and a warning
Both are minor changes:
1) Compiler error introduced in r4072: double ';' at the end.
2) Warning introduced in r3613: \mem\mem0pool.c(481) :
warning C4098: 'mem_area_free' : 'void' function returning a value
Approved by: Sunny (IM)
------------------------------------------------------------------------
r4098 | marko | 2009-02-03 09:52:45 +0200 (Tue, 03 Feb 2009) | 4 lines
branches/zip: mem_area_free(): Correct a bug that was introduced in r4088.
free() is not the same as ut_free(). ut_free() pairs with ut_malloc(),
not malloc(). free() pairs with malloc() and some other functions.
------------------------------------------------------------------------
r4114 | marko | 2009-02-04 16:09:24 +0200 (Wed, 04 Feb 2009) | 2 lines
branches/zip: buf_block_align(): Fix a bogus debug assertion
that was introduced in r4036, to address Issue #161.
------------------------------------------------------------------------
r4139 | vasil | 2009-02-09 13:47:16 +0200 (Mon, 09 Feb 2009) | 5 lines
branches/zip:
Remove mysql-test/patches/bug35261.diff because that bug has been fixed
in the MySQL repository.
------------------------------------------------------------------------
r4141 | marko | 2009-02-09 15:35:50 +0200 (Mon, 09 Feb 2009) | 1 line
branches/zip: fil_write_lsn_and_arch_no_to_file(): Plug a memory leak.
------------------------------------------------------------------------
r4144 | inaam | 2009-02-10 01:36:25 +0200 (Tue, 10 Feb 2009) | 9 lines
branches/zip rb://30
This patch changes the innodb mutexes and rw_locks implementation.
On supported platforms it uses GCC builtin atomics. These changes
are based on the patch sent by Mark Callaghan of Google under BSD
license. More technical discussion can be found at rb://30
Approved by: Heikki
------------------------------------------------------------------------
r4145 | vasil | 2009-02-10 07:34:43 +0200 (Tue, 10 Feb 2009) | 9 lines
branches/zip:
Non-functional change: Fix a compilation warning introduced in r4144:
gcc -DHAVE_CONFIG_H -I. -I../../include -I../../include -I../../include -I../../regex -I../../storage/innobase/include -I../../sql -I. -Werror -Wall -g -MT libinnobase_a-sync0arr.o -MD -MP -MF .deps/libinnobase_a-sync0arr.Tpo -c -o libinnobase_a-sync0arr.o `test -f 'sync/sync0arr.c' || echo './'`sync/sync0arr.c
cc1: warnings being treated as errors
sync/sync0arr.c: In function 'sync_array_object_signalled':
sync/sync0arr.c:869: warning: pointer targets in passing argument 1 of 'os_atomic_increment' differ in signedness
------------------------------------------------------------------------
r4148 | marko | 2009-02-10 10:38:41 +0200 (Tue, 10 Feb 2009) | 12 lines
branches/zip: Map ut_malloc(), ut_realloc(), ut_free() to
malloc(), realloc(), free() when innodb_use_sys_malloc is set.
ut_free_all_mem(): If innodb_use_sys_malloc is set, do nothing,
because then ut_mem_block_list_inited will never be set.
log_init(): Use mem_alloc() instead of ut_malloc(), so that the
memory will be freed. (Tested with Valgrind, although it is not
clear why the memory would be freed.)
rb://86 approved by Heikki Tuuri and Ken Jacobs. This addresses Issue #168.
------------------------------------------------------------------------
r4149 | marko | 2009-02-10 11:09:15 +0200 (Tue, 10 Feb 2009) | 1 line
branches/zip: ChangeLog: Document recent changes.
------------------------------------------------------------------------
r4150 | marko | 2009-02-10 11:51:43 +0200 (Tue, 10 Feb 2009) | 6 lines
branches/zip: get_share(), free_share(): Make table locking case sensitive.
If lower_case_table_names=1, MySQL will pass the table names in lower case.
Thus, we can use a binary comparison (strcmp) in the hash table.
rb://87 approved by Heikki Tuuri, to address Bug #41676 and Issue #167.
------------------------------------------------------------------------
2009-02-10 10:03:42 +00:00
|
|
|
/***********************************************************************
|
|
|
|
# Copyright (c) 2008, Google Inc.
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions
|
|
|
|
# are met:
|
|
|
|
# * Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# * Redistributions in binary form must reproduce the above
|
|
|
|
# copyright notice, this list of conditions and the following
|
|
|
|
# disclaimer in the documentation and/or other materials
|
|
|
|
# provided with the distribution.
|
|
|
|
# * Neither the name of the Google Inc. nor the names of its
|
|
|
|
# contributors may be used to endorse or promote products
|
|
|
|
# derived from this software without specific prior written
|
|
|
|
# permission.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
#
|
|
|
|
# Note, the BSD license applies to the new code. The old code is GPL.
|
|
|
|
***********************************************************************/
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
#include "btr0sea.h"
|
|
|
|
#ifdef UNIV_NONINL
|
|
|
|
#include "btr0sea.ic"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "buf0buf.h"
|
|
|
|
#include "page0page.h"
|
|
|
|
#include "page0cur.h"
|
|
|
|
#include "btr0cur.h"
|
|
|
|
#include "btr0pcur.h"
|
|
|
|
#include "btr0btr.h"
|
|
|
|
#include "ha0ha.h"
|
|
|
|
|
branches/innodb+: Merge revisions 4070:4072 from branches/zip:
------------------------------------------------------------------------
r4072 | marko | 2009-01-30 23:30:29 +0200 (Fri, 30 Jan 2009) | 32 lines
branches/zip: Make innodb_adaptive_hash_index settable.
btr_search_disabled: Rename to btr_search_enabled and change the type
to char, so that it can be directly linked to the MySQL parameters.
Note that the variable is protected by btr_search_latch and
btr_search_enabled_mutex, a new mutex introduced in this patch.
btr_search_enabled_mutex: A new mutex, to protect btr_search_enabled
together with btr_search_latch.
buf_pool_drop_hash_index(): New function, to be called from
btr_search_disable().
btr_search_disable(), btr_search_enable(): Fix bugs. These functions
were previously unused.
btr_search_guess_on_hash(), btr_search_build_page_hash_index():
Check btr_search_enabled once more, while holding btr_search_latch.
btr_cur_search_to_nth_level(): Note that the reads of btr_search_enabled
may be dirty and explain why it should not be a problem.
innobase_adaptive_hash_index: Remove. The variable btr_search_enabled will be used directly instead.
innodb_adaptive_hash_index_update(): New function, an update callback for
innodb_adaptive_hash_index. This will call either btr_search_disable()
or btr_search_enable() when the value is assigned. The functions will
be called even if the value does not appear to be changed, e.g., when
setting from TRUE to TRUE or FALSE to FALSE.
rb://85 approved by Heikki Tuuri. This addresses Issue #163.
------------------------------------------------------------------------
2009-01-30 21:45:02 +00:00
|
|
|
/* Flag: has the search system been enabled?
|
|
|
|
Protected by btr_search_latch and btr_search_enabled_mutex. */
|
|
|
|
UNIV_INTERN char btr_search_enabled = TRUE;
|
|
|
|
|
|
|
|
static mutex_t btr_search_enabled_mutex;
|
2006-11-21 14:40:14 +00:00
|
|
|
|
2008-02-06 14:17:36 +00:00
|
|
|
/* A dummy variable to fool the compiler */
|
|
|
|
UNIV_INTERN ulint btr_search_this_is_zero = 0;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
#ifdef UNIV_SEARCH_PERF_STAT
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN ulint btr_search_n_succ = 0;
|
|
|
|
UNIV_INTERN ulint btr_search_n_hash_fail = 0;
|
2006-04-12 09:32:17 +00:00
|
|
|
#endif /* UNIV_SEARCH_PERF_STAT */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2008-02-06 14:17:36 +00:00
|
|
|
/* padding to prevent other memory update
|
|
|
|
hotspots from residing on the same memory
|
|
|
|
cache line as btr_search_latch */
|
|
|
|
UNIV_INTERN byte btr_sea_pad1[64];
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* The latch protecting the adaptive search system: this latch protects the
|
|
|
|
(1) positions of records on those pages where a hash index has been built.
|
|
|
|
NOTE: It does not protect values of non-ordering fields within a record from
|
|
|
|
being updated in-place! We can use fact (1) to perform unique searches to
|
|
|
|
indexes. */
|
|
|
|
|
2008-02-06 14:17:36 +00:00
|
|
|
/* We will allocate the latch from dynamic memory to get it to the
|
|
|
|
same DRAM page as other hotspot semaphores */
|
|
|
|
UNIV_INTERN rw_lock_t* btr_search_latch_temp;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2008-02-06 14:17:36 +00:00
|
|
|
/* padding to prevent other memory update hotspots from residing on
|
|
|
|
the same memory cache line */
|
|
|
|
UNIV_INTERN byte btr_sea_pad2[64];
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN btr_search_sys_t* btr_search_sys;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* If the number of records on the page divided by this parameter
|
|
|
|
would have been successfully accessed using a hash index, the index
|
|
|
|
is then built on the page, assuming the global limit has been reached */
|
|
|
|
|
|
|
|
#define BTR_SEARCH_PAGE_BUILD_LIMIT 16
|
|
|
|
|
|
|
|
/* The global limit for consecutive potentially successful hash searches,
|
|
|
|
before hash index building is started */
|
|
|
|
|
|
|
|
#define BTR_SEARCH_BUILD_LIMIT 100
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Builds a hash index on a page with the given parameters. If the page already
|
|
|
|
has a hash index with different parameters, the old hash index is removed.
|
|
|
|
If index is non-NULL, this function checks if n_fields and n_bytes are
|
|
|
|
sensible values, and does not build a hash index if not. */
|
|
|
|
static
|
|
|
|
void
|
|
|
|
btr_search_build_page_hash_index(
|
|
|
|
/*=============================*/
|
|
|
|
dict_index_t* index, /* in: index for which to build, or NULL if
|
|
|
|
not known */
|
2006-10-19 08:27:34 +00:00
|
|
|
buf_block_t* block, /* in: index page, s- or x-latched */
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint n_fields,/* in: hash this many full fields */
|
|
|
|
ulint n_bytes,/* in: hash this many bytes from the next
|
|
|
|
field */
|
2006-09-19 10:14:07 +00:00
|
|
|
ibool left_side);/* in: hash for searches from left side? */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
This function should be called before reserving any btr search mutex, if
|
|
|
|
the intended operation might add nodes to the search system hash table.
|
|
|
|
Because of the latching order, once we have reserved the btr search system
|
|
|
|
latch, we cannot allocate a free frame from the buffer pool. Checks that
|
|
|
|
there is a free buffer frame allocated for hash table heap in the btr search
|
|
|
|
system. If not, allocates a free frames for the heap. This check makes it
|
|
|
|
probable that, when have reserved the btr search system latch and we need to
|
|
|
|
allocate a new node to the hash table, it will succeed. However, the check
|
|
|
|
will not guarantee success. */
|
|
|
|
static
|
|
|
|
void
|
|
|
|
btr_search_check_free_space_in_heap(void)
|
|
|
|
/*=====================================*/
|
|
|
|
{
|
|
|
|
hash_table_t* table;
|
|
|
|
mem_heap_t* heap;
|
|
|
|
|
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
|
|
|
ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED));
|
|
|
|
ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX));
|
|
|
|
#endif /* UNIV_SYNC_DEBUG */
|
|
|
|
|
|
|
|
table = btr_search_sys->hash_index;
|
|
|
|
|
|
|
|
heap = table->heap;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Note that we peek the value of heap->free_block without reserving
|
|
|
|
the latch: this is ok, because we will not guarantee that there will
|
|
|
|
be enough free space in the hash table. */
|
|
|
|
|
|
|
|
if (heap->free_block == NULL) {
|
2006-10-12 12:38:29 +00:00
|
|
|
buf_block_t* block = buf_block_alloc(0);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
rw_lock_x_lock(&btr_search_latch);
|
|
|
|
|
|
|
|
if (heap->free_block == NULL) {
|
2006-10-12 12:38:29 +00:00
|
|
|
heap->free_block = block;
|
2005-10-27 07:29:40 +00:00
|
|
|
} else {
|
2006-10-12 12:38:29 +00:00
|
|
|
buf_block_free(block);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
rw_lock_x_unlock(&btr_search_latch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
Creates and initializes the adaptive search system at a database start. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
btr_search_sys_create(
|
|
|
|
/*==================*/
|
|
|
|
ulint hash_size) /* in: hash index hash table size */
|
|
|
|
{
|
|
|
|
/* We allocate the search latch from dynamic memory:
|
|
|
|
see above at the global variable definition */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
btr_search_latch_temp = mem_alloc(sizeof(rw_lock_t));
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-05-08 06:18:59 +00:00
|
|
|
rw_lock_create(&btr_search_latch, SYNC_SEARCH_SYS);
|
branches/innodb+: Merge revisions 4070:4072 from branches/zip:
------------------------------------------------------------------------
r4072 | marko | 2009-01-30 23:30:29 +0200 (Fri, 30 Jan 2009) | 32 lines
branches/zip: Make innodb_adaptive_hash_index settable.
btr_search_disabled: Rename to btr_search_enabled and change the type
to char, so that it can be directly linked to the MySQL parameters.
Note that the variable is protected by btr_search_latch and
btr_search_enabled_mutex, a new mutex introduced in this patch.
btr_search_enabled_mutex: A new mutex, to protect btr_search_enabled
together with btr_search_latch.
buf_pool_drop_hash_index(): New function, to be called from
btr_search_disable().
btr_search_disable(), btr_search_enable(): Fix bugs. These functions
were previously unused.
btr_search_guess_on_hash(), btr_search_build_page_hash_index():
Check btr_search_enabled once more, while holding btr_search_latch.
btr_cur_search_to_nth_level(): Note that the reads of btr_search_enabled
may be dirty and explain why it should not be a problem.
innobase_adaptive_hash_index: Remove. The variable btr_search_enabled will be used directly instead.
innodb_adaptive_hash_index_update(): New function, an update callback for
innodb_adaptive_hash_index. This will call either btr_search_disable()
or btr_search_enable() when the value is assigned. The functions will
be called even if the value does not appear to be changed, e.g., when
setting from TRUE to TRUE or FALSE to FALSE.
rb://85 approved by Heikki Tuuri. This addresses Issue #163.
------------------------------------------------------------------------
2009-01-30 21:45:02 +00:00
|
|
|
mutex_create(&btr_search_enabled_mutex, SYNC_SEARCH_SYS_CONF);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
btr_search_sys = mem_alloc(sizeof(btr_search_sys_t));
|
|
|
|
|
2006-10-18 18:52:04 +00:00
|
|
|
btr_search_sys->hash_index = ha_create(hash_size, 0, 0);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2006-11-21 14:40:14 +00:00
|
|
|
/************************************************************************
|
|
|
|
Disable the adaptive hash search system and empty the index. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2006-11-21 14:40:14 +00:00
|
|
|
void
|
|
|
|
btr_search_disable(void)
|
|
|
|
/*====================*/
|
|
|
|
{
|
branches/innodb+: Merge revisions 4070:4072 from branches/zip:
------------------------------------------------------------------------
r4072 | marko | 2009-01-30 23:30:29 +0200 (Fri, 30 Jan 2009) | 32 lines
branches/zip: Make innodb_adaptive_hash_index settable.
btr_search_disabled: Rename to btr_search_enabled and change the type
to char, so that it can be directly linked to the MySQL parameters.
Note that the variable is protected by btr_search_latch and
btr_search_enabled_mutex, a new mutex introduced in this patch.
btr_search_enabled_mutex: A new mutex, to protect btr_search_enabled
together with btr_search_latch.
buf_pool_drop_hash_index(): New function, to be called from
btr_search_disable().
btr_search_disable(), btr_search_enable(): Fix bugs. These functions
were previously unused.
btr_search_guess_on_hash(), btr_search_build_page_hash_index():
Check btr_search_enabled once more, while holding btr_search_latch.
btr_cur_search_to_nth_level(): Note that the reads of btr_search_enabled
may be dirty and explain why it should not be a problem.
innobase_adaptive_hash_index: Remove. The variable btr_search_enabled will be used directly instead.
innodb_adaptive_hash_index_update(): New function, an update callback for
innodb_adaptive_hash_index. This will call either btr_search_disable()
or btr_search_enable() when the value is assigned. The functions will
be called even if the value does not appear to be changed, e.g., when
setting from TRUE to TRUE or FALSE to FALSE.
rb://85 approved by Heikki Tuuri. This addresses Issue #163.
------------------------------------------------------------------------
2009-01-30 21:45:02 +00:00
|
|
|
mutex_enter(&btr_search_enabled_mutex);
|
2006-11-21 14:40:14 +00:00
|
|
|
rw_lock_x_lock(&btr_search_latch);
|
|
|
|
|
branches/innodb+: Merge revisions 4070:4072 from branches/zip:
------------------------------------------------------------------------
r4072 | marko | 2009-01-30 23:30:29 +0200 (Fri, 30 Jan 2009) | 32 lines
branches/zip: Make innodb_adaptive_hash_index settable.
btr_search_disabled: Rename to btr_search_enabled and change the type
to char, so that it can be directly linked to the MySQL parameters.
Note that the variable is protected by btr_search_latch and
btr_search_enabled_mutex, a new mutex introduced in this patch.
btr_search_enabled_mutex: A new mutex, to protect btr_search_enabled
together with btr_search_latch.
buf_pool_drop_hash_index(): New function, to be called from
btr_search_disable().
btr_search_disable(), btr_search_enable(): Fix bugs. These functions
were previously unused.
btr_search_guess_on_hash(), btr_search_build_page_hash_index():
Check btr_search_enabled once more, while holding btr_search_latch.
btr_cur_search_to_nth_level(): Note that the reads of btr_search_enabled
may be dirty and explain why it should not be a problem.
innobase_adaptive_hash_index: Remove. The variable btr_search_enabled will be used directly instead.
innodb_adaptive_hash_index_update(): New function, an update callback for
innodb_adaptive_hash_index. This will call either btr_search_disable()
or btr_search_enable() when the value is assigned. The functions will
be called even if the value does not appear to be changed, e.g., when
setting from TRUE to TRUE or FALSE to FALSE.
rb://85 approved by Heikki Tuuri. This addresses Issue #163.
------------------------------------------------------------------------
2009-01-30 21:45:02 +00:00
|
|
|
btr_search_enabled = FALSE;
|
|
|
|
|
|
|
|
/* Clear all block->is_hashed flags and remove all entries
|
|
|
|
from btr_search_sys->hash_index. */
|
|
|
|
buf_pool_drop_hash_index();
|
|
|
|
|
|
|
|
/* btr_search_enabled_mutex should guarantee this. */
|
|
|
|
ut_ad(!btr_search_enabled);
|
2006-11-21 14:40:14 +00:00
|
|
|
|
|
|
|
rw_lock_x_unlock(&btr_search_latch);
|
branches/innodb+: Merge revisions 4070:4072 from branches/zip:
------------------------------------------------------------------------
r4072 | marko | 2009-01-30 23:30:29 +0200 (Fri, 30 Jan 2009) | 32 lines
branches/zip: Make innodb_adaptive_hash_index settable.
btr_search_disabled: Rename to btr_search_enabled and change the type
to char, so that it can be directly linked to the MySQL parameters.
Note that the variable is protected by btr_search_latch and
btr_search_enabled_mutex, a new mutex introduced in this patch.
btr_search_enabled_mutex: A new mutex, to protect btr_search_enabled
together with btr_search_latch.
buf_pool_drop_hash_index(): New function, to be called from
btr_search_disable().
btr_search_disable(), btr_search_enable(): Fix bugs. These functions
were previously unused.
btr_search_guess_on_hash(), btr_search_build_page_hash_index():
Check btr_search_enabled once more, while holding btr_search_latch.
btr_cur_search_to_nth_level(): Note that the reads of btr_search_enabled
may be dirty and explain why it should not be a problem.
innobase_adaptive_hash_index: Remove. The variable btr_search_enabled will be used directly instead.
innodb_adaptive_hash_index_update(): New function, an update callback for
innodb_adaptive_hash_index. This will call either btr_search_disable()
or btr_search_enable() when the value is assigned. The functions will
be called even if the value does not appear to be changed, e.g., when
setting from TRUE to TRUE or FALSE to FALSE.
rb://85 approved by Heikki Tuuri. This addresses Issue #163.
------------------------------------------------------------------------
2009-01-30 21:45:02 +00:00
|
|
|
mutex_exit(&btr_search_enabled_mutex);
|
2006-11-21 14:40:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Enable the adaptive hash search system. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2006-11-21 14:40:14 +00:00
|
|
|
void
|
|
|
|
btr_search_enable(void)
|
|
|
|
/*====================*/
|
|
|
|
{
|
branches/innodb+: Merge revisions 4070:4072 from branches/zip:
------------------------------------------------------------------------
r4072 | marko | 2009-01-30 23:30:29 +0200 (Fri, 30 Jan 2009) | 32 lines
branches/zip: Make innodb_adaptive_hash_index settable.
btr_search_disabled: Rename to btr_search_enabled and change the type
to char, so that it can be directly linked to the MySQL parameters.
Note that the variable is protected by btr_search_latch and
btr_search_enabled_mutex, a new mutex introduced in this patch.
btr_search_enabled_mutex: A new mutex, to protect btr_search_enabled
together with btr_search_latch.
buf_pool_drop_hash_index(): New function, to be called from
btr_search_disable().
btr_search_disable(), btr_search_enable(): Fix bugs. These functions
were previously unused.
btr_search_guess_on_hash(), btr_search_build_page_hash_index():
Check btr_search_enabled once more, while holding btr_search_latch.
btr_cur_search_to_nth_level(): Note that the reads of btr_search_enabled
may be dirty and explain why it should not be a problem.
innobase_adaptive_hash_index: Remove. The variable btr_search_enabled will be used directly instead.
innodb_adaptive_hash_index_update(): New function, an update callback for
innodb_adaptive_hash_index. This will call either btr_search_disable()
or btr_search_enable() when the value is assigned. The functions will
be called even if the value does not appear to be changed, e.g., when
setting from TRUE to TRUE or FALSE to FALSE.
rb://85 approved by Heikki Tuuri. This addresses Issue #163.
------------------------------------------------------------------------
2009-01-30 21:45:02 +00:00
|
|
|
mutex_enter(&btr_search_enabled_mutex);
|
|
|
|
rw_lock_x_lock(&btr_search_latch);
|
|
|
|
|
|
|
|
btr_search_enabled = TRUE;
|
|
|
|
|
|
|
|
rw_lock_x_unlock(&btr_search_latch);
|
|
|
|
mutex_exit(&btr_search_enabled_mutex);
|
2006-11-21 14:40:14 +00:00
|
|
|
}
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/*********************************************************************
|
|
|
|
Creates and initializes a search info struct. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
btr_search_t*
|
|
|
|
btr_search_info_create(
|
|
|
|
/*===================*/
|
|
|
|
/* out, own: search info struct */
|
|
|
|
mem_heap_t* heap) /* in: heap where created */
|
|
|
|
{
|
|
|
|
btr_search_t* info;
|
|
|
|
|
|
|
|
info = mem_heap_alloc(heap, sizeof(btr_search_t));
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
#ifdef UNIV_DEBUG
|
2005-10-27 07:29:40 +00:00
|
|
|
info->magic_n = BTR_SEARCH_MAGIC_N;
|
2006-09-19 10:14:07 +00:00
|
|
|
#endif /* UNIV_DEBUG */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2008-08-09 00:15:46 +00:00
|
|
|
info->ref_count = 0;
|
2005-10-27 07:29:40 +00:00
|
|
|
info->root_guess = NULL;
|
|
|
|
|
|
|
|
info->hash_analysis = 0;
|
|
|
|
info->n_hash_potential = 0;
|
|
|
|
|
|
|
|
info->last_hash_succ = FALSE;
|
|
|
|
|
2006-04-12 09:32:17 +00:00
|
|
|
#ifdef UNIV_SEARCH_PERF_STAT
|
2006-02-23 19:25:29 +00:00
|
|
|
info->n_hash_succ = 0;
|
|
|
|
info->n_hash_fail = 0;
|
|
|
|
info->n_patt_succ = 0;
|
|
|
|
info->n_searches = 0;
|
2006-04-12 09:32:17 +00:00
|
|
|
#endif /* UNIV_SEARCH_PERF_STAT */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Set some sensible values */
|
|
|
|
info->n_fields = 1;
|
|
|
|
info->n_bytes = 0;
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
info->left_side = TRUE;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
return(info);
|
|
|
|
}
|
|
|
|
|
2008-08-09 00:15:46 +00:00
|
|
|
/*********************************************************************
|
|
|
|
Returns the value of ref_count. The value is protected by
|
|
|
|
btr_search_latch. */
|
|
|
|
UNIV_INTERN
|
|
|
|
ulint
|
|
|
|
btr_search_info_get_ref_count(
|
|
|
|
/*==========================*/
|
|
|
|
/* out: ref_count value. */
|
|
|
|
btr_search_t* info) /* in: search info. */
|
|
|
|
{
|
|
|
|
ulint ret;
|
|
|
|
|
|
|
|
ut_ad(info);
|
|
|
|
|
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
|
|
|
ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED));
|
|
|
|
ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX));
|
|
|
|
#endif /* UNIV_SYNC_DEBUG */
|
|
|
|
|
|
|
|
rw_lock_s_lock(&btr_search_latch);
|
|
|
|
ret = info->ref_count;
|
|
|
|
rw_lock_s_unlock(&btr_search_latch);
|
|
|
|
|
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/*************************************************************************
|
|
|
|
Updates the search info of an index about hash successes. NOTE that info
|
|
|
|
is NOT protected by any semaphore, to save CPU time! Do not assume its fields
|
|
|
|
are consistent. */
|
|
|
|
static
|
|
|
|
void
|
|
|
|
btr_search_info_update_hash(
|
|
|
|
/*========================*/
|
2006-02-17 14:19:39 +00:00
|
|
|
btr_search_t* info, /* in/out: search info */
|
2005-10-27 07:29:40 +00:00
|
|
|
btr_cur_t* cursor) /* in: cursor which was just positioned */
|
|
|
|
{
|
|
|
|
dict_index_t* index;
|
|
|
|
ulint n_unique;
|
|
|
|
int cmp;
|
|
|
|
|
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
|
|
|
ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED));
|
|
|
|
ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX));
|
|
|
|
#endif /* UNIV_SYNC_DEBUG */
|
|
|
|
|
|
|
|
index = cursor->index;
|
|
|
|
|
2008-01-25 08:13:12 +00:00
|
|
|
if (dict_index_is_ibuf(index)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
/* So many deletes are performed on an insert buffer tree
|
|
|
|
that we do not consider a hash index useful on it: */
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
n_unique = dict_index_get_n_unique_in_tree(index);
|
|
|
|
|
|
|
|
if (info->n_hash_potential == 0) {
|
|
|
|
|
|
|
|
goto set_new_recomm;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Test if the search would have succeeded using the recommended
|
|
|
|
hash prefix */
|
|
|
|
|
|
|
|
if (info->n_fields >= n_unique && cursor->up_match >= n_unique) {
|
2006-09-19 10:14:07 +00:00
|
|
|
increment_potential:
|
2005-10-27 07:29:40 +00:00
|
|
|
info->n_hash_potential++;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmp = ut_pair_cmp(info->n_fields, info->n_bytes,
|
2006-08-29 09:30:31 +00:00
|
|
|
cursor->low_match, cursor->low_bytes);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
if (info->left_side ? cmp <= 0 : cmp > 0) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
goto set_new_recomm;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmp = ut_pair_cmp(info->n_fields, info->n_bytes,
|
2006-08-29 09:30:31 +00:00
|
|
|
cursor->up_match, cursor->up_bytes);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
if (info->left_side ? cmp <= 0 : cmp > 0) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
goto increment_potential;
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
set_new_recomm:
|
|
|
|
/* We have to set a new recommendation; skip the hash analysis
|
|
|
|
for a while to avoid unnecessary CPU time usage when there is no
|
|
|
|
chance for success */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
info->hash_analysis = 0;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
cmp = ut_pair_cmp(cursor->up_match, cursor->up_bytes,
|
2006-08-29 09:30:31 +00:00
|
|
|
cursor->low_match, cursor->low_bytes);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (cmp == 0) {
|
|
|
|
info->n_hash_potential = 0;
|
|
|
|
|
|
|
|
/* For extra safety, we set some sensible values here */
|
|
|
|
|
|
|
|
info->n_fields = 1;
|
|
|
|
info->n_bytes = 0;
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
info->left_side = TRUE;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
} else if (cmp > 0) {
|
|
|
|
info->n_hash_potential = 1;
|
|
|
|
|
|
|
|
if (cursor->up_match >= n_unique) {
|
|
|
|
|
|
|
|
info->n_fields = n_unique;
|
|
|
|
info->n_bytes = 0;
|
|
|
|
|
|
|
|
} else if (cursor->low_match < cursor->up_match) {
|
|
|
|
|
|
|
|
info->n_fields = cursor->low_match + 1;
|
|
|
|
info->n_bytes = 0;
|
2006-02-23 19:25:29 +00:00
|
|
|
} else {
|
2005-10-27 07:29:40 +00:00
|
|
|
info->n_fields = cursor->low_match;
|
|
|
|
info->n_bytes = cursor->low_bytes + 1;
|
|
|
|
}
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
info->left_side = TRUE;
|
2005-10-27 07:29:40 +00:00
|
|
|
} else {
|
|
|
|
info->n_hash_potential = 1;
|
|
|
|
|
|
|
|
if (cursor->low_match >= n_unique) {
|
|
|
|
|
|
|
|
info->n_fields = n_unique;
|
|
|
|
info->n_bytes = 0;
|
|
|
|
|
|
|
|
} else if (cursor->low_match > cursor->up_match) {
|
|
|
|
|
|
|
|
info->n_fields = cursor->up_match + 1;
|
|
|
|
info->n_bytes = 0;
|
2006-02-23 19:25:29 +00:00
|
|
|
} else {
|
2005-10-27 07:29:40 +00:00
|
|
|
info->n_fields = cursor->up_match;
|
|
|
|
info->n_bytes = cursor->up_bytes + 1;
|
|
|
|
}
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
info->left_side = FALSE;
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/*************************************************************************
|
|
|
|
Updates the block search info on hash successes. NOTE that info and
|
|
|
|
block->n_hash_helps, n_fields, n_bytes, side are NOT protected by any
|
|
|
|
semaphore, to save CPU time! Do not assume the fields are consistent. */
|
|
|
|
static
|
|
|
|
ibool
|
|
|
|
btr_search_update_block_hash_info(
|
|
|
|
/*==============================*/
|
|
|
|
/* out: TRUE if building a (new) hash index on
|
|
|
|
the block is recommended */
|
|
|
|
btr_search_t* info, /* in: search info */
|
|
|
|
buf_block_t* block, /* in: buffer block */
|
2006-09-19 10:14:07 +00:00
|
|
|
btr_cur_t* cursor __attribute__((unused)))
|
|
|
|
/* in: cursor */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
|
|
|
ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED));
|
|
|
|
ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX));
|
2006-10-19 07:27:26 +00:00
|
|
|
ut_ad(rw_lock_own(&block->lock, RW_LOCK_SHARED)
|
|
|
|
|| rw_lock_own(&block->lock, RW_LOCK_EX));
|
2005-10-27 07:29:40 +00:00
|
|
|
#endif /* UNIV_SYNC_DEBUG */
|
|
|
|
ut_ad(cursor);
|
|
|
|
|
|
|
|
info->last_hash_succ = FALSE;
|
|
|
|
|
2006-11-23 15:14:45 +00:00
|
|
|
ut_a(buf_block_state_valid(block));
|
2006-09-19 10:14:07 +00:00
|
|
|
ut_ad(info->magic_n == BTR_SEARCH_MAGIC_N);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if ((block->n_hash_helps > 0)
|
2006-08-29 09:30:31 +00:00
|
|
|
&& (info->n_hash_potential > 0)
|
|
|
|
&& (block->n_fields == info->n_fields)
|
|
|
|
&& (block->n_bytes == info->n_bytes)
|
2006-09-19 10:14:07 +00:00
|
|
|
&& (block->left_side == info->left_side)) {
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if ((block->is_hashed)
|
2006-08-29 09:30:31 +00:00
|
|
|
&& (block->curr_n_fields == info->n_fields)
|
|
|
|
&& (block->curr_n_bytes == info->n_bytes)
|
2006-09-19 10:14:07 +00:00
|
|
|
&& (block->curr_left_side == info->left_side)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* The search would presumably have succeeded using
|
|
|
|
the hash index */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
info->last_hash_succ = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
block->n_hash_helps++;
|
|
|
|
} else {
|
|
|
|
block->n_hash_helps = 1;
|
|
|
|
block->n_fields = info->n_fields;
|
|
|
|
block->n_bytes = info->n_bytes;
|
2006-09-19 10:14:07 +00:00
|
|
|
block->left_side = info->left_side;
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
#ifdef UNIV_DEBUG
|
2005-10-27 07:29:40 +00:00
|
|
|
if (cursor->index->table->does_not_fit_in_memory) {
|
|
|
|
block->n_hash_helps = 0;
|
|
|
|
}
|
2006-09-19 10:14:07 +00:00
|
|
|
#endif /* UNIV_DEBUG */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if ((block->n_hash_helps > page_get_n_recs(block->frame)
|
2006-08-29 09:30:31 +00:00
|
|
|
/ BTR_SEARCH_PAGE_BUILD_LIMIT)
|
|
|
|
&& (info->n_hash_potential >= BTR_SEARCH_BUILD_LIMIT)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
if ((!block->is_hashed)
|
2006-08-29 09:30:31 +00:00
|
|
|
|| (block->n_hash_helps
|
|
|
|
> 2 * page_get_n_recs(block->frame))
|
|
|
|
|| (block->n_fields != block->curr_n_fields)
|
|
|
|
|| (block->n_bytes != block->curr_n_bytes)
|
2006-09-19 10:14:07 +00:00
|
|
|
|| (block->left_side != block->curr_left_side)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
/* Build a new hash index on the page */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
return(TRUE);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Updates a hash node reference when it has been unsuccessfully used in a
|
|
|
|
search which could have succeeded with the used hash parameters. This can
|
|
|
|
happen because when building a hash index for a page, we do not check
|
|
|
|
what happens at page boundaries, and therefore there can be misleading
|
|
|
|
hash nodes. Also, collisions in the fold value can lead to misleading
|
|
|
|
references. This function lazily fixes these imperfections in the hash
|
|
|
|
index. */
|
|
|
|
static
|
|
|
|
void
|
|
|
|
btr_search_update_hash_ref(
|
|
|
|
/*=======================*/
|
|
|
|
btr_search_t* info, /* in: search info */
|
|
|
|
buf_block_t* block, /* in: buffer block where cursor positioned */
|
|
|
|
btr_cur_t* cursor) /* in: cursor */
|
|
|
|
{
|
|
|
|
ulint fold;
|
|
|
|
rec_t* rec;
|
2006-09-19 10:14:07 +00:00
|
|
|
dulint index_id;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ut_ad(cursor->flag == BTR_CUR_HASH_FAIL);
|
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
|
|
|
ut_ad(rw_lock_own(&btr_search_latch, RW_LOCK_EX));
|
|
|
|
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED)
|
2006-08-29 09:30:31 +00:00
|
|
|
|| rw_lock_own(&(block->lock), RW_LOCK_EX));
|
2005-10-27 07:29:40 +00:00
|
|
|
#endif /* UNIV_SYNC_DEBUG */
|
2006-10-09 19:36:58 +00:00
|
|
|
ut_ad(page_align(btr_cur_get_rec(cursor))
|
|
|
|
== buf_block_get_frame(block));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2008-01-25 14:37:11 +00:00
|
|
|
if (!block->is_hashed) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ut_a(block->index == cursor->index);
|
|
|
|
ut_a(!dict_index_is_ibuf(cursor->index));
|
|
|
|
|
|
|
|
if ((info->n_hash_potential > 0)
|
2006-08-29 09:30:31 +00:00
|
|
|
&& (block->curr_n_fields == info->n_fields)
|
|
|
|
&& (block->curr_n_bytes == info->n_bytes)
|
2006-09-19 10:14:07 +00:00
|
|
|
&& (block->curr_left_side == info->left_side)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
mem_heap_t* heap = NULL;
|
|
|
|
ulint offsets_[REC_OFFS_NORMAL_SIZE];
|
2007-09-28 07:05:57 +00:00
|
|
|
rec_offs_init(offsets_);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
rec = btr_cur_get_rec(cursor);
|
|
|
|
|
|
|
|
if (!page_rec_is_user_rec(rec)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
return;
|
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
index_id = cursor->index->id;
|
2006-08-29 09:30:31 +00:00
|
|
|
fold = rec_fold(rec,
|
|
|
|
rec_get_offsets(rec, cursor->index, offsets_,
|
|
|
|
ULINT_UNDEFINED, &heap),
|
2005-10-27 07:29:40 +00:00
|
|
|
block->curr_n_fields,
|
2006-09-19 10:14:07 +00:00
|
|
|
block->curr_n_bytes, index_id);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (UNIV_LIKELY_NULL(heap)) {
|
|
|
|
mem_heap_free(heap);
|
|
|
|
}
|
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
|
|
|
ut_ad(rw_lock_own(&btr_search_latch, RW_LOCK_EX));
|
|
|
|
#endif /* UNIV_SYNC_DEBUG */
|
|
|
|
|
2006-11-13 21:53:09 +00:00
|
|
|
ha_insert_for_fold(btr_search_sys->hash_index, fold,
|
|
|
|
block, rec);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
}
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/*************************************************************************
|
|
|
|
Updates the search info. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
btr_search_info_update_slow(
|
|
|
|
/*========================*/
|
2006-02-17 14:19:39 +00:00
|
|
|
btr_search_t* info, /* in/out: search info */
|
2005-10-27 07:29:40 +00:00
|
|
|
btr_cur_t* cursor) /* in: cursor which was just positioned */
|
|
|
|
{
|
|
|
|
buf_block_t* block;
|
|
|
|
ibool build_index;
|
|
|
|
ulint* params;
|
|
|
|
ulint* params2;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
|
|
|
ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED));
|
|
|
|
ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX));
|
|
|
|
#endif /* UNIV_SYNC_DEBUG */
|
|
|
|
|
2006-10-18 11:39:31 +00:00
|
|
|
block = btr_cur_get_block(cursor);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* NOTE that the following two function calls do NOT protect
|
|
|
|
info or block->n_fields etc. with any semaphore, to save CPU time!
|
|
|
|
We cannot assume the fields are consistent when we return from
|
|
|
|
those functions! */
|
|
|
|
|
|
|
|
btr_search_info_update_hash(info, cursor);
|
|
|
|
|
|
|
|
build_index = btr_search_update_block_hash_info(info, block, cursor);
|
|
|
|
|
|
|
|
if (build_index || (cursor->flag == BTR_CUR_HASH_FAIL)) {
|
|
|
|
|
|
|
|
btr_search_check_free_space_in_heap();
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (cursor->flag == BTR_CUR_HASH_FAIL) {
|
|
|
|
/* Update the hash node reference, if appropriate */
|
|
|
|
|
2006-04-12 09:32:17 +00:00
|
|
|
#ifdef UNIV_SEARCH_PERF_STAT
|
2005-10-27 07:29:40 +00:00
|
|
|
btr_search_n_hash_fail++;
|
2006-04-12 09:32:17 +00:00
|
|
|
#endif /* UNIV_SEARCH_PERF_STAT */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
rw_lock_x_lock(&btr_search_latch);
|
|
|
|
|
|
|
|
btr_search_update_hash_ref(info, block, cursor);
|
|
|
|
|
|
|
|
rw_lock_x_unlock(&btr_search_latch);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (build_index) {
|
|
|
|
/* Note that since we did not protect block->n_fields etc.
|
|
|
|
with any semaphore, the values can be inconsistent. We have
|
|
|
|
to check inside the function call that they make sense. We
|
|
|
|
also malloc an array and store the values there to make sure
|
|
|
|
the compiler does not let the function call parameters change
|
|
|
|
inside the called function. It might be that the compiler
|
|
|
|
would optimize the call just to pass pointers to block. */
|
|
|
|
|
|
|
|
params = mem_alloc(3 * sizeof(ulint));
|
|
|
|
params[0] = block->n_fields;
|
|
|
|
params[1] = block->n_bytes;
|
2006-09-19 10:14:07 +00:00
|
|
|
params[2] = block->left_side;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Make sure the compiler cannot deduce the values and do
|
|
|
|
optimizations */
|
|
|
|
|
|
|
|
params2 = params + btr_search_this_is_zero;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
btr_search_build_page_hash_index(cursor->index,
|
2006-10-19 08:27:34 +00:00
|
|
|
block,
|
2006-08-29 09:30:31 +00:00
|
|
|
params2[0],
|
|
|
|
params2[1],
|
|
|
|
params2[2]);
|
2005-10-27 07:29:40 +00:00
|
|
|
mem_free(params);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
Checks if a guessed position for a tree cursor is right. Note that if
|
|
|
|
mode is PAGE_CUR_LE, which is used in inserts, and the function returns
|
|
|
|
TRUE, then cursor->up_match and cursor->low_match both have sensible values. */
|
|
|
|
static
|
|
|
|
ibool
|
|
|
|
btr_search_check_guess(
|
|
|
|
/*===================*/
|
|
|
|
/* out: TRUE if success */
|
|
|
|
btr_cur_t* cursor, /* in: guessed cursor position */
|
2006-02-23 19:25:29 +00:00
|
|
|
ibool can_only_compare_to_cursor_rec,
|
|
|
|
/* in: if we do not have a latch on the page
|
2005-10-27 07:29:40 +00:00
|
|
|
of cursor, but only a latch on
|
2006-02-23 19:25:29 +00:00
|
|
|
btr_search_latch, then ONLY the columns
|
2005-10-27 07:29:40 +00:00
|
|
|
of the record UNDER the cursor are
|
|
|
|
protected, not the next or previous record
|
|
|
|
in the chain: we cannot look at the next or
|
|
|
|
previous record to check our guess! */
|
2006-10-20 08:30:07 +00:00
|
|
|
const dtuple_t* tuple, /* in: data tuple */
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint mode, /* in: PAGE_CUR_L, PAGE_CUR_LE, PAGE_CUR_G,
|
|
|
|
or PAGE_CUR_GE */
|
|
|
|
mtr_t* mtr) /* in: mtr */
|
|
|
|
{
|
|
|
|
rec_t* rec;
|
|
|
|
ulint n_unique;
|
|
|
|
ulint match;
|
|
|
|
ulint bytes;
|
|
|
|
int cmp;
|
|
|
|
mem_heap_t* heap = NULL;
|
|
|
|
ulint offsets_[REC_OFFS_NORMAL_SIZE];
|
|
|
|
ulint* offsets = offsets_;
|
|
|
|
ibool success = FALSE;
|
2007-09-28 07:05:57 +00:00
|
|
|
rec_offs_init(offsets_);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
n_unique = dict_index_get_n_unique_in_tree(cursor->index);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
rec = btr_cur_get_rec(cursor);
|
|
|
|
|
|
|
|
ut_ad(page_rec_is_user_rec(rec));
|
|
|
|
|
|
|
|
match = 0;
|
|
|
|
bytes = 0;
|
|
|
|
|
|
|
|
offsets = rec_get_offsets(rec, cursor->index, offsets,
|
2006-08-29 09:30:31 +00:00
|
|
|
n_unique, &heap);
|
2005-10-27 07:29:40 +00:00
|
|
|
cmp = page_cmp_dtuple_rec_with_match(tuple, rec,
|
2006-08-29 09:30:31 +00:00
|
|
|
offsets, &match, &bytes);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if (mode == PAGE_CUR_GE) {
|
|
|
|
if (cmp == 1) {
|
|
|
|
goto exit_func;
|
|
|
|
}
|
|
|
|
|
|
|
|
cursor->up_match = match;
|
|
|
|
|
|
|
|
if (match >= n_unique) {
|
|
|
|
success = TRUE;
|
|
|
|
goto exit_func;
|
2006-02-23 19:25:29 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
} else if (mode == PAGE_CUR_LE) {
|
|
|
|
if (cmp == -1) {
|
|
|
|
goto exit_func;
|
|
|
|
}
|
|
|
|
|
|
|
|
cursor->low_match = match;
|
|
|
|
|
|
|
|
} else if (mode == PAGE_CUR_G) {
|
|
|
|
if (cmp != -1) {
|
|
|
|
goto exit_func;
|
|
|
|
}
|
|
|
|
} else if (mode == PAGE_CUR_L) {
|
|
|
|
if (cmp != 1) {
|
|
|
|
goto exit_func;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (can_only_compare_to_cursor_rec) {
|
2006-02-23 19:25:29 +00:00
|
|
|
/* Since we could not determine if our guess is right just by
|
|
|
|
looking at the record under the cursor, return FALSE */
|
2005-10-27 07:29:40 +00:00
|
|
|
goto exit_func;
|
|
|
|
}
|
|
|
|
|
|
|
|
match = 0;
|
|
|
|
bytes = 0;
|
|
|
|
|
|
|
|
if ((mode == PAGE_CUR_G) || (mode == PAGE_CUR_GE)) {
|
|
|
|
rec_t* prev_rec;
|
|
|
|
|
|
|
|
ut_ad(!page_rec_is_infimum(rec));
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
prev_rec = page_rec_get_prev(rec);
|
|
|
|
|
|
|
|
if (page_rec_is_infimum(prev_rec)) {
|
2006-10-09 16:22:47 +00:00
|
|
|
success = btr_page_get_prev(page_align(prev_rec), mtr)
|
|
|
|
== FIL_NULL;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
goto exit_func;
|
|
|
|
}
|
|
|
|
|
|
|
|
offsets = rec_get_offsets(prev_rec, cursor->index, offsets,
|
2006-08-29 09:30:31 +00:00
|
|
|
n_unique, &heap);
|
2005-10-27 07:29:40 +00:00
|
|
|
cmp = page_cmp_dtuple_rec_with_match(tuple, prev_rec,
|
2006-08-29 09:30:31 +00:00
|
|
|
offsets, &match, &bytes);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (mode == PAGE_CUR_GE) {
|
|
|
|
success = cmp == 1;
|
|
|
|
} else {
|
|
|
|
success = cmp != -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
goto exit_func;
|
|
|
|
} else {
|
|
|
|
rec_t* next_rec;
|
|
|
|
|
|
|
|
ut_ad(!page_rec_is_supremum(rec));
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
next_rec = page_rec_get_next(rec);
|
|
|
|
|
|
|
|
if (page_rec_is_supremum(next_rec)) {
|
2006-10-09 16:22:47 +00:00
|
|
|
if (btr_page_get_next(page_align(next_rec), mtr)
|
2006-09-19 10:14:07 +00:00
|
|
|
== FIL_NULL) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
cursor->up_match = 0;
|
|
|
|
success = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
goto exit_func;
|
|
|
|
}
|
|
|
|
|
|
|
|
offsets = rec_get_offsets(next_rec, cursor->index, offsets,
|
2006-08-29 09:30:31 +00:00
|
|
|
n_unique, &heap);
|
2005-10-27 07:29:40 +00:00
|
|
|
cmp = page_cmp_dtuple_rec_with_match(tuple, next_rec,
|
2006-08-29 09:30:31 +00:00
|
|
|
offsets, &match, &bytes);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (mode == PAGE_CUR_LE) {
|
|
|
|
success = cmp == -1;
|
|
|
|
cursor->up_match = match;
|
|
|
|
} else {
|
|
|
|
success = cmp != 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exit_func:
|
|
|
|
if (UNIV_LIKELY_NULL(heap)) {
|
|
|
|
mem_heap_free(heap);
|
|
|
|
}
|
|
|
|
return(success);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
Tries to guess the right search position based on the hash search info
|
|
|
|
of the index. Note that if mode is PAGE_CUR_LE, which is used in inserts,
|
|
|
|
and the function returns TRUE, then cursor->up_match and cursor->low_match
|
|
|
|
both have sensible values. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
btr_search_guess_on_hash(
|
|
|
|
/*=====================*/
|
2006-02-23 19:25:29 +00:00
|
|
|
/* out: TRUE if succeeded */
|
2005-10-27 07:29:40 +00:00
|
|
|
dict_index_t* index, /* in: index */
|
|
|
|
btr_search_t* info, /* in: index search info */
|
2006-10-20 08:30:07 +00:00
|
|
|
const dtuple_t* tuple, /* in: logical record */
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint mode, /* in: PAGE_CUR_L, ... */
|
2006-02-23 19:25:29 +00:00
|
|
|
ulint latch_mode, /* in: BTR_SEARCH_LEAF, ...;
|
2005-10-27 07:29:40 +00:00
|
|
|
NOTE that only if has_search_latch
|
|
|
|
is 0, we will have a latch set on
|
|
|
|
the cursor page, otherwise we assume
|
|
|
|
the caller uses his search latch
|
|
|
|
to protect the record! */
|
2006-02-23 19:25:29 +00:00
|
|
|
btr_cur_t* cursor, /* out: tree cursor */
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint has_search_latch,/* in: latch mode the caller
|
|
|
|
currently has on btr_search_latch:
|
|
|
|
RW_S_LATCH, RW_X_LATCH, or 0 */
|
|
|
|
mtr_t* mtr) /* in: mtr */
|
|
|
|
{
|
|
|
|
buf_block_t* block;
|
|
|
|
rec_t* rec;
|
|
|
|
ulint fold;
|
2006-09-19 10:14:07 +00:00
|
|
|
dulint index_id;
|
2005-10-27 07:29:40 +00:00
|
|
|
#ifdef notdefined
|
|
|
|
btr_cur_t cursor2;
|
|
|
|
btr_pcur_t pcur;
|
|
|
|
#endif
|
|
|
|
ut_ad(index && info && tuple && cursor && mtr);
|
|
|
|
ut_ad((latch_mode == BTR_SEARCH_LEAF)
|
2006-08-29 09:30:31 +00:00
|
|
|
|| (latch_mode == BTR_MODIFY_LEAF));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Note that, for efficiency, the struct info may not be protected by
|
|
|
|
any latch here! */
|
|
|
|
|
|
|
|
if (UNIV_UNLIKELY(info->n_hash_potential == 0)) {
|
|
|
|
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
cursor->n_fields = info->n_fields;
|
|
|
|
cursor->n_bytes = info->n_bytes;
|
|
|
|
|
2007-01-31 14:28:37 +00:00
|
|
|
if (UNIV_UNLIKELY(dtuple_get_n_fields(tuple)
|
|
|
|
< cursor->n_fields + (cursor->n_bytes > 0))) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
return(FALSE);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
index_id = index->id;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
#ifdef UNIV_SEARCH_PERF_STAT
|
|
|
|
info->n_hash_succ++;
|
|
|
|
#endif
|
2006-09-19 10:14:07 +00:00
|
|
|
fold = dtuple_fold(tuple, cursor->n_fields, cursor->n_bytes, index_id);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
cursor->fold = fold;
|
|
|
|
cursor->flag = BTR_CUR_HASH;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (UNIV_LIKELY(!has_search_latch)) {
|
|
|
|
rw_lock_s_lock(&btr_search_latch);
|
branches/innodb+: Merge revisions 4070:4072 from branches/zip:
------------------------------------------------------------------------
r4072 | marko | 2009-01-30 23:30:29 +0200 (Fri, 30 Jan 2009) | 32 lines
branches/zip: Make innodb_adaptive_hash_index settable.
btr_search_disabled: Rename to btr_search_enabled and change the type
to char, so that it can be directly linked to the MySQL parameters.
Note that the variable is protected by btr_search_latch and
btr_search_enabled_mutex, a new mutex introduced in this patch.
btr_search_enabled_mutex: A new mutex, to protect btr_search_enabled
together with btr_search_latch.
buf_pool_drop_hash_index(): New function, to be called from
btr_search_disable().
btr_search_disable(), btr_search_enable(): Fix bugs. These functions
were previously unused.
btr_search_guess_on_hash(), btr_search_build_page_hash_index():
Check btr_search_enabled once more, while holding btr_search_latch.
btr_cur_search_to_nth_level(): Note that the reads of btr_search_enabled
may be dirty and explain why it should not be a problem.
innobase_adaptive_hash_index: Remove. The variable btr_search_enabled will be used directly instead.
innodb_adaptive_hash_index_update(): New function, an update callback for
innodb_adaptive_hash_index. This will call either btr_search_disable()
or btr_search_enable() when the value is assigned. The functions will
be called even if the value does not appear to be changed, e.g., when
setting from TRUE to TRUE or FALSE to FALSE.
rb://85 approved by Heikki Tuuri. This addresses Issue #163.
------------------------------------------------------------------------
2009-01-30 21:45:02 +00:00
|
|
|
|
|
|
|
if (UNIV_UNLIKELY(!btr_search_enabled)) {
|
|
|
|
goto failure_unlock;
|
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
branches/innodb+: Merge revisions 4072:4150 from branches/zip:
------------------------------------------------------------------------
r4074 | vasil | 2009-01-31 08:05:24 +0200 (Sat, 31 Jan 2009) | 4 lines
branches/zip:
Adjust the failing patch patches/information_schema.diff.
------------------------------------------------------------------------
r4076 | vasil | 2009-02-02 09:32:04 +0200 (Mon, 02 Feb 2009) | 4 lines
branches/zip:
Add ChangeLog entry for the change in r4072.
------------------------------------------------------------------------
r4077 | marko | 2009-02-02 10:48:05 +0200 (Mon, 02 Feb 2009) | 2 lines
branches/zip: innobase_start_or_create_for_mysql(): Remove a factual error
in the function comment. Parameters are not read from a file "srv_init".
------------------------------------------------------------------------
r4081 | marko | 2009-02-02 14:28:17 +0200 (Mon, 02 Feb 2009) | 4 lines
branches/zip: Enclose some backup functions in #ifdef UNIV_HOTBACKUP.
recv_read_cp_info_for_backup(), recv_scan_log_seg_for_backup():
These functions are only called by InnoDB Hot Backup.
------------------------------------------------------------------------
r4082 | vasil | 2009-02-02 18:24:08 +0200 (Mon, 02 Feb 2009) | 10 lines
branches/zip:
Fix a mysql-test failure in innodb-zip:
main.innodb-zip [ fail ]
Test ended at 2009-02-02 18:13:25
CURRENT_TEST: main.innodb-zip
mysqltest: At line 160: Found line beginning with -- that didn't contain a valid mysqltest command, check your syntax or use # if you intended to write a comment
------------------------------------------------------------------------
r4083 | vasil | 2009-02-02 18:33:20 +0200 (Mon, 02 Feb 2009) | 6 lines
branches/zip:
Fix the failing innodb-zip test to restore the environment as it was before
the test execution because a newly added feature in the mysql-test framework
does check for this.
------------------------------------------------------------------------
r4088 | calvin | 2009-02-03 02:35:56 +0200 (Tue, 03 Feb 2009) | 8 lines
branches/zip: fix a compiler error and a warning
Both are minor changes:
1) Compiler error introduced in r4072: double ';' at the end.
2) Warning introduced in r3613: \mem\mem0pool.c(481) :
warning C4098: 'mem_area_free' : 'void' function returning a value
Approved by: Sunny (IM)
------------------------------------------------------------------------
r4098 | marko | 2009-02-03 09:52:45 +0200 (Tue, 03 Feb 2009) | 4 lines
branches/zip: mem_area_free(): Correct a bug that was introduced in r4088.
free() is not the same as ut_free(). ut_free() pairs with ut_malloc(),
not malloc(). free() pairs with malloc() and some other functions.
------------------------------------------------------------------------
r4114 | marko | 2009-02-04 16:09:24 +0200 (Wed, 04 Feb 2009) | 2 lines
branches/zip: buf_block_align(): Fix a bogus debug assertion
that was introduced in r4036, to address Issue #161.
------------------------------------------------------------------------
r4139 | vasil | 2009-02-09 13:47:16 +0200 (Mon, 09 Feb 2009) | 5 lines
branches/zip:
Remove mysql-test/patches/bug35261.diff because that bug has been fixed
in the MySQL repository.
------------------------------------------------------------------------
r4141 | marko | 2009-02-09 15:35:50 +0200 (Mon, 09 Feb 2009) | 1 line
branches/zip: fil_write_lsn_and_arch_no_to_file(): Plug a memory leak.
------------------------------------------------------------------------
r4144 | inaam | 2009-02-10 01:36:25 +0200 (Tue, 10 Feb 2009) | 9 lines
branches/zip rb://30
This patch changes the innodb mutexes and rw_locks implementation.
On supported platforms it uses GCC builtin atomics. These changes
are based on the patch sent by Mark Callaghan of Google under BSD
license. More technical discussion can be found at rb://30
Approved by: Heikki
------------------------------------------------------------------------
r4145 | vasil | 2009-02-10 07:34:43 +0200 (Tue, 10 Feb 2009) | 9 lines
branches/zip:
Non-functional change: Fix a compilation warning introduced in r4144:
gcc -DHAVE_CONFIG_H -I. -I../../include -I../../include -I../../include -I../../regex -I../../storage/innobase/include -I../../sql -I. -Werror -Wall -g -MT libinnobase_a-sync0arr.o -MD -MP -MF .deps/libinnobase_a-sync0arr.Tpo -c -o libinnobase_a-sync0arr.o `test -f 'sync/sync0arr.c' || echo './'`sync/sync0arr.c
cc1: warnings being treated as errors
sync/sync0arr.c: In function 'sync_array_object_signalled':
sync/sync0arr.c:869: warning: pointer targets in passing argument 1 of 'os_atomic_increment' differ in signedness
------------------------------------------------------------------------
r4148 | marko | 2009-02-10 10:38:41 +0200 (Tue, 10 Feb 2009) | 12 lines
branches/zip: Map ut_malloc(), ut_realloc(), ut_free() to
malloc(), realloc(), free() when innodb_use_sys_malloc is set.
ut_free_all_mem(): If innodb_use_sys_malloc is set, do nothing,
because then ut_mem_block_list_inited will never be set.
log_init(): Use mem_alloc() instead of ut_malloc(), so that the
memory will be freed. (Tested with Valgrind, although it is not
clear why the memory would be freed.)
rb://86 approved by Heikki Tuuri and Ken Jacobs. This addresses Issue #168.
------------------------------------------------------------------------
r4149 | marko | 2009-02-10 11:09:15 +0200 (Tue, 10 Feb 2009) | 1 line
branches/zip: ChangeLog: Document recent changes.
------------------------------------------------------------------------
r4150 | marko | 2009-02-10 11:51:43 +0200 (Tue, 10 Feb 2009) | 6 lines
branches/zip: get_share(), free_share(): Make table locking case sensitive.
If lower_case_table_names=1, MySQL will pass the table names in lower case.
Thus, we can use a binary comparison (strcmp) in the hash table.
rb://87 approved by Heikki Tuuri, to address Bug #41676 and Issue #167.
------------------------------------------------------------------------
2009-02-10 10:03:42 +00:00
|
|
|
ut_ad(rw_lock_get_writer(&btr_search_latch) != RW_LOCK_EX);
|
|
|
|
ut_ad(rw_lock_get_reader_count(&btr_search_latch) > 0);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
rec = ha_search_and_get_data(btr_search_sys->hash_index, fold);
|
|
|
|
|
|
|
|
if (UNIV_UNLIKELY(!rec)) {
|
|
|
|
goto failure_unlock;
|
|
|
|
}
|
|
|
|
|
branches/innodb+: Merge revisions 4006:4060 from branches/zip:
------------------------------------------------------------------------
r4008 | vasil | 2009-01-20 17:01:08 +0200 (Tue, 20 Jan 2009) | 4 lines
branches/zip:
Add ChangeLog entries for the bugfixes in r4004 and r4005.
------------------------------------------------------------------------
r4027 | marko | 2009-01-23 11:04:49 +0200 (Fri, 23 Jan 2009) | 1 line
branches/zip: Remove some redundant #include statements.
------------------------------------------------------------------------
r4028 | marko | 2009-01-23 11:26:10 +0200 (Fri, 23 Jan 2009) | 13 lines
branches/zip: Enclose some more unused code in #ifdef UNIV_LOG_ARCHIVE.
This will help trim the dependencies of InnoDB Hot Backup.
recv_recovery_from_checkpoint_start(): Rename to
recv_recovery_from_checkpoint_start_func(), and remove the two first
parameters unless UNIV_LOG_ARCHIVE is defined. Define and use
the auxiliary macros TYPE_CHECKPOINT and LIMIT_LSN in the function.
struct recv_sys_struct: Remove archive_group unless UNIV_LOG_ARCHIVE
is defined.
Do not define LOG_ARCHIVE unless UNIV_LOG_ARCHIVE is defined.
------------------------------------------------------------------------
r4029 | marko | 2009-01-23 14:07:38 +0200 (Fri, 23 Jan 2009) | 1 line
branches/zip: Remove some redundant #include directives.
------------------------------------------------------------------------
r4030 | marko | 2009-01-23 15:31:36 +0200 (Fri, 23 Jan 2009) | 2 lines
branches/zip: buf_page_get_gen(): Remove the unused mode BUF_GET_NOWAIT.
This was noticed while investigating Issue #160.
------------------------------------------------------------------------
r4033 | marko | 2009-01-23 15:49:04 +0200 (Fri, 23 Jan 2009) | 16 lines
branches/zip: Merge revisions 4005:4032 from branches/5.1:
------------------------------------------------------------------------
r4032 | marko | 2009-01-23 15:43:51 +0200 (Fri, 23 Jan 2009) | 10 lines
branches/5.1: Merge r4031 from branches/5.0:
btr_search_drop_page_hash_when_freed(): Check if buf_page_get_gen()
returns NULL. The page may have been evicted from the buffer pool
between buf_page_peek_if_search_hashed() and buf_page_get_gen(),
because the buffer pool mutex will be released between these two calls.
(Bug #42279, Issue #160)
rb://82 approved by Heikki Tuuri
------------------------------------------------------------------------
------------------------------------------------------------------------
r4034 | marko | 2009-01-26 16:16:39 +0200 (Mon, 26 Jan 2009) | 2 lines
branches/zip: buf_page_get_gen(): Fix a "possibly uninitialized" warning
that was introduced in r4030.
------------------------------------------------------------------------
r4036 | marko | 2009-01-26 22:33:20 +0200 (Mon, 26 Jan 2009) | 22 lines
branches/zip: In r988, the function buf_block_align() was enclosed
within UNIV_DEBUG. The two remaining callers in non-debug builds,
btr_search_guess_on_hash() and btr_search_validate(), were rewritten
to call buf_page_hash_get().
To implement support for a resizeable buffer pool, the function
buf_block_align() had been rewritten to perform a page hash lookup in
the buffer pool. The caller was also made responsible for holding the
buffer pool mutex.
Because the page hash lookup is expensive and it has to be done while
holding the buffer pool mutex, implement buf_block_align() by pointer
arithmetics again, and make btr_search_guess_on_hash() call it. Note
that this will have to be adjusted if the interface to the resizeable
buffer pool is actually implemented.
rb://83 approved by Heikki Tuuri, to address Issue #161.
As a deviation from the approved patch, this patch also makes
btr_search_validate() (invoked by CHECK TABLE) check that
buf_pool->page_hash is consistent with buf_block_align().
------------------------------------------------------------------------
r4039 | vasil | 2009-01-27 08:04:17 +0200 (Tue, 27 Jan 2009) | 5 lines
branches/zip:
Adjust the paths in innodb_file_per_table.diff with a recent rename of
the test/result files in the MySQL tree.
------------------------------------------------------------------------
r4042 | marko | 2009-01-27 10:05:24 +0200 (Tue, 27 Jan 2009) | 2 lines
branches/zip: buf_LRU_invalidate_tablespace(): Fix a race condition:
read zip_size while still holding block_mutex.
------------------------------------------------------------------------
r4045 | marko | 2009-01-28 00:31:17 +0200 (Wed, 28 Jan 2009) | 8 lines
branches/zip: btr_search_validate(): Fix a bogus UNIV_DEBUG
assertion failure that was accidentally introduced in r4036.
Instead of calling buf_block_get_frame(), which asserts that the
block must be buffer-fixed, access block->frame directly. That
is safe, because changes of block->page.state are protected by
the buffer pool mutex, which we are holding.
This bug was reported by Michael.
------------------------------------------------------------------------
r4046 | marko | 2009-01-28 00:33:20 +0200 (Wed, 28 Jan 2009) | 2 lines
branches/zip: Revert the change to univ.i that was accidentally
committed in r4045.
------------------------------------------------------------------------
r4047 | marko | 2009-01-28 00:46:13 +0200 (Wed, 28 Jan 2009) | 6 lines
branches/zip: btr_search_validate(): Fix an assertion failure that was
introduced in r4036.
Do not call buf_block_get_space(), buf_block_get_page_no()
unless the block state is BUF_BLOCK_FILE_PAGE.
This bug was reported by Michael.
------------------------------------------------------------------------
r4050 | vasil | 2009-01-28 08:21:44 +0200 (Wed, 28 Jan 2009) | 5 lines
branches/zip:
Adjust the paths in innodb_lock_wait_timeout.diff with a recent rename of
the test/result files in the MySQL tree.
------------------------------------------------------------------------
r4051 | marko | 2009-01-28 14:35:49 +0200 (Wed, 28 Jan 2009) | 1 line
branches/zip: trx0sys.ic: Remove unnecessary #include <data0type.h>.
------------------------------------------------------------------------
r4052 | marko | 2009-01-28 15:21:45 +0200 (Wed, 28 Jan 2009) | 5 lines
branches/zip: Enclose some functions inside #ifdef UNIV_HOTBACKUP:
ut_sprintf_timestamp_without_extra_chars(), ut_get_year_month_day(),
log_reset_first_header_and_checkpoint(): These functions are only used
in InnoDB Hot Backup.
------------------------------------------------------------------------
r4056 | calvin | 2009-01-29 03:06:41 +0200 (Thu, 29 Jan 2009) | 33 lines
branches/zip: Merge revisions 4032:4035 from branches/5.1
All InnoDB related tests passed on Windows, except
known failure in partition_innodb_semi_consistent.
The inadvertent change to btr0sea.c in this commit is reverted in r4060.
------------------------------------------------------------------------
r4035 | vasil | 2009-01-26 09:26:25 -0600 (Mon, 26 Jan 2009) | 23 lines
branches/5.1:
Merge a change from MySQL:
------------------------------------------------------------
revno: 2646.161.4
committer: Tatiana A. Nurnberg <azundris@mysql.com>
branch nick: 51-31177v2
timestamp: Mon 2009-01-12 06:32:49 +0100
message:
Bug#31177: Server variables can't be set to their current values
Bounds-checks and blocksize corrections were applied to user-input,
but constants in the server were trusted implicitly. If these values
did not actually meet the requirements, the user could not set change
a variable, then set it back to the (wonky) factory default or maximum
by explicitly specifying it (SET <var>=<value> vs SET <var>=DEFAULT).
Now checks also apply to the server's presets. Wonky values and maxima
get corrected at startup. Consequently all non-offsetted values the user
sees are valid, and users can set the variable to that exact value if
they so desire.
------------------------------------------------------------------------
r4060 | marko | 2009-01-29 09:39:04 +0200 (Thu, 29 Jan 2009) | 1 line
branches/zip: btr0sea.c: Revert the inadvertent change made in r4056.
------------------------------------------------------------------------
2009-01-29 09:47:07 +00:00
|
|
|
block = buf_block_align(rec);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if (UNIV_LIKELY(!has_search_latch)) {
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
if (UNIV_UNLIKELY(
|
2006-10-12 11:05:22 +00:00
|
|
|
!buf_page_get_known_nowait(latch_mode, block,
|
2006-09-19 10:14:07 +00:00
|
|
|
BUF_MAKE_YOUNG,
|
|
|
|
__FILE__, __LINE__,
|
|
|
|
mtr))) {
|
2005-10-27 07:29:40 +00:00
|
|
|
goto failure_unlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
rw_lock_s_unlock(&btr_search_latch);
|
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_dbg_add_level(block, SYNC_TREE_NODE_FROM_HASH);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
branches/innodb+: Merge revisions 4006:4060 from branches/zip:
------------------------------------------------------------------------
r4008 | vasil | 2009-01-20 17:01:08 +0200 (Tue, 20 Jan 2009) | 4 lines
branches/zip:
Add ChangeLog entries for the bugfixes in r4004 and r4005.
------------------------------------------------------------------------
r4027 | marko | 2009-01-23 11:04:49 +0200 (Fri, 23 Jan 2009) | 1 line
branches/zip: Remove some redundant #include statements.
------------------------------------------------------------------------
r4028 | marko | 2009-01-23 11:26:10 +0200 (Fri, 23 Jan 2009) | 13 lines
branches/zip: Enclose some more unused code in #ifdef UNIV_LOG_ARCHIVE.
This will help trim the dependencies of InnoDB Hot Backup.
recv_recovery_from_checkpoint_start(): Rename to
recv_recovery_from_checkpoint_start_func(), and remove the two first
parameters unless UNIV_LOG_ARCHIVE is defined. Define and use
the auxiliary macros TYPE_CHECKPOINT and LIMIT_LSN in the function.
struct recv_sys_struct: Remove archive_group unless UNIV_LOG_ARCHIVE
is defined.
Do not define LOG_ARCHIVE unless UNIV_LOG_ARCHIVE is defined.
------------------------------------------------------------------------
r4029 | marko | 2009-01-23 14:07:38 +0200 (Fri, 23 Jan 2009) | 1 line
branches/zip: Remove some redundant #include directives.
------------------------------------------------------------------------
r4030 | marko | 2009-01-23 15:31:36 +0200 (Fri, 23 Jan 2009) | 2 lines
branches/zip: buf_page_get_gen(): Remove the unused mode BUF_GET_NOWAIT.
This was noticed while investigating Issue #160.
------------------------------------------------------------------------
r4033 | marko | 2009-01-23 15:49:04 +0200 (Fri, 23 Jan 2009) | 16 lines
branches/zip: Merge revisions 4005:4032 from branches/5.1:
------------------------------------------------------------------------
r4032 | marko | 2009-01-23 15:43:51 +0200 (Fri, 23 Jan 2009) | 10 lines
branches/5.1: Merge r4031 from branches/5.0:
btr_search_drop_page_hash_when_freed(): Check if buf_page_get_gen()
returns NULL. The page may have been evicted from the buffer pool
between buf_page_peek_if_search_hashed() and buf_page_get_gen(),
because the buffer pool mutex will be released between these two calls.
(Bug #42279, Issue #160)
rb://82 approved by Heikki Tuuri
------------------------------------------------------------------------
------------------------------------------------------------------------
r4034 | marko | 2009-01-26 16:16:39 +0200 (Mon, 26 Jan 2009) | 2 lines
branches/zip: buf_page_get_gen(): Fix a "possibly uninitialized" warning
that was introduced in r4030.
------------------------------------------------------------------------
r4036 | marko | 2009-01-26 22:33:20 +0200 (Mon, 26 Jan 2009) | 22 lines
branches/zip: In r988, the function buf_block_align() was enclosed
within UNIV_DEBUG. The two remaining callers in non-debug builds,
btr_search_guess_on_hash() and btr_search_validate(), were rewritten
to call buf_page_hash_get().
To implement support for a resizeable buffer pool, the function
buf_block_align() had been rewritten to perform a page hash lookup in
the buffer pool. The caller was also made responsible for holding the
buffer pool mutex.
Because the page hash lookup is expensive and it has to be done while
holding the buffer pool mutex, implement buf_block_align() by pointer
arithmetics again, and make btr_search_guess_on_hash() call it. Note
that this will have to be adjusted if the interface to the resizeable
buffer pool is actually implemented.
rb://83 approved by Heikki Tuuri, to address Issue #161.
As a deviation from the approved patch, this patch also makes
btr_search_validate() (invoked by CHECK TABLE) check that
buf_pool->page_hash is consistent with buf_block_align().
------------------------------------------------------------------------
r4039 | vasil | 2009-01-27 08:04:17 +0200 (Tue, 27 Jan 2009) | 5 lines
branches/zip:
Adjust the paths in innodb_file_per_table.diff with a recent rename of
the test/result files in the MySQL tree.
------------------------------------------------------------------------
r4042 | marko | 2009-01-27 10:05:24 +0200 (Tue, 27 Jan 2009) | 2 lines
branches/zip: buf_LRU_invalidate_tablespace(): Fix a race condition:
read zip_size while still holding block_mutex.
------------------------------------------------------------------------
r4045 | marko | 2009-01-28 00:31:17 +0200 (Wed, 28 Jan 2009) | 8 lines
branches/zip: btr_search_validate(): Fix a bogus UNIV_DEBUG
assertion failure that was accidentally introduced in r4036.
Instead of calling buf_block_get_frame(), which asserts that the
block must be buffer-fixed, access block->frame directly. That
is safe, because changes of block->page.state are protected by
the buffer pool mutex, which we are holding.
This bug was reported by Michael.
------------------------------------------------------------------------
r4046 | marko | 2009-01-28 00:33:20 +0200 (Wed, 28 Jan 2009) | 2 lines
branches/zip: Revert the change to univ.i that was accidentally
committed in r4045.
------------------------------------------------------------------------
r4047 | marko | 2009-01-28 00:46:13 +0200 (Wed, 28 Jan 2009) | 6 lines
branches/zip: btr_search_validate(): Fix an assertion failure that was
introduced in r4036.
Do not call buf_block_get_space(), buf_block_get_page_no()
unless the block state is BUF_BLOCK_FILE_PAGE.
This bug was reported by Michael.
------------------------------------------------------------------------
r4050 | vasil | 2009-01-28 08:21:44 +0200 (Wed, 28 Jan 2009) | 5 lines
branches/zip:
Adjust the paths in innodb_lock_wait_timeout.diff with a recent rename of
the test/result files in the MySQL tree.
------------------------------------------------------------------------
r4051 | marko | 2009-01-28 14:35:49 +0200 (Wed, 28 Jan 2009) | 1 line
branches/zip: trx0sys.ic: Remove unnecessary #include <data0type.h>.
------------------------------------------------------------------------
r4052 | marko | 2009-01-28 15:21:45 +0200 (Wed, 28 Jan 2009) | 5 lines
branches/zip: Enclose some functions inside #ifdef UNIV_HOTBACKUP:
ut_sprintf_timestamp_without_extra_chars(), ut_get_year_month_day(),
log_reset_first_header_and_checkpoint(): These functions are only used
in InnoDB Hot Backup.
------------------------------------------------------------------------
r4056 | calvin | 2009-01-29 03:06:41 +0200 (Thu, 29 Jan 2009) | 33 lines
branches/zip: Merge revisions 4032:4035 from branches/5.1
All InnoDB related tests passed on Windows, except
known failure in partition_innodb_semi_consistent.
The inadvertent change to btr0sea.c in this commit is reverted in r4060.
------------------------------------------------------------------------
r4035 | vasil | 2009-01-26 09:26:25 -0600 (Mon, 26 Jan 2009) | 23 lines
branches/5.1:
Merge a change from MySQL:
------------------------------------------------------------
revno: 2646.161.4
committer: Tatiana A. Nurnberg <azundris@mysql.com>
branch nick: 51-31177v2
timestamp: Mon 2009-01-12 06:32:49 +0100
message:
Bug#31177: Server variables can't be set to their current values
Bounds-checks and blocksize corrections were applied to user-input,
but constants in the server were trusted implicitly. If these values
did not actually meet the requirements, the user could not set change
a variable, then set it back to the (wonky) factory default or maximum
by explicitly specifying it (SET <var>=<value> vs SET <var>=DEFAULT).
Now checks also apply to the server's presets. Wonky values and maxima
get corrected at startup. Consequently all non-offsetted values the user
sees are valid, and users can set the variable to that exact value if
they so desire.
------------------------------------------------------------------------
r4060 | marko | 2009-01-29 09:39:04 +0200 (Thu, 29 Jan 2009) | 1 line
branches/zip: btr0sea.c: Revert the inadvertent change made in r4056.
------------------------------------------------------------------------
2009-01-29 09:47:07 +00:00
|
|
|
if (UNIV_UNLIKELY(buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE)) {
|
|
|
|
ut_ad(buf_block_get_state(block) == BUF_BLOCK_REMOVE_HASH);
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (UNIV_LIKELY(!has_search_latch)) {
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-10-13 07:45:52 +00:00
|
|
|
btr_leaf_page_release(block, latch_mode, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
|
|
|
|
ut_ad(page_rec_is_user_rec(rec));
|
|
|
|
|
2006-10-18 11:39:31 +00:00
|
|
|
btr_cur_position(index, rec, block, cursor);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Check the validity of the guess within the page */
|
|
|
|
|
|
|
|
/* If we only have the latch on btr_search_latch, not on the
|
|
|
|
page, it only protects the columns of the record the cursor
|
|
|
|
is positioned on. We cannot look at the next of the previous
|
|
|
|
record to determine if our guess for the cursor position is
|
|
|
|
right. */
|
branches/innodb+: Merge revisions 4006:4060 from branches/zip:
------------------------------------------------------------------------
r4008 | vasil | 2009-01-20 17:01:08 +0200 (Tue, 20 Jan 2009) | 4 lines
branches/zip:
Add ChangeLog entries for the bugfixes in r4004 and r4005.
------------------------------------------------------------------------
r4027 | marko | 2009-01-23 11:04:49 +0200 (Fri, 23 Jan 2009) | 1 line
branches/zip: Remove some redundant #include statements.
------------------------------------------------------------------------
r4028 | marko | 2009-01-23 11:26:10 +0200 (Fri, 23 Jan 2009) | 13 lines
branches/zip: Enclose some more unused code in #ifdef UNIV_LOG_ARCHIVE.
This will help trim the dependencies of InnoDB Hot Backup.
recv_recovery_from_checkpoint_start(): Rename to
recv_recovery_from_checkpoint_start_func(), and remove the two first
parameters unless UNIV_LOG_ARCHIVE is defined. Define and use
the auxiliary macros TYPE_CHECKPOINT and LIMIT_LSN in the function.
struct recv_sys_struct: Remove archive_group unless UNIV_LOG_ARCHIVE
is defined.
Do not define LOG_ARCHIVE unless UNIV_LOG_ARCHIVE is defined.
------------------------------------------------------------------------
r4029 | marko | 2009-01-23 14:07:38 +0200 (Fri, 23 Jan 2009) | 1 line
branches/zip: Remove some redundant #include directives.
------------------------------------------------------------------------
r4030 | marko | 2009-01-23 15:31:36 +0200 (Fri, 23 Jan 2009) | 2 lines
branches/zip: buf_page_get_gen(): Remove the unused mode BUF_GET_NOWAIT.
This was noticed while investigating Issue #160.
------------------------------------------------------------------------
r4033 | marko | 2009-01-23 15:49:04 +0200 (Fri, 23 Jan 2009) | 16 lines
branches/zip: Merge revisions 4005:4032 from branches/5.1:
------------------------------------------------------------------------
r4032 | marko | 2009-01-23 15:43:51 +0200 (Fri, 23 Jan 2009) | 10 lines
branches/5.1: Merge r4031 from branches/5.0:
btr_search_drop_page_hash_when_freed(): Check if buf_page_get_gen()
returns NULL. The page may have been evicted from the buffer pool
between buf_page_peek_if_search_hashed() and buf_page_get_gen(),
because the buffer pool mutex will be released between these two calls.
(Bug #42279, Issue #160)
rb://82 approved by Heikki Tuuri
------------------------------------------------------------------------
------------------------------------------------------------------------
r4034 | marko | 2009-01-26 16:16:39 +0200 (Mon, 26 Jan 2009) | 2 lines
branches/zip: buf_page_get_gen(): Fix a "possibly uninitialized" warning
that was introduced in r4030.
------------------------------------------------------------------------
r4036 | marko | 2009-01-26 22:33:20 +0200 (Mon, 26 Jan 2009) | 22 lines
branches/zip: In r988, the function buf_block_align() was enclosed
within UNIV_DEBUG. The two remaining callers in non-debug builds,
btr_search_guess_on_hash() and btr_search_validate(), were rewritten
to call buf_page_hash_get().
To implement support for a resizeable buffer pool, the function
buf_block_align() had been rewritten to perform a page hash lookup in
the buffer pool. The caller was also made responsible for holding the
buffer pool mutex.
Because the page hash lookup is expensive and it has to be done while
holding the buffer pool mutex, implement buf_block_align() by pointer
arithmetics again, and make btr_search_guess_on_hash() call it. Note
that this will have to be adjusted if the interface to the resizeable
buffer pool is actually implemented.
rb://83 approved by Heikki Tuuri, to address Issue #161.
As a deviation from the approved patch, this patch also makes
btr_search_validate() (invoked by CHECK TABLE) check that
buf_pool->page_hash is consistent with buf_block_align().
------------------------------------------------------------------------
r4039 | vasil | 2009-01-27 08:04:17 +0200 (Tue, 27 Jan 2009) | 5 lines
branches/zip:
Adjust the paths in innodb_file_per_table.diff with a recent rename of
the test/result files in the MySQL tree.
------------------------------------------------------------------------
r4042 | marko | 2009-01-27 10:05:24 +0200 (Tue, 27 Jan 2009) | 2 lines
branches/zip: buf_LRU_invalidate_tablespace(): Fix a race condition:
read zip_size while still holding block_mutex.
------------------------------------------------------------------------
r4045 | marko | 2009-01-28 00:31:17 +0200 (Wed, 28 Jan 2009) | 8 lines
branches/zip: btr_search_validate(): Fix a bogus UNIV_DEBUG
assertion failure that was accidentally introduced in r4036.
Instead of calling buf_block_get_frame(), which asserts that the
block must be buffer-fixed, access block->frame directly. That
is safe, because changes of block->page.state are protected by
the buffer pool mutex, which we are holding.
This bug was reported by Michael.
------------------------------------------------------------------------
r4046 | marko | 2009-01-28 00:33:20 +0200 (Wed, 28 Jan 2009) | 2 lines
branches/zip: Revert the change to univ.i that was accidentally
committed in r4045.
------------------------------------------------------------------------
r4047 | marko | 2009-01-28 00:46:13 +0200 (Wed, 28 Jan 2009) | 6 lines
branches/zip: btr_search_validate(): Fix an assertion failure that was
introduced in r4036.
Do not call buf_block_get_space(), buf_block_get_page_no()
unless the block state is BUF_BLOCK_FILE_PAGE.
This bug was reported by Michael.
------------------------------------------------------------------------
r4050 | vasil | 2009-01-28 08:21:44 +0200 (Wed, 28 Jan 2009) | 5 lines
branches/zip:
Adjust the paths in innodb_lock_wait_timeout.diff with a recent rename of
the test/result files in the MySQL tree.
------------------------------------------------------------------------
r4051 | marko | 2009-01-28 14:35:49 +0200 (Wed, 28 Jan 2009) | 1 line
branches/zip: trx0sys.ic: Remove unnecessary #include <data0type.h>.
------------------------------------------------------------------------
r4052 | marko | 2009-01-28 15:21:45 +0200 (Wed, 28 Jan 2009) | 5 lines
branches/zip: Enclose some functions inside #ifdef UNIV_HOTBACKUP:
ut_sprintf_timestamp_without_extra_chars(), ut_get_year_month_day(),
log_reset_first_header_and_checkpoint(): These functions are only used
in InnoDB Hot Backup.
------------------------------------------------------------------------
r4056 | calvin | 2009-01-29 03:06:41 +0200 (Thu, 29 Jan 2009) | 33 lines
branches/zip: Merge revisions 4032:4035 from branches/5.1
All InnoDB related tests passed on Windows, except
known failure in partition_innodb_semi_consistent.
The inadvertent change to btr0sea.c in this commit is reverted in r4060.
------------------------------------------------------------------------
r4035 | vasil | 2009-01-26 09:26:25 -0600 (Mon, 26 Jan 2009) | 23 lines
branches/5.1:
Merge a change from MySQL:
------------------------------------------------------------
revno: 2646.161.4
committer: Tatiana A. Nurnberg <azundris@mysql.com>
branch nick: 51-31177v2
timestamp: Mon 2009-01-12 06:32:49 +0100
message:
Bug#31177: Server variables can't be set to their current values
Bounds-checks and blocksize corrections were applied to user-input,
but constants in the server were trusted implicitly. If these values
did not actually meet the requirements, the user could not set change
a variable, then set it back to the (wonky) factory default or maximum
by explicitly specifying it (SET <var>=<value> vs SET <var>=DEFAULT).
Now checks also apply to the server's presets. Wonky values and maxima
get corrected at startup. Consequently all non-offsetted values the user
sees are valid, and users can set the variable to that exact value if
they so desire.
------------------------------------------------------------------------
r4060 | marko | 2009-01-29 09:39:04 +0200 (Thu, 29 Jan 2009) | 1 line
branches/zip: btr0sea.c: Revert the inadvertent change made in r4056.
------------------------------------------------------------------------
2009-01-29 09:47:07 +00:00
|
|
|
if (UNIV_EXPECT
|
|
|
|
(ut_dulint_cmp(index_id, btr_page_get_index_id(block->frame)), 0)
|
2006-08-29 09:30:31 +00:00
|
|
|
|| !btr_search_check_guess(cursor,
|
2007-01-31 14:28:37 +00:00
|
|
|
has_search_latch,
|
2006-08-29 09:30:31 +00:00
|
|
|
tuple, mode, mtr)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
if (UNIV_LIKELY(!has_search_latch)) {
|
2006-10-13 07:45:52 +00:00
|
|
|
btr_leaf_page_release(block, latch_mode, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (UNIV_LIKELY(info->n_hash_potential < BTR_SEARCH_BUILD_LIMIT + 5)) {
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
info->n_hash_potential++;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef notdefined
|
|
|
|
/* These lines of code can be used in a debug version to check
|
|
|
|
the correctness of the searched cursor position: */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
info->last_hash_succ = FALSE;
|
|
|
|
|
|
|
|
/* Currently, does not work if the following fails: */
|
|
|
|
ut_ad(!has_search_latch);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-10-13 07:45:52 +00:00
|
|
|
btr_leaf_page_release(block, latch_mode, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
btr_cur_search_to_nth_level(index, 0, tuple, mode, latch_mode,
|
2006-08-29 09:30:31 +00:00
|
|
|
&cursor2, 0, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (mode == PAGE_CUR_GE
|
2006-08-29 09:30:31 +00:00
|
|
|
&& page_rec_is_supremum(btr_cur_get_rec(&cursor2))) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* If mode is PAGE_CUR_GE, then the binary search
|
|
|
|
in the index tree may actually take us to the supremum
|
|
|
|
of the previous page */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
info->last_hash_succ = FALSE;
|
|
|
|
|
|
|
|
btr_pcur_open_on_user_rec(index, tuple, mode, latch_mode,
|
2006-08-29 09:30:31 +00:00
|
|
|
&pcur, mtr);
|
2005-10-27 07:29:40 +00:00
|
|
|
ut_ad(btr_pcur_get_rec(&pcur) == btr_cur_get_rec(cursor));
|
|
|
|
} else {
|
|
|
|
ut_ad(btr_cur_get_rec(&cursor2) == btr_cur_get_rec(cursor));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* NOTE that it is theoretically possible that the above assertions
|
|
|
|
fail if the page of the cursor gets removed from the buffer pool
|
|
|
|
meanwhile! Thus it might not be a bug. */
|
|
|
|
#endif
|
|
|
|
info->last_hash_succ = TRUE;
|
|
|
|
|
|
|
|
#ifdef UNIV_SEARCH_PERF_STAT
|
|
|
|
btr_search_n_succ++;
|
|
|
|
#endif
|
|
|
|
if (UNIV_LIKELY(!has_search_latch)
|
2007-08-01 11:18:43 +00:00
|
|
|
&& buf_page_peek_if_too_old(&block->page)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-11-30 12:27:49 +00:00
|
|
|
buf_page_make_young(&block->page);
|
2006-02-23 19:25:29 +00:00
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Increment the page get statistics though we did not really
|
|
|
|
fix the page: for user info only */
|
|
|
|
|
|
|
|
buf_pool->n_page_gets++;
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
return(TRUE);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/*-------------------------------------------*/
|
|
|
|
failure_unlock:
|
|
|
|
if (UNIV_LIKELY(!has_search_latch)) {
|
|
|
|
rw_lock_s_unlock(&btr_search_latch);
|
|
|
|
}
|
|
|
|
failure:
|
|
|
|
cursor->flag = BTR_CUR_HASH_FAIL;
|
|
|
|
|
|
|
|
#ifdef UNIV_SEARCH_PERF_STAT
|
2006-04-12 09:32:17 +00:00
|
|
|
info->n_hash_fail++;
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (info->n_hash_succ > 0) {
|
|
|
|
info->n_hash_succ--;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
info->last_hash_succ = FALSE;
|
|
|
|
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Drops a page hash index. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
btr_search_drop_page_hash_index(
|
|
|
|
/*============================*/
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_t* block) /* in: block containing index page,
|
|
|
|
s- or x-latched, or an index page
|
|
|
|
for which we know that
|
|
|
|
block->buf_fix_count == 0 */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
2008-09-17 19:52:30 +00:00
|
|
|
hash_table_t* table;
|
|
|
|
ulint n_fields;
|
|
|
|
ulint n_bytes;
|
|
|
|
const page_t* page;
|
|
|
|
const rec_t* rec;
|
|
|
|
ulint fold;
|
|
|
|
ulint prev_fold;
|
|
|
|
dulint index_id;
|
|
|
|
ulint n_cached;
|
|
|
|
ulint n_recs;
|
|
|
|
ulint* folds;
|
|
|
|
ulint i;
|
|
|
|
mem_heap_t* heap;
|
|
|
|
const dict_index_t* index;
|
|
|
|
ulint* offsets;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
|
|
|
ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED));
|
|
|
|
ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX));
|
|
|
|
#endif /* UNIV_SYNC_DEBUG */
|
2006-10-12 11:05:22 +00:00
|
|
|
|
2006-02-17 14:19:39 +00:00
|
|
|
retry:
|
2005-10-27 07:29:40 +00:00
|
|
|
rw_lock_s_lock(&btr_search_latch);
|
2006-10-20 13:49:42 +00:00
|
|
|
page = block->frame;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-17 14:19:39 +00:00
|
|
|
if (UNIV_LIKELY(!block->is_hashed)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
rw_lock_s_unlock(&btr_search_latch);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
table = btr_search_sys->hash_index;
|
|
|
|
|
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
|
|
|
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED)
|
2006-08-29 09:30:31 +00:00
|
|
|
|| rw_lock_own(&(block->lock), RW_LOCK_EX)
|
2006-11-30 12:27:49 +00:00
|
|
|
|| (block->page.buf_fix_count == 0));
|
2005-10-27 07:29:40 +00:00
|
|
|
#endif /* UNIV_SYNC_DEBUG */
|
|
|
|
|
|
|
|
n_fields = block->curr_n_fields;
|
|
|
|
n_bytes = block->curr_n_bytes;
|
2005-11-29 12:30:46 +00:00
|
|
|
index = block->index;
|
2008-01-25 14:37:11 +00:00
|
|
|
ut_a(!dict_index_is_ibuf(index));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2005-11-29 12:30:46 +00:00
|
|
|
/* NOTE: The fields of block must not be accessed after
|
|
|
|
releasing btr_search_latch, as the index page might only
|
|
|
|
be s-latched! */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
rw_lock_s_unlock(&btr_search_latch);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-11-29 12:30:46 +00:00
|
|
|
ut_a(n_fields + n_bytes > 0);
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
n_recs = page_get_n_recs(page);
|
|
|
|
|
|
|
|
/* Calculate and cache fold values into an array for fast deletion
|
|
|
|
from the hash index */
|
|
|
|
|
|
|
|
folds = mem_alloc(n_recs * sizeof(ulint));
|
|
|
|
|
|
|
|
n_cached = 0;
|
|
|
|
|
|
|
|
rec = page_get_infimum_rec(page);
|
2008-09-17 19:52:30 +00:00
|
|
|
rec = page_rec_get_next_low(rec, page_is_comp(page));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
index_id = btr_page_get_index_id(page);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
ut_a(0 == ut_dulint_cmp(index_id, index->id));
|
2006-02-17 14:19:39 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
prev_fold = 0;
|
|
|
|
|
|
|
|
heap = NULL;
|
|
|
|
offsets = NULL;
|
|
|
|
|
|
|
|
while (!page_rec_is_supremum(rec)) {
|
2005-11-29 12:30:46 +00:00
|
|
|
offsets = rec_get_offsets(rec, index, offsets,
|
2006-08-29 09:30:31 +00:00
|
|
|
n_fields + (n_bytes > 0), &heap);
|
2005-11-29 12:30:46 +00:00
|
|
|
ut_a(rec_offs_n_fields(offsets) == n_fields + (n_bytes > 0));
|
2006-09-19 10:14:07 +00:00
|
|
|
fold = rec_fold(rec, offsets, n_fields, n_bytes, index_id);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if (fold == prev_fold && prev_fold != 0) {
|
|
|
|
|
|
|
|
goto next_rec;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Remove all hash nodes pointing to this page from the
|
|
|
|
hash chain */
|
|
|
|
|
|
|
|
folds[n_cached] = fold;
|
|
|
|
n_cached++;
|
|
|
|
next_rec:
|
2008-09-17 19:52:30 +00:00
|
|
|
rec = page_rec_get_next_low(rec, page_rec_is_comp(rec));
|
2005-10-27 07:29:40 +00:00
|
|
|
prev_fold = fold;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (UNIV_LIKELY_NULL(heap)) {
|
|
|
|
mem_heap_free(heap);
|
|
|
|
}
|
|
|
|
|
|
|
|
rw_lock_x_lock(&btr_search_latch);
|
|
|
|
|
2006-02-17 14:19:39 +00:00
|
|
|
if (UNIV_UNLIKELY(!block->is_hashed)) {
|
|
|
|
/* Someone else has meanwhile dropped the hash index */
|
|
|
|
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
ut_a(block->index == index);
|
|
|
|
|
|
|
|
if (UNIV_UNLIKELY(block->curr_n_fields != n_fields)
|
2006-08-29 09:30:31 +00:00
|
|
|
|| UNIV_UNLIKELY(block->curr_n_bytes != n_bytes)) {
|
2006-02-17 14:19:39 +00:00
|
|
|
|
|
|
|
/* Someone else has meanwhile built a new hash index on the
|
|
|
|
page, with different parameters */
|
|
|
|
|
|
|
|
rw_lock_x_unlock(&btr_search_latch);
|
|
|
|
|
|
|
|
mem_free(folds);
|
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
for (i = 0; i < n_cached; i++) {
|
|
|
|
|
2006-11-14 10:42:50 +00:00
|
|
|
ha_remove_all_nodes_to_page(table, folds[i], page);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2008-08-09 00:15:46 +00:00
|
|
|
ut_a(index->search_info->ref_count > 0);
|
|
|
|
index->search_info->ref_count--;
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
block->is_hashed = FALSE;
|
|
|
|
block->index = NULL;
|
2008-08-09 00:15:46 +00:00
|
|
|
|
2006-02-17 14:19:39 +00:00
|
|
|
cleanup:
|
2008-12-17 12:48:23 +00:00
|
|
|
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
|
2006-02-17 14:19:39 +00:00
|
|
|
if (UNIV_UNLIKELY(block->n_pointers)) {
|
|
|
|
/* Corruption */
|
|
|
|
ut_print_timestamp(stderr);
|
|
|
|
fprintf(stderr,
|
2006-08-29 09:30:31 +00:00
|
|
|
" InnoDB: Corruption of adaptive hash index."
|
|
|
|
" After dropping\n"
|
|
|
|
"InnoDB: the hash index to a page of %s,"
|
|
|
|
" still %lu hash nodes remain.\n",
|
2006-02-17 14:19:39 +00:00
|
|
|
index->name, (ulong) block->n_pointers);
|
|
|
|
rw_lock_x_unlock(&btr_search_latch);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-17 14:19:39 +00:00
|
|
|
btr_search_validate();
|
|
|
|
} else {
|
|
|
|
rw_lock_x_unlock(&btr_search_latch);
|
|
|
|
}
|
2008-12-17 12:48:23 +00:00
|
|
|
#else /* UNIV_AHI_DEBUG || UNIV_DEBUG */
|
2006-10-18 18:52:04 +00:00
|
|
|
rw_lock_x_unlock(&btr_search_latch);
|
2008-12-17 12:48:23 +00:00
|
|
|
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mem_free(folds);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Drops a page hash index when a page is freed from a fseg to the file system.
|
|
|
|
Drops possible hash index if the page happens to be in the buffer pool. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
btr_search_drop_page_hash_when_freed(
|
|
|
|
/*=================================*/
|
|
|
|
ulint space, /* in: space id */
|
2007-01-18 09:59:00 +00:00
|
|
|
ulint zip_size, /* in: compressed page size in bytes
|
|
|
|
or 0 for uncompressed pages */
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint page_no) /* in: page number */
|
|
|
|
{
|
2006-10-12 11:05:22 +00:00
|
|
|
buf_block_t* block;
|
|
|
|
mtr_t mtr;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
if (!buf_page_peek_if_search_hashed(space, page_no)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
mtr_start(&mtr);
|
|
|
|
|
|
|
|
/* We assume that if the caller has a latch on the page, then the
|
|
|
|
caller has already dropped the hash index for the page, and we never
|
|
|
|
get here. Therefore we can acquire the s-latch to the page without
|
|
|
|
having to fear a deadlock. */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2007-01-18 09:59:00 +00:00
|
|
|
block = buf_page_get_gen(space, zip_size, page_no, RW_S_LATCH, NULL,
|
2005-10-27 07:29:40 +00:00
|
|
|
BUF_GET_IF_IN_POOL, __FILE__, __LINE__,
|
|
|
|
&mtr);
|
branches/innodb+: Merge revisions 4006:4060 from branches/zip:
------------------------------------------------------------------------
r4008 | vasil | 2009-01-20 17:01:08 +0200 (Tue, 20 Jan 2009) | 4 lines
branches/zip:
Add ChangeLog entries for the bugfixes in r4004 and r4005.
------------------------------------------------------------------------
r4027 | marko | 2009-01-23 11:04:49 +0200 (Fri, 23 Jan 2009) | 1 line
branches/zip: Remove some redundant #include statements.
------------------------------------------------------------------------
r4028 | marko | 2009-01-23 11:26:10 +0200 (Fri, 23 Jan 2009) | 13 lines
branches/zip: Enclose some more unused code in #ifdef UNIV_LOG_ARCHIVE.
This will help trim the dependencies of InnoDB Hot Backup.
recv_recovery_from_checkpoint_start(): Rename to
recv_recovery_from_checkpoint_start_func(), and remove the two first
parameters unless UNIV_LOG_ARCHIVE is defined. Define and use
the auxiliary macros TYPE_CHECKPOINT and LIMIT_LSN in the function.
struct recv_sys_struct: Remove archive_group unless UNIV_LOG_ARCHIVE
is defined.
Do not define LOG_ARCHIVE unless UNIV_LOG_ARCHIVE is defined.
------------------------------------------------------------------------
r4029 | marko | 2009-01-23 14:07:38 +0200 (Fri, 23 Jan 2009) | 1 line
branches/zip: Remove some redundant #include directives.
------------------------------------------------------------------------
r4030 | marko | 2009-01-23 15:31:36 +0200 (Fri, 23 Jan 2009) | 2 lines
branches/zip: buf_page_get_gen(): Remove the unused mode BUF_GET_NOWAIT.
This was noticed while investigating Issue #160.
------------------------------------------------------------------------
r4033 | marko | 2009-01-23 15:49:04 +0200 (Fri, 23 Jan 2009) | 16 lines
branches/zip: Merge revisions 4005:4032 from branches/5.1:
------------------------------------------------------------------------
r4032 | marko | 2009-01-23 15:43:51 +0200 (Fri, 23 Jan 2009) | 10 lines
branches/5.1: Merge r4031 from branches/5.0:
btr_search_drop_page_hash_when_freed(): Check if buf_page_get_gen()
returns NULL. The page may have been evicted from the buffer pool
between buf_page_peek_if_search_hashed() and buf_page_get_gen(),
because the buffer pool mutex will be released between these two calls.
(Bug #42279, Issue #160)
rb://82 approved by Heikki Tuuri
------------------------------------------------------------------------
------------------------------------------------------------------------
r4034 | marko | 2009-01-26 16:16:39 +0200 (Mon, 26 Jan 2009) | 2 lines
branches/zip: buf_page_get_gen(): Fix a "possibly uninitialized" warning
that was introduced in r4030.
------------------------------------------------------------------------
r4036 | marko | 2009-01-26 22:33:20 +0200 (Mon, 26 Jan 2009) | 22 lines
branches/zip: In r988, the function buf_block_align() was enclosed
within UNIV_DEBUG. The two remaining callers in non-debug builds,
btr_search_guess_on_hash() and btr_search_validate(), were rewritten
to call buf_page_hash_get().
To implement support for a resizeable buffer pool, the function
buf_block_align() had been rewritten to perform a page hash lookup in
the buffer pool. The caller was also made responsible for holding the
buffer pool mutex.
Because the page hash lookup is expensive and it has to be done while
holding the buffer pool mutex, implement buf_block_align() by pointer
arithmetics again, and make btr_search_guess_on_hash() call it. Note
that this will have to be adjusted if the interface to the resizeable
buffer pool is actually implemented.
rb://83 approved by Heikki Tuuri, to address Issue #161.
As a deviation from the approved patch, this patch also makes
btr_search_validate() (invoked by CHECK TABLE) check that
buf_pool->page_hash is consistent with buf_block_align().
------------------------------------------------------------------------
r4039 | vasil | 2009-01-27 08:04:17 +0200 (Tue, 27 Jan 2009) | 5 lines
branches/zip:
Adjust the paths in innodb_file_per_table.diff with a recent rename of
the test/result files in the MySQL tree.
------------------------------------------------------------------------
r4042 | marko | 2009-01-27 10:05:24 +0200 (Tue, 27 Jan 2009) | 2 lines
branches/zip: buf_LRU_invalidate_tablespace(): Fix a race condition:
read zip_size while still holding block_mutex.
------------------------------------------------------------------------
r4045 | marko | 2009-01-28 00:31:17 +0200 (Wed, 28 Jan 2009) | 8 lines
branches/zip: btr_search_validate(): Fix a bogus UNIV_DEBUG
assertion failure that was accidentally introduced in r4036.
Instead of calling buf_block_get_frame(), which asserts that the
block must be buffer-fixed, access block->frame directly. That
is safe, because changes of block->page.state are protected by
the buffer pool mutex, which we are holding.
This bug was reported by Michael.
------------------------------------------------------------------------
r4046 | marko | 2009-01-28 00:33:20 +0200 (Wed, 28 Jan 2009) | 2 lines
branches/zip: Revert the change to univ.i that was accidentally
committed in r4045.
------------------------------------------------------------------------
r4047 | marko | 2009-01-28 00:46:13 +0200 (Wed, 28 Jan 2009) | 6 lines
branches/zip: btr_search_validate(): Fix an assertion failure that was
introduced in r4036.
Do not call buf_block_get_space(), buf_block_get_page_no()
unless the block state is BUF_BLOCK_FILE_PAGE.
This bug was reported by Michael.
------------------------------------------------------------------------
r4050 | vasil | 2009-01-28 08:21:44 +0200 (Wed, 28 Jan 2009) | 5 lines
branches/zip:
Adjust the paths in innodb_lock_wait_timeout.diff with a recent rename of
the test/result files in the MySQL tree.
------------------------------------------------------------------------
r4051 | marko | 2009-01-28 14:35:49 +0200 (Wed, 28 Jan 2009) | 1 line
branches/zip: trx0sys.ic: Remove unnecessary #include <data0type.h>.
------------------------------------------------------------------------
r4052 | marko | 2009-01-28 15:21:45 +0200 (Wed, 28 Jan 2009) | 5 lines
branches/zip: Enclose some functions inside #ifdef UNIV_HOTBACKUP:
ut_sprintf_timestamp_without_extra_chars(), ut_get_year_month_day(),
log_reset_first_header_and_checkpoint(): These functions are only used
in InnoDB Hot Backup.
------------------------------------------------------------------------
r4056 | calvin | 2009-01-29 03:06:41 +0200 (Thu, 29 Jan 2009) | 33 lines
branches/zip: Merge revisions 4032:4035 from branches/5.1
All InnoDB related tests passed on Windows, except
known failure in partition_innodb_semi_consistent.
The inadvertent change to btr0sea.c in this commit is reverted in r4060.
------------------------------------------------------------------------
r4035 | vasil | 2009-01-26 09:26:25 -0600 (Mon, 26 Jan 2009) | 23 lines
branches/5.1:
Merge a change from MySQL:
------------------------------------------------------------
revno: 2646.161.4
committer: Tatiana A. Nurnberg <azundris@mysql.com>
branch nick: 51-31177v2
timestamp: Mon 2009-01-12 06:32:49 +0100
message:
Bug#31177: Server variables can't be set to their current values
Bounds-checks and blocksize corrections were applied to user-input,
but constants in the server were trusted implicitly. If these values
did not actually meet the requirements, the user could not set change
a variable, then set it back to the (wonky) factory default or maximum
by explicitly specifying it (SET <var>=<value> vs SET <var>=DEFAULT).
Now checks also apply to the server's presets. Wonky values and maxima
get corrected at startup. Consequently all non-offsetted values the user
sees are valid, and users can set the variable to that exact value if
they so desire.
------------------------------------------------------------------------
r4060 | marko | 2009-01-29 09:39:04 +0200 (Thu, 29 Jan 2009) | 1 line
branches/zip: btr0sea.c: Revert the inadvertent change made in r4056.
------------------------------------------------------------------------
2009-01-29 09:47:07 +00:00
|
|
|
/* Because the buffer pool mutex was released by
|
|
|
|
buf_page_peek_if_search_hashed(), it is possible that the
|
|
|
|
block was removed from the buffer pool by another thread
|
|
|
|
before buf_page_get_gen() got a chance to acquire the buffer
|
|
|
|
pool mutex again. Thus, we must check for a NULL return. */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
branches/innodb+: Merge revisions 4006:4060 from branches/zip:
------------------------------------------------------------------------
r4008 | vasil | 2009-01-20 17:01:08 +0200 (Tue, 20 Jan 2009) | 4 lines
branches/zip:
Add ChangeLog entries for the bugfixes in r4004 and r4005.
------------------------------------------------------------------------
r4027 | marko | 2009-01-23 11:04:49 +0200 (Fri, 23 Jan 2009) | 1 line
branches/zip: Remove some redundant #include statements.
------------------------------------------------------------------------
r4028 | marko | 2009-01-23 11:26:10 +0200 (Fri, 23 Jan 2009) | 13 lines
branches/zip: Enclose some more unused code in #ifdef UNIV_LOG_ARCHIVE.
This will help trim the dependencies of InnoDB Hot Backup.
recv_recovery_from_checkpoint_start(): Rename to
recv_recovery_from_checkpoint_start_func(), and remove the two first
parameters unless UNIV_LOG_ARCHIVE is defined. Define and use
the auxiliary macros TYPE_CHECKPOINT and LIMIT_LSN in the function.
struct recv_sys_struct: Remove archive_group unless UNIV_LOG_ARCHIVE
is defined.
Do not define LOG_ARCHIVE unless UNIV_LOG_ARCHIVE is defined.
------------------------------------------------------------------------
r4029 | marko | 2009-01-23 14:07:38 +0200 (Fri, 23 Jan 2009) | 1 line
branches/zip: Remove some redundant #include directives.
------------------------------------------------------------------------
r4030 | marko | 2009-01-23 15:31:36 +0200 (Fri, 23 Jan 2009) | 2 lines
branches/zip: buf_page_get_gen(): Remove the unused mode BUF_GET_NOWAIT.
This was noticed while investigating Issue #160.
------------------------------------------------------------------------
r4033 | marko | 2009-01-23 15:49:04 +0200 (Fri, 23 Jan 2009) | 16 lines
branches/zip: Merge revisions 4005:4032 from branches/5.1:
------------------------------------------------------------------------
r4032 | marko | 2009-01-23 15:43:51 +0200 (Fri, 23 Jan 2009) | 10 lines
branches/5.1: Merge r4031 from branches/5.0:
btr_search_drop_page_hash_when_freed(): Check if buf_page_get_gen()
returns NULL. The page may have been evicted from the buffer pool
between buf_page_peek_if_search_hashed() and buf_page_get_gen(),
because the buffer pool mutex will be released between these two calls.
(Bug #42279, Issue #160)
rb://82 approved by Heikki Tuuri
------------------------------------------------------------------------
------------------------------------------------------------------------
r4034 | marko | 2009-01-26 16:16:39 +0200 (Mon, 26 Jan 2009) | 2 lines
branches/zip: buf_page_get_gen(): Fix a "possibly uninitialized" warning
that was introduced in r4030.
------------------------------------------------------------------------
r4036 | marko | 2009-01-26 22:33:20 +0200 (Mon, 26 Jan 2009) | 22 lines
branches/zip: In r988, the function buf_block_align() was enclosed
within UNIV_DEBUG. The two remaining callers in non-debug builds,
btr_search_guess_on_hash() and btr_search_validate(), were rewritten
to call buf_page_hash_get().
To implement support for a resizeable buffer pool, the function
buf_block_align() had been rewritten to perform a page hash lookup in
the buffer pool. The caller was also made responsible for holding the
buffer pool mutex.
Because the page hash lookup is expensive and it has to be done while
holding the buffer pool mutex, implement buf_block_align() by pointer
arithmetics again, and make btr_search_guess_on_hash() call it. Note
that this will have to be adjusted if the interface to the resizeable
buffer pool is actually implemented.
rb://83 approved by Heikki Tuuri, to address Issue #161.
As a deviation from the approved patch, this patch also makes
btr_search_validate() (invoked by CHECK TABLE) check that
buf_pool->page_hash is consistent with buf_block_align().
------------------------------------------------------------------------
r4039 | vasil | 2009-01-27 08:04:17 +0200 (Tue, 27 Jan 2009) | 5 lines
branches/zip:
Adjust the paths in innodb_file_per_table.diff with a recent rename of
the test/result files in the MySQL tree.
------------------------------------------------------------------------
r4042 | marko | 2009-01-27 10:05:24 +0200 (Tue, 27 Jan 2009) | 2 lines
branches/zip: buf_LRU_invalidate_tablespace(): Fix a race condition:
read zip_size while still holding block_mutex.
------------------------------------------------------------------------
r4045 | marko | 2009-01-28 00:31:17 +0200 (Wed, 28 Jan 2009) | 8 lines
branches/zip: btr_search_validate(): Fix a bogus UNIV_DEBUG
assertion failure that was accidentally introduced in r4036.
Instead of calling buf_block_get_frame(), which asserts that the
block must be buffer-fixed, access block->frame directly. That
is safe, because changes of block->page.state are protected by
the buffer pool mutex, which we are holding.
This bug was reported by Michael.
------------------------------------------------------------------------
r4046 | marko | 2009-01-28 00:33:20 +0200 (Wed, 28 Jan 2009) | 2 lines
branches/zip: Revert the change to univ.i that was accidentally
committed in r4045.
------------------------------------------------------------------------
r4047 | marko | 2009-01-28 00:46:13 +0200 (Wed, 28 Jan 2009) | 6 lines
branches/zip: btr_search_validate(): Fix an assertion failure that was
introduced in r4036.
Do not call buf_block_get_space(), buf_block_get_page_no()
unless the block state is BUF_BLOCK_FILE_PAGE.
This bug was reported by Michael.
------------------------------------------------------------------------
r4050 | vasil | 2009-01-28 08:21:44 +0200 (Wed, 28 Jan 2009) | 5 lines
branches/zip:
Adjust the paths in innodb_lock_wait_timeout.diff with a recent rename of
the test/result files in the MySQL tree.
------------------------------------------------------------------------
r4051 | marko | 2009-01-28 14:35:49 +0200 (Wed, 28 Jan 2009) | 1 line
branches/zip: trx0sys.ic: Remove unnecessary #include <data0type.h>.
------------------------------------------------------------------------
r4052 | marko | 2009-01-28 15:21:45 +0200 (Wed, 28 Jan 2009) | 5 lines
branches/zip: Enclose some functions inside #ifdef UNIV_HOTBACKUP:
ut_sprintf_timestamp_without_extra_chars(), ut_get_year_month_day(),
log_reset_first_header_and_checkpoint(): These functions are only used
in InnoDB Hot Backup.
------------------------------------------------------------------------
r4056 | calvin | 2009-01-29 03:06:41 +0200 (Thu, 29 Jan 2009) | 33 lines
branches/zip: Merge revisions 4032:4035 from branches/5.1
All InnoDB related tests passed on Windows, except
known failure in partition_innodb_semi_consistent.
The inadvertent change to btr0sea.c in this commit is reverted in r4060.
------------------------------------------------------------------------
r4035 | vasil | 2009-01-26 09:26:25 -0600 (Mon, 26 Jan 2009) | 23 lines
branches/5.1:
Merge a change from MySQL:
------------------------------------------------------------
revno: 2646.161.4
committer: Tatiana A. Nurnberg <azundris@mysql.com>
branch nick: 51-31177v2
timestamp: Mon 2009-01-12 06:32:49 +0100
message:
Bug#31177: Server variables can't be set to their current values
Bounds-checks and blocksize corrections were applied to user-input,
but constants in the server were trusted implicitly. If these values
did not actually meet the requirements, the user could not set change
a variable, then set it back to the (wonky) factory default or maximum
by explicitly specifying it (SET <var>=<value> vs SET <var>=DEFAULT).
Now checks also apply to the server's presets. Wonky values and maxima
get corrected at startup. Consequently all non-offsetted values the user
sees are valid, and users can set the variable to that exact value if
they so desire.
------------------------------------------------------------------------
r4060 | marko | 2009-01-29 09:39:04 +0200 (Thu, 29 Jan 2009) | 1 line
branches/zip: btr0sea.c: Revert the inadvertent change made in r4056.
------------------------------------------------------------------------
2009-01-29 09:47:07 +00:00
|
|
|
if (UNIV_LIKELY(block != NULL)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
branches/innodb+: Merge revisions 4006:4060 from branches/zip:
------------------------------------------------------------------------
r4008 | vasil | 2009-01-20 17:01:08 +0200 (Tue, 20 Jan 2009) | 4 lines
branches/zip:
Add ChangeLog entries for the bugfixes in r4004 and r4005.
------------------------------------------------------------------------
r4027 | marko | 2009-01-23 11:04:49 +0200 (Fri, 23 Jan 2009) | 1 line
branches/zip: Remove some redundant #include statements.
------------------------------------------------------------------------
r4028 | marko | 2009-01-23 11:26:10 +0200 (Fri, 23 Jan 2009) | 13 lines
branches/zip: Enclose some more unused code in #ifdef UNIV_LOG_ARCHIVE.
This will help trim the dependencies of InnoDB Hot Backup.
recv_recovery_from_checkpoint_start(): Rename to
recv_recovery_from_checkpoint_start_func(), and remove the two first
parameters unless UNIV_LOG_ARCHIVE is defined. Define and use
the auxiliary macros TYPE_CHECKPOINT and LIMIT_LSN in the function.
struct recv_sys_struct: Remove archive_group unless UNIV_LOG_ARCHIVE
is defined.
Do not define LOG_ARCHIVE unless UNIV_LOG_ARCHIVE is defined.
------------------------------------------------------------------------
r4029 | marko | 2009-01-23 14:07:38 +0200 (Fri, 23 Jan 2009) | 1 line
branches/zip: Remove some redundant #include directives.
------------------------------------------------------------------------
r4030 | marko | 2009-01-23 15:31:36 +0200 (Fri, 23 Jan 2009) | 2 lines
branches/zip: buf_page_get_gen(): Remove the unused mode BUF_GET_NOWAIT.
This was noticed while investigating Issue #160.
------------------------------------------------------------------------
r4033 | marko | 2009-01-23 15:49:04 +0200 (Fri, 23 Jan 2009) | 16 lines
branches/zip: Merge revisions 4005:4032 from branches/5.1:
------------------------------------------------------------------------
r4032 | marko | 2009-01-23 15:43:51 +0200 (Fri, 23 Jan 2009) | 10 lines
branches/5.1: Merge r4031 from branches/5.0:
btr_search_drop_page_hash_when_freed(): Check if buf_page_get_gen()
returns NULL. The page may have been evicted from the buffer pool
between buf_page_peek_if_search_hashed() and buf_page_get_gen(),
because the buffer pool mutex will be released between these two calls.
(Bug #42279, Issue #160)
rb://82 approved by Heikki Tuuri
------------------------------------------------------------------------
------------------------------------------------------------------------
r4034 | marko | 2009-01-26 16:16:39 +0200 (Mon, 26 Jan 2009) | 2 lines
branches/zip: buf_page_get_gen(): Fix a "possibly uninitialized" warning
that was introduced in r4030.
------------------------------------------------------------------------
r4036 | marko | 2009-01-26 22:33:20 +0200 (Mon, 26 Jan 2009) | 22 lines
branches/zip: In r988, the function buf_block_align() was enclosed
within UNIV_DEBUG. The two remaining callers in non-debug builds,
btr_search_guess_on_hash() and btr_search_validate(), were rewritten
to call buf_page_hash_get().
To implement support for a resizeable buffer pool, the function
buf_block_align() had been rewritten to perform a page hash lookup in
the buffer pool. The caller was also made responsible for holding the
buffer pool mutex.
Because the page hash lookup is expensive and it has to be done while
holding the buffer pool mutex, implement buf_block_align() by pointer
arithmetics again, and make btr_search_guess_on_hash() call it. Note
that this will have to be adjusted if the interface to the resizeable
buffer pool is actually implemented.
rb://83 approved by Heikki Tuuri, to address Issue #161.
As a deviation from the approved patch, this patch also makes
btr_search_validate() (invoked by CHECK TABLE) check that
buf_pool->page_hash is consistent with buf_block_align().
------------------------------------------------------------------------
r4039 | vasil | 2009-01-27 08:04:17 +0200 (Tue, 27 Jan 2009) | 5 lines
branches/zip:
Adjust the paths in innodb_file_per_table.diff with a recent rename of
the test/result files in the MySQL tree.
------------------------------------------------------------------------
r4042 | marko | 2009-01-27 10:05:24 +0200 (Tue, 27 Jan 2009) | 2 lines
branches/zip: buf_LRU_invalidate_tablespace(): Fix a race condition:
read zip_size while still holding block_mutex.
------------------------------------------------------------------------
r4045 | marko | 2009-01-28 00:31:17 +0200 (Wed, 28 Jan 2009) | 8 lines
branches/zip: btr_search_validate(): Fix a bogus UNIV_DEBUG
assertion failure that was accidentally introduced in r4036.
Instead of calling buf_block_get_frame(), which asserts that the
block must be buffer-fixed, access block->frame directly. That
is safe, because changes of block->page.state are protected by
the buffer pool mutex, which we are holding.
This bug was reported by Michael.
------------------------------------------------------------------------
r4046 | marko | 2009-01-28 00:33:20 +0200 (Wed, 28 Jan 2009) | 2 lines
branches/zip: Revert the change to univ.i that was accidentally
committed in r4045.
------------------------------------------------------------------------
r4047 | marko | 2009-01-28 00:46:13 +0200 (Wed, 28 Jan 2009) | 6 lines
branches/zip: btr_search_validate(): Fix an assertion failure that was
introduced in r4036.
Do not call buf_block_get_space(), buf_block_get_page_no()
unless the block state is BUF_BLOCK_FILE_PAGE.
This bug was reported by Michael.
------------------------------------------------------------------------
r4050 | vasil | 2009-01-28 08:21:44 +0200 (Wed, 28 Jan 2009) | 5 lines
branches/zip:
Adjust the paths in innodb_lock_wait_timeout.diff with a recent rename of
the test/result files in the MySQL tree.
------------------------------------------------------------------------
r4051 | marko | 2009-01-28 14:35:49 +0200 (Wed, 28 Jan 2009) | 1 line
branches/zip: trx0sys.ic: Remove unnecessary #include <data0type.h>.
------------------------------------------------------------------------
r4052 | marko | 2009-01-28 15:21:45 +0200 (Wed, 28 Jan 2009) | 5 lines
branches/zip: Enclose some functions inside #ifdef UNIV_HOTBACKUP:
ut_sprintf_timestamp_without_extra_chars(), ut_get_year_month_day(),
log_reset_first_header_and_checkpoint(): These functions are only used
in InnoDB Hot Backup.
------------------------------------------------------------------------
r4056 | calvin | 2009-01-29 03:06:41 +0200 (Thu, 29 Jan 2009) | 33 lines
branches/zip: Merge revisions 4032:4035 from branches/5.1
All InnoDB related tests passed on Windows, except
known failure in partition_innodb_semi_consistent.
The inadvertent change to btr0sea.c in this commit is reverted in r4060.
------------------------------------------------------------------------
r4035 | vasil | 2009-01-26 09:26:25 -0600 (Mon, 26 Jan 2009) | 23 lines
branches/5.1:
Merge a change from MySQL:
------------------------------------------------------------
revno: 2646.161.4
committer: Tatiana A. Nurnberg <azundris@mysql.com>
branch nick: 51-31177v2
timestamp: Mon 2009-01-12 06:32:49 +0100
message:
Bug#31177: Server variables can't be set to their current values
Bounds-checks and blocksize corrections were applied to user-input,
but constants in the server were trusted implicitly. If these values
did not actually meet the requirements, the user could not set change
a variable, then set it back to the (wonky) factory default or maximum
by explicitly specifying it (SET <var>=<value> vs SET <var>=DEFAULT).
Now checks also apply to the server's presets. Wonky values and maxima
get corrected at startup. Consequently all non-offsetted values the user
sees are valid, and users can set the variable to that exact value if
they so desire.
------------------------------------------------------------------------
r4060 | marko | 2009-01-29 09:39:04 +0200 (Thu, 29 Jan 2009) | 1 line
branches/zip: btr0sea.c: Revert the inadvertent change made in r4056.
------------------------------------------------------------------------
2009-01-29 09:47:07 +00:00
|
|
|
buf_block_dbg_add_level(block, SYNC_TREE_NODE_FROM_HASH);
|
|
|
|
|
|
|
|
btr_search_drop_page_hash_index(block);
|
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Builds a hash index on a page with the given parameters. If the page already
|
|
|
|
has a hash index with different parameters, the old hash index is removed.
|
|
|
|
If index is non-NULL, this function checks if n_fields and n_bytes are
|
|
|
|
sensible values, and does not build a hash index if not. */
|
|
|
|
static
|
|
|
|
void
|
|
|
|
btr_search_build_page_hash_index(
|
|
|
|
/*=============================*/
|
|
|
|
dict_index_t* index, /* in: index for which to build */
|
2006-10-19 08:27:34 +00:00
|
|
|
buf_block_t* block, /* in: index page, s- or x-latched */
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint n_fields,/* in: hash this many full fields */
|
|
|
|
ulint n_bytes,/* in: hash this many bytes from the next
|
|
|
|
field */
|
2006-09-19 10:14:07 +00:00
|
|
|
ibool left_side)/* in: hash for searches from left side? */
|
2005-10-27 07:29:40 +00:00
|
|
|
{
|
|
|
|
hash_table_t* table;
|
2006-10-19 08:27:34 +00:00
|
|
|
page_t* page;
|
2005-10-27 07:29:40 +00:00
|
|
|
rec_t* rec;
|
|
|
|
rec_t* next_rec;
|
|
|
|
ulint fold;
|
|
|
|
ulint next_fold;
|
2006-09-19 10:14:07 +00:00
|
|
|
dulint index_id;
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint n_cached;
|
|
|
|
ulint n_recs;
|
|
|
|
ulint* folds;
|
|
|
|
rec_t** recs;
|
|
|
|
ulint i;
|
|
|
|
mem_heap_t* heap = NULL;
|
|
|
|
ulint offsets_[REC_OFFS_NORMAL_SIZE];
|
|
|
|
ulint* offsets = offsets_;
|
2007-09-28 07:05:57 +00:00
|
|
|
rec_offs_init(offsets_);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ut_ad(index);
|
2008-01-25 14:37:11 +00:00
|
|
|
ut_a(!dict_index_is_ibuf(index));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
table = btr_search_sys->hash_index;
|
2006-10-19 08:27:34 +00:00
|
|
|
page = buf_block_get_frame(block);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
|
|
|
ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX));
|
|
|
|
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED)
|
2006-08-29 09:30:31 +00:00
|
|
|
|| rw_lock_own(&(block->lock), RW_LOCK_EX));
|
2005-10-27 07:29:40 +00:00
|
|
|
#endif /* UNIV_SYNC_DEBUG */
|
|
|
|
|
|
|
|
rw_lock_s_lock(&btr_search_latch);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (block->is_hashed && ((block->curr_n_fields != n_fields)
|
2006-08-29 09:30:31 +00:00
|
|
|
|| (block->curr_n_bytes != n_bytes)
|
2006-09-19 10:14:07 +00:00
|
|
|
|| (block->curr_left_side != left_side))) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
rw_lock_s_unlock(&btr_search_latch);
|
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
btr_search_drop_page_hash_index(block);
|
2005-10-27 07:29:40 +00:00
|
|
|
} else {
|
|
|
|
rw_lock_s_unlock(&btr_search_latch);
|
|
|
|
}
|
|
|
|
|
|
|
|
n_recs = page_get_n_recs(page);
|
|
|
|
|
|
|
|
if (n_recs == 0) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check that the values for hash index build are sensible */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (n_fields + n_bytes == 0) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dict_index_get_n_unique_in_tree(index) < n_fields
|
2006-08-29 09:30:31 +00:00
|
|
|
|| (dict_index_get_n_unique_in_tree(index) == n_fields
|
|
|
|
&& n_bytes > 0)) {
|
2005-10-27 07:29:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Calculate and cache fold values and corresponding records into
|
|
|
|
an array for fast insertion to the hash index */
|
|
|
|
|
|
|
|
folds = mem_alloc(n_recs * sizeof(ulint));
|
|
|
|
recs = mem_alloc(n_recs * sizeof(rec_t*));
|
|
|
|
|
|
|
|
n_cached = 0;
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
index_id = btr_page_get_index_id(page);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-10-19 08:27:34 +00:00
|
|
|
rec = page_rec_get_next(page_get_infimum_rec(page));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
offsets = rec_get_offsets(rec, index, offsets,
|
2006-08-29 09:30:31 +00:00
|
|
|
n_fields + (n_bytes > 0), &heap);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if (!page_rec_is_supremum(rec)) {
|
|
|
|
ut_a(n_fields <= rec_offs_n_fields(offsets));
|
|
|
|
|
|
|
|
if (n_bytes > 0) {
|
|
|
|
ut_a(n_fields < rec_offs_n_fields(offsets));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
fold = rec_fold(rec, offsets, n_fields, n_bytes, index_id);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
if (left_side) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
folds[n_cached] = fold;
|
|
|
|
recs[n_cached] = rec;
|
|
|
|
n_cached++;
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
for (;;) {
|
|
|
|
next_rec = page_rec_get_next(rec);
|
|
|
|
|
|
|
|
if (page_rec_is_supremum(next_rec)) {
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
if (!left_side) {
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
folds[n_cached] = fold;
|
|
|
|
recs[n_cached] = rec;
|
|
|
|
n_cached++;
|
|
|
|
}
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
break;
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
offsets = rec_get_offsets(next_rec, index, offsets,
|
2006-08-29 09:30:31 +00:00
|
|
|
n_fields + (n_bytes > 0), &heap);
|
2005-10-27 07:29:40 +00:00
|
|
|
next_fold = rec_fold(next_rec, offsets, n_fields,
|
2006-09-19 10:14:07 +00:00
|
|
|
n_bytes, index_id);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if (fold != next_fold) {
|
|
|
|
/* Insert an entry into the hash index */
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
if (left_side) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
folds[n_cached] = next_fold;
|
|
|
|
recs[n_cached] = next_rec;
|
|
|
|
n_cached++;
|
|
|
|
} else {
|
|
|
|
folds[n_cached] = fold;
|
|
|
|
recs[n_cached] = rec;
|
|
|
|
n_cached++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rec = next_rec;
|
|
|
|
fold = next_fold;
|
|
|
|
}
|
|
|
|
|
|
|
|
btr_search_check_free_space_in_heap();
|
|
|
|
|
|
|
|
rw_lock_x_lock(&btr_search_latch);
|
|
|
|
|
branches/innodb+: Merge revisions 4070:4072 from branches/zip:
------------------------------------------------------------------------
r4072 | marko | 2009-01-30 23:30:29 +0200 (Fri, 30 Jan 2009) | 32 lines
branches/zip: Make innodb_adaptive_hash_index settable.
btr_search_disabled: Rename to btr_search_enabled and change the type
to char, so that it can be directly linked to the MySQL parameters.
Note that the variable is protected by btr_search_latch and
btr_search_enabled_mutex, a new mutex introduced in this patch.
btr_search_enabled_mutex: A new mutex, to protect btr_search_enabled
together with btr_search_latch.
buf_pool_drop_hash_index(): New function, to be called from
btr_search_disable().
btr_search_disable(), btr_search_enable(): Fix bugs. These functions
were previously unused.
btr_search_guess_on_hash(), btr_search_build_page_hash_index():
Check btr_search_enabled once more, while holding btr_search_latch.
btr_cur_search_to_nth_level(): Note that the reads of btr_search_enabled
may be dirty and explain why it should not be a problem.
innobase_adaptive_hash_index: Remove. The variable btr_search_enabled will be used directly instead.
innodb_adaptive_hash_index_update(): New function, an update callback for
innodb_adaptive_hash_index. This will call either btr_search_disable()
or btr_search_enable() when the value is assigned. The functions will
be called even if the value does not appear to be changed, e.g., when
setting from TRUE to TRUE or FALSE to FALSE.
rb://85 approved by Heikki Tuuri. This addresses Issue #163.
------------------------------------------------------------------------
2009-01-30 21:45:02 +00:00
|
|
|
if (UNIV_UNLIKELY(!btr_search_enabled)) {
|
|
|
|
goto exit_func;
|
|
|
|
}
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (block->is_hashed && ((block->curr_n_fields != n_fields)
|
2006-08-29 09:30:31 +00:00
|
|
|
|| (block->curr_n_bytes != n_bytes)
|
2006-09-19 10:14:07 +00:00
|
|
|
|| (block->curr_left_side != left_side))) {
|
2005-10-27 07:29:40 +00:00
|
|
|
goto exit_func;
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2008-08-09 00:15:46 +00:00
|
|
|
/* This counter is decremented every time we drop page
|
|
|
|
hash index entries and is incremented here. Since we can
|
|
|
|
rebuild hash index for a page that is already hashed, we
|
|
|
|
have to take care not to increment the counter in that
|
|
|
|
case. */
|
|
|
|
if (!block->is_hashed) {
|
|
|
|
index->search_info->ref_count++;
|
|
|
|
}
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
block->is_hashed = TRUE;
|
|
|
|
block->n_hash_helps = 0;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
block->curr_n_fields = n_fields;
|
|
|
|
block->curr_n_bytes = n_bytes;
|
2006-09-19 10:14:07 +00:00
|
|
|
block->curr_left_side = left_side;
|
2005-10-27 07:29:40 +00:00
|
|
|
block->index = index;
|
|
|
|
|
|
|
|
for (i = 0; i < n_cached; i++) {
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-11-13 21:53:09 +00:00
|
|
|
ha_insert_for_fold(table, folds[i], block, recs[i]);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
exit_func:
|
|
|
|
rw_lock_x_unlock(&btr_search_latch);
|
|
|
|
|
|
|
|
mem_free(folds);
|
|
|
|
mem_free(recs);
|
|
|
|
if (UNIV_LIKELY_NULL(heap)) {
|
|
|
|
mem_heap_free(heap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Moves or deletes hash entries for moved records. If new_page is already hashed,
|
|
|
|
then the hash index for page, if any, is dropped. If new_page is not hashed,
|
|
|
|
and page is hashed, then a new hash index is built to new_page with the same
|
|
|
|
parameters as page (this often happens when a page is split). */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
btr_search_move_or_delete_hash_entries(
|
|
|
|
/*===================================*/
|
2006-10-20 12:45:53 +00:00
|
|
|
buf_block_t* new_block, /* in: records are copied
|
2005-10-27 07:29:40 +00:00
|
|
|
to this page */
|
2006-10-20 12:45:53 +00:00
|
|
|
buf_block_t* block, /* in: index page from which
|
2005-10-27 07:29:40 +00:00
|
|
|
records were copied, and the
|
|
|
|
copied records will be deleted
|
|
|
|
from this page */
|
|
|
|
dict_index_t* index) /* in: record descriptor */
|
|
|
|
{
|
2006-10-20 12:45:53 +00:00
|
|
|
ulint n_fields;
|
|
|
|
ulint n_bytes;
|
|
|
|
ibool left_side;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
|
|
|
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
|
|
|
|
ut_ad(rw_lock_own(&(new_block->lock), RW_LOCK_EX));
|
|
|
|
#endif /* UNIV_SYNC_DEBUG */
|
|
|
|
ut_a(!new_block->is_hashed || new_block->index == index);
|
|
|
|
ut_a(!block->is_hashed || block->index == index);
|
2008-01-25 14:37:11 +00:00
|
|
|
ut_a(!(new_block->is_hashed || block->is_hashed)
|
|
|
|
|| !dict_index_is_ibuf(index));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
rw_lock_s_lock(&btr_search_latch);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (new_block->is_hashed) {
|
|
|
|
|
|
|
|
rw_lock_s_unlock(&btr_search_latch);
|
|
|
|
|
2006-10-12 11:05:22 +00:00
|
|
|
btr_search_drop_page_hash_index(block);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (block->is_hashed) {
|
|
|
|
|
|
|
|
n_fields = block->curr_n_fields;
|
|
|
|
n_bytes = block->curr_n_bytes;
|
2006-09-19 10:14:07 +00:00
|
|
|
left_side = block->curr_left_side;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
new_block->n_fields = block->curr_n_fields;
|
|
|
|
new_block->n_bytes = block->curr_n_bytes;
|
2006-09-19 10:14:07 +00:00
|
|
|
new_block->left_side = left_side;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
rw_lock_s_unlock(&btr_search_latch);
|
|
|
|
|
|
|
|
ut_a(n_fields + n_bytes > 0);
|
|
|
|
|
2006-10-19 08:27:34 +00:00
|
|
|
btr_search_build_page_hash_index(index, new_block, n_fields,
|
2006-09-19 10:14:07 +00:00
|
|
|
n_bytes, left_side);
|
2006-10-20 12:45:53 +00:00
|
|
|
ut_ad(n_fields == block->curr_n_fields);
|
|
|
|
ut_ad(n_bytes == block->curr_n_bytes);
|
|
|
|
ut_ad(left_side == block->curr_left_side);
|
2005-10-27 07:29:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rw_lock_s_unlock(&btr_search_latch);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Updates the page hash index when a single record is deleted from a page. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
btr_search_update_hash_on_delete(
|
|
|
|
/*=============================*/
|
|
|
|
btr_cur_t* cursor) /* in: cursor which was positioned on the
|
|
|
|
record to delete using btr_cur_search_...,
|
|
|
|
the record is not yet deleted */
|
|
|
|
{
|
|
|
|
hash_table_t* table;
|
|
|
|
buf_block_t* block;
|
|
|
|
rec_t* rec;
|
|
|
|
ulint fold;
|
2006-09-19 10:14:07 +00:00
|
|
|
dulint index_id;
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool found;
|
|
|
|
ulint offsets_[REC_OFFS_NORMAL_SIZE];
|
|
|
|
mem_heap_t* heap = NULL;
|
2007-09-28 07:05:57 +00:00
|
|
|
rec_offs_init(offsets_);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
rec = btr_cur_get_rec(cursor);
|
|
|
|
|
2006-10-19 08:27:34 +00:00
|
|
|
block = btr_cur_get_block(cursor);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
|
|
|
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
|
|
|
|
#endif /* UNIV_SYNC_DEBUG */
|
|
|
|
|
|
|
|
if (!block->is_hashed) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ut_a(block->index == cursor->index);
|
|
|
|
ut_a(block->curr_n_fields + block->curr_n_bytes > 0);
|
2008-01-25 14:37:11 +00:00
|
|
|
ut_a(!dict_index_is_ibuf(cursor->index));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
table = btr_search_sys->hash_index;
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
index_id = cursor->index->id;
|
2005-10-27 07:29:40 +00:00
|
|
|
fold = rec_fold(rec, rec_get_offsets(rec, cursor->index, offsets_,
|
2006-08-29 09:30:31 +00:00
|
|
|
ULINT_UNDEFINED, &heap),
|
2006-09-19 10:14:07 +00:00
|
|
|
block->curr_n_fields, block->curr_n_bytes, index_id);
|
2005-10-27 07:29:40 +00:00
|
|
|
if (UNIV_LIKELY_NULL(heap)) {
|
|
|
|
mem_heap_free(heap);
|
|
|
|
}
|
|
|
|
rw_lock_x_lock(&btr_search_latch);
|
|
|
|
|
2006-11-14 10:42:50 +00:00
|
|
|
found = ha_search_and_delete_if_found(table, fold, rec);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
rw_lock_x_unlock(&btr_search_latch);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Updates the page hash index when a single record is inserted on a page. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
btr_search_update_hash_node_on_insert(
|
|
|
|
/*==================================*/
|
|
|
|
btr_cur_t* cursor) /* in: cursor which was positioned to the
|
|
|
|
place to insert using btr_cur_search_...,
|
|
|
|
and the new record has been inserted next
|
|
|
|
to the cursor */
|
|
|
|
{
|
|
|
|
hash_table_t* table;
|
|
|
|
buf_block_t* block;
|
|
|
|
rec_t* rec;
|
|
|
|
|
|
|
|
rec = btr_cur_get_rec(cursor);
|
|
|
|
|
2006-10-19 08:27:34 +00:00
|
|
|
block = btr_cur_get_block(cursor);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
|
|
|
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
|
|
|
|
#endif /* UNIV_SYNC_DEBUG */
|
|
|
|
|
|
|
|
if (!block->is_hashed) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ut_a(block->index == cursor->index);
|
2008-01-25 14:37:11 +00:00
|
|
|
ut_a(!dict_index_is_ibuf(cursor->index));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
rw_lock_x_lock(&btr_search_latch);
|
|
|
|
|
|
|
|
if ((cursor->flag == BTR_CUR_HASH)
|
2006-08-29 09:30:31 +00:00
|
|
|
&& (cursor->n_fields == block->curr_n_fields)
|
|
|
|
&& (cursor->n_bytes == block->curr_n_bytes)
|
2006-09-19 10:14:07 +00:00
|
|
|
&& !block->curr_left_side) {
|
2006-02-23 19:25:29 +00:00
|
|
|
|
|
|
|
table = btr_search_sys->hash_index;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
ha_search_and_update_if_found(table, cursor->fold, rec,
|
2006-11-13 21:53:09 +00:00
|
|
|
block, page_rec_get_next(rec));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
rw_lock_x_unlock(&btr_search_latch);
|
|
|
|
} else {
|
|
|
|
rw_lock_x_unlock(&btr_search_latch);
|
|
|
|
|
|
|
|
btr_search_update_hash_on_insert(cursor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Updates the page hash index when a single record is inserted on a page. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
btr_search_update_hash_on_insert(
|
|
|
|
/*=============================*/
|
|
|
|
btr_cur_t* cursor) /* in: cursor which was positioned to the
|
|
|
|
place to insert using btr_cur_search_...,
|
|
|
|
and the new record has been inserted next
|
|
|
|
to the cursor */
|
|
|
|
{
|
2006-02-23 19:25:29 +00:00
|
|
|
hash_table_t* table;
|
2005-10-27 07:29:40 +00:00
|
|
|
buf_block_t* block;
|
|
|
|
rec_t* rec;
|
|
|
|
rec_t* ins_rec;
|
|
|
|
rec_t* next_rec;
|
2006-09-19 10:14:07 +00:00
|
|
|
dulint index_id;
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint fold;
|
|
|
|
ulint ins_fold;
|
|
|
|
ulint next_fold = 0; /* remove warning (??? bug ???) */
|
|
|
|
ulint n_fields;
|
|
|
|
ulint n_bytes;
|
2006-09-19 10:14:07 +00:00
|
|
|
ibool left_side;
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool locked = FALSE;
|
|
|
|
mem_heap_t* heap = NULL;
|
|
|
|
ulint offsets_[REC_OFFS_NORMAL_SIZE];
|
|
|
|
ulint* offsets = offsets_;
|
2007-09-28 07:05:57 +00:00
|
|
|
rec_offs_init(offsets_);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
table = btr_search_sys->hash_index;
|
|
|
|
|
|
|
|
btr_search_check_free_space_in_heap();
|
|
|
|
|
|
|
|
rec = btr_cur_get_rec(cursor);
|
|
|
|
|
2006-10-19 08:27:34 +00:00
|
|
|
block = btr_cur_get_block(cursor);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
|
|
|
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
|
|
|
|
#endif /* UNIV_SYNC_DEBUG */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (!block->is_hashed) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ut_a(block->index == cursor->index);
|
2008-01-25 14:37:11 +00:00
|
|
|
ut_a(!dict_index_is_ibuf(cursor->index));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
index_id = cursor->index->id;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
n_fields = block->curr_n_fields;
|
|
|
|
n_bytes = block->curr_n_bytes;
|
2006-09-19 10:14:07 +00:00
|
|
|
left_side = block->curr_left_side;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
ins_rec = page_rec_get_next(rec);
|
|
|
|
next_rec = page_rec_get_next(ins_rec);
|
|
|
|
|
|
|
|
offsets = rec_get_offsets(ins_rec, cursor->index, offsets,
|
2006-08-29 09:30:31 +00:00
|
|
|
ULINT_UNDEFINED, &heap);
|
2006-09-19 10:14:07 +00:00
|
|
|
ins_fold = rec_fold(ins_rec, offsets, n_fields, n_bytes, index_id);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
if (!page_rec_is_supremum(next_rec)) {
|
|
|
|
offsets = rec_get_offsets(next_rec, cursor->index, offsets,
|
2006-08-29 09:30:31 +00:00
|
|
|
n_fields + (n_bytes > 0), &heap);
|
2005-10-27 07:29:40 +00:00
|
|
|
next_fold = rec_fold(next_rec, offsets, n_fields,
|
2006-09-19 10:14:07 +00:00
|
|
|
n_bytes, index_id);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!page_rec_is_infimum(rec)) {
|
|
|
|
offsets = rec_get_offsets(rec, cursor->index, offsets,
|
2006-08-29 09:30:31 +00:00
|
|
|
n_fields + (n_bytes > 0), &heap);
|
2006-09-19 10:14:07 +00:00
|
|
|
fold = rec_fold(rec, offsets, n_fields, n_bytes, index_id);
|
2005-10-27 07:29:40 +00:00
|
|
|
} else {
|
2006-09-19 10:14:07 +00:00
|
|
|
if (left_side) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
rw_lock_x_lock(&btr_search_latch);
|
|
|
|
|
|
|
|
locked = TRUE;
|
|
|
|
|
2006-11-13 21:53:09 +00:00
|
|
|
ha_insert_for_fold(table, ins_fold, block, ins_rec);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
goto check_next_rec;
|
|
|
|
}
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
if (fold != ins_fold) {
|
|
|
|
|
|
|
|
if (!locked) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
rw_lock_x_lock(&btr_search_latch);
|
|
|
|
|
|
|
|
locked = TRUE;
|
|
|
|
}
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
if (!left_side) {
|
2006-11-13 21:53:09 +00:00
|
|
|
ha_insert_for_fold(table, fold, block, rec);
|
2005-10-27 07:29:40 +00:00
|
|
|
} else {
|
2006-11-13 21:53:09 +00:00
|
|
|
ha_insert_for_fold(table, ins_fold, block, ins_rec);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
check_next_rec:
|
|
|
|
if (page_rec_is_supremum(next_rec)) {
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
if (!left_side) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
if (!locked) {
|
2005-10-27 07:29:40 +00:00
|
|
|
rw_lock_x_lock(&btr_search_latch);
|
|
|
|
|
|
|
|
locked = TRUE;
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-11-13 21:53:09 +00:00
|
|
|
ha_insert_for_fold(table, ins_fold, block, ins_rec);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
goto function_exit;
|
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
if (ins_fold != next_fold) {
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
if (!locked) {
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
rw_lock_x_lock(&btr_search_latch);
|
|
|
|
|
|
|
|
locked = TRUE;
|
|
|
|
}
|
|
|
|
|
2006-09-19 10:14:07 +00:00
|
|
|
if (!left_side) {
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-11-13 21:53:09 +00:00
|
|
|
ha_insert_for_fold(table, ins_fold, block, ins_rec);
|
2006-08-29 09:30:31 +00:00
|
|
|
/*
|
2005-10-27 07:29:40 +00:00
|
|
|
fputs("Hash insert for ", stderr);
|
|
|
|
dict_index_name_print(stderr, cursor->index);
|
|
|
|
fprintf(stderr, " fold %lu\n", ins_fold);
|
2006-08-29 09:30:31 +00:00
|
|
|
*/
|
2005-10-27 07:29:40 +00:00
|
|
|
} else {
|
2006-11-13 21:53:09 +00:00
|
|
|
ha_insert_for_fold(table, next_fold, block, next_rec);
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
}
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
function_exit:
|
|
|
|
if (UNIV_LIKELY_NULL(heap)) {
|
|
|
|
mem_heap_free(heap);
|
|
|
|
}
|
|
|
|
if (locked) {
|
|
|
|
rw_lock_x_unlock(&btr_search_latch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
Validates the search system. */
|
2008-02-06 14:17:36 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ibool
|
|
|
|
btr_search_validate(void)
|
|
|
|
/*=====================*/
|
|
|
|
/* out: TRUE if ok */
|
|
|
|
{
|
|
|
|
ha_node_t* node;
|
|
|
|
ulint n_page_dumps = 0;
|
|
|
|
ibool ok = TRUE;
|
|
|
|
ulint i;
|
2006-02-17 14:19:39 +00:00
|
|
|
ulint cell_count;
|
2005-10-27 07:29:40 +00:00
|
|
|
mem_heap_t* heap = NULL;
|
|
|
|
ulint offsets_[REC_OFFS_NORMAL_SIZE];
|
|
|
|
ulint* offsets = offsets_;
|
2006-02-17 14:19:39 +00:00
|
|
|
|
|
|
|
/* How many cells to check before temporarily releasing
|
|
|
|
btr_search_latch. */
|
|
|
|
ulint chunk_size = 10000;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2007-09-28 07:05:57 +00:00
|
|
|
rec_offs_init(offsets_);
|
2006-04-12 09:32:17 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
rw_lock_x_lock(&btr_search_latch);
|
2008-01-10 09:37:13 +00:00
|
|
|
buf_pool_mutex_enter();
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-17 14:19:39 +00:00
|
|
|
cell_count = hash_get_n_cells(btr_search_sys->hash_index);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-02-17 14:19:39 +00:00
|
|
|
for (i = 0; i < cell_count; i++) {
|
|
|
|
/* We release btr_search_latch every once in a while to
|
|
|
|
give other queries a chance to run. */
|
|
|
|
if ((i != 0) && ((i % chunk_size) == 0)) {
|
2008-01-10 09:37:13 +00:00
|
|
|
buf_pool_mutex_exit();
|
2006-02-17 14:19:39 +00:00
|
|
|
rw_lock_x_unlock(&btr_search_latch);
|
|
|
|
os_thread_yield();
|
|
|
|
rw_lock_x_lock(&btr_search_latch);
|
2008-01-10 09:37:13 +00:00
|
|
|
buf_pool_mutex_enter();
|
2006-02-17 14:19:39 +00:00
|
|
|
}
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
node = hash_get_nth_cell(btr_search_sys->hash_index, i)->node;
|
|
|
|
|
2006-11-02 09:06:49 +00:00
|
|
|
for (; node != NULL; node = node->next) {
|
branches/innodb+: Merge revisions 4006:4060 from branches/zip:
------------------------------------------------------------------------
r4008 | vasil | 2009-01-20 17:01:08 +0200 (Tue, 20 Jan 2009) | 4 lines
branches/zip:
Add ChangeLog entries for the bugfixes in r4004 and r4005.
------------------------------------------------------------------------
r4027 | marko | 2009-01-23 11:04:49 +0200 (Fri, 23 Jan 2009) | 1 line
branches/zip: Remove some redundant #include statements.
------------------------------------------------------------------------
r4028 | marko | 2009-01-23 11:26:10 +0200 (Fri, 23 Jan 2009) | 13 lines
branches/zip: Enclose some more unused code in #ifdef UNIV_LOG_ARCHIVE.
This will help trim the dependencies of InnoDB Hot Backup.
recv_recovery_from_checkpoint_start(): Rename to
recv_recovery_from_checkpoint_start_func(), and remove the two first
parameters unless UNIV_LOG_ARCHIVE is defined. Define and use
the auxiliary macros TYPE_CHECKPOINT and LIMIT_LSN in the function.
struct recv_sys_struct: Remove archive_group unless UNIV_LOG_ARCHIVE
is defined.
Do not define LOG_ARCHIVE unless UNIV_LOG_ARCHIVE is defined.
------------------------------------------------------------------------
r4029 | marko | 2009-01-23 14:07:38 +0200 (Fri, 23 Jan 2009) | 1 line
branches/zip: Remove some redundant #include directives.
------------------------------------------------------------------------
r4030 | marko | 2009-01-23 15:31:36 +0200 (Fri, 23 Jan 2009) | 2 lines
branches/zip: buf_page_get_gen(): Remove the unused mode BUF_GET_NOWAIT.
This was noticed while investigating Issue #160.
------------------------------------------------------------------------
r4033 | marko | 2009-01-23 15:49:04 +0200 (Fri, 23 Jan 2009) | 16 lines
branches/zip: Merge revisions 4005:4032 from branches/5.1:
------------------------------------------------------------------------
r4032 | marko | 2009-01-23 15:43:51 +0200 (Fri, 23 Jan 2009) | 10 lines
branches/5.1: Merge r4031 from branches/5.0:
btr_search_drop_page_hash_when_freed(): Check if buf_page_get_gen()
returns NULL. The page may have been evicted from the buffer pool
between buf_page_peek_if_search_hashed() and buf_page_get_gen(),
because the buffer pool mutex will be released between these two calls.
(Bug #42279, Issue #160)
rb://82 approved by Heikki Tuuri
------------------------------------------------------------------------
------------------------------------------------------------------------
r4034 | marko | 2009-01-26 16:16:39 +0200 (Mon, 26 Jan 2009) | 2 lines
branches/zip: buf_page_get_gen(): Fix a "possibly uninitialized" warning
that was introduced in r4030.
------------------------------------------------------------------------
r4036 | marko | 2009-01-26 22:33:20 +0200 (Mon, 26 Jan 2009) | 22 lines
branches/zip: In r988, the function buf_block_align() was enclosed
within UNIV_DEBUG. The two remaining callers in non-debug builds,
btr_search_guess_on_hash() and btr_search_validate(), were rewritten
to call buf_page_hash_get().
To implement support for a resizeable buffer pool, the function
buf_block_align() had been rewritten to perform a page hash lookup in
the buffer pool. The caller was also made responsible for holding the
buffer pool mutex.
Because the page hash lookup is expensive and it has to be done while
holding the buffer pool mutex, implement buf_block_align() by pointer
arithmetics again, and make btr_search_guess_on_hash() call it. Note
that this will have to be adjusted if the interface to the resizeable
buffer pool is actually implemented.
rb://83 approved by Heikki Tuuri, to address Issue #161.
As a deviation from the approved patch, this patch also makes
btr_search_validate() (invoked by CHECK TABLE) check that
buf_pool->page_hash is consistent with buf_block_align().
------------------------------------------------------------------------
r4039 | vasil | 2009-01-27 08:04:17 +0200 (Tue, 27 Jan 2009) | 5 lines
branches/zip:
Adjust the paths in innodb_file_per_table.diff with a recent rename of
the test/result files in the MySQL tree.
------------------------------------------------------------------------
r4042 | marko | 2009-01-27 10:05:24 +0200 (Tue, 27 Jan 2009) | 2 lines
branches/zip: buf_LRU_invalidate_tablespace(): Fix a race condition:
read zip_size while still holding block_mutex.
------------------------------------------------------------------------
r4045 | marko | 2009-01-28 00:31:17 +0200 (Wed, 28 Jan 2009) | 8 lines
branches/zip: btr_search_validate(): Fix a bogus UNIV_DEBUG
assertion failure that was accidentally introduced in r4036.
Instead of calling buf_block_get_frame(), which asserts that the
block must be buffer-fixed, access block->frame directly. That
is safe, because changes of block->page.state are protected by
the buffer pool mutex, which we are holding.
This bug was reported by Michael.
------------------------------------------------------------------------
r4046 | marko | 2009-01-28 00:33:20 +0200 (Wed, 28 Jan 2009) | 2 lines
branches/zip: Revert the change to univ.i that was accidentally
committed in r4045.
------------------------------------------------------------------------
r4047 | marko | 2009-01-28 00:46:13 +0200 (Wed, 28 Jan 2009) | 6 lines
branches/zip: btr_search_validate(): Fix an assertion failure that was
introduced in r4036.
Do not call buf_block_get_space(), buf_block_get_page_no()
unless the block state is BUF_BLOCK_FILE_PAGE.
This bug was reported by Michael.
------------------------------------------------------------------------
r4050 | vasil | 2009-01-28 08:21:44 +0200 (Wed, 28 Jan 2009) | 5 lines
branches/zip:
Adjust the paths in innodb_lock_wait_timeout.diff with a recent rename of
the test/result files in the MySQL tree.
------------------------------------------------------------------------
r4051 | marko | 2009-01-28 14:35:49 +0200 (Wed, 28 Jan 2009) | 1 line
branches/zip: trx0sys.ic: Remove unnecessary #include <data0type.h>.
------------------------------------------------------------------------
r4052 | marko | 2009-01-28 15:21:45 +0200 (Wed, 28 Jan 2009) | 5 lines
branches/zip: Enclose some functions inside #ifdef UNIV_HOTBACKUP:
ut_sprintf_timestamp_without_extra_chars(), ut_get_year_month_day(),
log_reset_first_header_and_checkpoint(): These functions are only used
in InnoDB Hot Backup.
------------------------------------------------------------------------
r4056 | calvin | 2009-01-29 03:06:41 +0200 (Thu, 29 Jan 2009) | 33 lines
branches/zip: Merge revisions 4032:4035 from branches/5.1
All InnoDB related tests passed on Windows, except
known failure in partition_innodb_semi_consistent.
The inadvertent change to btr0sea.c in this commit is reverted in r4060.
------------------------------------------------------------------------
r4035 | vasil | 2009-01-26 09:26:25 -0600 (Mon, 26 Jan 2009) | 23 lines
branches/5.1:
Merge a change from MySQL:
------------------------------------------------------------
revno: 2646.161.4
committer: Tatiana A. Nurnberg <azundris@mysql.com>
branch nick: 51-31177v2
timestamp: Mon 2009-01-12 06:32:49 +0100
message:
Bug#31177: Server variables can't be set to their current values
Bounds-checks and blocksize corrections were applied to user-input,
but constants in the server were trusted implicitly. If these values
did not actually meet the requirements, the user could not set change
a variable, then set it back to the (wonky) factory default or maximum
by explicitly specifying it (SET <var>=<value> vs SET <var>=DEFAULT).
Now checks also apply to the server's presets. Wonky values and maxima
get corrected at startup. Consequently all non-offsetted values the user
sees are valid, and users can set the variable to that exact value if
they so desire.
------------------------------------------------------------------------
r4060 | marko | 2009-01-29 09:39:04 +0200 (Thu, 29 Jan 2009) | 1 line
branches/zip: btr0sea.c: Revert the inadvertent change made in r4056.
------------------------------------------------------------------------
2009-01-29 09:47:07 +00:00
|
|
|
const buf_block_t* block
|
|
|
|
= buf_block_align(node->data);
|
|
|
|
const buf_block_t* hash_block;
|
|
|
|
|
|
|
|
if (UNIV_LIKELY(buf_block_get_state(block)
|
|
|
|
== BUF_BLOCK_FILE_PAGE)) {
|
|
|
|
|
|
|
|
/* The space and offset are only valid
|
|
|
|
for file blocks. It is possible that
|
|
|
|
the block is being freed
|
|
|
|
(BUF_BLOCK_REMOVE_HASH, see the
|
|
|
|
assertion and the comment below) */
|
|
|
|
hash_block = buf_block_hash_get(
|
|
|
|
buf_block_get_space(block),
|
|
|
|
buf_block_get_page_no(block));
|
|
|
|
} else {
|
|
|
|
hash_block = NULL;
|
2006-11-02 09:06:49 +00:00
|
|
|
}
|
|
|
|
|
branches/innodb+: Merge revisions 4006:4060 from branches/zip:
------------------------------------------------------------------------
r4008 | vasil | 2009-01-20 17:01:08 +0200 (Tue, 20 Jan 2009) | 4 lines
branches/zip:
Add ChangeLog entries for the bugfixes in r4004 and r4005.
------------------------------------------------------------------------
r4027 | marko | 2009-01-23 11:04:49 +0200 (Fri, 23 Jan 2009) | 1 line
branches/zip: Remove some redundant #include statements.
------------------------------------------------------------------------
r4028 | marko | 2009-01-23 11:26:10 +0200 (Fri, 23 Jan 2009) | 13 lines
branches/zip: Enclose some more unused code in #ifdef UNIV_LOG_ARCHIVE.
This will help trim the dependencies of InnoDB Hot Backup.
recv_recovery_from_checkpoint_start(): Rename to
recv_recovery_from_checkpoint_start_func(), and remove the two first
parameters unless UNIV_LOG_ARCHIVE is defined. Define and use
the auxiliary macros TYPE_CHECKPOINT and LIMIT_LSN in the function.
struct recv_sys_struct: Remove archive_group unless UNIV_LOG_ARCHIVE
is defined.
Do not define LOG_ARCHIVE unless UNIV_LOG_ARCHIVE is defined.
------------------------------------------------------------------------
r4029 | marko | 2009-01-23 14:07:38 +0200 (Fri, 23 Jan 2009) | 1 line
branches/zip: Remove some redundant #include directives.
------------------------------------------------------------------------
r4030 | marko | 2009-01-23 15:31:36 +0200 (Fri, 23 Jan 2009) | 2 lines
branches/zip: buf_page_get_gen(): Remove the unused mode BUF_GET_NOWAIT.
This was noticed while investigating Issue #160.
------------------------------------------------------------------------
r4033 | marko | 2009-01-23 15:49:04 +0200 (Fri, 23 Jan 2009) | 16 lines
branches/zip: Merge revisions 4005:4032 from branches/5.1:
------------------------------------------------------------------------
r4032 | marko | 2009-01-23 15:43:51 +0200 (Fri, 23 Jan 2009) | 10 lines
branches/5.1: Merge r4031 from branches/5.0:
btr_search_drop_page_hash_when_freed(): Check if buf_page_get_gen()
returns NULL. The page may have been evicted from the buffer pool
between buf_page_peek_if_search_hashed() and buf_page_get_gen(),
because the buffer pool mutex will be released between these two calls.
(Bug #42279, Issue #160)
rb://82 approved by Heikki Tuuri
------------------------------------------------------------------------
------------------------------------------------------------------------
r4034 | marko | 2009-01-26 16:16:39 +0200 (Mon, 26 Jan 2009) | 2 lines
branches/zip: buf_page_get_gen(): Fix a "possibly uninitialized" warning
that was introduced in r4030.
------------------------------------------------------------------------
r4036 | marko | 2009-01-26 22:33:20 +0200 (Mon, 26 Jan 2009) | 22 lines
branches/zip: In r988, the function buf_block_align() was enclosed
within UNIV_DEBUG. The two remaining callers in non-debug builds,
btr_search_guess_on_hash() and btr_search_validate(), were rewritten
to call buf_page_hash_get().
To implement support for a resizeable buffer pool, the function
buf_block_align() had been rewritten to perform a page hash lookup in
the buffer pool. The caller was also made responsible for holding the
buffer pool mutex.
Because the page hash lookup is expensive and it has to be done while
holding the buffer pool mutex, implement buf_block_align() by pointer
arithmetics again, and make btr_search_guess_on_hash() call it. Note
that this will have to be adjusted if the interface to the resizeable
buffer pool is actually implemented.
rb://83 approved by Heikki Tuuri, to address Issue #161.
As a deviation from the approved patch, this patch also makes
btr_search_validate() (invoked by CHECK TABLE) check that
buf_pool->page_hash is consistent with buf_block_align().
------------------------------------------------------------------------
r4039 | vasil | 2009-01-27 08:04:17 +0200 (Tue, 27 Jan 2009) | 5 lines
branches/zip:
Adjust the paths in innodb_file_per_table.diff with a recent rename of
the test/result files in the MySQL tree.
------------------------------------------------------------------------
r4042 | marko | 2009-01-27 10:05:24 +0200 (Tue, 27 Jan 2009) | 2 lines
branches/zip: buf_LRU_invalidate_tablespace(): Fix a race condition:
read zip_size while still holding block_mutex.
------------------------------------------------------------------------
r4045 | marko | 2009-01-28 00:31:17 +0200 (Wed, 28 Jan 2009) | 8 lines
branches/zip: btr_search_validate(): Fix a bogus UNIV_DEBUG
assertion failure that was accidentally introduced in r4036.
Instead of calling buf_block_get_frame(), which asserts that the
block must be buffer-fixed, access block->frame directly. That
is safe, because changes of block->page.state are protected by
the buffer pool mutex, which we are holding.
This bug was reported by Michael.
------------------------------------------------------------------------
r4046 | marko | 2009-01-28 00:33:20 +0200 (Wed, 28 Jan 2009) | 2 lines
branches/zip: Revert the change to univ.i that was accidentally
committed in r4045.
------------------------------------------------------------------------
r4047 | marko | 2009-01-28 00:46:13 +0200 (Wed, 28 Jan 2009) | 6 lines
branches/zip: btr_search_validate(): Fix an assertion failure that was
introduced in r4036.
Do not call buf_block_get_space(), buf_block_get_page_no()
unless the block state is BUF_BLOCK_FILE_PAGE.
This bug was reported by Michael.
------------------------------------------------------------------------
r4050 | vasil | 2009-01-28 08:21:44 +0200 (Wed, 28 Jan 2009) | 5 lines
branches/zip:
Adjust the paths in innodb_lock_wait_timeout.diff with a recent rename of
the test/result files in the MySQL tree.
------------------------------------------------------------------------
r4051 | marko | 2009-01-28 14:35:49 +0200 (Wed, 28 Jan 2009) | 1 line
branches/zip: trx0sys.ic: Remove unnecessary #include <data0type.h>.
------------------------------------------------------------------------
r4052 | marko | 2009-01-28 15:21:45 +0200 (Wed, 28 Jan 2009) | 5 lines
branches/zip: Enclose some functions inside #ifdef UNIV_HOTBACKUP:
ut_sprintf_timestamp_without_extra_chars(), ut_get_year_month_day(),
log_reset_first_header_and_checkpoint(): These functions are only used
in InnoDB Hot Backup.
------------------------------------------------------------------------
r4056 | calvin | 2009-01-29 03:06:41 +0200 (Thu, 29 Jan 2009) | 33 lines
branches/zip: Merge revisions 4032:4035 from branches/5.1
All InnoDB related tests passed on Windows, except
known failure in partition_innodb_semi_consistent.
The inadvertent change to btr0sea.c in this commit is reverted in r4060.
------------------------------------------------------------------------
r4035 | vasil | 2009-01-26 09:26:25 -0600 (Mon, 26 Jan 2009) | 23 lines
branches/5.1:
Merge a change from MySQL:
------------------------------------------------------------
revno: 2646.161.4
committer: Tatiana A. Nurnberg <azundris@mysql.com>
branch nick: 51-31177v2
timestamp: Mon 2009-01-12 06:32:49 +0100
message:
Bug#31177: Server variables can't be set to their current values
Bounds-checks and blocksize corrections were applied to user-input,
but constants in the server were trusted implicitly. If these values
did not actually meet the requirements, the user could not set change
a variable, then set it back to the (wonky) factory default or maximum
by explicitly specifying it (SET <var>=<value> vs SET <var>=DEFAULT).
Now checks also apply to the server's presets. Wonky values and maxima
get corrected at startup. Consequently all non-offsetted values the user
sees are valid, and users can set the variable to that exact value if
they so desire.
------------------------------------------------------------------------
r4060 | marko | 2009-01-29 09:39:04 +0200 (Thu, 29 Jan 2009) | 1 line
branches/zip: btr0sea.c: Revert the inadvertent change made in r4056.
------------------------------------------------------------------------
2009-01-29 09:47:07 +00:00
|
|
|
if (hash_block) {
|
|
|
|
ut_a(hash_block == block);
|
|
|
|
} else {
|
|
|
|
/* When a block is being freed,
|
|
|
|
buf_LRU_search_and_free_block() first
|
|
|
|
removes the block from
|
2006-11-02 09:06:49 +00:00
|
|
|
buf_pool->page_hash by calling
|
|
|
|
buf_LRU_block_remove_hashed_page().
|
|
|
|
After that, it invokes
|
branches/innodb+: Merge revisions 4006:4060 from branches/zip:
------------------------------------------------------------------------
r4008 | vasil | 2009-01-20 17:01:08 +0200 (Tue, 20 Jan 2009) | 4 lines
branches/zip:
Add ChangeLog entries for the bugfixes in r4004 and r4005.
------------------------------------------------------------------------
r4027 | marko | 2009-01-23 11:04:49 +0200 (Fri, 23 Jan 2009) | 1 line
branches/zip: Remove some redundant #include statements.
------------------------------------------------------------------------
r4028 | marko | 2009-01-23 11:26:10 +0200 (Fri, 23 Jan 2009) | 13 lines
branches/zip: Enclose some more unused code in #ifdef UNIV_LOG_ARCHIVE.
This will help trim the dependencies of InnoDB Hot Backup.
recv_recovery_from_checkpoint_start(): Rename to
recv_recovery_from_checkpoint_start_func(), and remove the two first
parameters unless UNIV_LOG_ARCHIVE is defined. Define and use
the auxiliary macros TYPE_CHECKPOINT and LIMIT_LSN in the function.
struct recv_sys_struct: Remove archive_group unless UNIV_LOG_ARCHIVE
is defined.
Do not define LOG_ARCHIVE unless UNIV_LOG_ARCHIVE is defined.
------------------------------------------------------------------------
r4029 | marko | 2009-01-23 14:07:38 +0200 (Fri, 23 Jan 2009) | 1 line
branches/zip: Remove some redundant #include directives.
------------------------------------------------------------------------
r4030 | marko | 2009-01-23 15:31:36 +0200 (Fri, 23 Jan 2009) | 2 lines
branches/zip: buf_page_get_gen(): Remove the unused mode BUF_GET_NOWAIT.
This was noticed while investigating Issue #160.
------------------------------------------------------------------------
r4033 | marko | 2009-01-23 15:49:04 +0200 (Fri, 23 Jan 2009) | 16 lines
branches/zip: Merge revisions 4005:4032 from branches/5.1:
------------------------------------------------------------------------
r4032 | marko | 2009-01-23 15:43:51 +0200 (Fri, 23 Jan 2009) | 10 lines
branches/5.1: Merge r4031 from branches/5.0:
btr_search_drop_page_hash_when_freed(): Check if buf_page_get_gen()
returns NULL. The page may have been evicted from the buffer pool
between buf_page_peek_if_search_hashed() and buf_page_get_gen(),
because the buffer pool mutex will be released between these two calls.
(Bug #42279, Issue #160)
rb://82 approved by Heikki Tuuri
------------------------------------------------------------------------
------------------------------------------------------------------------
r4034 | marko | 2009-01-26 16:16:39 +0200 (Mon, 26 Jan 2009) | 2 lines
branches/zip: buf_page_get_gen(): Fix a "possibly uninitialized" warning
that was introduced in r4030.
------------------------------------------------------------------------
r4036 | marko | 2009-01-26 22:33:20 +0200 (Mon, 26 Jan 2009) | 22 lines
branches/zip: In r988, the function buf_block_align() was enclosed
within UNIV_DEBUG. The two remaining callers in non-debug builds,
btr_search_guess_on_hash() and btr_search_validate(), were rewritten
to call buf_page_hash_get().
To implement support for a resizeable buffer pool, the function
buf_block_align() had been rewritten to perform a page hash lookup in
the buffer pool. The caller was also made responsible for holding the
buffer pool mutex.
Because the page hash lookup is expensive and it has to be done while
holding the buffer pool mutex, implement buf_block_align() by pointer
arithmetics again, and make btr_search_guess_on_hash() call it. Note
that this will have to be adjusted if the interface to the resizeable
buffer pool is actually implemented.
rb://83 approved by Heikki Tuuri, to address Issue #161.
As a deviation from the approved patch, this patch also makes
btr_search_validate() (invoked by CHECK TABLE) check that
buf_pool->page_hash is consistent with buf_block_align().
------------------------------------------------------------------------
r4039 | vasil | 2009-01-27 08:04:17 +0200 (Tue, 27 Jan 2009) | 5 lines
branches/zip:
Adjust the paths in innodb_file_per_table.diff with a recent rename of
the test/result files in the MySQL tree.
------------------------------------------------------------------------
r4042 | marko | 2009-01-27 10:05:24 +0200 (Tue, 27 Jan 2009) | 2 lines
branches/zip: buf_LRU_invalidate_tablespace(): Fix a race condition:
read zip_size while still holding block_mutex.
------------------------------------------------------------------------
r4045 | marko | 2009-01-28 00:31:17 +0200 (Wed, 28 Jan 2009) | 8 lines
branches/zip: btr_search_validate(): Fix a bogus UNIV_DEBUG
assertion failure that was accidentally introduced in r4036.
Instead of calling buf_block_get_frame(), which asserts that the
block must be buffer-fixed, access block->frame directly. That
is safe, because changes of block->page.state are protected by
the buffer pool mutex, which we are holding.
This bug was reported by Michael.
------------------------------------------------------------------------
r4046 | marko | 2009-01-28 00:33:20 +0200 (Wed, 28 Jan 2009) | 2 lines
branches/zip: Revert the change to univ.i that was accidentally
committed in r4045.
------------------------------------------------------------------------
r4047 | marko | 2009-01-28 00:46:13 +0200 (Wed, 28 Jan 2009) | 6 lines
branches/zip: btr_search_validate(): Fix an assertion failure that was
introduced in r4036.
Do not call buf_block_get_space(), buf_block_get_page_no()
unless the block state is BUF_BLOCK_FILE_PAGE.
This bug was reported by Michael.
------------------------------------------------------------------------
r4050 | vasil | 2009-01-28 08:21:44 +0200 (Wed, 28 Jan 2009) | 5 lines
branches/zip:
Adjust the paths in innodb_lock_wait_timeout.diff with a recent rename of
the test/result files in the MySQL tree.
------------------------------------------------------------------------
r4051 | marko | 2009-01-28 14:35:49 +0200 (Wed, 28 Jan 2009) | 1 line
branches/zip: trx0sys.ic: Remove unnecessary #include <data0type.h>.
------------------------------------------------------------------------
r4052 | marko | 2009-01-28 15:21:45 +0200 (Wed, 28 Jan 2009) | 5 lines
branches/zip: Enclose some functions inside #ifdef UNIV_HOTBACKUP:
ut_sprintf_timestamp_without_extra_chars(), ut_get_year_month_day(),
log_reset_first_header_and_checkpoint(): These functions are only used
in InnoDB Hot Backup.
------------------------------------------------------------------------
r4056 | calvin | 2009-01-29 03:06:41 +0200 (Thu, 29 Jan 2009) | 33 lines
branches/zip: Merge revisions 4032:4035 from branches/5.1
All InnoDB related tests passed on Windows, except
known failure in partition_innodb_semi_consistent.
The inadvertent change to btr0sea.c in this commit is reverted in r4060.
------------------------------------------------------------------------
r4035 | vasil | 2009-01-26 09:26:25 -0600 (Mon, 26 Jan 2009) | 23 lines
branches/5.1:
Merge a change from MySQL:
------------------------------------------------------------
revno: 2646.161.4
committer: Tatiana A. Nurnberg <azundris@mysql.com>
branch nick: 51-31177v2
timestamp: Mon 2009-01-12 06:32:49 +0100
message:
Bug#31177: Server variables can't be set to their current values
Bounds-checks and blocksize corrections were applied to user-input,
but constants in the server were trusted implicitly. If these values
did not actually meet the requirements, the user could not set change
a variable, then set it back to the (wonky) factory default or maximum
by explicitly specifying it (SET <var>=<value> vs SET <var>=DEFAULT).
Now checks also apply to the server's presets. Wonky values and maxima
get corrected at startup. Consequently all non-offsetted values the user
sees are valid, and users can set the variable to that exact value if
they so desire.
------------------------------------------------------------------------
r4060 | marko | 2009-01-29 09:39:04 +0200 (Thu, 29 Jan 2009) | 1 line
branches/zip: btr0sea.c: Revert the inadvertent change made in r4056.
------------------------------------------------------------------------
2009-01-29 09:47:07 +00:00
|
|
|
btr_search_drop_page_hash_index() to
|
|
|
|
remove the block from
|
|
|
|
btr_search_sys->hash_index. */
|
|
|
|
|
|
|
|
ut_a(buf_block_get_state(block)
|
|
|
|
== BUF_BLOCK_REMOVE_HASH);
|
2006-11-02 09:06:49 +00:00
|
|
|
}
|
|
|
|
|
2008-01-25 14:37:11 +00:00
|
|
|
ut_a(!dict_index_is_ibuf(block->index));
|
|
|
|
|
2007-10-01 07:45:02 +00:00
|
|
|
offsets = rec_get_offsets((const rec_t*) node->data,
|
2006-08-29 09:30:31 +00:00
|
|
|
block->index, offsets,
|
|
|
|
block->curr_n_fields
|
|
|
|
+ (block->curr_n_bytes > 0),
|
|
|
|
&heap);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-08-29 09:30:31 +00:00
|
|
|
if (!block->is_hashed || node->fold
|
|
|
|
!= rec_fold((rec_t*)(node->data),
|
2006-02-23 19:25:29 +00:00
|
|
|
offsets,
|
|
|
|
block->curr_n_fields,
|
|
|
|
block->curr_n_bytes,
|
branches/innodb+: Merge revisions 4006:4060 from branches/zip:
------------------------------------------------------------------------
r4008 | vasil | 2009-01-20 17:01:08 +0200 (Tue, 20 Jan 2009) | 4 lines
branches/zip:
Add ChangeLog entries for the bugfixes in r4004 and r4005.
------------------------------------------------------------------------
r4027 | marko | 2009-01-23 11:04:49 +0200 (Fri, 23 Jan 2009) | 1 line
branches/zip: Remove some redundant #include statements.
------------------------------------------------------------------------
r4028 | marko | 2009-01-23 11:26:10 +0200 (Fri, 23 Jan 2009) | 13 lines
branches/zip: Enclose some more unused code in #ifdef UNIV_LOG_ARCHIVE.
This will help trim the dependencies of InnoDB Hot Backup.
recv_recovery_from_checkpoint_start(): Rename to
recv_recovery_from_checkpoint_start_func(), and remove the two first
parameters unless UNIV_LOG_ARCHIVE is defined. Define and use
the auxiliary macros TYPE_CHECKPOINT and LIMIT_LSN in the function.
struct recv_sys_struct: Remove archive_group unless UNIV_LOG_ARCHIVE
is defined.
Do not define LOG_ARCHIVE unless UNIV_LOG_ARCHIVE is defined.
------------------------------------------------------------------------
r4029 | marko | 2009-01-23 14:07:38 +0200 (Fri, 23 Jan 2009) | 1 line
branches/zip: Remove some redundant #include directives.
------------------------------------------------------------------------
r4030 | marko | 2009-01-23 15:31:36 +0200 (Fri, 23 Jan 2009) | 2 lines
branches/zip: buf_page_get_gen(): Remove the unused mode BUF_GET_NOWAIT.
This was noticed while investigating Issue #160.
------------------------------------------------------------------------
r4033 | marko | 2009-01-23 15:49:04 +0200 (Fri, 23 Jan 2009) | 16 lines
branches/zip: Merge revisions 4005:4032 from branches/5.1:
------------------------------------------------------------------------
r4032 | marko | 2009-01-23 15:43:51 +0200 (Fri, 23 Jan 2009) | 10 lines
branches/5.1: Merge r4031 from branches/5.0:
btr_search_drop_page_hash_when_freed(): Check if buf_page_get_gen()
returns NULL. The page may have been evicted from the buffer pool
between buf_page_peek_if_search_hashed() and buf_page_get_gen(),
because the buffer pool mutex will be released between these two calls.
(Bug #42279, Issue #160)
rb://82 approved by Heikki Tuuri
------------------------------------------------------------------------
------------------------------------------------------------------------
r4034 | marko | 2009-01-26 16:16:39 +0200 (Mon, 26 Jan 2009) | 2 lines
branches/zip: buf_page_get_gen(): Fix a "possibly uninitialized" warning
that was introduced in r4030.
------------------------------------------------------------------------
r4036 | marko | 2009-01-26 22:33:20 +0200 (Mon, 26 Jan 2009) | 22 lines
branches/zip: In r988, the function buf_block_align() was enclosed
within UNIV_DEBUG. The two remaining callers in non-debug builds,
btr_search_guess_on_hash() and btr_search_validate(), were rewritten
to call buf_page_hash_get().
To implement support for a resizeable buffer pool, the function
buf_block_align() had been rewritten to perform a page hash lookup in
the buffer pool. The caller was also made responsible for holding the
buffer pool mutex.
Because the page hash lookup is expensive and it has to be done while
holding the buffer pool mutex, implement buf_block_align() by pointer
arithmetics again, and make btr_search_guess_on_hash() call it. Note
that this will have to be adjusted if the interface to the resizeable
buffer pool is actually implemented.
rb://83 approved by Heikki Tuuri, to address Issue #161.
As a deviation from the approved patch, this patch also makes
btr_search_validate() (invoked by CHECK TABLE) check that
buf_pool->page_hash is consistent with buf_block_align().
------------------------------------------------------------------------
r4039 | vasil | 2009-01-27 08:04:17 +0200 (Tue, 27 Jan 2009) | 5 lines
branches/zip:
Adjust the paths in innodb_file_per_table.diff with a recent rename of
the test/result files in the MySQL tree.
------------------------------------------------------------------------
r4042 | marko | 2009-01-27 10:05:24 +0200 (Tue, 27 Jan 2009) | 2 lines
branches/zip: buf_LRU_invalidate_tablespace(): Fix a race condition:
read zip_size while still holding block_mutex.
------------------------------------------------------------------------
r4045 | marko | 2009-01-28 00:31:17 +0200 (Wed, 28 Jan 2009) | 8 lines
branches/zip: btr_search_validate(): Fix a bogus UNIV_DEBUG
assertion failure that was accidentally introduced in r4036.
Instead of calling buf_block_get_frame(), which asserts that the
block must be buffer-fixed, access block->frame directly. That
is safe, because changes of block->page.state are protected by
the buffer pool mutex, which we are holding.
This bug was reported by Michael.
------------------------------------------------------------------------
r4046 | marko | 2009-01-28 00:33:20 +0200 (Wed, 28 Jan 2009) | 2 lines
branches/zip: Revert the change to univ.i that was accidentally
committed in r4045.
------------------------------------------------------------------------
r4047 | marko | 2009-01-28 00:46:13 +0200 (Wed, 28 Jan 2009) | 6 lines
branches/zip: btr_search_validate(): Fix an assertion failure that was
introduced in r4036.
Do not call buf_block_get_space(), buf_block_get_page_no()
unless the block state is BUF_BLOCK_FILE_PAGE.
This bug was reported by Michael.
------------------------------------------------------------------------
r4050 | vasil | 2009-01-28 08:21:44 +0200 (Wed, 28 Jan 2009) | 5 lines
branches/zip:
Adjust the paths in innodb_lock_wait_timeout.diff with a recent rename of
the test/result files in the MySQL tree.
------------------------------------------------------------------------
r4051 | marko | 2009-01-28 14:35:49 +0200 (Wed, 28 Jan 2009) | 1 line
branches/zip: trx0sys.ic: Remove unnecessary #include <data0type.h>.
------------------------------------------------------------------------
r4052 | marko | 2009-01-28 15:21:45 +0200 (Wed, 28 Jan 2009) | 5 lines
branches/zip: Enclose some functions inside #ifdef UNIV_HOTBACKUP:
ut_sprintf_timestamp_without_extra_chars(), ut_get_year_month_day(),
log_reset_first_header_and_checkpoint(): These functions are only used
in InnoDB Hot Backup.
------------------------------------------------------------------------
r4056 | calvin | 2009-01-29 03:06:41 +0200 (Thu, 29 Jan 2009) | 33 lines
branches/zip: Merge revisions 4032:4035 from branches/5.1
All InnoDB related tests passed on Windows, except
known failure in partition_innodb_semi_consistent.
The inadvertent change to btr0sea.c in this commit is reverted in r4060.
------------------------------------------------------------------------
r4035 | vasil | 2009-01-26 09:26:25 -0600 (Mon, 26 Jan 2009) | 23 lines
branches/5.1:
Merge a change from MySQL:
------------------------------------------------------------
revno: 2646.161.4
committer: Tatiana A. Nurnberg <azundris@mysql.com>
branch nick: 51-31177v2
timestamp: Mon 2009-01-12 06:32:49 +0100
message:
Bug#31177: Server variables can't be set to their current values
Bounds-checks and blocksize corrections were applied to user-input,
but constants in the server were trusted implicitly. If these values
did not actually meet the requirements, the user could not set change
a variable, then set it back to the (wonky) factory default or maximum
by explicitly specifying it (SET <var>=<value> vs SET <var>=DEFAULT).
Now checks also apply to the server's presets. Wonky values and maxima
get corrected at startup. Consequently all non-offsetted values the user
sees are valid, and users can set the variable to that exact value if
they so desire.
------------------------------------------------------------------------
r4060 | marko | 2009-01-29 09:39:04 +0200 (Thu, 29 Jan 2009) | 1 line
branches/zip: btr0sea.c: Revert the inadvertent change made in r4056.
------------------------------------------------------------------------
2009-01-29 09:47:07 +00:00
|
|
|
btr_page_get_index_id(block->frame))) {
|
|
|
|
const page_t* page = block->frame;
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
ok = FALSE;
|
|
|
|
ut_print_timestamp(stderr);
|
|
|
|
|
|
|
|
fprintf(stderr,
|
2006-08-29 09:30:31 +00:00
|
|
|
" InnoDB: Error in an adaptive hash"
|
|
|
|
" index pointer to page %lu\n"
|
|
|
|
"InnoDB: ptr mem address %p"
|
|
|
|
" index id %lu %lu,"
|
|
|
|
" node fold %lu, rec fold %lu\n",
|
2006-10-12 07:02:36 +00:00
|
|
|
(ulong) page_get_page_no(page),
|
2005-10-27 07:29:40 +00:00
|
|
|
node->data,
|
2006-09-19 10:14:07 +00:00
|
|
|
(ulong) ut_dulint_get_high(
|
|
|
|
btr_page_get_index_id(page)),
|
|
|
|
(ulong) ut_dulint_get_low(
|
|
|
|
btr_page_get_index_id(page)),
|
2005-10-27 07:29:40 +00:00
|
|
|
(ulong) node->fold,
|
|
|
|
(ulong) rec_fold((rec_t*)(node->data),
|
2006-08-29 09:30:31 +00:00
|
|
|
offsets,
|
|
|
|
block->curr_n_fields,
|
|
|
|
block->curr_n_bytes,
|
2006-09-19 10:14:07 +00:00
|
|
|
btr_page_get_index_id(
|
|
|
|
page)));
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
fputs("InnoDB: Record ", stderr);
|
|
|
|
rec_print_new(stderr, (rec_t*)node->data,
|
2006-08-29 09:30:31 +00:00
|
|
|
offsets);
|
2005-10-27 07:29:40 +00:00
|
|
|
fprintf(stderr, "\nInnoDB: on that page."
|
2006-08-29 09:30:31 +00:00
|
|
|
" Page mem address %p, is hashed %lu,"
|
|
|
|
" n fields %lu, n bytes %lu\n"
|
|
|
|
"InnoDB: side %lu\n",
|
|
|
|
(void*) page, (ulong) block->is_hashed,
|
|
|
|
(ulong) block->curr_n_fields,
|
|
|
|
(ulong) block->curr_n_bytes,
|
2006-09-19 10:14:07 +00:00
|
|
|
(ulong) block->curr_left_side);
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
if (n_page_dumps < 20) {
|
2006-05-02 11:44:39 +00:00
|
|
|
buf_page_print(page, 0);
|
2005-10-27 07:29:40 +00:00
|
|
|
n_page_dumps++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-17 14:19:39 +00:00
|
|
|
for (i = 0; i < cell_count; i += chunk_size) {
|
|
|
|
ulint end_index = ut_min(i + chunk_size - 1, cell_count - 1);
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2006-02-17 14:19:39 +00:00
|
|
|
/* We release btr_search_latch every once in a while to
|
|
|
|
give other queries a chance to run. */
|
|
|
|
if (i != 0) {
|
2008-01-10 09:37:13 +00:00
|
|
|
buf_pool_mutex_exit();
|
2006-02-17 14:19:39 +00:00
|
|
|
rw_lock_x_unlock(&btr_search_latch);
|
|
|
|
os_thread_yield();
|
|
|
|
rw_lock_x_lock(&btr_search_latch);
|
2008-01-10 09:37:13 +00:00
|
|
|
buf_pool_mutex_enter();
|
2006-02-17 14:19:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!ha_validate(btr_search_sys->hash_index, i, end_index)) {
|
|
|
|
ok = FALSE;
|
|
|
|
}
|
2005-10-27 07:29:40 +00:00
|
|
|
}
|
|
|
|
|
2008-01-10 09:37:13 +00:00
|
|
|
buf_pool_mutex_exit();
|
2005-10-27 07:29:40 +00:00
|
|
|
rw_lock_x_unlock(&btr_search_latch);
|
|
|
|
if (UNIV_LIKELY_NULL(heap)) {
|
|
|
|
mem_heap_free(heap);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(ok);
|
|
|
|
}
|