summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorJan Lindström <jan.lindstrom@mariadb.com>2016-09-26 12:29:31 +0300
committerJan Lindström <jan.lindstrom@mariadb.com>2016-09-27 07:54:27 +0300
commit452e84952228a290b3c1fb16a8f60e2990aa8710 (patch)
treefdfac1ee276f6da64eff7a2a4385794649ed271e /storage
parent4e2a0c34b02dd556c2a521555662ed993cdc66a6 (diff)
downloadmariadb-git-452e84952228a290b3c1fb16a8f60e2990aa8710.tar.gz
MDEV-10886: encryption.innodb-bad-key-change fails (crashes) in buildbot
Problem was that NULL-pointer was accessed inside a macro when page read from tablespace is encrypted but decrypt fails because of incorrect key file. Removed unsafe macro using inlined function where used pointers are checked.
Diffstat (limited to 'storage')
-rw-r--r--storage/innobase/btr/btr0cur.cc9
-rw-r--r--storage/innobase/btr/btr0scrub.cc20
-rw-r--r--storage/innobase/ibuf/ibuf0ibuf.cc14
-rw-r--r--storage/innobase/include/btr0btr.h14
-rw-r--r--storage/innobase/include/btr0btr.ic32
-rw-r--r--storage/xtradb/btr/btr0cur.cc9
-rw-r--r--storage/xtradb/btr/btr0scrub.cc20
-rw-r--r--storage/xtradb/ibuf/ibuf0ibuf.cc14
-rw-r--r--storage/xtradb/include/btr0btr.h14
-rw-r--r--storage/xtradb/include/btr0btr.ic32
10 files changed, 148 insertions, 30 deletions
diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc
index eca232d81b4..18f193094e2 100644
--- a/storage/innobase/btr/btr0cur.cc
+++ b/storage/innobase/btr/btr0cur.cc
@@ -2138,9 +2138,12 @@ func_exit:
if (page_zip
&& !(flags & BTR_KEEP_IBUF_BITMAP)
&& !dict_index_is_clust(index)
- && page_is_leaf(buf_block_get_frame(block))) {
- /* Update the free bits in the insert buffer. */
- ibuf_update_free_bits_zip(block, mtr);
+ && block) {
+ buf_frame_t* frame = buf_block_get_frame(block);
+ if (frame && page_is_leaf(frame)) {
+ /* Update the free bits in the insert buffer. */
+ ibuf_update_free_bits_zip(block, mtr);
+ }
}
return(err);
diff --git a/storage/innobase/btr/btr0scrub.cc b/storage/innobase/btr/btr0scrub.cc
index e6acb7802f1..62a41d19768 100644
--- a/storage/innobase/btr/btr0scrub.cc
+++ b/storage/innobase/btr/btr0scrub.cc
@@ -368,12 +368,17 @@ btr_optimistic_scrub(
/* We play safe and reset the free bits */
if (!dict_index_is_clust(index) &&
- page_is_leaf(buf_block_get_frame(block))) {
+ block != NULL) {
+ buf_frame_t* frame = buf_block_get_frame(block);
+ if (frame &&
+ page_is_leaf(frame)) {
ibuf_reset_free_bits(block);
+ }
}
scrub_data->scrub_stat.page_reorganizations++;
+
return DB_SUCCESS;
}
@@ -488,9 +493,13 @@ btr_pessimistic_scrub(
/* We play safe and reset the free bits
* NOTE: need to call this prior to btr_page_split_and_insert */
if (!dict_index_is_clust(index) &&
- page_is_leaf(buf_block_get_frame(block))) {
+ block != NULL) {
+ buf_frame_t* frame = buf_block_get_frame(block);
+ if (frame &&
+ page_is_leaf(frame)) {
- ibuf_reset_free_bits(block);
+ ibuf_reset_free_bits(block);
+ }
}
rec = btr_page_split_and_insert(
@@ -788,11 +797,8 @@ btr_scrub_page(
return BTR_SCRUB_SKIP_PAGE_AND_CLOSE_TABLE;
}
- buf_frame_t* frame = NULL;
+ buf_frame_t* frame = buf_block_get_frame(block);
- if (block) {
- frame = buf_block_get_frame(block);
- }
if (!frame || btr_page_get_index_id(frame) !=
scrub_data->current_index->id) {
/* page has been reallocated to new index */
diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc
index 0a2140c4a29..fcf0388d80a 100644
--- a/storage/innobase/ibuf/ibuf0ibuf.cc
+++ b/storage/innobase/ibuf/ibuf0ibuf.cc
@@ -915,9 +915,15 @@ ibuf_set_free_bits_low(
page_t* bitmap_page;
ulint space;
ulint page_no;
+ buf_frame_t* frame;
- if (!page_is_leaf(buf_block_get_frame(block))) {
+ if (!block) {
+ return;
+ }
+
+ frame = buf_block_get_frame(block);
+ if (!frame || !page_is_leaf(frame)) {
return;
}
@@ -1091,7 +1097,11 @@ ibuf_update_free_bits_zip(
page_no = buf_block_get_page_no(block);
zip_size = buf_block_get_zip_size(block);
- ut_a(page_is_leaf(buf_block_get_frame(block)));
+ ut_a(block);
+
+ buf_frame_t* frame = buf_block_get_frame(block);
+
+ ut_a(frame && page_is_leaf(frame));
ut_a(zip_size);
bitmap_page = ibuf_bitmap_get_map_page(space, page_no, zip_size, mtr);
diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h
index bf3f4a76301..a1882cdd0ad 100644
--- a/storage/innobase/include/btr0btr.h
+++ b/storage/innobase/include/btr0btr.h
@@ -295,9 +295,17 @@ btr_block_get_func(
@param idx index tree, may be NULL if not the insert buffer tree
@param mtr mini-transaction handle
@return the uncompressed page frame */
-# define btr_page_get(space,zip_size,page_no,mode,idx,mtr) \
- buf_block_get_frame(btr_block_get(space,zip_size,page_no, \
- mode,idx,mtr))
+UNIV_INLINE
+page_t*
+btr_page_get(
+/*=========*/
+ ulint space,
+ ulint zip_size,
+ ulint root_page_no,
+ ulint mode,
+ dict_index_t* index,
+ mtr_t* mtr)
+ MY_ATTRIBUTE((warn_unused_result));
#endif /* !UNIV_HOTBACKUP */
/**************************************************************//**
Gets the index id field of a page.
diff --git a/storage/innobase/include/btr0btr.ic b/storage/innobase/include/btr0btr.ic
index e9410310213..5acbee1751e 100644
--- a/storage/innobase/include/btr0btr.ic
+++ b/storage/innobase/include/btr0btr.ic
@@ -98,6 +98,38 @@ btr_page_set_index_id(
mlog_write_ull(page + (PAGE_HEADER + PAGE_INDEX_ID), id, mtr);
}
}
+
+/** Gets a buffer page and declares its latching order level.
+@param space tablespace identifier
+@param zip_size compressed page size in bytes or 0 for uncompressed pages
+@param page_no page number
+@param mode latch mode
+@param idx index tree, may be NULL if not the insert buffer tree
+@param mtr mini-transaction handle
+@return the uncompressed page frame */
+UNIV_INLINE
+page_t*
+btr_page_get(
+/*=========*/
+ ulint space,
+ ulint zip_size,
+ ulint root_page_no,
+ ulint mode,
+ dict_index_t* index,
+ mtr_t* mtr)
+{
+ buf_block_t* block=NULL;
+ buf_frame_t* frame=NULL;
+
+ block = btr_block_get(space, zip_size, root_page_no, mode, index, mtr);
+
+ if (block) {
+ frame = buf_block_get_frame(block);
+ }
+
+ return ((page_t*)frame);
+}
+
#endif /* !UNIV_HOTBACKUP */
/**************************************************************//**
diff --git a/storage/xtradb/btr/btr0cur.cc b/storage/xtradb/btr/btr0cur.cc
index 0d117e644d0..5449397f832 100644
--- a/storage/xtradb/btr/btr0cur.cc
+++ b/storage/xtradb/btr/btr0cur.cc
@@ -2281,9 +2281,12 @@ func_exit:
if (page_zip
&& !(flags & BTR_KEEP_IBUF_BITMAP)
&& !dict_index_is_clust(index)
- && page_is_leaf(buf_block_get_frame(block))) {
- /* Update the free bits in the insert buffer. */
- ibuf_update_free_bits_zip(block, mtr);
+ && block) {
+ buf_frame_t* frame = buf_block_get_frame(block);
+ if (frame && page_is_leaf(frame)) {
+ /* Update the free bits in the insert buffer. */
+ ibuf_update_free_bits_zip(block, mtr);
+ }
}
return(err);
diff --git a/storage/xtradb/btr/btr0scrub.cc b/storage/xtradb/btr/btr0scrub.cc
index e6acb7802f1..62a41d19768 100644
--- a/storage/xtradb/btr/btr0scrub.cc
+++ b/storage/xtradb/btr/btr0scrub.cc
@@ -368,12 +368,17 @@ btr_optimistic_scrub(
/* We play safe and reset the free bits */
if (!dict_index_is_clust(index) &&
- page_is_leaf(buf_block_get_frame(block))) {
+ block != NULL) {
+ buf_frame_t* frame = buf_block_get_frame(block);
+ if (frame &&
+ page_is_leaf(frame)) {
ibuf_reset_free_bits(block);
+ }
}
scrub_data->scrub_stat.page_reorganizations++;
+
return DB_SUCCESS;
}
@@ -488,9 +493,13 @@ btr_pessimistic_scrub(
/* We play safe and reset the free bits
* NOTE: need to call this prior to btr_page_split_and_insert */
if (!dict_index_is_clust(index) &&
- page_is_leaf(buf_block_get_frame(block))) {
+ block != NULL) {
+ buf_frame_t* frame = buf_block_get_frame(block);
+ if (frame &&
+ page_is_leaf(frame)) {
- ibuf_reset_free_bits(block);
+ ibuf_reset_free_bits(block);
+ }
}
rec = btr_page_split_and_insert(
@@ -788,11 +797,8 @@ btr_scrub_page(
return BTR_SCRUB_SKIP_PAGE_AND_CLOSE_TABLE;
}
- buf_frame_t* frame = NULL;
+ buf_frame_t* frame = buf_block_get_frame(block);
- if (block) {
- frame = buf_block_get_frame(block);
- }
if (!frame || btr_page_get_index_id(frame) !=
scrub_data->current_index->id) {
/* page has been reallocated to new index */
diff --git a/storage/xtradb/ibuf/ibuf0ibuf.cc b/storage/xtradb/ibuf/ibuf0ibuf.cc
index dc6ad49838e..13597d38433 100644
--- a/storage/xtradb/ibuf/ibuf0ibuf.cc
+++ b/storage/xtradb/ibuf/ibuf0ibuf.cc
@@ -956,9 +956,15 @@ ibuf_set_free_bits_low(
page_t* bitmap_page;
ulint space;
ulint page_no;
+ buf_frame_t* frame;
- if (!page_is_leaf(buf_block_get_frame(block))) {
+ if (!block) {
+ return;
+ }
+
+ frame = buf_block_get_frame(block);
+ if (!frame || !page_is_leaf(frame)) {
return;
}
@@ -1132,7 +1138,11 @@ ibuf_update_free_bits_zip(
page_no = buf_block_get_page_no(block);
zip_size = buf_block_get_zip_size(block);
- ut_a(page_is_leaf(buf_block_get_frame(block)));
+ ut_a(block);
+
+ buf_frame_t* frame = buf_block_get_frame(block);
+
+ ut_a(frame && page_is_leaf(frame));
ut_a(zip_size);
bitmap_page = ibuf_bitmap_get_map_page(space, page_no, zip_size, mtr);
diff --git a/storage/xtradb/include/btr0btr.h b/storage/xtradb/include/btr0btr.h
index 5047d1b2d4e..9ab62f7739f 100644
--- a/storage/xtradb/include/btr0btr.h
+++ b/storage/xtradb/include/btr0btr.h
@@ -298,9 +298,17 @@ btr_block_get_func(
@param idx index tree, may be NULL if not the insert buffer tree
@param mtr mini-transaction handle
@return the uncompressed page frame */
-# define btr_page_get(space,zip_size,page_no,mode,idx,mtr) \
- buf_block_get_frame(btr_block_get(space,zip_size,page_no, \
- mode,idx,mtr))
+UNIV_INLINE
+page_t*
+btr_page_get(
+/*=========*/
+ ulint space,
+ ulint zip_size,
+ ulint root_page_no,
+ ulint mode,
+ dict_index_t* index,
+ mtr_t* mtr)
+ MY_ATTRIBUTE((warn_unused_result));
#endif /* !UNIV_HOTBACKUP */
/**************************************************************//**
Gets the index id field of a page.
diff --git a/storage/xtradb/include/btr0btr.ic b/storage/xtradb/include/btr0btr.ic
index 34e0d36e230..62a24873482 100644
--- a/storage/xtradb/include/btr0btr.ic
+++ b/storage/xtradb/include/btr0btr.ic
@@ -98,6 +98,38 @@ btr_page_set_index_id(
mlog_write_ull(page + (PAGE_HEADER + PAGE_INDEX_ID), id, mtr);
}
}
+
+/** Gets a buffer page and declares its latching order level.
+@param space tablespace identifier
+@param zip_size compressed page size in bytes or 0 for uncompressed pages
+@param page_no page number
+@param mode latch mode
+@param idx index tree, may be NULL if not the insert buffer tree
+@param mtr mini-transaction handle
+@return the uncompressed page frame */
+UNIV_INLINE
+page_t*
+btr_page_get(
+/*=========*/
+ ulint space,
+ ulint zip_size,
+ ulint root_page_no,
+ ulint mode,
+ dict_index_t* index,
+ mtr_t* mtr)
+{
+ buf_block_t* block=NULL;
+ buf_frame_t* frame=NULL;
+
+ block = btr_block_get(space, zip_size, root_page_no, mode, index, mtr);
+
+ if (block) {
+ frame = buf_block_get_frame(block);
+ }
+
+ return ((page_t*)frame);
+}
+
#endif /* !UNIV_HOTBACKUP */
/**************************************************************//**