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