Commit d967aaa6 authored by marko's avatar marko

branches/zip: Remove const warnings reported by GCC 4.2.1.

page_cur_set_before_first(), page_cur_set_after_last(),
page_cur_position(): Add const qualifiers to buf_block_t and rec.
A better solution would be to define a const_page_cur_t and a
set of accessors, but it would lead to severe code duplication.

page_rec_get_n_recs_before(): Add const qualifiers.

page_dir_get_nth_slot(): Define as a const-preserving macro.

page_dir_slot_get_rec(), page_dir_slot_get_n_owned(),
page_dir_find_owner_slot(), page_check_dir(): Add const qualifiers.

page_rec_get_next_low(): Add const qualifiers.

page_rec_get_next_const(), page_rec_get_prev_const(): New functions,
based on the const-less page_rec_get_next() and page_rec_get_prev().

page_cur_get_page(), page_cur_get_block(), page_cur_get_page_zip(),
page_cur_get_rec(): Define as const-preserving macros.

page_cur_try_search_shortcut(), page_cur_search_with_match():
Add const qualifiers.

buf_page_get_mutex(): Add a const qualifier to buf_page_t*.

rec_get_next_ptr_const(): Const variant of rec_get_next_ptr().
parent 00b1b124
...@@ -1536,7 +1536,7 @@ btr_page_insert_fits( ...@@ -1536,7 +1536,7 @@ btr_page_insert_fits(
return(TRUE); return(TRUE);
} }
rec = page_rec_get_next((rec_t*) rec); rec = page_rec_get_next_const(rec);
} }
return(FALSE); return(FALSE);
......
...@@ -665,8 +665,9 @@ UNIV_INLINE ...@@ -665,8 +665,9 @@ UNIV_INLINE
mutex_t* mutex_t*
buf_page_get_mutex( buf_page_get_mutex(
/*===============*/ /*===============*/
/* out: pointer to mutex protecting bpage */ /* out: pointer to mutex
buf_page_t* bpage) /* in: pointer to control block */ protecting bpage */
const buf_page_t* bpage) /* in: pointer to control block */
__attribute__((pure)); __attribute__((pure));
/************************************************************************* /*************************************************************************
......
...@@ -255,8 +255,9 @@ UNIV_INLINE ...@@ -255,8 +255,9 @@ UNIV_INLINE
mutex_t* mutex_t*
buf_page_get_mutex( buf_page_get_mutex(
/*===============*/ /*===============*/
/* out: pointer to mutex protecting bpage */ /* out: pointer to mutex
buf_page_t* bpage) /* in: pointer to control block */ protecting bpage */
const buf_page_t* bpage) /* in: pointer to control block */
{ {
switch (buf_page_get_state(bpage)) { switch (buf_page_get_state(bpage)) {
case BUF_BLOCK_ZIP_FREE: case BUF_BLOCK_ZIP_FREE:
...@@ -394,7 +395,7 @@ buf_page_can_relocate( ...@@ -394,7 +395,7 @@ buf_page_can_relocate(
const buf_page_t* bpage) /* control block being relocated */ const buf_page_t* bpage) /* control block being relocated */
{ {
ut_ad(mutex_own(&buf_pool->mutex)); ut_ad(mutex_own(&buf_pool->mutex));
ut_ad(mutex_own(buf_page_get_mutex((buf_page_t*) bpage))); ut_ad(mutex_own(buf_page_get_mutex(bpage)));
ut_ad(buf_page_in_file(bpage)); ut_ad(buf_page_in_file(bpage));
ut_ad(bpage->in_LRU_list); ut_ad(bpage->in_LRU_list);
......
...@@ -40,6 +40,7 @@ extern ulint page_cur_short_succ; ...@@ -40,6 +40,7 @@ extern ulint page_cur_short_succ;
# endif /* UNIV_SEARCH_PERF_STAT */ # endif /* UNIV_SEARCH_PERF_STAT */
#endif /* PAGE_CUR_ADAPT */ #endif /* PAGE_CUR_ADAPT */
#ifdef UNIV_DEBUG
/************************************************************* /*************************************************************
Gets pointer to the page frame where the cursor is positioned. */ Gets pointer to the page frame where the cursor is positioned. */
UNIV_INLINE UNIV_INLINE
...@@ -72,6 +73,12 @@ page_cur_get_rec( ...@@ -72,6 +73,12 @@ page_cur_get_rec(
/*=============*/ /*=============*/
/* out: record */ /* out: record */
page_cur_t* cur); /* in: page cursor */ page_cur_t* cur); /* in: page cursor */
#else /* UNIV_DEBUG */
# define page_cur_get_page(cur) page_align((cur)->rec)
# define page_cur_get_block(cur) (cur)->block
# define page_cur_get_page_zip(cur) buf_block_get_page_zip((cur)->block)
# define page_cur_get_rec(cur) (cur)->rec
#endif /* UNIV_DEBUG */
/************************************************************* /*************************************************************
Sets the cursor object to point before the first user record Sets the cursor object to point before the first user record
on the page. */ on the page. */
...@@ -79,8 +86,8 @@ UNIV_INLINE ...@@ -79,8 +86,8 @@ UNIV_INLINE
void void
page_cur_set_before_first( page_cur_set_before_first(
/*======================*/ /*======================*/
buf_block_t* block, /* in: index page */ const buf_block_t* block, /* in: index page */
page_cur_t* cur); /* in: cursor */ page_cur_t* cur); /* in: cursor */
/************************************************************* /*************************************************************
Sets the cursor object to point after the last user record on Sets the cursor object to point after the last user record on
the page. */ the page. */
...@@ -88,8 +95,8 @@ UNIV_INLINE ...@@ -88,8 +95,8 @@ UNIV_INLINE
void void
page_cur_set_after_last( page_cur_set_after_last(
/*====================*/ /*====================*/
buf_block_t* block, /* in: index page */ const buf_block_t* block, /* in: index page */
page_cur_t* cur); /* in: cursor */ page_cur_t* cur); /* in: cursor */
/************************************************************* /*************************************************************
Returns TRUE if the cursor is before first user record on page. */ Returns TRUE if the cursor is before first user record on page. */
UNIV_INLINE UNIV_INLINE
...@@ -112,30 +119,31 @@ UNIV_INLINE ...@@ -112,30 +119,31 @@ UNIV_INLINE
void void
page_cur_position( page_cur_position(
/*==============*/ /*==============*/
rec_t* rec, /* in: record on a page */ const rec_t* rec, /* in: record on a page */
buf_block_t* block, /* in: buffer block containing the record */ const buf_block_t* block, /* in: buffer block containing
page_cur_t* cur); /* out: page cursor */ the record */
page_cur_t* cur); /* out: page cursor */
/************************************************************** /**************************************************************
Invalidates a page cursor by setting the record pointer NULL. */ Invalidates a page cursor by setting the record pointer NULL. */
UNIV_INLINE UNIV_INLINE
void void
page_cur_invalidate( page_cur_invalidate(
/*================*/ /*================*/
page_cur_t* cur); /* in: page cursor */ page_cur_t* cur); /* out: page cursor */
/************************************************************** /**************************************************************
Moves the cursor to the next record on page. */ Moves the cursor to the next record on page. */
UNIV_INLINE UNIV_INLINE
void void
page_cur_move_to_next( page_cur_move_to_next(
/*==================*/ /*==================*/
page_cur_t* cur); /* in: cursor; must not be after last */ page_cur_t* cur); /* in/out: cursor; must not be after last */
/************************************************************** /**************************************************************
Moves the cursor to the previous record on page. */ Moves the cursor to the previous record on page. */
UNIV_INLINE UNIV_INLINE
void void
page_cur_move_to_prev( page_cur_move_to_prev(
/*==================*/ /*==================*/
page_cur_t* cur); /* in: cursor; must not before first */ page_cur_t* cur); /* in/out: cursor; not before first */
/*************************************************************** /***************************************************************
Inserts a record next to page cursor. Returns pointer to inserted record if Inserts a record next to page cursor. Returns pointer to inserted record if
succeed, i.e., enough space available, NULL otherwise. The cursor stays at succeed, i.e., enough space available, NULL otherwise. The cursor stays at
...@@ -243,24 +251,27 @@ Searches the right position for a page cursor. */ ...@@ -243,24 +251,27 @@ Searches the right position for a page cursor. */
void void
page_cur_search_with_match( page_cur_search_with_match(
/*=======================*/ /*=======================*/
buf_block_t* block, /* in: buffer block */ const buf_block_t* block, /* in: buffer block */
dict_index_t* index, /* in: record descriptor */ const dict_index_t* index, /* in: record descriptor */
const dtuple_t* tuple, /* in: data tuple */ const dtuple_t* tuple, /* in: data tuple */
ulint mode, /* in: PAGE_CUR_L, PAGE_CUR_LE, PAGE_CUR_G, ulint mode, /* in: PAGE_CUR_L,
or PAGE_CUR_GE */ PAGE_CUR_LE, PAGE_CUR_G, or
ulint* iup_matched_fields, PAGE_CUR_GE */
/* in/out: already matched fields in upper ulint* iup_matched_fields,
limit record */ /* in/out: already matched
ulint* iup_matched_bytes, fields in upper limit record */
/* in/out: already matched bytes in a field ulint* iup_matched_bytes,
not yet completely matched */ /* in/out: already matched
ulint* ilow_matched_fields, bytes in a field not yet
/* in/out: already matched fields in lower completely matched */
limit record */ ulint* ilow_matched_fields,
ulint* ilow_matched_bytes, /* in/out: already matched
/* in/out: already matched bytes in a field fields in lower limit record */
not yet completely matched */ ulint* ilow_matched_bytes,
page_cur_t* cursor); /* out: page cursor */ /* in/out: already matched
bytes in a field not yet
completely matched */
page_cur_t* cursor);/* out: page cursor */
/*************************************************************** /***************************************************************
Positions a page cursor on a randomly chosen user record on a page. If there Positions a page cursor on a randomly chosen user record on a page. If there
are no user records, sets the cursor on the infimum record. */ are no user records, sets the cursor on the infimum record. */
......
...@@ -9,7 +9,7 @@ Created 10/4/1994 Heikki Tuuri ...@@ -9,7 +9,7 @@ Created 10/4/1994 Heikki Tuuri
#include "page0page.h" #include "page0page.h"
#include "buf0types.h" #include "buf0types.h"
#ifdef UNIV_DEBUG
/************************************************************* /*************************************************************
Gets pointer to the page frame where the cursor is positioned. */ Gets pointer to the page frame where the cursor is positioned. */
UNIV_INLINE UNIV_INLINE
...@@ -64,6 +64,7 @@ page_cur_get_rec( ...@@ -64,6 +64,7 @@ page_cur_get_rec(
return(cur->rec); return(cur->rec);
} }
#endif /* UNIV_DEBUG */
/************************************************************* /*************************************************************
Sets the cursor object to point before the first user record Sets the cursor object to point before the first user record
...@@ -72,11 +73,11 @@ UNIV_INLINE ...@@ -72,11 +73,11 @@ UNIV_INLINE
void void
page_cur_set_before_first( page_cur_set_before_first(
/*======================*/ /*======================*/
buf_block_t* block, /* in: index page */ const buf_block_t* block, /* in: index page */
page_cur_t* cur) /* in: cursor */ page_cur_t* cur) /* in: cursor */
{ {
cur->rec = page_get_infimum_rec(buf_block_get_frame(block)); cur->block = (buf_block_t*) block;
cur->block = block; cur->rec = page_get_infimum_rec(buf_block_get_frame(cur->block));
} }
/************************************************************* /*************************************************************
...@@ -86,11 +87,11 @@ UNIV_INLINE ...@@ -86,11 +87,11 @@ UNIV_INLINE
void void
page_cur_set_after_last( page_cur_set_after_last(
/*====================*/ /*====================*/
buf_block_t* block, /* in: index page */ const buf_block_t* block, /* in: index page */
page_cur_t* cur) /* in: cursor */ page_cur_t* cur) /* in: cursor */
{ {
cur->rec = page_get_supremum_rec(buf_block_get_frame(block)); cur->block = (buf_block_t*) block;
cur->block = block; cur->rec = page_get_supremum_rec(buf_block_get_frame(cur->block));
} }
/************************************************************* /*************************************************************
...@@ -123,15 +124,16 @@ UNIV_INLINE ...@@ -123,15 +124,16 @@ UNIV_INLINE
void void
page_cur_position( page_cur_position(
/*==============*/ /*==============*/
rec_t* rec, /* in: record on a page */ const rec_t* rec, /* in: record on a page */
buf_block_t* block, /* in: buffer block containing the record */ const buf_block_t* block, /* in: buffer block containing
page_cur_t* cur) /* out: page cursor */ the record */
page_cur_t* cur) /* out: page cursor */
{ {
ut_ad(rec && block && cur); ut_ad(rec && block && cur);
ut_ad(page_align(rec) == block->frame); ut_ad(page_align(rec) == block->frame);
cur->rec = rec; cur->rec = (rec_t*) rec;
cur->block = block; cur->block = (buf_block_t*) block;
} }
/************************************************************** /**************************************************************
...@@ -140,7 +142,7 @@ UNIV_INLINE ...@@ -140,7 +142,7 @@ UNIV_INLINE
void void
page_cur_invalidate( page_cur_invalidate(
/*================*/ /*================*/
page_cur_t* cur) /* in: page cursor */ page_cur_t* cur) /* out: page cursor */
{ {
ut_ad(cur); ut_ad(cur);
...@@ -154,7 +156,7 @@ UNIV_INLINE ...@@ -154,7 +156,7 @@ UNIV_INLINE
void void
page_cur_move_to_next( page_cur_move_to_next(
/*==================*/ /*==================*/
page_cur_t* cur) /* in: cursor; must not be after last */ page_cur_t* cur) /* in/out: cursor; must not be after last */
{ {
ut_ad(!page_cur_is_after_last(cur)); ut_ad(!page_cur_is_after_last(cur));
...@@ -167,7 +169,7 @@ UNIV_INLINE ...@@ -167,7 +169,7 @@ UNIV_INLINE
void void
page_cur_move_to_prev( page_cur_move_to_prev(
/*==================*/ /*==================*/
page_cur_t* cur) /* in: page cursor, not before first */ page_cur_t* cur) /* in/out: page cursor, not before first */
{ {
ut_ad(!page_cur_is_before_first(cur)); ut_ad(!page_cur_is_before_first(cur));
......
...@@ -326,8 +326,8 @@ The number includes infimum and supremum records. */ ...@@ -326,8 +326,8 @@ The number includes infimum and supremum records. */
ulint ulint
page_rec_get_n_recs_before( page_rec_get_n_recs_before(
/*=======================*/ /*=======================*/
/* out: number of records */ /* out: number of records */
rec_t* rec); /* in: the physical record */ const rec_t* rec); /* in: the physical record */
/***************************************************************** /*****************************************************************
Gets the number of records in the heap. */ Gets the number of records in the heap. */
UNIV_INLINE UNIV_INLINE
...@@ -367,15 +367,21 @@ page_dir_set_n_slots( ...@@ -367,15 +367,21 @@ page_dir_set_n_slots(
page_zip_des_t* page_zip,/* in/out: compressed page whose page_zip_des_t* page_zip,/* in/out: compressed page whose
uncompressed part will be updated, or NULL */ uncompressed part will be updated, or NULL */
ulint n_slots);/* in: number of slots */ ulint n_slots);/* in: number of slots */
#ifdef UNIV_DEBUG
/***************************************************************** /*****************************************************************
Gets pointer to nth directory slot. */ Gets pointer to nth directory slot. */
UNIV_INLINE UNIV_INLINE
page_dir_slot_t* page_dir_slot_t*
page_dir_get_nth_slot( page_dir_get_nth_slot(
/*==================*/ /*==================*/
/* out: pointer to dir slot */ /* out: pointer to dir slot */
page_t* page, /* in: index page */ const page_t* page, /* in: index page */
ulint n); /* in: position */ ulint n); /* in: position */
#else /* UNIV_DEBUG */
# define page_dir_get_nth_slot(page, n) \
((page) + UNIV_PAGE_SIZE - PAGE_DIR \
- (n + 1) * PAGE_DIR_SLOT_SIZE)
#endif /* UNIV_DEBUG */
/****************************************************************** /******************************************************************
Used to check the consistency of a record on a page. */ Used to check the consistency of a record on a page. */
UNIV_INLINE UNIV_INLINE
...@@ -387,11 +393,11 @@ page_rec_check( ...@@ -387,11 +393,11 @@ page_rec_check(
/******************************************************************* /*******************************************************************
Gets the record pointed to by a directory slot. */ Gets the record pointed to by a directory slot. */
UNIV_INLINE UNIV_INLINE
rec_t* const rec_t*
page_dir_slot_get_rec( page_dir_slot_get_rec(
/*==================*/ /*==================*/
/* out: pointer to record */ /* out: pointer to record */
page_dir_slot_t* slot); /* in: directory slot */ const page_dir_slot_t* slot); /* in: directory slot */
/******************************************************************* /*******************************************************************
This is used to set the record offset in a directory slot. */ This is used to set the record offset in a directory slot. */
UNIV_INLINE UNIV_INLINE
...@@ -407,7 +413,7 @@ ulint ...@@ -407,7 +413,7 @@ ulint
page_dir_slot_get_n_owned( page_dir_slot_get_n_owned(
/*======================*/ /*======================*/
/* out: number of records */ /* out: number of records */
page_dir_slot_t* slot); /* in: page directory slot */ const page_dir_slot_t* slot); /* in: page directory slot */
/******************************************************************* /*******************************************************************
This is used to set the owned records field of a directory slot. */ This is used to set the owned records field of a directory slot. */
UNIV_INLINE UNIV_INLINE
...@@ -434,7 +440,7 @@ ulint ...@@ -434,7 +440,7 @@ ulint
page_dir_find_owner_slot( page_dir_find_owner_slot(
/*=====================*/ /*=====================*/
/* out: the directory slot number */ /* out: the directory slot number */
rec_t* rec); /* in: the physical record */ const rec_t* rec); /* in: the physical record */
/**************************************************************** /****************************************************************
Determine whether the page is in new-style compact format. */ Determine whether the page is in new-style compact format. */
UNIV_INLINE UNIV_INLINE
...@@ -472,12 +478,12 @@ page_is_leaf( ...@@ -472,12 +478,12 @@ page_is_leaf(
/**************************************************************** /****************************************************************
Gets the pointer to the next record on the page. */ Gets the pointer to the next record on the page. */
UNIV_INLINE UNIV_INLINE
rec_t* const rec_t*
page_rec_get_next_low( page_rec_get_next_low(
/*==================*/ /*==================*/
/* out: pointer to next record */ /* out: pointer to next record */
rec_t* rec, /* in: pointer to record */ const rec_t* rec, /* in: pointer to record */
ulint comp); /* in: nonzero=compact page layout */ ulint comp); /* in: nonzero=compact page layout */
/**************************************************************** /****************************************************************
Gets the pointer to the next record on the page. */ Gets the pointer to the next record on the page. */
UNIV_INLINE UNIV_INLINE
...@@ -487,6 +493,14 @@ page_rec_get_next( ...@@ -487,6 +493,14 @@ page_rec_get_next(
/* out: pointer to next record */ /* out: pointer to next record */
rec_t* rec); /* in: pointer to record */ rec_t* rec); /* in: pointer to record */
/**************************************************************** /****************************************************************
Gets the pointer to the next record on the page. */
UNIV_INLINE
const rec_t*
page_rec_get_next_const(
/*====================*/
/* out: pointer to next record */
const rec_t* rec); /* in: pointer to record */
/****************************************************************
Sets the pointer to the next record on the page. */ Sets the pointer to the next record on the page. */
UNIV_INLINE UNIV_INLINE
void void
...@@ -499,6 +513,15 @@ page_rec_set_next( ...@@ -499,6 +513,15 @@ page_rec_set_next(
/**************************************************************** /****************************************************************
Gets the pointer to the previous record. */ Gets the pointer to the previous record. */
UNIV_INLINE UNIV_INLINE
const rec_t*
page_rec_get_prev_const(
/*====================*/
/* out: pointer to previous record */
const rec_t* rec); /* in: pointer to record, must not be page
infimum */
/****************************************************************
Gets the pointer to the previous record. */
UNIV_INLINE
rec_t* rec_t*
page_rec_get_prev( page_rec_get_prev(
/*==============*/ /*==============*/
...@@ -924,7 +947,7 @@ bug fixed in 4.0.14 has caused corruption to users' databases. */ ...@@ -924,7 +947,7 @@ bug fixed in 4.0.14 has caused corruption to users' databases. */
void void
page_check_dir( page_check_dir(
/*===========*/ /*===========*/
page_t* page); /* in: index page */ const page_t* page); /* in: index page */
/******************************************************************* /*******************************************************************
This function checks the consistency of an index page when we do not This function checks the consistency of an index page when we do not
know the index. This is also resilient so that this should never crash know the index. This is also resilient so that this should never crash
......
...@@ -533,21 +533,24 @@ page_dir_set_n_heap( ...@@ -533,21 +533,24 @@ page_dir_set_n_heap(
& page_header_get_field(page, PAGE_N_HEAP))); & page_header_get_field(page, PAGE_N_HEAP)));
} }
#ifdef UNIV_DEBUG
/***************************************************************** /*****************************************************************
Gets pointer to nth directory slot. */ Gets pointer to nth directory slot. */
UNIV_INLINE UNIV_INLINE
page_dir_slot_t* page_dir_slot_t*
page_dir_get_nth_slot( page_dir_get_nth_slot(
/*==================*/ /*==================*/
/* out: pointer to dir slot */ /* out: pointer to dir slot */
page_t* page, /* in: index page */ const page_t* page, /* in: index page */
ulint n) /* in: position */ ulint n) /* in: position */
{ {
ut_ad(page_dir_get_n_slots(page) > n); ut_ad(page_dir_get_n_slots(page) > n);
return(page + UNIV_PAGE_SIZE - PAGE_DIR return((page_dir_slot_t*)
page + UNIV_PAGE_SIZE - PAGE_DIR
- (n + 1) * PAGE_DIR_SLOT_SIZE); - (n + 1) * PAGE_DIR_SLOT_SIZE);
} }
#endif /* UNIV_DEBUG */
/****************************************************************** /******************************************************************
Used to check the consistency of a record on a page. */ Used to check the consistency of a record on a page. */
...@@ -571,11 +574,11 @@ page_rec_check( ...@@ -571,11 +574,11 @@ page_rec_check(
/******************************************************************* /*******************************************************************
Gets the record pointed to by a directory slot. */ Gets the record pointed to by a directory slot. */
UNIV_INLINE UNIV_INLINE
rec_t* const rec_t*
page_dir_slot_get_rec( page_dir_slot_get_rec(
/*==================*/ /*==================*/
/* out: pointer to record */ /* out: pointer to record */
page_dir_slot_t* slot) /* in: directory slot */ const page_dir_slot_t* slot) /* in: directory slot */
{ {
return(page_align(slot) + mach_read_from_2(slot)); return(page_align(slot) + mach_read_from_2(slot));
} }
...@@ -601,9 +604,9 @@ ulint ...@@ -601,9 +604,9 @@ ulint
page_dir_slot_get_n_owned( page_dir_slot_get_n_owned(
/*======================*/ /*======================*/
/* out: number of records */ /* out: number of records */
page_dir_slot_t* slot) /* in: page directory slot */ const page_dir_slot_t* slot) /* in: page directory slot */
{ {
rec_t* rec = page_dir_slot_get_rec(slot); const rec_t* rec = page_dir_slot_get_rec(slot);
if (page_rec_is_comp(slot)) { if (page_rec_is_comp(slot)) {
return(rec_get_n_owned_new(rec)); return(rec_get_n_owned_new(rec));
} else { } else {
...@@ -621,7 +624,7 @@ page_dir_slot_set_n_owned( ...@@ -621,7 +624,7 @@ page_dir_slot_set_n_owned(
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */ page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
ulint n) /* in: number of records owned by the slot */ ulint n) /* in: number of records owned by the slot */
{ {
rec_t* rec = page_dir_slot_get_rec(slot); rec_t* rec = (rec_t*) page_dir_slot_get_rec(slot);
if (page_rec_is_comp(slot)) { if (page_rec_is_comp(slot)) {
rec_set_n_owned_new(rec, page_zip, n); rec_set_n_owned_new(rec, page_zip, n);
} else { } else {
...@@ -647,15 +650,15 @@ page_dir_calc_reserved_space( ...@@ -647,15 +650,15 @@ page_dir_calc_reserved_space(
/**************************************************************** /****************************************************************
Gets the pointer to the next record on the page. */ Gets the pointer to the next record on the page. */
UNIV_INLINE UNIV_INLINE
rec_t* const rec_t*
page_rec_get_next_low( page_rec_get_next_low(
/*==================*/ /*==================*/
/* out: pointer to next record */ /* out: pointer to next record */
rec_t* rec, /* in: pointer to record */ const rec_t* rec, /* in: pointer to record */
ulint comp) /* in: nonzero=compact page layout */ ulint comp) /* in: nonzero=compact page layout */
{ {
ulint offs; ulint offs;
page_t* page; const page_t* page;
ut_ad(page_rec_check(rec)); ut_ad(page_rec_check(rec));
...@@ -693,9 +696,22 @@ page_rec_get_next( ...@@ -693,9 +696,22 @@ page_rec_get_next(
/*==============*/ /*==============*/
/* out: pointer to next record */ /* out: pointer to next record */
rec_t* rec) /* in: pointer to record */ rec_t* rec) /* in: pointer to record */
{
return((rec_t*) page_rec_get_next_low(rec, page_rec_is_comp(rec)));
}
/****************************************************************
Gets the pointer to the next record on the page. */
UNIV_INLINE
const rec_t*
page_rec_get_next_const(
/*====================*/
/* out: pointer to next record */
const rec_t* rec) /* in: pointer to record */
{ {
return(page_rec_get_next_low(rec, page_rec_is_comp(rec))); return(page_rec_get_next_low(rec, page_rec_is_comp(rec)));
} }
/**************************************************************** /****************************************************************
Sets the pointer to the next record on the page. */ Sets the pointer to the next record on the page. */
UNIV_INLINE UNIV_INLINE
...@@ -732,18 +748,18 @@ page_rec_set_next( ...@@ -732,18 +748,18 @@ page_rec_set_next(
/**************************************************************** /****************************************************************
Gets the pointer to the previous record. */ Gets the pointer to the previous record. */
UNIV_INLINE UNIV_INLINE
rec_t* const rec_t*
page_rec_get_prev( page_rec_get_prev_const(
/*==============*/ /*====================*/
/* out: pointer to previous record */ /* out: pointer to previous record */
rec_t* rec) /* in: pointer to record, must not be page const rec_t* rec) /* in: pointer to record, must not be page
infimum */ infimum */
{ {
page_dir_slot_t* slot; const page_dir_slot_t* slot;
ulint slot_no; ulint slot_no;
rec_t* rec2; const rec_t* rec2;
rec_t* prev_rec = NULL; const rec_t* prev_rec = NULL;
page_t* page; const page_t* page;
ut_ad(page_rec_check(rec)); ut_ad(page_rec_check(rec));
...@@ -776,6 +792,19 @@ page_rec_get_prev( ...@@ -776,6 +792,19 @@ page_rec_get_prev(
return(prev_rec); return(prev_rec);
} }
/****************************************************************
Gets the pointer to the previous record. */
UNIV_INLINE
rec_t*
page_rec_get_prev(
/*==============*/
/* out: pointer to previous record */
rec_t* rec) /* in: pointer to record, must not be page
infimum */
{
return((rec_t*) page_rec_get_prev_const(rec));
}
/******************************************************************* /*******************************************************************
Looks for the record which owns the given record. */ Looks for the record which owns the given record. */
UNIV_INLINE UNIV_INLINE
......
...@@ -62,6 +62,17 @@ offsets[] array, first passed to rec_get_offsets() */ ...@@ -62,6 +62,17 @@ offsets[] array, first passed to rec_get_offsets() */
#define REC_OFFS_NORMAL_SIZE 100 #define REC_OFFS_NORMAL_SIZE 100
#define REC_OFFS_SMALL_SIZE 10 #define REC_OFFS_SMALL_SIZE 10
/**********************************************************
The following function is used to get the pointer of the next chained record
on the same page. */
UNIV_INLINE
const rec_t*
rec_get_next_ptr_const(
/*===================*/
/* out: pointer to the next chained record, or
NULL if none */
const rec_t* rec, /* in: physical record */
ulint comp); /* in: nonzero=compact page format */
/********************************************************** /**********************************************************
The following function is used to get the pointer of the next chained record The following function is used to get the pointer of the next chained record
on the same page. */ on the same page. */
......
...@@ -232,13 +232,13 @@ rec_set_bit_field_2( ...@@ -232,13 +232,13 @@ rec_set_bit_field_2(
The following function is used to get the pointer of the next chained record The following function is used to get the pointer of the next chained record
on the same page. */ on the same page. */
UNIV_INLINE UNIV_INLINE
rec_t* const rec_t*
rec_get_next_ptr( rec_get_next_ptr_const(
/*=============*/ /*===================*/
/* out: pointer to the next chained record, or /* out: pointer to the next chained record, or
NULL if none */ NULL if none */
rec_t* rec, /* in: physical record */ const rec_t* rec, /* in: physical record */
ulint comp) /* in: nonzero=compact page format */ ulint comp) /* in: nonzero=compact page format */
{ {
ulint field_value; ulint field_value;
...@@ -285,6 +285,21 @@ rec_get_next_ptr( ...@@ -285,6 +285,21 @@ rec_get_next_ptr(
} }
} }
/**********************************************************
The following function is used to get the pointer of the next chained record
on the same page. */
UNIV_INLINE
rec_t*
rec_get_next_ptr(
/*=============*/
/* out: pointer to the next chained record, or
NULL if none */
rec_t* rec, /* in: physical record */
ulint comp) /* in: nonzero=compact page format */
{
return((rec_t*) rec_get_next_ptr_const(rec, comp));
}
/********************************************************** /**********************************************************
The following function is used to get the offset of the next chained record The following function is used to get the offset of the next chained record
on the same page. */ on the same page. */
......
...@@ -2578,8 +2578,8 @@ lock_move_reorganize_page( ...@@ -2578,8 +2578,8 @@ lock_move_reorganize_page(
page_cur_t cur1; page_cur_t cur1;
page_cur_t cur2; page_cur_t cur2;
page_cur_set_before_first((buf_block_t*) block, &cur1); page_cur_set_before_first(block, &cur1);
page_cur_set_before_first((buf_block_t*) oblock, &cur2); page_cur_set_before_first(oblock, &cur2);
/* Set locks according to old locks */ /* Set locks according to old locks */
for (;;) { for (;;) {
...@@ -2690,13 +2690,13 @@ lock_move_rec_list_end( ...@@ -2690,13 +2690,13 @@ lock_move_rec_list_end(
page_cur_t cur2; page_cur_t cur2;
const ulint type_mode = lock->type_mode; const ulint type_mode = lock->type_mode;
page_cur_position((rec_t*) rec, (buf_block_t*) block, &cur1); page_cur_position(rec, block, &cur1);
if (page_cur_is_before_first(&cur1)) { if (page_cur_is_before_first(&cur1)) {
page_cur_move_to_next(&cur1); page_cur_move_to_next(&cur1);
} }
page_cur_set_before_first((buf_block_t*) new_block, &cur2); page_cur_set_before_first(new_block, &cur2);
page_cur_move_to_next(&cur2); page_cur_move_to_next(&cur2);
/* Copy lock requests on user records to new page and /* Copy lock requests on user records to new page and
...@@ -2785,11 +2785,10 @@ lock_move_rec_list_start( ...@@ -2785,11 +2785,10 @@ lock_move_rec_list_start(
page_cur_t cur2; page_cur_t cur2;
const ulint type_mode = lock->type_mode; const ulint type_mode = lock->type_mode;
page_cur_set_before_first((buf_block_t*) block, &cur1); page_cur_set_before_first(block, &cur1);
page_cur_move_to_next(&cur1); page_cur_move_to_next(&cur1);
page_cur_position((rec_t*) old_end, (buf_block_t*) new_block, page_cur_position(old_end, new_block, &cur2);
&cur2);
page_cur_move_to_next(&cur2); page_cur_move_to_next(&cur2);
/* Copy lock requests on user records to new page and /* Copy lock requests on user records to new page and
...@@ -3018,7 +3017,7 @@ lock_update_merge_left( ...@@ -3018,7 +3017,7 @@ lock_update_merge_left(
lock_mutex_enter_kernel(); lock_mutex_enter_kernel();
left_next_rec = page_rec_get_next((rec_t*) orig_pred); left_next_rec = page_rec_get_next_const(orig_pred);
if (!page_rec_is_supremum(left_next_rec)) { if (!page_rec_is_supremum(left_next_rec)) {
...@@ -3157,11 +3156,11 @@ lock_update_insert( ...@@ -3157,11 +3156,11 @@ lock_update_insert(
if (page_rec_is_comp(rec)) { if (page_rec_is_comp(rec)) {
receiver_heap_no = rec_get_heap_no_new(rec); receiver_heap_no = rec_get_heap_no_new(rec);
donator_heap_no = rec_get_heap_no_new( donator_heap_no = rec_get_heap_no_new(
page_rec_get_next_low((rec_t*) rec, TRUE)); page_rec_get_next_low(rec, TRUE));
} else { } else {
receiver_heap_no = rec_get_heap_no_old(rec); receiver_heap_no = rec_get_heap_no_old(rec);
donator_heap_no = rec_get_heap_no_old( donator_heap_no = rec_get_heap_no_old(
page_rec_get_next_low((rec_t*) rec, FALSE)); page_rec_get_next_low(rec, FALSE));
} }
lock_mutex_enter_kernel(); lock_mutex_enter_kernel();
......
...@@ -30,25 +30,27 @@ UNIV_INLINE ...@@ -30,25 +30,27 @@ UNIV_INLINE
ibool ibool
page_cur_try_search_shortcut( page_cur_try_search_shortcut(
/*=========================*/ /*=========================*/
/* out: TRUE on success */ /* out: TRUE on success */
buf_block_t* block, /* in: index page */ const buf_block_t* block, /* in: index page */
dict_index_t* index, /* in: record descriptor */ const dict_index_t* index, /* in: record descriptor */
const dtuple_t* tuple, /* in: data tuple */ const dtuple_t* tuple, /* in: data tuple */
ulint* iup_matched_fields, ulint* iup_matched_fields,
/* in/out: already matched fields in upper /* in/out: already matched
limit record */ fields in upper limit record */
ulint* iup_matched_bytes, ulint* iup_matched_bytes,
/* in/out: already matched bytes in a field /* in/out: already matched
not yet completely matched */ bytes in a field not yet
ulint* ilow_matched_fields, completely matched */
/* in/out: already matched fields in lower ulint* ilow_matched_fields,
limit record */ /* in/out: already matched
ulint* ilow_matched_bytes, fields in lower limit record */
/* in/out: already matched bytes in a field ulint* ilow_matched_bytes,
not yet completely matched */ /* in/out: already matched
page_cur_t* cursor) /* out: page cursor */ bytes in a field not yet
completely matched */
page_cur_t* cursor) /* out: page cursor */
{ {
rec_t* rec; const rec_t* rec;
const rec_t* next_rec; const rec_t* next_rec;
ulint low_match; ulint low_match;
ulint low_bytes; ulint low_bytes;
...@@ -58,7 +60,7 @@ page_cur_try_search_shortcut( ...@@ -58,7 +60,7 @@ page_cur_try_search_shortcut(
page_cur_t cursor2; page_cur_t cursor2;
#endif #endif
ibool success = FALSE; ibool success = FALSE;
page_t* page = buf_block_get_frame(block); const page_t* page = buf_block_get_frame(block);
mem_heap_t* heap = NULL; mem_heap_t* heap = NULL;
ulint offsets_[REC_OFFS_NORMAL_SIZE]; ulint offsets_[REC_OFFS_NORMAL_SIZE];
ulint* offsets = offsets_; ulint* offsets = offsets_;
...@@ -85,7 +87,7 @@ page_cur_try_search_shortcut( ...@@ -85,7 +87,7 @@ page_cur_try_search_shortcut(
goto exit_func; goto exit_func;
} }
next_rec = page_rec_get_next(rec); next_rec = page_rec_get_next_const(rec);
offsets = rec_get_offsets(next_rec, index, offsets, offsets = rec_get_offsets(next_rec, index, offsets,
dtuple_get_n_fields(tuple), &heap); dtuple_get_n_fields(tuple), &heap);
...@@ -194,45 +196,51 @@ Searches the right position for a page cursor. */ ...@@ -194,45 +196,51 @@ Searches the right position for a page cursor. */
void void
page_cur_search_with_match( page_cur_search_with_match(
/*=======================*/ /*=======================*/
buf_block_t* block, /* in: buffer block */ const buf_block_t* block, /* in: buffer block */
dict_index_t* index, /* in: record descriptor */ const dict_index_t* index, /* in: record descriptor */
const dtuple_t* tuple, /* in: data tuple */ const dtuple_t* tuple, /* in: data tuple */
ulint mode, /* in: PAGE_CUR_L, PAGE_CUR_LE, PAGE_CUR_G, ulint mode, /* in: PAGE_CUR_L,
or PAGE_CUR_GE */ PAGE_CUR_LE, PAGE_CUR_G, or
ulint* iup_matched_fields, PAGE_CUR_GE */
/* in/out: already matched fields in upper ulint* iup_matched_fields,
limit record */ /* in/out: already matched
ulint* iup_matched_bytes, fields in upper limit record */
/* in/out: already matched bytes in a field ulint* iup_matched_bytes,
not yet completely matched */ /* in/out: already matched
ulint* ilow_matched_fields, bytes in a field not yet
/* in/out: already matched fields in lower completely matched */
limit record */ ulint* ilow_matched_fields,
ulint* ilow_matched_bytes, /* in/out: already matched
/* in/out: already matched bytes in a field fields in lower limit record */
not yet completely matched */ ulint* ilow_matched_bytes,
page_cur_t* cursor) /* out: page cursor */ /* in/out: already matched
bytes in a field not yet
completely matched */
page_cur_t* cursor) /* out: page cursor */
{ {
ulint up; ulint up;
ulint low; ulint low;
ulint mid; ulint mid;
page_t* page; const page_t* page;
page_dir_slot_t* slot; const page_dir_slot_t* slot;
rec_t* up_rec; const rec_t* up_rec;
rec_t* low_rec; const rec_t* low_rec;
rec_t* mid_rec; const rec_t* mid_rec;
ulint up_matched_fields; ulint up_matched_fields;
ulint up_matched_bytes; ulint up_matched_bytes;
ulint low_matched_fields; ulint low_matched_fields;
ulint low_matched_bytes; ulint low_matched_bytes;
ulint cur_matched_fields; ulint cur_matched_fields;
ulint cur_matched_bytes; ulint cur_matched_bytes;
int cmp; int cmp;
#ifdef UNIV_SEARCH_DEBUG #ifdef UNIV_SEARCH_DEBUG
int dbg_cmp; int dbg_cmp;
ulint dbg_matched_fields; ulint dbg_matched_fields;
ulint dbg_matched_bytes; ulint dbg_matched_bytes;
#endif #endif
#ifdef UNIV_ZIP_DEBUG
const page_zip_des_t* page_zip = buf_block_get_page_zip(block);
#endif /* UNIV_ZIP_DEBUG */
mem_heap_t* heap = NULL; mem_heap_t* heap = NULL;
ulint offsets_[REC_OFFS_NORMAL_SIZE]; ulint offsets_[REC_OFFS_NORMAL_SIZE];
ulint* offsets = offsets_; ulint* offsets = offsets_;
...@@ -253,7 +261,6 @@ page_cur_search_with_match( ...@@ -253,7 +261,6 @@ page_cur_search_with_match(
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
page = buf_block_get_frame(block); page = buf_block_get_frame(block);
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
page_zip_des_t* page_zip = buf_block_get_page_zip(block);
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip || page_zip_validate(page_zip, page));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
...@@ -366,9 +373,9 @@ page_cur_search_with_match( ...@@ -366,9 +373,9 @@ page_cur_search_with_match(
/* Perform linear search until the upper and lower records come to /* Perform linear search until the upper and lower records come to
distance 1 of each other. */ distance 1 of each other. */
while (page_rec_get_next(low_rec) != up_rec) { while (page_rec_get_next_const(low_rec) != up_rec) {
mid_rec = page_rec_get_next(low_rec); mid_rec = page_rec_get_next_const(low_rec);
ut_pair_min(&cur_matched_fields, &cur_matched_bytes, ut_pair_min(&cur_matched_fields, &cur_matched_bytes,
low_matched_fields, low_matched_bytes, low_matched_fields, low_matched_bytes,
...@@ -436,7 +443,7 @@ page_cur_search_with_match( ...@@ -436,7 +443,7 @@ page_cur_search_with_match(
ut_a(dbg_cmp >= 0); ut_a(dbg_cmp >= 0);
} }
if (low_rec != page_get_infimum_rec(page)) { if (!page_rec_is_infimum(low_rec)) {
ut_a(low_matched_fields == dbg_matched_fields); ut_a(low_matched_fields == dbg_matched_fields);
ut_a(low_matched_bytes == dbg_matched_bytes); ut_a(low_matched_bytes == dbg_matched_bytes);
...@@ -460,7 +467,7 @@ page_cur_search_with_match( ...@@ -460,7 +467,7 @@ page_cur_search_with_match(
ut_a(dbg_cmp == -1); ut_a(dbg_cmp == -1);
} }
if (up_rec != page_get_supremum_rec(page)) { if (!page_rec_is_supremum(up_rec)) {
ut_a(up_matched_fields == dbg_matched_fields); ut_a(up_matched_fields == dbg_matched_fields);
ut_a(up_matched_bytes == dbg_matched_bytes); ut_a(up_matched_bytes == dbg_matched_bytes);
...@@ -1791,7 +1798,7 @@ page_cur_delete_rec( ...@@ -1791,7 +1798,7 @@ page_cur_delete_rec(
ut_ad(cur_slot_no > 0); ut_ad(cur_slot_no > 0);
prev_slot = page_dir_get_nth_slot(page, cur_slot_no - 1); prev_slot = page_dir_get_nth_slot(page, cur_slot_no - 1);
rec = page_dir_slot_get_rec(prev_slot); rec = (rec_t*) page_dir_slot_get_rec(prev_slot);
/* rec now points to the record of the previous directory slot. Look /* rec now points to the record of the previous directory slot. Look
for the immediate predecessor of current_rec in a loop. */ for the immediate predecessor of current_rec in a loop. */
......
...@@ -70,14 +70,14 @@ Looks for the directory slot which owns the given record. */ ...@@ -70,14 +70,14 @@ Looks for the directory slot which owns the given record. */
ulint ulint
page_dir_find_owner_slot( page_dir_find_owner_slot(
/*=====================*/ /*=====================*/
/* out: the directory slot number */ /* out: the directory slot number */
rec_t* rec) /* in: the physical record */ const rec_t* rec) /* in: the physical record */
{ {
page_t* page; const page_t* page;
register uint16 rec_offs_bytes; register uint16 rec_offs_bytes;
register page_dir_slot_t* slot; register const page_dir_slot_t* slot;
register const page_dir_slot_t* first_slot; register const page_dir_slot_t* first_slot;
register rec_t* r = rec; register const rec_t* r = rec;
ut_ad(page_rec_check(rec)); ut_ad(page_rec_check(rec));
...@@ -87,13 +87,13 @@ page_dir_find_owner_slot( ...@@ -87,13 +87,13 @@ page_dir_find_owner_slot(
if (page_is_comp(page)) { if (page_is_comp(page)) {
while (rec_get_n_owned_new(r) == 0) { while (rec_get_n_owned_new(r) == 0) {
r = rec_get_next_ptr(r, TRUE); r = rec_get_next_ptr_const(r, TRUE);
ut_ad(r >= page + PAGE_NEW_SUPREMUM); ut_ad(r >= page + PAGE_NEW_SUPREMUM);
ut_ad(r < page + (UNIV_PAGE_SIZE - PAGE_DIR)); ut_ad(r < page + (UNIV_PAGE_SIZE - PAGE_DIR));
} }
} else { } else {
while (rec_get_n_owned_old(r) == 0) { while (rec_get_n_owned_old(r) == 0) {
r = rec_get_next_ptr(r, FALSE); r = rec_get_next_ptr_const(r, FALSE);
ut_ad(r >= page + PAGE_OLD_SUPREMUM); ut_ad(r >= page + PAGE_OLD_SUPREMUM);
ut_ad(r < page + (UNIV_PAGE_SIZE - PAGE_DIR)); ut_ad(r < page + (UNIV_PAGE_SIZE - PAGE_DIR));
} }
...@@ -1220,8 +1220,8 @@ page_dir_delete_slot( ...@@ -1220,8 +1220,8 @@ page_dir_delete_slot(
/* 3. Destroy the slot by copying slots */ /* 3. Destroy the slot by copying slots */
for (i = slot_no + 1; i < n_slots; i++) { for (i = slot_no + 1; i < n_slots; i++) {
rec_t* rec; rec_t* rec = (rec_t*)
rec = page_dir_slot_get_rec(page_dir_get_nth_slot(page, i)); page_dir_slot_get_rec(page_dir_get_nth_slot(page, i));
page_dir_slot_set_rec(page_dir_get_nth_slot(page, i - 1), rec); page_dir_slot_set_rec(page_dir_get_nth_slot(page, i - 1), rec);
} }
...@@ -1292,7 +1292,7 @@ page_dir_split_slot( ...@@ -1292,7 +1292,7 @@ page_dir_split_slot(
records owned by the slot. */ records owned by the slot. */
prev_slot = page_dir_get_nth_slot(page, slot_no - 1); prev_slot = page_dir_get_nth_slot(page, slot_no - 1);
rec = page_dir_slot_get_rec(prev_slot); rec = (rec_t*) page_dir_slot_get_rec(prev_slot);
for (i = 0; i < n_owned / 2; i++) { for (i = 0; i < n_owned / 2; i++) {
rec = page_rec_get_next(rec); rec = page_rec_get_next(rec);
...@@ -1370,7 +1370,7 @@ page_dir_balance_slot( ...@@ -1370,7 +1370,7 @@ page_dir_balance_slot(
/* In this case we can just transfer one record owned /* In this case we can just transfer one record owned
by the upper slot to the property of the lower slot */ by the upper slot to the property of the lower slot */
old_rec = page_dir_slot_get_rec(slot); old_rec = (rec_t*) page_dir_slot_get_rec(slot);
if (page_is_comp(page)) { if (page_is_comp(page)) {
new_rec = rec_get_next_ptr(old_rec, TRUE); new_rec = rec_get_next_ptr(old_rec, TRUE);
...@@ -1429,7 +1429,7 @@ page_get_middle_rec( ...@@ -1429,7 +1429,7 @@ page_get_middle_rec(
ut_ad(i > 0); ut_ad(i > 0);
slot = page_dir_get_nth_slot(page, i - 1); slot = page_dir_get_nth_slot(page, i - 1);
rec = page_dir_slot_get_rec(slot); rec = (rec_t*) page_dir_slot_get_rec(slot);
rec = page_rec_get_next(rec); rec = page_rec_get_next(rec);
/* There are now count records behind rec */ /* There are now count records behind rec */
...@@ -1448,12 +1448,12 @@ The number includes infimum and supremum records. */ ...@@ -1448,12 +1448,12 @@ The number includes infimum and supremum records. */
ulint ulint
page_rec_get_n_recs_before( page_rec_get_n_recs_before(
/*=======================*/ /*=======================*/
/* out: number of records */ /* out: number of records */
rec_t* rec) /* in: the physical record */ const rec_t* rec) /* in: the physical record */
{ {
page_dir_slot_t* slot; const page_dir_slot_t* slot;
rec_t* slot_rec; const rec_t* slot_rec;
page_t* page; const page_t* page;
ulint i; ulint i;
lint n = 0; lint n = 0;
...@@ -1463,7 +1463,7 @@ page_rec_get_n_recs_before( ...@@ -1463,7 +1463,7 @@ page_rec_get_n_recs_before(
if (page_is_comp(page)) { if (page_is_comp(page)) {
while (rec_get_n_owned_new(rec) == 0) { while (rec_get_n_owned_new(rec) == 0) {
rec = rec_get_next_ptr(rec, TRUE); rec = rec_get_next_ptr_const(rec, TRUE);
n--; n--;
} }
...@@ -1481,7 +1481,7 @@ page_rec_get_n_recs_before( ...@@ -1481,7 +1481,7 @@ page_rec_get_n_recs_before(
} else { } else {
while (rec_get_n_owned_old(rec) == 0) { while (rec_get_n_owned_old(rec) == 0) {
rec = rec_get_next_ptr(rec, FALSE); rec = rec_get_next_ptr_const(rec, FALSE);
n--; n--;
} }
...@@ -1752,14 +1752,18 @@ bug fixed in 4.0.14 has caused corruption to users' databases. */ ...@@ -1752,14 +1752,18 @@ bug fixed in 4.0.14 has caused corruption to users' databases. */
void void
page_check_dir( page_check_dir(
/*===========*/ /*===========*/
page_t* page) /* in: index page */ const page_t* page) /* in: index page */
{ {
ulint n_slots; ulint n_slots;
ulint infimum_offs;
ulint supremum_offs;
n_slots = page_dir_get_n_slots(page); n_slots = page_dir_get_n_slots(page);
infimum_offs = mach_read_from_2(page_dir_get_nth_slot(page, 0));
supremum_offs = mach_read_from_2(page_dir_get_nth_slot(page,
n_slots - 1));
if (UNIV_UNLIKELY(page_dir_slot_get_rec(page_dir_get_nth_slot(page, 0)) if (UNIV_UNLIKELY(!page_rec_is_infimum_low(infimum_offs))) {
!= page_get_infimum_rec(page))) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Page directory corruption:" "InnoDB: Page directory corruption:"
...@@ -1767,9 +1771,7 @@ page_check_dir( ...@@ -1767,9 +1771,7 @@ page_check_dir(
buf_page_print(page, 0); buf_page_print(page, 0);
} }
if (UNIV_UNLIKELY if (UNIV_UNLIKELY(!page_rec_is_supremum_low(supremum_offs))) {
(page_dir_slot_get_rec(page_dir_get_nth_slot(page, n_slots - 1))
!= page_get_supremum_rec(page))) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Page directory corruption:" "InnoDB: Page directory corruption:"
......
...@@ -711,7 +711,7 @@ row_ins_foreign_report_add_err( ...@@ -711,7 +711,7 @@ row_ins_foreign_report_add_err(
/* If the cursor ended on a supremum record, it is better /* If the cursor ended on a supremum record, it is better
to report the previous record in the error message, so that to report the previous record in the error message, so that
the user gets a more descriptive error message. */ the user gets a more descriptive error message. */
rec = page_rec_get_prev((rec_t*) rec); rec = page_rec_get_prev_const(rec);
} }
if (rec) { if (rec) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment