summaryrefslogtreecommitdiff
path: root/storage/xtradb/include/page0page.ic
diff options
context:
space:
mode:
Diffstat (limited to 'storage/xtradb/include/page0page.ic')
-rw-r--r--storage/xtradb/include/page0page.ic123
1 files changed, 84 insertions, 39 deletions
diff --git a/storage/xtradb/include/page0page.ic b/storage/xtradb/include/page0page.ic
index 4fe93345ce5..58add015d34 100644
--- a/storage/xtradb/include/page0page.ic
+++ b/storage/xtradb/include/page0page.ic
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1994, 2012, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1994, 2013, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -136,7 +136,7 @@ page_header_set_field(
ut_ad(field != PAGE_N_HEAP || (val & 0x7fff) < UNIV_PAGE_SIZE);
mach_write_to_2(page + PAGE_HEADER + field, val);
- if (UNIV_LIKELY_NULL(page_zip)) {
+ if (page_zip) {
page_zip_write_header(page_zip,
page + PAGE_HEADER + field, 2, NULL);
}
@@ -211,7 +211,7 @@ page_header_reset_last_insert(
{
ut_ad(page && mtr);
- if (UNIV_LIKELY_NULL(page_zip)) {
+ if (page_zip) {
mach_write_to_2(page + (PAGE_HEADER + PAGE_LAST_INSERT), 0);
page_zip_write_header(page_zip,
page + (PAGE_HEADER + PAGE_LAST_INSERT),
@@ -233,8 +233,7 @@ page_is_comp(
/*=========*/
const page_t* page) /*!< in: index page */
{
- return(UNIV_EXPECT(page_header_get_field(page, PAGE_N_HEAP) & 0x8000,
- 0x8000));
+ return(page_header_get_field(page, PAGE_N_HEAP) & 0x8000);
}
/************************************************************//**
@@ -267,9 +266,9 @@ page_rec_get_heap_no(
/************************************************************//**
Determine whether the page is a B-tree leaf.
-@return TRUE if the page is a B-tree leaf */
+@return true if the page is a B-tree leaf (PAGE_LEVEL = 0) */
UNIV_INLINE
-ibool
+bool
page_is_leaf(
/*=========*/
const page_t* page) /*!< in: page */
@@ -281,6 +280,30 @@ page_is_leaf(
}
/************************************************************//**
+Determine whether the page is empty.
+@return true if the page is empty (PAGE_N_RECS = 0) */
+UNIV_INLINE
+bool
+page_is_empty(
+/*==========*/
+ const page_t* page) /*!< in: page */
+{
+ return(!*(const uint16*) (page + (PAGE_HEADER + PAGE_N_RECS)));
+}
+
+/************************************************************//**
+Determine whether the page contains garbage.
+@return true if the page contains garbage (PAGE_GARBAGE is not 0) */
+UNIV_INLINE
+bool
+page_has_garbage(
+/*=============*/
+ const page_t* page) /*!< in: page */
+{
+ return(!!*(const uint16*) (page + (PAGE_HEADER + PAGE_GARBAGE)));
+}
+
+/************************************************************//**
Gets the offset of the first record on the page.
@return offset of the first record in record list, relative from page */
UNIV_INLINE
@@ -348,10 +371,10 @@ page_rec_is_user_rec_low(
#endif
ut_ad(offset <= UNIV_PAGE_SIZE - PAGE_EMPTY_DIR_START);
- return(UNIV_LIKELY(offset != PAGE_NEW_SUPREMUM)
- && UNIV_LIKELY(offset != PAGE_NEW_INFIMUM)
- && UNIV_LIKELY(offset != PAGE_OLD_INFIMUM)
- && UNIV_LIKELY(offset != PAGE_OLD_SUPREMUM));
+ return(offset != PAGE_NEW_SUPREMUM
+ && offset != PAGE_NEW_INFIMUM
+ && offset != PAGE_OLD_INFIMUM
+ && offset != PAGE_OLD_SUPREMUM);
}
/************************************************************//**
@@ -366,8 +389,8 @@ page_rec_is_supremum_low(
ut_ad(offset >= PAGE_NEW_INFIMUM);
ut_ad(offset <= UNIV_PAGE_SIZE - PAGE_EMPTY_DIR_START);
- return(UNIV_UNLIKELY(offset == PAGE_NEW_SUPREMUM)
- || UNIV_UNLIKELY(offset == PAGE_OLD_SUPREMUM));
+ return(offset == PAGE_NEW_SUPREMUM
+ || offset == PAGE_OLD_SUPREMUM);
}
/************************************************************//**
@@ -382,8 +405,7 @@ page_rec_is_infimum_low(
ut_ad(offset >= PAGE_NEW_INFIMUM);
ut_ad(offset <= UNIV_PAGE_SIZE - PAGE_EMPTY_DIR_START);
- return(UNIV_UNLIKELY(offset == PAGE_NEW_INFIMUM)
- || UNIV_UNLIKELY(offset == PAGE_OLD_INFIMUM));
+ return(offset == PAGE_NEW_INFIMUM || offset == PAGE_OLD_INFIMUM);
}
/************************************************************//**
@@ -487,12 +509,14 @@ page_cmp_dtuple_rec_with_match(
rec_offset = page_offset(rec);
- if (UNIV_UNLIKELY(rec_offset == PAGE_NEW_INFIMUM)
- || UNIV_UNLIKELY(rec_offset == PAGE_OLD_INFIMUM)) {
+ if (rec_offset == PAGE_NEW_INFIMUM
+ || rec_offset == PAGE_OLD_INFIMUM) {
+
return(1);
- }
- if (UNIV_UNLIKELY(rec_offset == PAGE_NEW_SUPREMUM)
- || UNIV_UNLIKELY(rec_offset == PAGE_OLD_SUPREMUM)) {
+
+ } else if (rec_offset == PAGE_NEW_SUPREMUM
+ || rec_offset == PAGE_OLD_SUPREMUM) {
+
return(-1);
}
@@ -734,21 +758,19 @@ page_rec_get_next_low(
offs = rec_get_next_offs(rec, comp);
- if (UNIV_UNLIKELY(offs >= UNIV_PAGE_SIZE)) {
+ if (offs >= UNIV_PAGE_SIZE) {
fprintf(stderr,
"InnoDB: Next record offset is nonsensical %lu"
" in record at offset %lu\n"
"InnoDB: rec address %p, space id %lu, page %lu\n",
- (ulong)offs, (ulong) page_offset(rec),
+ (ulong) offs, (ulong) page_offset(rec),
(void*) rec,
(ulong) page_get_space_id(page),
(ulong) page_get_page_no(page));
buf_page_print(page, 0, 0);
ut_error;
- }
-
- if (UNIV_UNLIKELY(offs == 0)) {
+ } else if (offs == 0) {
return(NULL);
}
@@ -781,14 +803,38 @@ page_rec_get_next_const(
}
/************************************************************//**
+Gets the pointer to the next non delete-marked record on the page.
+If all subsequent records are delete-marked, then this function
+will return the supremum record.
+@return pointer to next non delete-marked record or pointer to supremum */
+UNIV_INLINE
+const rec_t*
+page_rec_get_next_non_del_marked(
+/*=============================*/
+ const rec_t* rec) /*!< in: pointer to record */
+{
+ const rec_t* r;
+ ulint page_is_compact = page_rec_is_comp(rec);
+
+ for (r = page_rec_get_next_const(rec);
+ !page_rec_is_supremum(r)
+ && rec_get_deleted_flag(r, page_is_compact);
+ r = page_rec_get_next_const(r)) {
+ /* noop */
+ }
+
+ return(r);
+}
+
+/************************************************************//**
Sets the pointer to the next record on the page. */
UNIV_INLINE
void
page_rec_set_next(
/*==============*/
- rec_t* rec, /*!< in: pointer to record,
+ rec_t* rec, /*!< in: pointer to record,
must not be page supremum */
- rec_t* next) /*!< in: pointer to next record,
+ const rec_t* next) /*!< in: pointer to next record,
must not be page infimum */
{
ulint offs;
@@ -800,11 +846,7 @@ page_rec_set_next(
ut_ad(!next || !page_rec_is_infimum(next));
ut_ad(!next || page_align(rec) == page_align(next));
- if (UNIV_LIKELY(next != NULL)) {
- offs = page_offset(next);
- } else {
- offs = 0;
- }
+ offs = next != NULL ? page_offset(next) : 0;
if (page_rec_is_comp(rec)) {
rec_set_next_offs_new(rec, offs);
@@ -979,7 +1021,7 @@ page_get_free_space_of_empty(
/*=========================*/
ulint comp) /*!< in: nonzero=compact page layout */
{
- if (UNIV_LIKELY(comp)) {
+ if (comp) {
return((ulint)(UNIV_PAGE_SIZE
- PAGE_NEW_SUPREMUM_END
- PAGE_DIR
@@ -1094,11 +1136,14 @@ UNIV_INLINE
void
page_mem_free(
/*==========*/
- page_t* page, /*!< in/out: index page */
- page_zip_des_t* page_zip,/*!< in/out: compressed page, or NULL */
- rec_t* rec, /*!< in: pointer to the (origin of) record */
- dict_index_t* index, /*!< in: index of rec */
- const ulint* offsets)/*!< in: array returned by rec_get_offsets() */
+ page_t* page, /*!< in/out: index page */
+ page_zip_des_t* page_zip, /*!< in/out: compressed page,
+ or NULL */
+ rec_t* rec, /*!< in: pointer to the
+ (origin of) record */
+ const dict_index_t* index, /*!< in: index of rec */
+ const ulint* offsets) /*!< in: array returned by
+ rec_get_offsets() */
{
rec_t* free;
ulint garbage;
@@ -1114,7 +1159,7 @@ page_mem_free(
page_header_set_field(page, page_zip, PAGE_GARBAGE,
garbage + rec_offs_size(offsets));
- if (UNIV_LIKELY_NULL(page_zip)) {
+ if (page_zip) {
page_zip_dir_delete(page_zip, rec, index, offsets, free);
} else {
page_header_set_field(page, page_zip, PAGE_N_RECS,