summaryrefslogtreecommitdiff
path: root/storage/innobase
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-03-25 16:14:39 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2019-03-25 16:14:39 +0200
commitdbc0d576a3f402ae52423fe424ed0a68f49537ef (patch)
tree8b4b725681dd96d190f3e23932a5a3b67114c769 /storage/innobase
parentc3a6c683e2bba4111a69a34303af13ff9a45b46a (diff)
parent525e79b057ce1256aac9f8248b89d8d507ab22c3 (diff)
downloadmariadb-git-dbc0d576a3f402ae52423fe424ed0a68f49537ef.tar.gz
Merge 10.2 into 10.3
Diffstat (limited to 'storage/innobase')
-rw-r--r--storage/innobase/btr/btr0btr.cc74
-rw-r--r--storage/innobase/btr/btr0cur.cc24
-rw-r--r--storage/innobase/btr/btr0defragment.cc8
-rw-r--r--storage/innobase/btr/btr0sea.cc2
-rw-r--r--storage/innobase/include/btr0btr.h17
-rw-r--r--storage/innobase/include/btr0cur.h7
6 files changed, 61 insertions, 71 deletions
diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc
index df0ea3cebe1..6a269ac3d83 100644
--- a/storage/innobase/btr/btr0btr.cc
+++ b/storage/innobase/btr/btr0btr.cc
@@ -1062,18 +1062,13 @@ btr_page_get_father_block(
return(btr_page_get_father_node_ptr(offsets, heap, cursor, mtr));
}
-/************************************************************//**
-Seeks to the upper level node pointer to a page.
-It is assumed that mtr holds an x-latch on the tree. */
-static
-void
-btr_page_get_father(
-/*================*/
- dict_index_t* index, /*!< in: b-tree index */
- buf_block_t* block, /*!< in: child page in the index */
- mtr_t* mtr, /*!< in: mtr */
- btr_cur_t* cursor) /*!< out: cursor on node pointer record,
- its page x-latched */
+/** Seek to the parent page of a B-tree page.
+@param[in,out] index b-tree
+@param[in] block child page
+@param[in,out] mtr mini-transaction
+@param[out] cursor cursor pointing to the x-latched parent page */
+void btr_page_get_father(dict_index_t* index, buf_block_t* block, mtr_t* mtr,
+ btr_cur_t* cursor)
{
mem_heap_t* heap;
rec_t* rec
@@ -3470,33 +3465,6 @@ btr_set_min_rec_mark(
}
/*************************************************************//**
-Deletes on the upper level the node pointer to a page. */
-void
-btr_node_ptr_delete(
-/*================*/
- dict_index_t* index, /*!< in: index tree */
- buf_block_t* block, /*!< in: page whose node pointer is deleted */
- mtr_t* mtr) /*!< in: mtr */
-{
- btr_cur_t cursor;
- ibool compressed;
- dberr_t err;
-
- ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
-
- /* Delete node pointer on father page */
- btr_page_get_father(index, block, mtr, &cursor);
-
- compressed = btr_cur_pessimistic_delete(&err, TRUE, &cursor,
- BTR_CREATE_FLAG, false, mtr);
- ut_a(err == DB_SUCCESS);
-
- if (!compressed) {
- btr_cur_compress_if_useful(&cursor, FALSE, mtr);
- }
-}
-
-/*************************************************************//**
If page is the only on its level, this function moves its records to the
father page, thus reducing the tree height.
@return father block */
@@ -3952,7 +3920,7 @@ retry:
lock_rec_free_all_from_discard_page(block);
lock_mutex_exit();
} else {
- btr_node_ptr_delete(index, block, mtr);
+ btr_cur_node_ptr_delete(&father_cursor, mtr);
if (!dict_table_is_locking_disabled(index->table)) {
lock_update_merge_left(
merge_block, orig_pred, block);
@@ -4225,8 +4193,9 @@ err_exit:
/*************************************************************//**
Discards a page that is the only page on its level. This will empty
the whole B-tree, leaving just an empty root page. This function
-should never be reached, because btr_compress(), which is invoked in
+should almost never be reached, because btr_compress(), which is invoked in
delete operations, calls btr_lift_page_up() to flatten the B-tree. */
+ATTRIBUTE_COLD
static
void
btr_discard_only_page_on_level(
@@ -4331,10 +4300,7 @@ btr_discard_page(
buf_block_t* block;
page_t* page;
rec_t* node_ptr;
-#ifdef UNIV_DEBUG
btr_cur_t parent_cursor;
- bool parent_is_different = false;
-#endif
block = btr_cur_get_block(cursor);
index = btr_cur_get_index(cursor);
@@ -4348,13 +4314,11 @@ btr_discard_page(
MONITOR_INC(MONITOR_INDEX_DISCARD);
-#ifdef UNIV_DEBUG
if (dict_index_is_spatial(index)) {
rtr_page_get_father(index, block, mtr, cursor, &parent_cursor);
} else {
btr_page_get_father(index, block, mtr, &parent_cursor);
}
-#endif
/* Decide the page which will inherit the locks */
@@ -4362,7 +4326,7 @@ btr_discard_page(
right_page_no = btr_page_get_next(buf_block_get_frame(block), mtr);
const page_size_t page_size(index->table->space->flags);
-
+ ut_d(bool parent_is_different = false);
if (left_page_no != FIL_NULL) {
merge_block = btr_block_get(
page_id_t(index->table->space_id, left_page_no),
@@ -4418,15 +4382,9 @@ btr_discard_page(
}
if (dict_index_is_spatial(index)) {
- btr_cur_t father_cursor;
-
- /* Since rtr_node_ptr_delete doesn't contain get father
- node ptr, so, we need to get father node ptr first and then
- delete it. */
- rtr_page_get_father(index, block, mtr, cursor, &father_cursor);
- rtr_node_ptr_delete(&father_cursor, mtr);
+ rtr_node_ptr_delete(&parent_cursor, mtr);
} else {
- btr_node_ptr_delete(index, block, mtr);
+ btr_cur_node_ptr_delete(&parent_cursor, mtr);
}
/* Remove the page from the level list */
@@ -4465,6 +4423,12 @@ btr_discard_page(
we cannot use btr_check_node_ptr() */
ut_ad(parent_is_different
|| btr_check_node_ptr(index, merge_block, mtr));
+
+ if (btr_cur_get_block(&parent_cursor)->page.id.page_no() == index->page
+ && !page_has_siblings(btr_cur_get_page(&parent_cursor))
+ && page_get_n_recs(btr_cur_get_page(&parent_cursor)) == 1) {
+ btr_lift_page_up(index, merge_block, mtr);
+ }
}
#ifdef UNIV_BTR_PRINT
diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc
index 65035fd20e7..1c4fb6f1829 100644
--- a/storage/innobase/btr/btr0cur.cc
+++ b/storage/innobase/btr/btr0cur.cc
@@ -5804,10 +5804,11 @@ discard_page:
on a page, we have to change the parent node pointer
so that it is equal to the new leftmost node pointer
on the page */
-
- btr_node_ptr_delete(index, block, mtr);
+ btr_cur_t cursor;
+ btr_page_get_father(index, block, mtr, &cursor);
+ btr_cur_node_ptr_delete(&cursor, mtr);
const ulint level = btr_page_get_level(page);
-
+ // FIXME: reuse the node_ptr from above
dtuple_t* node_ptr = dict_index_build_node_ptr(
index, next_rec, block->page.id.page_no(),
heap, level);
@@ -5873,6 +5874,23 @@ return_after_reservations:
return(ret);
}
+/** Delete the node pointer in a parent page.
+@param[in,out] parent cursor pointing to parent record
+@param[in,out] mtr mini-transaction */
+void btr_cur_node_ptr_delete(btr_cur_t* parent, mtr_t* mtr)
+{
+ ut_ad(mtr_memo_contains(mtr, btr_cur_get_block(parent),
+ MTR_MEMO_PAGE_X_FIX));
+ dberr_t err;
+ ibool compressed = btr_cur_pessimistic_delete(&err, TRUE, parent,
+ BTR_CREATE_FLAG, false,
+ mtr);
+ ut_a(err == DB_SUCCESS);
+ if (!compressed) {
+ btr_cur_compress_if_useful(parent, FALSE, mtr);
+ }
+}
+
/*******************************************************************//**
Adds path information to the cursor for the current page, for which
the binary search has been performed. */
diff --git a/storage/innobase/btr/btr0defragment.cc b/storage/innobase/btr/btr0defragment.cc
index a649256120c..aa142e15a50 100644
--- a/storage/innobase/btr/btr0defragment.cc
+++ b/storage/innobase/btr/btr0defragment.cc
@@ -483,6 +483,7 @@ btr_defragment_merge_pages(
ULINT_UNDEFINED);
}
}
+ btr_cur_t parent;
if (n_recs_to_move == n_recs) {
/* The whole page is merged with the previous page,
free it. */
@@ -492,7 +493,8 @@ btr_defragment_merge_pages(
btr_level_list_remove(
index->table->space_id,
page_size, from_page, index, mtr);
- btr_node_ptr_delete(index, from_block, mtr);
+ btr_page_get_father(index, from_block, mtr, &parent);
+ btr_cur_node_ptr_delete(&parent, mtr);
/* btr_blob_dbg_remove(from_page, index,
"btr_defragment_n_pages"); */
btr_page_free(index, from_block, mtr);
@@ -510,7 +512,9 @@ btr_defragment_merge_pages(
lock_update_split_and_merge(to_block,
orig_pred,
from_block);
- btr_node_ptr_delete(index, from_block, mtr);
+ // FIXME: reuse the node_ptr!
+ btr_page_get_father(index, from_block, mtr, &parent);
+ btr_cur_node_ptr_delete(&parent, mtr);
rec = page_rec_get_next(
page_get_infimum_rec(from_page));
node_ptr = dict_index_build_node_ptr(
diff --git a/storage/innobase/btr/btr0sea.cc b/storage/innobase/btr/btr0sea.cc
index 9c2dedeef9e..74f9816801d 100644
--- a/storage/innobase/btr/btr0sea.cc
+++ b/storage/innobase/btr/btr0sea.cc
@@ -2,7 +2,7 @@
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
-Copyright (c) 2017, 2018, MariaDB Corporation.
+Copyright (c) 2017, 2019, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h
index b99e7e4c522..139e4add16c 100644
--- a/storage/innobase/include/btr0btr.h
+++ b/storage/innobase/include/btr0btr.h
@@ -2,7 +2,7 @@
Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
-Copyright (c) 2014, 2018, MariaDB Corporation.
+Copyright (c) 2014, 2019, MariaDB Corporation.
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
@@ -557,14 +557,13 @@ btr_set_min_rec_mark(
rec_t* rec, /*!< in/out: record */
mtr_t* mtr) /*!< in: mtr */
MY_ATTRIBUTE((nonnull));
-/*************************************************************//**
-Deletes on the upper level the node pointer to a page. */
-void
-btr_node_ptr_delete(
-/*================*/
- dict_index_t* index, /*!< in: index tree */
- buf_block_t* block, /*!< in: page whose node pointer is deleted */
- mtr_t* mtr) /*!< in: mtr */
+/** Seek to the parent page of a B-tree page.
+@param[in,out] index b-tree
+@param[in] block child page
+@param[in,out] mtr mini-transaction
+@param[out] cursor cursor pointing to the x-latched parent page */
+void btr_page_get_father(dict_index_t* index, buf_block_t* block, mtr_t* mtr,
+ btr_cur_t* cursor)
MY_ATTRIBUTE((nonnull));
#ifdef UNIV_DEBUG
/************************************************************//**
diff --git a/storage/innobase/include/btr0cur.h b/storage/innobase/include/btr0cur.h
index 358f394c5b4..1ddec6b9815 100644
--- a/storage/innobase/include/btr0cur.h
+++ b/storage/innobase/include/btr0cur.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, 2018, MariaDB Corporation.
+Copyright (c) 2017, 2019, MariaDB Corporation.
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
@@ -558,6 +558,11 @@ btr_cur_pessimistic_delete(
bool rollback,/*!< in: performing rollback? */
mtr_t* mtr) /*!< in: mtr */
MY_ATTRIBUTE((nonnull));
+/** Delete the node pointer in a parent page.
+@param[in,out] parent cursor pointing to parent record
+@param[in,out] mtr mini-transaction */
+void btr_cur_node_ptr_delete(btr_cur_t* parent, mtr_t* mtr)
+ MY_ATTRIBUTE((nonnull));
/***********************************************************//**
Parses a redo log record of updating a record in-place.
@return end of log record or NULL */