Commit b6e26f24 authored by marko's avatar marko

branches/zip: Remove some more buf_block_align() calls.

btr_cur_t: Move page_block to page_cur_t::block.

page_cur_get_block(), page_cur_get_page_zip(): New functions.

page_cur_position(): Add parameter block.

Remove many page_zip parameters, now that there is page_cur_get_page_zip().
Replace some page, page_zip parameters with block.

Add some const qualifiers to function parameters and remove casts.

PAGE_HEAP_NO_INFIMUM, PAGE_HEAP_NO_SUPREMUM, PAGE_HEAP_NO_USER_LOW:
New constants.

Replace some cursor code in low-level diagnostic functions with
direct management of rec, because buf_block_t::buf_fix_count may be 0
when the functions are called, and debug assertions would fail.
parent bb9b1b0c
This diff is collapsed.
......@@ -539,8 +539,7 @@ btr_cur_search_to_nth_level(
page_mode = mode;
}
cursor->page_block = block;
page_cur_search_with_match(page, index, tuple, page_mode,
page_cur_search_with_match(block, index, tuple, page_mode,
&up_match, &up_bytes,
&low_match, &low_bytes,
page_cursor);
......@@ -685,7 +684,6 @@ btr_cur_open_at_index_side(
btr_page_get_index_id(page)));
block->check_index_page_at_flush = TRUE;
cursor->page_block = block;
if (height == ULINT_UNDEFINED) {
/* We are in the root node */
......@@ -715,11 +713,10 @@ btr_cur_open_at_index_side(
}
}
ut_ad(buf_block_get_frame(cursor->page_block) == page);
if (from_left) {
page_cur_set_before_first(page, page_cursor);
page_cur_set_before_first(block, page_cursor);
} else {
page_cur_set_after_last(page, page_cursor);
page_cur_set_after_last(block, page_cursor);
}
if (height == 0) {
......@@ -815,8 +812,7 @@ btr_cur_open_at_rnd_pos(
latch_mode, cursor, mtr);
}
cursor->page_block = block;
page_cur_open_on_rnd_user_rec(page, page_cursor);
page_cur_open_on_rnd_user_rec(block, page_cursor);
if (height == 0) {
......@@ -854,7 +850,6 @@ btr_cur_insert_if_possible(
else NULL */
btr_cur_t* cursor, /* in: cursor on page after which to insert;
cursor stays valid */
page_zip_des_t* page_zip,/* in: compressed page of cursor */
const dtuple_t* tuple, /* in: tuple to insert; the size info need not
have been stored to tuple */
const ulint* ext, /* in: array of extern field numbers */
......@@ -873,20 +868,19 @@ btr_cur_insert_if_possible(
page_cursor = btr_cur_get_page_cur(cursor);
/* Now, try the insert */
rec = page_cur_tuple_insert(page_cursor, page_zip,
tuple, cursor->index, ext, n_ext, mtr);
rec = page_cur_tuple_insert(page_cursor, tuple,
cursor->index, ext, n_ext, mtr);
if (UNIV_UNLIKELY(!rec)) {
/* If record did not fit, reorganize */
if (btr_page_reorganize(block, cursor->index, mtr)) {
page_cur_search(buf_block_get_frame(block),
cursor->index, tuple,
page_cur_search(block, cursor->index, tuple,
PAGE_CUR_LE, page_cursor);
rec = page_cur_tuple_insert(page_cursor, page_zip,
tuple, cursor->index,
rec = page_cur_tuple_insert(page_cursor, tuple,
cursor->index,
ext, n_ext, mtr);
}
}
......@@ -1146,8 +1140,8 @@ btr_cur_optimistic_insert(
/* Now, try the insert */
*rec = page_cur_tuple_insert(page_cursor, page_zip,
entry, index, ext, n_ext, mtr);
*rec = page_cur_tuple_insert(page_cursor, entry, index,
ext, n_ext, mtr);
if (UNIV_UNLIKELY(!(*rec))) {
/* If the record did not fit, reorganize */
if (UNIV_UNLIKELY(!btr_page_reorganize(block, index, mtr))) {
......@@ -1160,10 +1154,10 @@ btr_cur_optimistic_insert(
reorg = TRUE;
page_cur_search(page, index, entry, PAGE_CUR_LE, page_cursor);
page_cur_search(block, index, entry, PAGE_CUR_LE, page_cursor);
*rec = page_cur_tuple_insert(page_cursor, page_zip,
entry, index, ext, n_ext, mtr);
*rec = page_cur_tuple_insert(page_cursor, entry, index,
ext, n_ext, mtr);
if (UNIV_UNLIKELY(!*rec)) {
if (UNIV_LIKELY(page_zip != NULL)) {
......@@ -1353,11 +1347,11 @@ btr_cur_pessimistic_insert(
rec_t* temp_rec;
page_cur_position(temp_page + PAGE_NEW_INFIMUM,
&temp_cursor);
temp_block, &temp_cursor);
temp_rec = page_cur_tuple_insert(
&temp_cursor, &temp_block->page_zip,
entry, index, ext, n_ext, NULL);
temp_rec = page_cur_tuple_insert(&temp_cursor,
entry, index,
ext, n_ext, NULL);
buf_block_free(temp_block);
if (UNIV_UNLIKELY(!temp_rec)) {
......@@ -1883,7 +1877,7 @@ btr_cur_optimistic_update(
btr_search_update_hash_on_delete(cursor);
page_cur_delete_rec(page_cursor, index, offsets, page_zip, mtr);
page_cur_delete_rec(page_cursor, index, offsets, mtr);
page_cur_move_to_prev(page_cursor);
......@@ -1897,8 +1891,7 @@ btr_cur_optimistic_update(
}
/* There are no externally stored columns in new_entry */
rec = btr_cur_insert_if_possible(cursor, page_zip, new_entry,
NULL, 0, mtr);
rec = btr_cur_insert_if_possible(cursor, new_entry, NULL, 0, mtr);
ut_a(rec); /* <- We calculated above the insert would fit */
if (!rec_get_deleted_flag(rec, page_is_comp(page))) {
......@@ -2143,11 +2136,11 @@ btr_cur_pessimistic_update(
#ifdef UNIV_ZIP_DEBUG
ut_a(!page_zip || page_zip_validate(page_zip, page));
#endif /* UNIV_ZIP_DEBUG */
page_cur_delete_rec(page_cursor, index, offsets, page_zip, mtr);
page_cur_delete_rec(page_cursor, index, offsets, mtr);
page_cur_move_to_prev(page_cursor);
rec = btr_cur_insert_if_possible(cursor, page_zip, new_entry,
rec = btr_cur_insert_if_possible(cursor, new_entry,
ext_vect, n_ext_vect, mtr);
ut_a(rec || optim_err != DB_UNDERFLOW);
......@@ -2663,7 +2656,9 @@ btr_cur_optimistic_delete(
if (no_compress_needed) {
page_t* page = buf_block_get_frame(block);
#ifdef UNIV_ZIP_DEBUG
page_zip_des_t* page_zip= buf_block_get_page_zip(block);
#endif /* UNIV_ZIP_DEBUG */
lock_update_delete(rec);
......@@ -2675,7 +2670,7 @@ btr_cur_optimistic_delete(
ut_a(!page_zip || page_zip_validate(page_zip, page));
#endif /* UNIV_ZIP_DEBUG */
page_cur_delete_rec(btr_cur_get_page_cur(cursor),
cursor->index, offsets, page_zip, mtr);
cursor->index, offsets, mtr);
#ifdef UNIV_ZIP_DEBUG
ut_a(!page_zip || page_zip_validate(page_zip, page));
#endif /* UNIV_ZIP_DEBUG */
......@@ -2836,8 +2831,7 @@ btr_cur_pessimistic_delete(
btr_search_update_hash_on_delete(cursor);
page_cur_delete_rec(btr_cur_get_page_cur(cursor), index,
offsets, page_zip, mtr);
page_cur_delete_rec(btr_cur_get_page_cur(cursor), index, offsets, mtr);
#ifdef UNIV_ZIP_DEBUG
ut_a(!page_zip || page_zip_validate(page_zip, page));
#endif /* UNIV_ZIP_DEBUG */
......
......@@ -408,8 +408,7 @@ btr_pcur_move_to_next_page(
btr_leaf_page_release(btr_pcur_get_block(cursor),
cursor->latch_mode, mtr);
btr_pcur_get_btr_cur(cursor)->page_block = next_block;
page_cur_set_before_first(next_page, btr_pcur_get_page_cur(cursor));
page_cur_set_before_first(next_block, btr_pcur_get_page_cur(cursor));
page_check_dir(next_page);
}
......@@ -478,8 +477,7 @@ btr_pcur_move_backward_from_page(
btr_leaf_page_release(btr_pcur_get_block(cursor),
latch_mode, mtr);
btr_pcur_get_btr_cur(cursor)->page_block = prev_block;
page_cur_set_after_last(buf_block_get_frame(prev_block),
page_cur_set_after_last(prev_block,
btr_pcur_get_page_cur(cursor));
} else {
......
......@@ -1276,23 +1276,17 @@ parameters as page (this often happens when a page is split). */
void
btr_search_move_or_delete_hash_entries(
/*===================================*/
page_t* new_page, /* in: records are copied
buf_block_t* new_block, /* in: records are copied
to this page */
page_t* page, /* in: index page from which
buf_block_t* block, /* in: index page from which
records were copied, and the
copied records will be deleted
from this page */
dict_index_t* index) /* in: record descriptor */
{
buf_block_t* block;
buf_block_t* new_block;
ulint n_fields;
ulint n_bytes;
ibool left_side;
block = buf_block_align(page);
new_block = buf_block_align(new_page);
ut_a(page_is_comp(page) == page_is_comp(new_page));
ulint n_fields;
ulint n_bytes;
ibool left_side;
#ifdef UNIV_SYNC_DEBUG
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
......@@ -1328,11 +1322,9 @@ btr_search_move_or_delete_hash_entries(
btr_search_build_page_hash_index(index, new_block, n_fields,
n_bytes, left_side);
#if 1 /* TODO: safe to remove? */
ut_a(n_fields == block->curr_n_fields);
ut_a(n_bytes == block->curr_n_bytes);
ut_a(left_side == block->curr_left_side);
#endif
ut_ad(n_fields == block->curr_n_fields);
ut_ad(n_bytes == block->curr_n_bytes);
ut_ad(left_side == block->curr_left_side);
return;
}
......
......@@ -2917,7 +2917,7 @@ ibuf_insert_to_index_page(
return;
}
low_match = page_cur_search(page, index, entry,
low_match = page_cur_search(block, index, entry,
PAGE_CUR_LE, &page_cur);
if (low_match == dtuple_get_n_fields(entry)) {
......@@ -2925,23 +2925,21 @@ ibuf_insert_to_index_page(
btr_cur_del_unmark_for_ibuf(rec, mtr);
} else {
rec = page_cur_tuple_insert(&page_cur,
buf_block_get_page_zip(block),
entry, index, NULL, 0, mtr);
rec = page_cur_tuple_insert(&page_cur, entry, index,
NULL, 0, mtr);
if (UNIV_UNLIKELY(rec == NULL)) {
/* If the record did not fit, reorganize */
btr_page_reorganize(block, index, mtr);
page_cur_search(page, index, entry,
page_cur_search(block, index, entry,
PAGE_CUR_LE, &page_cur);
/* This time the record must fit */
if (UNIV_UNLIKELY
(!page_cur_tuple_insert(
&page_cur, buf_block_get_page_zip(block),
entry, index, NULL, 0, mtr))) {
(!page_cur_tuple_insert(&page_cur, entry, index,
NULL, 0, mtr))) {
ulint space;
ulint page_no;
......
......@@ -81,42 +81,42 @@ dulint
btr_page_get_index_id(
/*==================*/
/* out: index id */
page_t* page); /* in: index page */
const page_t* page); /* in: index page */
/************************************************************
Gets the node level field in an index page. */
UNIV_INLINE
ulint
btr_page_get_level_low(
/*===================*/
/* out: level, leaf level == 0 */
page_t* page); /* in: index page */
/* out: level, leaf level == 0 */
const page_t* page); /* in: index page */
/************************************************************
Gets the node level field in an index page. */
UNIV_INLINE
ulint
btr_page_get_level(
/*===============*/
/* out: level, leaf level == 0 */
page_t* page, /* in: index page */
mtr_t* mtr); /* in: mini-transaction handle */
/* out: level, leaf level == 0 */
const page_t* page, /* in: index page */
mtr_t* mtr); /* in: mini-transaction handle */
/************************************************************
Gets the next index page number. */
UNIV_INLINE
ulint
btr_page_get_next(
/*==============*/
/* out: next page number */
page_t* page, /* in: index page */
mtr_t* mtr); /* in: mini-transaction handle */
/* out: next page number */
const page_t* page, /* in: index page */
mtr_t* mtr); /* in: mini-transaction handle */
/************************************************************
Gets the previous index page number. */
UNIV_INLINE
ulint
btr_page_get_prev(
/*==============*/
/* out: prev page number */
page_t* page, /* in: index page */
mtr_t* mtr); /* in: mini-transaction handle */
/* out: prev page number */
const page_t* page, /* in: index page */
mtr_t* mtr); /* in: mini-transaction handle */
/*****************************************************************
Gets pointer to the previous user record in the tree. It is assumed
that the caller has appropriate latches on the page and its neighbor. */
......
......@@ -80,7 +80,7 @@ dulint
btr_page_get_index_id(
/*==================*/
/* out: index id */
page_t* page) /* in: index page */
const page_t* page) /* in: index page */
{
return(mach_read_from_8(page + PAGE_HEADER + PAGE_INDEX_ID));
}
......@@ -91,8 +91,8 @@ UNIV_INLINE
ulint
btr_page_get_level_low(
/*===================*/
/* out: level, leaf level == 0 */
page_t* page) /* in: index page */
/* out: level, leaf level == 0 */
const page_t* page) /* in: index page */
{
ulint level;
......@@ -111,9 +111,10 @@ UNIV_INLINE
ulint
btr_page_get_level(
/*===============*/
/* out: level, leaf level == 0 */
page_t* page, /* in: index page */
mtr_t* mtr __attribute__((unused))) /* in: mini-transaction handle */
/* out: level, leaf level == 0 */
const page_t* page, /* in: index page */
mtr_t* mtr __attribute__((unused)))
/* in: mini-transaction handle */
{
ut_ad(page && mtr);
......@@ -152,9 +153,10 @@ UNIV_INLINE
ulint
btr_page_get_next(
/*==============*/
/* out: next page number */
page_t* page, /* in: index page */
mtr_t* mtr __attribute__((unused))) /* in: mini-transaction handle */
/* out: next page number */
const page_t* page, /* in: index page */
mtr_t* mtr __attribute__((unused)))
/* in: mini-transaction handle */
{
ut_ad(page && mtr);
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX)
......@@ -191,8 +193,8 @@ UNIV_INLINE
ulint
btr_page_get_prev(
/*==============*/
/* out: prev page number */
page_t* page, /* in: index page */
/* out: prev page number */
const page_t* page, /* in: index page */
mtr_t* mtr __attribute__((unused))) /* in: mini-transaction handle */
{
ut_ad(page && mtr);
......
......@@ -595,9 +595,6 @@ to know struct size! */
struct btr_cur_struct {
dict_index_t* index; /* index where positioned */
page_cur_t page_cur; /* page cursor */
buf_block_t* page_block; /* buffer pool block were
cursor is positioned; needed
to avoid buf_block_align() */
buf_block_t* left_block; /* this field is used to store
a pointer to the left neighbor
page, in the cases
......
......@@ -28,8 +28,7 @@ btr_cur_get_block(
/* out: pointer to buffer block */
btr_cur_t* cursor) /* in: tree cursor */
{
ut_ad(page_align(cursor->page_cur.rec) == cursor->page_block->frame);
return(cursor->page_block);
return(page_cur_get_block(btr_cur_get_page_cur(cursor)));
}
/*************************************************************
......@@ -41,7 +40,6 @@ btr_cur_get_rec(
/* out: pointer to record */
btr_cur_t* cursor) /* in: tree cursor */
{
ut_ad(page_align(cursor->page_cur.rec) == cursor->page_block->frame);
return(page_cur_get_rec(&(cursor->page_cur)));
}
......@@ -67,7 +65,6 @@ btr_cur_invalidate(
btr_cur_t* cursor) /* in: tree cursor */
{
page_cur_invalidate(&(cursor->page_cur));
cursor->page_block = NULL;
}
/*************************************************************
......@@ -107,8 +104,7 @@ btr_cur_position(
{
ut_ad(page_align(rec) == buf_block_get_frame(block));
page_cur_position(rec, btr_cur_get_page_cur(cursor));
cursor->page_block = block;
page_cur_position(rec, block, btr_cur_get_page_cur(cursor));
cursor->index = index;
}
......
......@@ -310,7 +310,7 @@ btr_pcur_move_to_last_on_page(
UT_NOT_USED(mtr);
ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
page_cur_set_after_last(btr_pcur_get_page(cursor),
page_cur_set_after_last(btr_pcur_get_block(cursor),
btr_pcur_get_page_cur(cursor));
cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
......@@ -633,8 +633,8 @@ btr_pcur_close(
cursor->old_rec_buf = NULL;
}
cursor->btr_cur.page_block = NULL;
cursor->btr_cur.page_cur.rec = NULL;
cursor->btr_cur.page_cur.block = NULL;
cursor->old_rec = NULL;
cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
......
......@@ -77,9 +77,12 @@ parameters as page (this often happens when a page is split). */
void
btr_search_move_or_delete_hash_entries(
/*===================================*/
page_t* new_page, /* in: records are copied
buf_block_t* new_block, /* in: records are copied
to this page */
page_t* page, /* in: index page */
buf_block_t* block, /* in: index page from which
records were copied, and the
copied records will be deleted
from this page */
dict_index_t* index); /* in: record descriptor */
/************************************************************************
Drops a page hash index. */
......
......@@ -581,16 +581,18 @@ UNIV_INLINE
ulint
buf_block_get_space(
/*================*/
/* out: space id */
buf_block_t* block); /* in: pointer to the control block */
/* out: space id */
const buf_block_t* block) /* in: pointer to the control block */
__attribute((const));
/*************************************************************************
Gets the page number of a block. */
UNIV_INLINE
ulint
buf_block_get_page_no(
/*==================*/
/* out: page number */
buf_block_t* block); /* in: pointer to the control block */
/* out: page number */
const buf_block_t* block) /* in: pointer to the control block */
__attribute((const));
/*************************************************************************
Gets the compressed page size of a block. */
UNIV_INLINE
......
......@@ -162,8 +162,8 @@ UNIV_INLINE
ulint
buf_block_get_space(
/*================*/
/* out: space id */
buf_block_t* block) /* in: pointer to the control block */
/* out: space id */
const buf_block_t* block) /* in: pointer to the control block */
{
ut_ad(block);
ut_ad(block >= buf_pool->blocks);
......@@ -180,8 +180,8 @@ UNIV_INLINE
ulint
buf_block_get_page_no(
/*==================*/
/* out: page number */
buf_block_t* block) /* in: pointer to the control block */
/* out: page number */
const buf_block_t* block) /* in: pointer to the control block */
{
ut_ad(block);
ut_ad(block >= buf_pool->blocks);
......
......@@ -293,10 +293,10 @@ Checks if memo contains the given page. */
ibool
mtr_memo_contains_page(
/*===================*/
/* out: TRUE if contains */
mtr_t* mtr, /* in: mtr */
byte* ptr, /* in: pointer to buffer frame */
ulint type); /* in: type of object */
/* out: TRUE if contains */
mtr_t* mtr, /* in: mtr */
const byte* ptr, /* in: pointer to buffer frame */
ulint type); /* in: type of object */
/*************************************************************
Prints info of an mtr handle. */
......
......@@ -11,7 +11,7 @@ Created 10/4/1994 Heikki Tuuri
#include "univ.i"
#include "page0types.h"
#include "buf0types.h"
#include "page0page.h"
#include "rem0rec.h"
#include "data0data.h"
......@@ -49,6 +49,22 @@ page_cur_get_page(
/* out: page */
page_cur_t* cur); /* in: page cursor */
/*************************************************************
Gets pointer to the buffer block where the cursor is positioned. */
UNIV_INLINE
buf_block_t*
page_cur_get_block(
/*===============*/
/* out: page */
page_cur_t* cur); /* in: page cursor */
/*************************************************************
Gets pointer to the page frame where the cursor is positioned. */
UNIV_INLINE
page_zip_des_t*
page_cur_get_page_zip(
/*==================*/
/* out: page */
page_cur_t* cur); /* in: page cursor */
/*************************************************************
Gets the record where the cursor is positioned. */
UNIV_INLINE
rec_t*
......@@ -63,7 +79,7 @@ UNIV_INLINE
void
page_cur_set_before_first(
/*======================*/
page_t* page, /* in: index page */
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
......@@ -72,7 +88,7 @@ UNIV_INLINE
void
page_cur_set_after_last(
/*====================*/
page_t* page, /* in: index page */
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. */
......@@ -97,7 +113,8 @@ void
page_cur_position(
/*==============*/
rec_t* rec, /* in: record on a page */
page_cur_t* cur); /* in: page cursor */
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
......@@ -130,7 +147,6 @@ page_cur_tuple_insert(
/* out: pointer to record if succeed, NULL
otherwise */
page_cur_t* cursor, /* in: a page cursor */
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
const dtuple_t* tuple, /* in: pointer to a data tuple */
dict_index_t* index, /* in: record descriptor */
const ulint* ext, /* in: array of extern field numbers */
......@@ -147,7 +163,6 @@ page_cur_rec_insert(
/* out: pointer to record if succeed, NULL
otherwise */
page_cur_t* cursor, /* in: a page cursor */
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
rec_t* rec, /* in: record to insert */
dict_index_t* index, /* in: record descriptor */
ulint* offsets,/* in/out: rec_get_offsets(rec, index) */
......@@ -163,8 +178,9 @@ page_cur_insert_rec_low(
/*====================*/
/* out: pointer to record if succeed, NULL
otherwise */
page_cur_t* cursor, /* in: a page cursor */
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
rec_t* current_rec,/* in: current record after which the
new record is inserted */
page_zip_des_t* page_zip,/* in: compressed page, or NULL */
dict_index_t* index, /* in: record descriptor */
rec_t* rec, /* in: pointer to a physical record */
ulint* offsets,/* in/out: rec_get_offsets(rec, index) */
......@@ -190,7 +206,6 @@ page_cur_delete_rec(
page_cur_t* cursor, /* in/out: a page cursor */
dict_index_t* index, /* in: record descriptor */
const ulint* offsets,/* in: rec_get_offsets(cursor->rec, index) */
page_zip_des_t* page_zip,/* in/out: compressed, or NULL */
mtr_t* mtr); /* in: mini-transaction handle */
/********************************************************************
Searches the right position for a page cursor. */
......@@ -199,7 +214,7 @@ ulint
page_cur_search(
/*============*/
/* out: number of matched fields on the left */
page_t* page, /* in: index page */
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,
......@@ -211,7 +226,7 @@ Searches the right position for a page cursor. */
void
page_cur_search_with_match(
/*=======================*/
page_t* page, /* in: index page */
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,
......@@ -236,8 +251,8 @@ are no user records, sets the cursor on the infimum record. */
void
page_cur_open_on_rnd_user_rec(
/*==========================*/
page_t* page, /* in: page */
page_cur_t* cursor);/* in/out: page cursor */
buf_block_t* block, /* in: page */
page_cur_t* cursor);/* out: page cursor */
/***************************************************************
Parses a log record of a record insert on a page. */
......@@ -248,9 +263,8 @@ page_cur_parse_insert_rec(
ibool is_short,/* in: TRUE if short inserts */
byte* ptr, /* in: buffer */
byte* end_ptr,/* in: buffer end */
buf_block_t* block, /* in: page or NULL */
dict_index_t* index, /* in: record descriptor */
page_t* page, /* in/out: page or NULL */
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
mtr_t* mtr); /* in: mtr or NULL */
/**************************************************************
Parses a log record of copying a record list end to a new created page. */
......@@ -261,9 +275,8 @@ page_parse_copy_rec_list_to_created_page(
/* out: end of log record or NULL */
byte* ptr, /* in: buffer */
byte* end_ptr,/* in: buffer end */
buf_block_t* block, /* in: page or NULL */
dict_index_t* index, /* in: record descriptor */
page_t* page, /* in/out: page or NULL */
page_zip_des_t* page_zip,/* in/out: compressed page or NULL */
mtr_t* mtr); /* in: mtr or NULL */
/***************************************************************
Parses log record of a record delete on a page. */
......@@ -274,15 +287,15 @@ page_cur_parse_delete_rec(
/* out: pointer to record end or NULL */
byte* ptr, /* in: buffer */
byte* end_ptr,/* in: buffer end */
buf_block_t* block, /* in: page or NULL */
dict_index_t* index, /* in: record descriptor */
page_t* page, /* in/out: page or NULL */
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
mtr_t* mtr); /* in: mtr or NULL */
/* Index page cursor */
struct page_cur_struct{
byte* rec; /* pointer to a record on page */
byte* rec; /* pointer to a record on page */
buf_block_t* block; /* pointer to the block containing rec */
};
#ifndef UNIV_NONINL
......
......@@ -7,6 +7,7 @@ Created 10/4/1994 Heikki Tuuri
*************************************************************************/
#include "page0page.h"
#include "buf0types.h"
/*************************************************************
......@@ -23,6 +24,32 @@ page_cur_get_page(
return(page_align(cur->rec));
}
/*************************************************************
Gets pointer to the buffer block where the cursor is positioned. */
UNIV_INLINE
buf_block_t*
page_cur_get_block(
/*===============*/
/* out: page */
page_cur_t* cur) /* in: page cursor */
{
ut_ad(cur);
ut_ad(page_align(cur->rec) == cur->block->frame);
return(cur->block);
}
/*************************************************************
Gets pointer to the page frame where the cursor is positioned. */
UNIV_INLINE
page_zip_des_t*
page_cur_get_page_zip(
/*==================*/
/* out: page */
page_cur_t* cur) /* in: page cursor */
{
return(buf_block_get_page_zip(page_cur_get_block(cur)));
}
/*************************************************************
Gets the record where the cursor is positioned. */
UNIV_INLINE
......@@ -33,6 +60,7 @@ page_cur_get_rec(
page_cur_t* cur) /* in: page cursor */
{
ut_ad(cur);
ut_ad(page_align(cur->rec) == cur->block->frame);
return(cur->rec);
}
......@@ -44,10 +72,11 @@ UNIV_INLINE
void
page_cur_set_before_first(
/*======================*/
page_t* page, /* in: index page */
buf_block_t* block, /* in: index page */
page_cur_t* cur) /* in: cursor */
{
cur->rec = page_get_infimum_rec(page);
cur->rec = page_get_infimum_rec(buf_block_get_frame(block));
cur->block = block;
}
/*************************************************************
......@@ -57,10 +86,11 @@ UNIV_INLINE
void
page_cur_set_after_last(
/*====================*/
page_t* page, /* in: index page */
buf_block_t* block, /* in: index page */
page_cur_t* cur) /* in: cursor */
{
cur->rec = page_get_supremum_rec(page);
cur->rec = page_get_supremum_rec(buf_block_get_frame(block));
cur->block = block;
}
/*************************************************************
......@@ -94,11 +124,14 @@ void
page_cur_position(
/*==============*/
rec_t* rec, /* in: record on a page */
page_cur_t* cur) /* in: page cursor */
buf_block_t* block, /* in: buffer block containing the record */
page_cur_t* cur) /* out: page cursor */
{
ut_ad(rec && cur);
ut_ad(rec && block && cur);
ut_ad(page_align(rec) == block->frame);
cur->rec = rec;
cur->block = block;
}
/**************************************************************
......@@ -112,6 +145,7 @@ page_cur_invalidate(
ut_ad(cur);
cur->rec = NULL;
cur->block = NULL;
}
/**************************************************************
......@@ -147,7 +181,7 @@ ulint
page_cur_search(
/*============*/
/* out: number of matched fields on the left */
page_t* page, /* in: index page */
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,
......@@ -161,7 +195,7 @@ page_cur_search(
ut_ad(dtuple_check_typed(tuple));
page_cur_search_with_match(page, index, tuple, mode,
page_cur_search_with_match(block, index, tuple, mode,
&up_matched_fields,
&up_matched_bytes,
&low_matched_fields,
......@@ -181,7 +215,6 @@ page_cur_tuple_insert(
/* out: pointer to record if succeed, NULL
otherwise */
page_cur_t* cursor, /* in: a page cursor */
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
const dtuple_t* tuple, /* in: pointer to a data tuple */
dict_index_t* index, /* in: record descriptor */
const ulint* ext, /* in: array of extern field numbers */
......@@ -202,7 +235,8 @@ page_cur_tuple_insert(
index, tuple, ext, n_ext);
offsets = rec_get_offsets(rec, index, NULL, ULINT_UNDEFINED, &heap);
rec = page_cur_insert_rec_low(cursor, page_zip,
rec = page_cur_insert_rec_low(cursor->rec,
buf_block_get_page_zip(cursor->block),
index, rec, offsets, mtr);
mem_heap_free(heap);
return(rec);
......@@ -219,13 +253,13 @@ page_cur_rec_insert(
/* out: pointer to record if succeed, NULL
otherwise */
page_cur_t* cursor, /* in: a page cursor */
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
rec_t* rec, /* in: record to insert */
dict_index_t* index, /* in: record descriptor */
ulint* offsets,/* in/out: rec_get_offsets(rec, index) */
mtr_t* mtr) /* in: mini-transaction handle, or NULL */
{
return(page_cur_insert_rec_low(cursor, page_zip,
return(page_cur_insert_rec_low(cursor->rec,
buf_block_get_page_zip(cursor->block),
index, rec, offsets, mtr));
}
......@@ -100,6 +100,14 @@ typedef byte page_header_t;
a new-style compact page */
/*-----------------------------*/
/* Heap numbers */
#define PAGE_HEAP_NO_INFIMUM 0 /* page infimum */
#define PAGE_HEAP_NO_SUPREMUM 1 /* page supremum */
#define PAGE_HEAP_NO_USER_LOW 2 /* first user record in
creation (insertion) order,
not necessarily collation order;
this record may have been deleted */
/* Directions of cursor movement */
#define PAGE_LEFT 1
#define PAGE_RIGHT 2
......@@ -681,7 +689,8 @@ touch the lock table and max trx id on page or compress the page. */
void
page_copy_rec_list_end_no_locks(
/*============================*/
page_t* new_page, /* in: index page to copy to */
buf_block_t* new_block, /* in: index page to copy to */
buf_block_t* block, /* in: index page of rec */
rec_t* rec, /* in: record on page */
dict_index_t* index, /* in: record descriptor */
mtr_t* mtr); /* in: mtr */
......@@ -696,9 +705,9 @@ page_copy_rec_list_end(
/* out: pointer to the original
successor of the infimum record
on new_page, or NULL on zip overflow
(new_page will be decompressed
from new_page_zip) */
(new_block will be decompressed) */
buf_block_t* new_block, /* in/out: index page to copy to */
buf_block_t* block, /* in: index page containing rec */
rec_t* rec, /* in: record on page */
dict_index_t* index, /* in: record descriptor */
mtr_t* mtr) /* in: mtr */
......@@ -714,9 +723,9 @@ page_copy_rec_list_start(
/* out: pointer to the original
predecessor of the supremum record
on new_page, or NULL on zip overflow
(new_page will be decompressed
from new_page_zip) */
(new_block will be decompressed) */
buf_block_t* new_block, /* in/out: index page to copy to */
buf_block_t* block, /* in: index page containing rec */
rec_t* rec, /* in: record on page */
dict_index_t* index, /* in: record descriptor */
mtr_t* mtr) /* in: mtr */
......@@ -729,15 +738,15 @@ void
page_delete_rec_list_end(
/*=====================*/
rec_t* rec, /* in: pointer to record on page */
buf_block_t* block, /* in: buffer block of the page */
dict_index_t* index, /* in: record descriptor */
ulint n_recs, /* in: number of records to delete,
or ULINT_UNDEFINED if not known */
ulint size, /* in: the sum of the sizes of the
records in the end of the chain to
delete, or ULINT_UNDEFINED if not known */
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
mtr_t* mtr) /* in: mtr */
__attribute__((nonnull(1, 2, 6)));
__attribute__((nonnull));
/*****************************************************************
Deletes records from page, up to the given record, NOT including
that record. Infimum and supremum records are not deleted. */
......@@ -746,10 +755,10 @@ void
page_delete_rec_list_start(
/*=======================*/
rec_t* rec, /* in: record on page */
buf_block_t* block, /* in: buffer block of the page */
dict_index_t* index, /* in: record descriptor */
page_zip_des_t* page_zip,/* in/out: compressed page of rec, or NULL */
mtr_t* mtr) /* in: mtr */
__attribute__((nonnull(1, 2, 4)));
__attribute__((nonnull));
/*****************************************************************
Moves record list end to another page. Moved records include
split_rec. */
......@@ -758,12 +767,11 @@ ibool
page_move_rec_list_end(
/*===================*/
/* out: TRUE on success; FALSE on
compression failure (new_page will
be decompressed from new_page_zip) */
compression failure
(new_block will be decompressed) */
buf_block_t* new_block, /* in/out: index page where to move */
buf_block_t* block, /* in: index page from where to move */
rec_t* split_rec, /* in: first record to move */
page_zip_des_t* page_zip, /* in/out: compressed page of
split_rec, or NULL */
dict_index_t* index, /* in: record descriptor */
mtr_t* mtr) /* in: mtr */
__attribute__((nonnull(1, 2, 4, 5)));
......@@ -777,9 +785,8 @@ page_move_rec_list_start(
/* out: TRUE on success; FALSE on
compression failure */
buf_block_t* new_block, /* in/out: index page where to move */
buf_block_t* block, /* in/out: page containing split_rec */
rec_t* split_rec, /* in: first record not to move */
page_zip_des_t* page_zip, /* in/out: compressed page of
split_rec, or NULL */
dict_index_t* index, /* in: record descriptor */
mtr_t* mtr) /* in: mtr */
__attribute__((nonnull(1, 2, 4, 5)));
......@@ -820,9 +827,8 @@ page_parse_delete_rec_list(
MLOG_COMP_LIST_START_DELETE */
byte* ptr, /* in: buffer */
byte* end_ptr,/* in: buffer end */
buf_block_t* block, /* in/out: buffer block or NULL */
dict_index_t* index, /* in: record descriptor */
page_t* page, /* in/out: page or NULL */
page_zip_des_t* page_zip,/* in/out: compressed page or NULL */
mtr_t* mtr); /* in: mtr or NULL */
/***************************************************************
Parses a redo log record of creating a page. */
......@@ -874,7 +880,7 @@ debugging purposes. */
void
page_print_list(
/*============*/
page_t* page, /* in: index page */
buf_block_t* block, /* in: index page */
dict_index_t* index, /* in: dictionary index of the page */
ulint pr_n); /* in: print n first and n last entries */
/*******************************************************************
......@@ -883,7 +889,7 @@ Prints the info in a page header. */
void
page_header_print(
/*==============*/
page_t* page);
const page_t* page);
/*******************************************************************
This is used to print the contents of the page for
debugging purposes. */
......@@ -891,7 +897,7 @@ debugging purposes. */
void
page_print(
/*=======*/
page_t* page, /* in: index page */
buf_block_t* block, /* in: index page */
dict_index_t* index, /* in: dictionary index of the page */
ulint dn, /* in: print dn first and last entries
in directory */
......@@ -936,7 +942,7 @@ ibool
page_simple_validate_new(
/*=====================*/
/* out: TRUE if ok */
page_t* page); /* in: new-style index page */
page_t* block); /* in: new-style index page */
/*******************************************************************
This function checks the consistency of an index page. */
......@@ -950,12 +956,12 @@ page_validate(
/*******************************************************************
Looks in the page record list for a record with the given heap number. */
rec_t*
const rec_t*
page_find_rec_with_heap_no(
/*=======================*/
/* out: record, NULL if not found */
page_t* page, /* in: index page */
ulint heap_no);/* in: heap number */
/* out: record, NULL if not found */
const page_t* page, /* in: index page */
ulint heap_no);/* in: heap number */
#ifdef UNIV_MATERIALIZE
#undef UNIV_INLINE
......
......@@ -2702,8 +2702,8 @@ lock_move_reorganize_page(
update of a record is occurring on the page, and its locks
were temporarily stored on the infimum */
page_cur_set_before_first(page, &cur1);
page_cur_set_before_first(old_page, &cur2);
page_cur_set_before_first(buf_block_align(page), &cur1);
page_cur_set_before_first(buf_block_align(old_page), &cur2);
/* Set locks according to old locks */
for (;;) {
......@@ -2798,13 +2798,13 @@ lock_move_rec_list_end(
while (lock != NULL) {
page_cur_position(rec, &cur1);
page_cur_position(rec, buf_block_align(rec), &cur1);
if (page_cur_is_before_first(&cur1)) {
page_cur_move_to_next(&cur1);
}
page_cur_set_before_first(new_page, &cur2);
page_cur_set_before_first(buf_block_align(new_page), &cur2);
page_cur_move_to_next(&cur2);
/* Copy lock requests on user records to new page and
......@@ -2894,10 +2894,10 @@ lock_move_rec_list_start(
while (lock != NULL) {
page_cur_set_before_first(page, &cur1);
page_cur_set_before_first(buf_block_align(page), &cur1);
page_cur_move_to_next(&cur1);
page_cur_position(old_end, &cur2);
page_cur_position(old_end, buf_block_align(old_end), &cur2);
page_cur_move_to_next(&cur2);
/* Copy lock requests on user records to new page and
......@@ -4302,7 +4302,7 @@ lock_rec_print(
fprintf(file, "Record lock, heap no %lu ", (ulong) i);
if (block) {
rec_t* rec
const rec_t* rec
= page_find_rec_with_heap_no(
buf_block_get_frame(block), i);
offsets = rec_get_offsets(
......
......@@ -803,8 +803,7 @@ recv_parse_or_apply_log_rec_body(
|| (ibool)!!page_is_comp(page)
== dict_table_is_comp(index->table));
ptr = page_cur_parse_insert_rec(FALSE, ptr, end_ptr,
index,
page, page_zip, mtr);
block, index, mtr);
}
break;
case MLOG_REC_CLUST_DELETE_MARK: case MLOG_COMP_REC_CLUST_DELETE_MARK:
......@@ -856,8 +855,7 @@ recv_parse_or_apply_log_rec_body(
|| (ibool)!!page_is_comp(page)
== dict_table_is_comp(index->table));
ptr = page_parse_delete_rec_list(type, ptr, end_ptr,
index, page,
page_zip, mtr);
block, index, mtr);
}
break;
case MLOG_LIST_END_COPY_CREATED: case MLOG_COMP_LIST_END_COPY_CREATED:
......@@ -869,7 +867,7 @@ recv_parse_or_apply_log_rec_body(
|| (ibool)!!page_is_comp(page)
== dict_table_is_comp(index->table));
ptr = page_parse_copy_rec_list_to_created_page(
ptr, end_ptr, index, page, page_zip, mtr);
ptr, end_ptr, block, index, mtr);
}
break;
case MLOG_PAGE_REORGANIZE: case MLOG_COMP_PAGE_REORGANIZE:
......@@ -925,8 +923,8 @@ recv_parse_or_apply_log_rec_body(
ut_a(!page
|| (ibool)!!page_is_comp(page)
== dict_table_is_comp(index->table));
ptr = page_cur_parse_delete_rec(ptr, end_ptr, index,
page, page_zip, mtr);
ptr = page_cur_parse_delete_rec(ptr, end_ptr,
block, index, mtr);
}
break;
case MLOG_IBUF_BITMAP_INIT:
......
......@@ -317,12 +317,12 @@ Checks if memo contains the given page. */
ibool
mtr_memo_contains_page(
/*===================*/
/* out: TRUE if contains */
mtr_t* mtr, /* in: mtr */
byte* ptr, /* in: pointer to buffer frame */
ulint type) /* in: type of object */
/* out: TRUE if contains */
mtr_t* mtr, /* in: mtr */
const byte* ptr, /* in: pointer to buffer frame */
ulint type) /* in: type of object */
{
return(mtr_memo_contains(mtr, buf_block_align(ptr), type));
return(mtr_memo_contains(mtr, buf_block_align((byte*) ptr), type));
}
/*************************************************************
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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