summaryrefslogtreecommitdiff
path: root/innobase/page/page0page.c
diff options
context:
space:
mode:
Diffstat (limited to 'innobase/page/page0page.c')
-rw-r--r--innobase/page/page0page.c206
1 files changed, 87 insertions, 119 deletions
diff --git a/innobase/page/page0page.c b/innobase/page/page0page.c
index c64a7590b94..aecc2dc4fd2 100644
--- a/innobase/page/page0page.c
+++ b/innobase/page/page0page.c
@@ -75,7 +75,6 @@ page_dir_find_owner_slot(
page_t* page;
page_dir_slot_t* slot;
rec_t* original_rec = rec;
- char err_buf[1000];
ut_ad(page_rec_check(rec));
@@ -93,20 +92,20 @@ page_dir_find_owner_slot(
if (i == 0) {
fprintf(stderr,
- "InnoDB: Probable data corruption on page %lu\n",
+ "InnoDB: Probable data corruption on page %lu\n"
+ "InnoDB: Original record ",
(ulong) buf_frame_get_page_no(page));
- rec_sprintf(err_buf, 900, original_rec);
+ rec_print(stderr, original_rec);
- fprintf(stderr,
- "InnoDB: Original record %s\n"
- "InnoDB: on that page. Steps %lu.\n", err_buf, (ulong) steps);
-
- rec_sprintf(err_buf, 900, rec);
-
- fprintf(stderr,
- "InnoDB: Cannot find the dir slot for record %s\n"
- "InnoDB: on that page!\n", err_buf);
+ fprintf(stderr, "\n"
+ "InnoDB: on that page. Steps %lu.\n", (ulong) steps);
+ fputs(
+ "InnoDB: Cannot find the dir slot for record ",
+ stderr);
+ rec_print(stderr, rec);
+ fputs("\n"
+ "InnoDB: on that page!\n", stderr);
buf_page_print(page);
@@ -1121,8 +1120,8 @@ page_rec_print(
/*===========*/
rec_t* rec)
{
- rec_print(rec);
- printf(
+ rec_print(stderr, rec);
+ fprintf(stderr,
" n_owned: %lu; heap_no: %lu; next rec: %lu\n",
(ulong) rec_get_n_owned(rec),
(ulong) rec_get_heap_no(rec),
@@ -1148,25 +1147,26 @@ page_dir_print(
n = page_dir_get_n_slots(page);
- printf("--------------------------------\n");
- printf("PAGE DIRECTORY\n");
- printf("Page address %lx\n", (ulong)page);
- printf("Directory stack top at offs: %lu; number of slots: %lu\n",
- (ulong)(page_dir_get_nth_slot(page, n - 1) - page), (ulong) n);
+ fprintf(stderr, "--------------------------------\n"
+ "PAGE DIRECTORY\n"
+ "Page address %p\n"
+ "Directory stack top at offs: %lu; number of slots: %lu\n",
+ page, (ulong)(page_dir_get_nth_slot(page, n - 1) - page), (ulong) n);
for (i = 0; i < n; i++) {
slot = page_dir_get_nth_slot(page, i);
if ((i == pr_n) && (i < n - pr_n)) {
- printf(" ... \n");
+ fputs(" ... \n", stderr);
}
if ((i < pr_n) || (i >= n - pr_n)) {
- printf(
+ fprintf(stderr,
"Contents of slot: %lu: n_owned: %lu, rec offs: %lu\n",
(ulong) i, (ulong) page_dir_slot_get_n_owned(slot),
(ulong)(page_dir_slot_get_rec(slot) - page));
}
}
- printf("Total of %lu records\n", (ulong) (2 + page_get_n_recs(page)));
- printf("--------------------------------\n");
+ fprintf(stderr, "Total of %lu records\n"
+ "--------------------------------\n",
+ (ulong) (2 + page_get_n_recs(page)));
}
/*******************************************************************
@@ -1180,21 +1180,20 @@ page_print_list(
ulint pr_n) /* in: print n first and n last entries */
{
page_cur_t cur;
- rec_t* rec;
ulint count;
ulint n_recs;
- printf("--------------------------------\n");
- printf("PAGE RECORD LIST\n");
- printf("Page address %lu\n", (ulong) page);
+ fprintf(stderr,
+ "--------------------------------\n"
+ "PAGE RECORD LIST\n"
+ "Page address %p\n", page);
n_recs = page_get_n_recs(page);
page_cur_set_before_first(page, &cur);
count = 0;
for (;;) {
- rec = (&cur)->rec;
- page_rec_print(rec);
+ page_rec_print(cur.rec);
if (count == pr_n) {
break;
@@ -1207,24 +1206,22 @@ page_print_list(
}
if (n_recs > 2 * pr_n) {
- printf(" ... \n");
+ fputs(" ... \n", stderr);
}
- for (;;) {
- if (page_cur_is_after_last(&cur)) {
- break;
- }
+ while (!page_cur_is_after_last(&cur)) {
page_cur_move_to_next(&cur);
if (count + pr_n >= n_recs) {
- rec = (&cur)->rec;
- page_rec_print(rec);
+ page_rec_print(cur.rec);
}
count++;
}
- printf("Total of %lu records \n", (ulong) (count + 1));
- printf("--------------------------------\n");
+ fprintf(stderr,
+ "Total of %lu records \n"
+ "--------------------------------\n",
+ (ulong) (count + 1));
}
/*******************************************************************
@@ -1235,21 +1232,19 @@ page_header_print(
/*==============*/
page_t* page)
{
- printf("--------------------------------\n");
- printf("PAGE HEADER INFO\n");
- printf("Page address %lx, n records %lu\n", (ulong) page,
- (ulong) page_header_get_field(page, PAGE_N_RECS));
-
- printf("n dir slots %lu, heap top %lu\n",
+ fprintf(stderr,
+ "--------------------------------\n"
+ "PAGE HEADER INFO\n"
+ "Page address %p, n records %lu\n"
+ "n dir slots %lu, heap top %lu\n"
+ "Page n heap %lu, free %lu, garbage %lu\n"
+ "Page last insert %lu, direction %lu, n direction %lu\n",
+ page, (ulong) page_header_get_field(page, PAGE_N_RECS),
(ulong) page_header_get_field(page, PAGE_N_DIR_SLOTS),
- (ulong) page_header_get_field(page, PAGE_HEAP_TOP));
-
- printf("Page n heap %lu, free %lu, garbage %lu\n",
+ (ulong) page_header_get_field(page, PAGE_HEAP_TOP),
(ulong) page_header_get_field(page, PAGE_N_HEAP),
(ulong) page_header_get_field(page, PAGE_FREE),
- (ulong) page_header_get_field(page, PAGE_GARBAGE));
-
- printf("Page last insert %lu, direction %lu, n direction %lu\n",
+ (ulong) page_header_get_field(page, PAGE_GARBAGE),
(ulong) page_header_get_field(page, PAGE_LAST_INSERT),
(ulong) page_header_get_field(page, PAGE_DIRECTION),
(ulong) page_header_get_field(page, PAGE_N_DIRECTION));
@@ -1559,17 +1554,9 @@ page_validate(
ulint n_slots;
ibool ret = FALSE;
ulint i;
- char err_buf[1000];
if (!page_simple_validate(page)) {
- fprintf(stderr,
-"InnoDB: Apparent corruption in page %lu in index %s in table %s\n",
- (ulong) buf_frame_get_page_no(page), index->name,
- index->table_name);
-
- buf_page_print(page);
-
- return(FALSE);
+ goto func_exit2;
}
heap = mem_heap_create(UNIV_PAGE_SIZE);
@@ -1589,10 +1576,13 @@ page_validate(
if (!(page_header_get_ptr(page, PAGE_HEAP_TOP) <=
page_dir_get_nth_slot(page, n_slots - 1))) {
- fprintf(stderr,
-"InnoDB: Record heap and dir overlap on a page in index %s, %lu, %lu\n",
- index->name, (ulong)page_header_get_ptr(page, PAGE_HEAP_TOP),
- (ulong)page_dir_get_nth_slot(page, n_slots - 1));
+
+ fputs("InnoDB: Record heap and dir overlap on a page ",
+ stderr);
+ dict_index_name_print(stderr, index);
+ fprintf(stderr, ", %p, %p\n",
+ page_header_get_ptr(page, PAGE_HEAP_TOP),
+ page_dir_get_nth_slot(page, n_slots - 1));
goto func_exit;
}
@@ -1608,7 +1598,7 @@ page_validate(
page_cur_set_before_first(page, &cur);
for (;;) {
- rec = (&cur)->rec;
+ rec = cur.rec;
if (!page_rec_validate(rec)) {
goto func_exit;
@@ -1618,18 +1608,14 @@ page_validate(
if ((count >= 2) && (!page_cur_is_after_last(&cur))) {
if (!(1 == cmp_rec_rec(rec, old_rec, index))) {
fprintf(stderr,
-"InnoDB: Records in wrong order on page %lu index %s table %s\n",
- (ulong) buf_frame_get_page_no(page),
- index->name,
- index->table_name);
-
- rec_sprintf(err_buf, 900, old_rec);
- fprintf(stderr,
- "InnoDB: previous record %s\n", err_buf);
-
- rec_sprintf(err_buf, 900, rec);
- fprintf(stderr,
- "InnoDB: record %s\n", err_buf);
+ "InnoDB: Records in wrong order on page %lu",
+ (ulong) buf_frame_get_page_no(page));
+ dict_index_name_print(stderr, index);
+ fputs("\nInnoDB: previous record ", stderr);
+ rec_print(stderr, old_rec);
+ fputs("\nInnoDB: record ", stderr);
+ rec_print(stderr, rec);
+ putc('\n', stderr);
goto func_exit;
}
@@ -1647,10 +1633,8 @@ page_validate(
if (!buf[offs + i] == 0) {
/* No other record may overlap this */
- fprintf(stderr,
- "InnoDB: Record overlaps another in index %s \n",
- index->name);
-
+ fputs("InnoDB: Record overlaps another\n",
+ stderr);
goto func_exit;
}
@@ -1661,19 +1645,16 @@ page_validate(
/* This is a record pointed to by a dir slot */
if (rec_get_n_owned(rec) != own_count) {
fprintf(stderr,
- "InnoDB: Wrong owned count %lu, %lu, in index %s\n",
+ "InnoDB: Wrong owned count %lu, %lu\n",
(ulong) rec_get_n_owned(rec),
- (ulong) own_count,
- index->name);
-
+ (ulong) own_count);
goto func_exit;
}
if (page_dir_slot_get_rec(slot) != rec) {
- fprintf(stderr,
- "InnoDB: Dir slot does not point to right rec in %s\n",
- index->name);
-
+ fputs(
+ "InnoDB: Dir slot does not point to right rec\n",
+ stderr);
goto func_exit;
}
@@ -1693,9 +1674,8 @@ page_validate(
if (rec_get_next_offs(rec) < FIL_PAGE_DATA
|| rec_get_next_offs(rec) >= UNIV_PAGE_SIZE) {
fprintf(stderr,
- "InnoDB: Next record offset wrong %lu in index %s\n",
- (ulong) rec_get_next_offs(rec), index->name);
-
+ "InnoDB: Next record offset wrong %lu\n",
+ (ulong) rec_get_next_offs(rec));
goto func_exit;
}
@@ -1706,24 +1686,20 @@ page_validate(
}
if (rec_get_n_owned(rec) == 0) {
- fprintf(stderr,
- "InnoDB: n owned is zero in index %s\n", index->name);
-
+ fputs("InnoDB: n owned is zero\n", stderr);
goto func_exit;
}
if (slot_no != n_slots - 1) {
- fprintf(stderr, "InnoDB: n slots wrong %lu %lu in index %s\n",
- (ulong) slot_no, (ulong) (n_slots - 1), index->name);
+ fprintf(stderr, "InnoDB: n slots wrong %lu %lu\n",
+ (ulong) slot_no, (ulong) (n_slots - 1));
goto func_exit;
}
if (page_header_get_field(page, PAGE_N_RECS) + 2 != count + 1) {
- fprintf(stderr, "InnoDB: n recs wrong %lu %lu in index %s\n",
+ fprintf(stderr, "InnoDB: n recs wrong %lu %lu\n",
(ulong) page_header_get_field(page, PAGE_N_RECS) + 2,
- (ulong) (count + 1),
- index->name);
-
+ (ulong) (count + 1));
goto func_exit;
}
@@ -1749,10 +1725,8 @@ page_validate(
for (i = 0; i < rec_get_size(rec); i++) {
if (buf[offs + i] != 0) {
- fprintf(stderr,
- "InnoDB: Record overlaps another in free list, index %s \n",
- index->name);
-
+ fputs(
+ "InnoDB: Record overlaps another in free list\n", stderr);
goto func_exit;
}
@@ -1763,12 +1737,9 @@ page_validate(
}
if (page_header_get_field(page, PAGE_N_HEAP) != count + 1) {
-
- fprintf(stderr,
- "InnoDB: N heap is wrong %lu %lu in index %s\n",
+ fprintf(stderr, "InnoDB: N heap is wrong %lu %lu\n",
(ulong) page_header_get_field(page, PAGE_N_HEAP),
- (ulong) count + 1,
- index->name);
+ (ulong) count + 1);
goto func_exit;
}
@@ -1778,11 +1749,11 @@ func_exit:
mem_heap_free(heap);
if (ret == FALSE) {
- fprintf(stderr,
-"InnoDB: Apparent corruption in page %lu in index %s in table %s\n",
- (ulong) buf_frame_get_page_no(page), index->name,
- index->table_name);
-
+ func_exit2:
+ fprintf(stderr, "InnoDB: Apparent corruption in page %lu in ",
+ (ulong) buf_frame_get_page_no(page));
+ dict_index_name_print(stderr, index);
+ putc('\n', stderr);
buf_page_print(page);
}
@@ -1800,16 +1771,13 @@ page_find_rec_with_heap_no(
ulint heap_no)/* in: heap number */
{
page_cur_t cur;
- rec_t* rec;
page_cur_set_before_first(page, &cur);
for (;;) {
- rec = (&cur)->rec;
-
- if (rec_get_heap_no(rec) == heap_no) {
+ if (rec_get_heap_no(cur.rec) == heap_no) {
- return(rec);
+ return(cur.rec);
}
if (page_cur_is_after_last(&cur)) {