Commit 72b934e3 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-14126: Detect unexpected emptying of B-tree pages

If an index page becomes empty, btr_page_empty() should be called.
parent a4d0d682
...@@ -173,8 +173,9 @@ page_header_set_field( ...@@ -173,8 +173,9 @@ page_header_set_field(
{ {
ut_ad(page); ut_ad(page);
ut_ad(field <= PAGE_N_RECS); ut_ad(field <= PAGE_N_RECS);
ut_ad(field == PAGE_N_HEAP || val < UNIV_PAGE_SIZE); ut_ad(field != PAGE_N_RECS || val);
ut_ad(field != PAGE_N_HEAP || (val & 0x7fff) < UNIV_PAGE_SIZE); ut_ad(field == PAGE_N_HEAP || val < srv_page_size);
ut_ad(field != PAGE_N_HEAP || (val & 0x7fff) < srv_page_size);
mach_write_to_2(page + PAGE_HEADER + field, val); mach_write_to_2(page + PAGE_HEADER + field, val);
if (page_zip) { if (page_zip) {
......
...@@ -2140,6 +2140,8 @@ page_copy_rec_list_end_to_created_page( ...@@ -2140,6 +2140,8 @@ page_copy_rec_list_end_to_created_page(
rec = page_rec_get_next(rec); rec = page_rec_get_next(rec);
} while (!page_rec_is_supremum(rec)); } while (!page_rec_is_supremum(rec));
ut_ad(n_recs);
if ((slot_index > 0) && (count + 1 if ((slot_index > 0) && (count + 1
+ (PAGE_DIR_SLOT_MAX_N_OWNED + 1) / 2 + (PAGE_DIR_SLOT_MAX_N_OWNED + 1) / 2
<= PAGE_DIR_SLOT_MAX_N_OWNED)) { <= PAGE_DIR_SLOT_MAX_N_OWNED)) {
......
...@@ -1231,6 +1231,7 @@ page_delete_rec_list_end( ...@@ -1231,6 +1231,7 @@ page_delete_rec_list_end(
page_header_set_field(page, NULL, PAGE_GARBAGE, size page_header_set_field(page, NULL, PAGE_GARBAGE, size
+ page_header_get_field(page, PAGE_GARBAGE)); + page_header_get_field(page, PAGE_GARBAGE));
ut_ad(page_get_n_recs(page) > n_recs);
page_header_set_field(page, NULL, PAGE_N_RECS, page_header_set_field(page, NULL, PAGE_N_RECS,
(ulint)(page_get_n_recs(page) - n_recs)); (ulint)(page_get_n_recs(page) - n_recs));
} }
......
...@@ -4448,10 +4448,12 @@ page_zip_dir_delete( ...@@ -4448,10 +4448,12 @@ page_zip_dir_delete(
slot_rec = page_zip_dir_find(page_zip, page_offset(rec)); slot_rec = page_zip_dir_find(page_zip, page_offset(rec));
ut_a(slot_rec); ut_a(slot_rec);
uint16_t n_recs = page_get_n_recs(page);
ut_ad(n_recs);
ut_ad(n_recs > 1 || page_get_page_no(page) == index->page);
/* This could not be done before page_zip_dir_find(). */ /* This could not be done before page_zip_dir_find(). */
page_header_set_field(page, page_zip, PAGE_N_RECS, page_header_set_field(page, page_zip, PAGE_N_RECS,
(ulint)(page_get_n_recs(page) - 1)); n_recs - 1);
if (UNIV_UNLIKELY(!free)) { if (UNIV_UNLIKELY(!free)) {
/* Make the last slot the start of the free list. */ /* Make the last slot the start of the free list. */
......
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