summaryrefslogtreecommitdiff
path: root/innobase/btr
diff options
context:
space:
mode:
authorunknown <marko@hundin.mysql.fi>2004-04-06 16:14:43 +0300
committerunknown <marko@hundin.mysql.fi>2004-04-06 16:14:43 +0300
commit80fe399fee3a7752aecdfc888edfcf56a2be7b0a (patch)
treef7bc427aa7ce4a54802d6e8931ca1dfe64c7bfa8 /innobase/btr
parentd809c4413e9f991bde407690aafdaaa3eaae9232 (diff)
downloadmariadb-git-80fe399fee3a7752aecdfc888edfcf56a2be7b0a.tar.gz
InnoDB: send diagnostic output to stderr or files
instead of stdout or fixed-size memory buffers innobase/btr/btr0btr.c: Output to stderr; quote table and index names innobase/btr/btr0cur.c: Output to stderr; quote table and index names innobase/btr/btr0sea.c: Output to stderr innobase/buf/buf0buf.c: Output to stderr; quote table and index names innobase/buf/buf0flu.c: Output to stderr innobase/buf/buf0lru.c: Output to stderr innobase/buf/buf0rea.c: Output to stderr innobase/data/data0data.c: Remove dtuple_validate() unless #ifdef UNIV_DEBUG Remove unnecessary sprintf() calls Output to stderr innobase/data/data0type.c: Output to stderr innobase/dict/dict0boot.c: Remove dummy call to printf() innobase/dict/dict0crea.c: Output diagnostic information to stream, not to memory innobase/dict/dict0dict.c: Output diagnostics to a file, not to a memory buffer innobase/dict/dict0load.c: Output to stderr; quote table and index names innobase/eval/eval0eval.c: Output to stderr innobase/fil/fil0fil.c: Output to stderr innobase/fsp/fsp0fsp.c: Output to stderr Avoid sprintf() innobase/fut/fut0lst.c: Output to stderr innobase/ha/ha0ha.c: Output to stream, not to memory buffer innobase/ibuf/ibuf0ibuf.c: Output to stderr Avoid sprintf() innobase/include/buf0buf.h: Output to stream, not to memory buffer innobase/include/buf0buf.ic: Use %p for displaying pointers innobase/include/data0data.h: Remove dtuple_sprintf() innobase/include/dict0dict.h: Output to stream, not to memory buffer innobase/include/ha0ha.h: Output to stream, not to memory buffer innobase/include/ibuf0ibuf.h: Output to stream, not to memory buffer innobase/include/lock0lock.h: Output to stream, not to memory buffer innobase/include/log0log.h: Output to stream, not to memory buffer innobase/include/mtr0log.ic: Output to stderr Display pointers with %p innobase/include/os0file.h: Output to stream, not to memory buffer innobase/include/rem0rec.h: Remove rec_sprintf() innobase/include/rem0rec.ic: Output to stderr innobase/include/row0sel.ic: Output to stderr innobase/include/row0upd.ic: Quote table and index names innobase/include/srv0srv.h: Remove srv_sprintf_innodb_monitor() innobase/include/sync0arr.h: Output to stream, not to memory buffer innobase/include/sync0sync.h: Output to stream, not to memory buffer innobase/include/trx0sys.h: Output to stderr innobase/include/trx0trx.h: Output to stream, not to memory buffer innobase/include/ut0ut.h: Remove ut_sprintf_buf() Add ut_print_name(), ut_print_namel() and ut_copy_file() innobase/lock/lock0lock.c: Output to stream, not to memory buffer innobase/log/log0log.c: Output to stderr innobase/log/log0recv.c: Output to stderr innobase/mem/mem0dbg.c: Output to stderr innobase/mtr/mtr0log.c: Display pointers with %p innobase/mtr/mtr0mtr.c: Output to stderr innobase/os/os0file.c: Output to stream, not to memory buffer innobase/os/os0proc.c: Output to stderr innobase/os/os0thread.c: Output to stderr innobase/page/page0cur.c: Output to stderr innobase/page/page0page.c: Avoid sprintf() Output to stderr instead of stdout innobase/pars/pars0opt.c: Output to stderr instead of stdout innobase/rem/rem0rec.c: Remove rec_sprintf() Output to stderr instead of stdout innobase/row/row0ins.c: Output diagnostics to stream instead of memory buffer innobase/row/row0mysql.c: Output to stderr instead of stdout Quote table and index names innobase/row/row0purge.c: Output to stderr instead of stdout innobase/row/row0row.c: Quote table and index names innobase/row/row0sel.c: Output to stderr instead of stdout Quote table and index names innobase/row/row0umod.c: Avoid sprintf() Quote table and index names innobase/row/row0undo.c: Output to stderr instead of stdout innobase/row/row0upd.c: Avoid sprintf() innobase/srv/srv0srv.c: Output to stderr instead of stdout innobase/srv/srv0start.c: Handle srv_monitor_file Make some global variables static innobase/sync/sync0arr.c: Output to stderr instead of stdout Output to stream instead of memory buffer innobase/sync/sync0rw.c: Output to stderr instead of stdout innobase/sync/sync0sync.c: Output to stderr instead of stdout Output to stream instead of memory buffer innobase/trx/trx0purge.c: Output to stderr instead of stdout innobase/trx/trx0rec.c: Quote index and table names Avoid sprintf() innobase/trx/trx0roll.c: Quote identifier names Output to stderr instead of stdout innobase/trx/trx0sys.c: Output to stderr instead of stdout innobase/trx/trx0trx.c: Output to stream instead of memory buffer innobase/trx/trx0undo.c: Output to stderr instead of stdout innobase/ut/ut0ut.c: Declare mysql_get_identifier_quote_char() Remove ut_sprintf_buf() Add ut_print_name() and ut_print_namel() Add ut_copy_file() sql/ha_innodb.cc: innobase_mysql_print_thd(): output to stream, not to memory buffer Add mysql_get_identifier_quote_char() Remove unused function innobase_print_error() Display pointers with %p Buffer InnoDB output via files, not via statically allocated memory
Diffstat (limited to 'innobase/btr')
-rw-r--r--innobase/btr/btr0btr.c258
-rw-r--r--innobase/btr/btr0cur.c88
-rw-r--r--innobase/btr/btr0sea.c30
3 files changed, 195 insertions, 181 deletions
diff --git a/innobase/btr/btr0btr.c b/innobase/btr/btr0btr.c
index 1d22d107b12..2e9de9b39bf 100644
--- a/innobase/btr/btr0btr.c
+++ b/innobase/btr/btr0btr.c
@@ -588,28 +588,29 @@ btr_page_get_father_for_rec(
if (btr_node_ptr_get_child_page_no(node_ptr) !=
buf_frame_get_page_no(page)) {
- fprintf(stderr,
-"InnoDB: Dump of the child page:\n");
+ fputs("InnoDB: Dump of the child page:\n", stderr);
buf_page_print(buf_frame_align(page));
- fprintf(stderr,
-"InnoDB: Dump of the parent page:\n");
+ fputs("InnoDB: Dump of the parent page:\n", stderr);
buf_page_print(buf_frame_align(node_ptr));
- fprintf(stderr,
-"InnoDB: Corruption of an index tree: table %s, index %s,\n"
+ fputs("InnoDB: Corruption of an index tree: table ", stderr);
+ ut_print_name(stderr,
+ UT_LIST_GET_FIRST(tree->tree_indexes)->table_name);
+ fputs(", index ", stderr);
+ ut_print_name(stderr,
+ UT_LIST_GET_FIRST(tree->tree_indexes)->name);
+ fprintf(stderr, ",\n"
"InnoDB: father ptr page no %lu, child page no %lu\n",
- (UT_LIST_GET_FIRST(tree->tree_indexes))->table_name,
- (UT_LIST_GET_FIRST(tree->tree_indexes))->name,
- btr_node_ptr_get_child_page_no(node_ptr),
- buf_frame_get_page_no(page));
+ btr_node_ptr_get_child_page_no(node_ptr),
+ buf_frame_get_page_no(page));
page_rec_print(page_rec_get_next(page_get_infimum_rec(page)));
page_rec_print(node_ptr);
- fprintf(stderr,
+ fputs(
"InnoDB: You should dump + drop + reimport the table to fix the\n"
"InnoDB: corruption. If the crash happens at the database startup, see\n"
-"InnoDB: section 6.1 of http://www.innodb.com/ibman.html about forcing\n"
-"InnoDB: recovery. Then dump + drop + reimport.\n");
+"InnoDB: section 6.1 of http://www.innodb.com/ibman.php about forcing\n"
+"InnoDB: recovery. Then dump + drop + reimport.\n", stderr);
}
ut_a(btr_node_ptr_get_child_page_no(node_ptr) ==
@@ -1050,7 +1051,7 @@ btr_root_raise_and_insert(
/* We play safe and reset the free bits for the new page */
-/* printf("Root raise new page no %lu\n",
+/* fprintf(stderr, "Root raise new page no %lu\n",
buf_frame_get_page_no(new_page)); */
ibuf_reset_free_bits(UT_LIST_GET_FIRST(tree->tree_indexes),
@@ -1599,7 +1600,7 @@ func_start:
/* 5. Move then the records to the new page */
if (direction == FSP_DOWN) {
-/* printf("Split left\n"); */
+/* fputs("Split left\n", stderr); */
page_move_rec_list_start(new_page, page, move_limit, mtr);
left_page = new_page;
@@ -1607,7 +1608,7 @@ func_start:
lock_update_split_left(right_page, left_page);
} else {
-/* printf("Split right\n"); */
+/* fputs("Split right\n", stderr); */
page_move_rec_list_end(new_page, page, move_limit, mtr);
left_page = page;
@@ -1643,7 +1644,7 @@ func_start:
ibuf_update_free_bits_for_two_pages_low(cursor->index,
left_page,
right_page, mtr);
- /* printf("Split and insert done %lu %lu\n",
+ /* fprintf(stderr, "Split and insert done %lu %lu\n",
buf_frame_get_page_no(left_page),
buf_frame_get_page_no(right_page)); */
return(rec);
@@ -1663,7 +1664,7 @@ func_start:
/* We play safe and reset the free bits for new_page */
ibuf_reset_free_bits(cursor->index, new_page);
- /* printf("Split second round %lu\n",
+ /* fprintf(stderr, "Split second round %lu\n",
buf_frame_get_page_no(page)); */
n_iterations++;
ut_ad(n_iterations < 2);
@@ -1677,7 +1678,7 @@ func_start:
ibuf_update_free_bits_for_two_pages_low(cursor->index, left_page,
right_page, mtr);
- /* printf("Split and insert done %lu %lu\n",
+ /* fprintf(stderr, "Split and insert done %lu %lu\n",
buf_frame_get_page_no(left_page),
buf_frame_get_page_no(right_page)); */
@@ -1924,7 +1925,7 @@ btr_compress(
left_page_no = btr_page_get_prev(page, mtr);
right_page_no = btr_page_get_next(page, mtr);
-/* printf("Merge left page %lu right %lu \n", left_page_no,
+/* fprintf(stderr, "Merge left page %lu right %lu \n", left_page_no,
right_page_no); */
node_ptr = btr_page_get_father_node_ptr(tree, page, mtr);
@@ -2174,8 +2175,9 @@ btr_print_size(
mtr_t mtr;
if (tree->type & DICT_IBUF) {
- printf(
- "Sorry, cannot print info of an ibuf tree: use ibuf functions\n");
+ fputs(
+ "Sorry, cannot print info of an ibuf tree: use ibuf functions\n",
+ stderr);
return;
}
@@ -2186,14 +2188,14 @@ btr_print_size(
seg = root + PAGE_HEADER + PAGE_BTR_SEG_TOP;
- printf("INFO OF THE NON-LEAF PAGE SEGMENT\n");
+ fputs("INFO OF THE NON-LEAF PAGE SEGMENT\n", stderr);
fseg_print(seg, &mtr);
if (!(tree->type & DICT_UNIVERSAL)) {
seg = root + PAGE_HEADER + PAGE_BTR_SEG_LEAF;
- printf("INFO OF THE LEAF PAGE SEGMENT\n");
+ fputs("INFO OF THE LEAF PAGE SEGMENT\n", stderr);
fseg_print(seg, &mtr);
}
@@ -2221,7 +2223,7 @@ btr_print_recursive(
ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
MTR_MEMO_PAGE_X_FIX));
- printf("NODE ON LEVEL %lu page number %lu\n",
+ fprintf(stderr, "NODE ON LEVEL %lu page number %lu\n",
btr_page_get_level(page, mtr), buf_frame_get_page_no(page));
page_print(page, width, width);
@@ -2267,8 +2269,8 @@ btr_print_tree(
mtr_t mtr;
page_t* root;
- printf("--------------------------\n");
- printf("INDEX TREE PRINT\n");
+ fputs("--------------------------\n"
+ "INDEX TREE PRINT\n", stderr);
mtr_start(&mtr);
@@ -2325,6 +2327,22 @@ btr_check_node_ptr(
}
/****************************************************************
+Display identification information for a record. */
+static
+void
+btr_index_rec_validate_report(
+/*==========================*/
+ page_t* page, /* in: index page */
+ rec_t* rec, /* in: index record */
+ dict_index_t* index) /* in: index */
+{
+ fputs("InnoDB: Record in ", stderr);
+ dict_index_name_print(stderr, index);
+ fprintf(stderr, ", page %lu, at offset %lu\n",
+ buf_frame_get_page_no(page), (ulint)(rec - page));
+}
+
+/****************************************************************
Checks the size and number of fields in a record based on the definition of
the index. */
@@ -2338,13 +2356,10 @@ btr_index_rec_validate(
should print hex dump of record
and page on error */
{
- dtype_t* type;
- byte* data;
ulint len;
ulint n;
ulint i;
page_t* page;
- char err_buf[1000];
page = buf_frame_align(rec);
@@ -2359,11 +2374,8 @@ btr_index_rec_validate(
n = dict_index_get_n_fields(index);
if (rec_get_n_fields(rec) != n) {
- fprintf(stderr,
-"InnoDB: Record in index %s in table %s, page %lu, at offset %lu\n"
-"InnoDB: has %lu fields, should have %lu\n",
- index->name, index->table_name,
- buf_frame_get_page_no(page), (ulint)(rec - page),
+ btr_index_rec_validate_report(page, rec, index);
+ fprintf(stderr, "InnoDB: has %lu fields, should have %lu\n",
rec_get_n_fields(rec), n);
if (!dump_on_error) {
@@ -2373,16 +2385,17 @@ btr_index_rec_validate(
buf_page_print(page);
- rec_sprintf(err_buf, 900, rec);
- fprintf(stderr, "InnoDB: corrupt record %s\n", err_buf);
+ fputs("InnoDB: corrupt record ", stderr);
+ rec_print(stderr, rec);
+ putc('\n', stderr);
return(FALSE);
}
for (i = 0; i < n; i++) {
- data = rec_get_nth_field(rec, i, &len);
+ dtype_t* type = dict_index_get_nth_type(index, i);
- type = dict_index_get_nth_type(index, i);
+ rec_get_nth_field(rec, i, &len);
if ((dict_index_get_nth_field(index, i)->prefix_len == 0
&& len != UNIV_SQL_NULL && dtype_is_fixed_size(type)
@@ -2393,12 +2406,9 @@ btr_index_rec_validate(
&& len !=
dict_index_get_nth_field(index, i)->prefix_len)) {
+ btr_index_rec_validate_report(page, rec, index);
fprintf(stderr,
-"InnoDB: Record in index %s in table %s, page %lu, at offset %lu\n"
"InnoDB: field %lu len is %lu, should be %lu\n",
- index->name, index->table_name,
- buf_frame_get_page_no(page),
- (ulint)(rec - page),
i, len, dtype_get_fixed_size(type));
if (!dump_on_error) {
@@ -2408,9 +2418,9 @@ btr_index_rec_validate(
buf_page_print(page);
- rec_sprintf(err_buf, 900, rec);
- fprintf(stderr,
- "InnoDB: corrupt record %s\n", err_buf);
+ fputs("InnoDB: corrupt record ", stderr);
+ rec_print(stderr, rec);
+ putc('\n', stderr);
return(FALSE);
}
@@ -2430,7 +2440,6 @@ btr_index_page_validate(
page_t* page, /* in: index page */
dict_index_t* index) /* in: index */
{
- rec_t* rec;
page_cur_t cur;
ibool ret = TRUE;
@@ -2438,14 +2447,12 @@ btr_index_page_validate(
page_cur_move_to_next(&cur);
for (;;) {
- rec = (&cur)->rec;
-
if (page_cur_is_after_last(&cur)) {
break;
}
- if (!btr_index_rec_validate(rec, index, TRUE)) {
+ if (!btr_index_rec_validate(cur.rec, index, TRUE)) {
return(FALSE);
}
@@ -2457,6 +2464,46 @@ btr_index_page_validate(
}
/****************************************************************
+Report an error on one page of an index tree. */
+static
+void
+btr_validate_report1(
+ /* out: TRUE if ok */
+ dict_index_t* index, /* in: index */
+ ulint level, /* in: B-tree level */
+ page_t* page) /* in: index page */
+{
+ fprintf(stderr, "InnoDB: Error in page %lu of ",
+ buf_frame_get_page_no(page));
+ dict_index_name_print(stderr, index);
+ if (level) {
+ fprintf(stderr, ", index tree level %lu", level);
+ }
+ putc('\n', stderr);
+}
+
+/****************************************************************
+Report an error on two pages of an index tree. */
+static
+void
+btr_validate_report2(
+ /* out: TRUE if ok */
+ dict_index_t* index, /* in: index */
+ ulint level, /* in: B-tree level */
+ page_t* page1, /* in: first index page */
+ page_t* page2) /* in: second index page */
+{
+ fprintf(stderr, "InnoDB: Error in pages %lu and %lu of ",
+ buf_frame_get_page_no(page1),
+ buf_frame_get_page_no(page2));
+ dict_index_name_print(stderr, index);
+ if (level) {
+ fprintf(stderr, ", index tree level %lu", level);
+ }
+ putc('\n', stderr);
+}
+
+/****************************************************************
Validates index tree level. */
static
ibool
@@ -2481,7 +2528,6 @@ btr_validate_level(
ibool ret = TRUE;
dict_index_t* index;
mtr_t mtr;
- char err_buf[1000];
mtr_start(&mtr);
@@ -2512,10 +2558,7 @@ loop:
/* Check ordering etc. of records */
if (!page_validate(page, index)) {
- fprintf(stderr,
-"InnoDB: Error in page %lu in index %s table %s, index tree level %lu\n",
- buf_frame_get_page_no(page), index->name,
- index->table_name, level);
+ btr_validate_report1(index, level, page);
ret = FALSE;
} else if (level == 0) {
@@ -2545,25 +2588,22 @@ loop:
page_rec_get_next(page_get_infimum_rec(right_page)),
UT_LIST_GET_FIRST(tree->tree_indexes)) >= 0) {
- fprintf(stderr,
- "InnoDB: Error on pages %lu and %lu in index %s table %s\n",
- buf_frame_get_page_no(page),
- right_page_no,
- index->name, index->table_name);
+ btr_validate_report2(index, level, page, right_page);
- fprintf(stderr,
- "InnoDB: records in wrong order on adjacent pages\n");
+ fputs("InnoDB: records in wrong order"
+ " on adjacent pages\n", stderr);
buf_page_print(page);
buf_page_print(right_page);
- rec_sprintf(err_buf, 900,
- page_rec_get_prev(page_get_supremum_rec(page)));
- fprintf(stderr, "InnoDB: record %s\n", err_buf);
-
- rec_sprintf(err_buf, 900,
- page_rec_get_next(page_get_infimum_rec(right_page)));
- fprintf(stderr, "InnoDB: record %s\n", err_buf);
+ fputs("InnoDB: record ", stderr);
+ rec_print(stderr, page_rec_get_prev(
+ page_get_supremum_rec(page)));
+ putc('\n', stderr);
+ fputs("InnoDB: record ", stderr);
+ rec_print(stderr, page_rec_get_next(
+ page_get_infimum_rec(right_page)));
+ putc('\n', stderr);
ret = FALSE;
}
@@ -2586,32 +2626,27 @@ loop:
|| node_ptr != btr_page_get_father_for_rec(tree, page,
page_rec_get_prev(page_get_supremum_rec(page)),
&mtr)) {
- fprintf(stderr,
- "InnoDB: Error on page %lu in index %s table %s\n",
- buf_frame_get_page_no(page),
- index->name, index->table_name);
+ btr_validate_report1(index, level, page);
- fprintf(stderr,
- "InnoDB: node pointer to the page is wrong\n");
+ fputs("InnoDB: node pointer to the page is wrong\n",
+ stderr);
buf_page_print(father_page);
buf_page_print(page);
- rec_sprintf(err_buf, 900, node_ptr);
-
- fprintf(stderr, "InnoDB: node ptr %s\n", err_buf);
+ fputs("InnoDB: node ptr ", stderr);
+ rec_print(stderr, node_ptr);
- fprintf(stderr,
+ fprintf(stderr, "\n"
"InnoDB: node ptr child page n:o %lu\n",
btr_node_ptr_get_child_page_no(node_ptr));
- rec_sprintf(err_buf, 900,
+ fputs("InnoDB: record on page ", stderr);
+ rec_print(stderr,
btr_page_get_father_for_rec(tree, page,
page_rec_get_prev(page_get_supremum_rec(page)),
&mtr));
-
- fprintf(stderr, "InnoDB: record on page %s\n",
- err_buf);
+ putc('\n', stderr);
ret = FALSE;
goto node_ptr_fails;
@@ -2629,27 +2664,19 @@ loop:
if (cmp_dtuple_rec(node_ptr_tuple, node_ptr) != 0) {
- fprintf(stderr,
- "InnoDB: Error on page %lu in index %s table %s\n",
- buf_frame_get_page_no(page),
- index->name, index->table_name);
+ btr_validate_report1(index, level, page);
buf_page_print(father_page);
buf_page_print(page);
- fprintf(stderr,
- "InnoDB: Error: node ptrs differ on levels > 0\n");
-
- rec_sprintf(err_buf, 900, node_ptr);
-
- fprintf(stderr, "InnoDB: node ptr %s\n",
- err_buf);
- rec_sprintf(err_buf, 900,
- page_rec_get_next(
+ fputs("InnoDB: Error: node ptrs differ"
+ " on levels > 0\n"
+ "InnoDB: node ptr ", stderr);
+ rec_print(stderr, node_ptr);
+ fputs("InnoDB: first rec ", stderr);
+ rec_print(stderr, page_rec_get_next(
page_get_infimum_rec(page)));
-
- fprintf(stderr, "InnoDB: first rec %s\n",
- err_buf);
+ putc('\n', stderr);
ret = FALSE;
mem_heap_free(heap);
@@ -2681,13 +2708,12 @@ loop:
if (right_node_ptr !=
page_rec_get_next(node_ptr)) {
ret = FALSE;
- fprintf(stderr,
- "InnoDB: node pointer to the right page is wrong\n");
+ fputs(
+ "InnoDB: node pointer to the right page is wrong\n",
+ stderr);
- fprintf(stderr,
- "InnoDB: Error on page %lu in index %s table %s\n",
- buf_frame_get_page_no(page),
- index->name, index->table_name);
+ btr_validate_report1(index, level,
+ page);
buf_page_print(father_page);
buf_page_print(page);
@@ -2701,13 +2727,12 @@ loop:
page_get_infimum_rec(
right_father_page))) {
ret = FALSE;
- fprintf(stderr,
- "InnoDB: node pointer 2 to the right page is wrong\n");
+ fputs(
+ "InnoDB: node pointer 2 to the right page is wrong\n",
+ stderr);
- fprintf(stderr,
- "InnoDB: Error on page %lu in index %s table %s\n",
- buf_frame_get_page_no(page),
- index->name, index->table_name);
+ btr_validate_report1(index, level,
+ page);
buf_page_print(father_page);
buf_page_print(right_father_page);
@@ -2719,13 +2744,12 @@ loop:
!= btr_page_get_next(father_page, &mtr)) {
ret = FALSE;
- fprintf(stderr,
- "InnoDB: node pointer 3 to the right page is wrong\n");
+ fputs(
+ "InnoDB: node pointer 3 to the right page is wrong\n",
+ stderr);
- fprintf(stderr,
- "InnoDB: Error on page %lu in index %s table %s\n",
- buf_frame_get_page_no(page),
- index->name, index->table_name);
+ btr_validate_report1(index, level,
+ page);
buf_page_print(father_page);
buf_page_print(right_father_page);
diff --git a/innobase/btr/btr0cur.c b/innobase/btr/btr0cur.c
index c7863ba08e4..8974200efe8 100644
--- a/innobase/btr/btr0cur.c
+++ b/innobase/btr/btr0cur.c
@@ -831,6 +831,24 @@ btr_cur_ins_lock_and_undo(
}
/*****************************************************************
+Report information about a transaction. */
+static
+void
+btr_cur_trx_report(
+/*===============*/
+ const trx_t* trx, /* in: transaction */
+ const dict_index_t* index, /* in: index */
+ const char* op) /* in: operation */
+{
+ fprintf(stderr, "Trx with id %lu %lu going to ",
+ ut_dulint_get_high(trx->id),
+ ut_dulint_get_low(trx->id));
+ fputs(op, stderr);
+ dict_index_name_print(stderr, index);
+ putc('\n', stderr);
+}
+
+/*****************************************************************
Tries to perform an insert to a page in an index tree, next to cursor.
It is assumed that mtr holds an x-latch on the page. The operation does
not succeed if there is too little space on the page. If there is just
@@ -877,18 +895,13 @@ btr_cur_optimistic_insert(
index = cursor->index;
if (!dtuple_check_typed_no_assert(entry)) {
- fprintf(stderr,
-"InnoDB: Error in a tuple to insert into table %s index %s\n",
- index->table_name, index->name);
+ fputs("InnoDB: Error in a tuple to insert into ", stderr);
+ dict_index_name_print(stderr, index);
}
if (btr_cur_print_record_ops && thr) {
- printf(
- "Trx with id %lu %lu going to insert to table %s index %s\n",
- ut_dulint_get_high(thr_get_trx(thr)->id),
- ut_dulint_get_low(thr_get_trx(thr)->id),
- index->table_name, index->name);
- dtuple_print(entry);
+ btr_cur_trx_report(thr_get_trx(thr), index, "insert into ");
+ dtuple_print(stderr, entry);
}
ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
@@ -981,20 +994,15 @@ calculate_sizes_again:
*rec = page_cur_tuple_insert(page_cursor, entry, mtr);
- if (!(*rec)) {
- char* err_buf = mem_alloc(1000);
-
- dtuple_sprintf(err_buf, 900, entry);
-
- fprintf(stderr,
- "InnoDB: Error: cannot insert tuple %s to index %s of table %s\n"
- "InnoDB: max insert size %lu\n",
- err_buf, index->name, index->table->name, max_size);
-
- mem_free(err_buf);
+ if (!*rec) {
+ fputs("InnoDB: Error: cannot insert tuple ", stderr);
+ dtuple_print(stderr, entry);
+ fputs(" into ", stderr);
+ dict_index_name_print(stderr, index);
+ fprintf(stderr, "\nInnoDB: max insert size %lu\n",
+ max_size);
+ ut_error;
}
-
- ut_a(*rec); /* <- We calculated above the record would fit */
}
#ifdef BTR_CUR_HASH_ADAPT
@@ -1010,7 +1018,8 @@ calculate_sizes_again:
lock_update_insert(*rec);
}
-/* printf("Insert to page %lu, max ins size %lu, rec %lu ind type %lu\n",
+/* fprintf(stderr, "Insert into page %lu, max ins size %lu,"
+ " rec %lu ind type %lu\n",
buf_frame_get_page_no(page), max_size,
rec_size + PAGE_DIR_SLOT_SIZE, type);
*/
@@ -1361,12 +1370,8 @@ btr_cur_update_in_place(
trx = thr_get_trx(thr);
if (btr_cur_print_record_ops && thr) {
- printf(
- "Trx with id %lu %lu going to update table %s index %s\n",
- ut_dulint_get_high(thr_get_trx(thr)->id),
- ut_dulint_get_low(thr_get_trx(thr)->id),
- index->table_name, index->name);
- rec_print(rec);
+ btr_cur_trx_report(trx, index, "update ");
+ rec_print(stderr, rec);
}
/* Do lock checking and undo logging */
@@ -1465,12 +1470,8 @@ btr_cur_optimistic_update(
index = cursor->index;
if (btr_cur_print_record_ops && thr) {
- printf(
- "Trx with id %lu %lu going to update table %s index %s\n",
- ut_dulint_get_high(thr_get_trx(thr)->id),
- ut_dulint_get_low(thr_get_trx(thr)->id),
- index->table_name, index->name);
- rec_print(rec);
+ btr_cur_trx_report(thr_get_trx(thr), index, "update ");
+ rec_print(stderr, rec);
}
ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
@@ -2012,12 +2013,8 @@ btr_cur_del_mark_set_clust_rec(
index = cursor->index;
if (btr_cur_print_record_ops && thr) {
- printf(
- "Trx with id %lu %lu going to del mark table %s index %s\n",
- ut_dulint_get_high(thr_get_trx(thr)->id),
- ut_dulint_get_low(thr_get_trx(thr)->id),
- index->table_name, index->name);
- rec_print(rec);
+ btr_cur_trx_report(thr_get_trx(thr), index, "del mark ");
+ rec_print(stderr, rec);
}
ut_ad(index->type & DICT_CLUSTERED);
@@ -2152,12 +2149,9 @@ btr_cur_del_mark_set_sec_rec(
rec = btr_cur_get_rec(cursor);
if (btr_cur_print_record_ops && thr) {
- printf(
- "Trx with id %lu %lu going to del mark table %s index %s\n",
- ut_dulint_get_high(thr_get_trx(thr)->id),
- ut_dulint_get_low(thr_get_trx(thr)->id),
- cursor->index->table_name, cursor->index->name);
- rec_print(rec);
+ btr_cur_trx_report(thr_get_trx(thr), cursor->index,
+ "del mark ");
+ rec_print(stderr, rec);
}
err = lock_sec_rec_modify_check_and_lock(flags, rec, cursor->index,
diff --git a/innobase/btr/btr0sea.c b/innobase/btr/btr0sea.c
index f629dea74de..e01ce94dc97 100644
--- a/innobase/btr/btr0sea.c
+++ b/innobase/btr/btr0sea.c
@@ -803,7 +803,7 @@ btr_search_guess_on_hash(
success = FALSE;
/*
- printf("Tree id %lu, page index id %lu fold %lu\n",
+ fprintf(stderr, "Tree id %lu, page index id %lu fold %lu\n",
ut_dulint_get_low(tree_id),
ut_dulint_get_low(btr_page_get_index_id(page)),
fold);
@@ -1045,7 +1045,7 @@ btr_search_drop_page_hash_when_freed(
/* We assume that if the caller has a latch on the page,
then the caller has already dropped the hash index for the page,
and we never get here. Therefore we can acquire the s-latch to
- the page without fearing a deadlock. */
+ the page without having to fear a deadlock. */
page = buf_page_get(space, page_no, RW_S_LATCH, &mtr);
@@ -1515,8 +1515,9 @@ check_next_rec:
ha_insert_for_fold(table, ins_fold, ins_rec);
/*
- printf("Hash insert for %s, fold %lu\n",
- cursor->index->name, ins_fold);
+ fputs("Hash insert for ", stderr);
+ dict_index_name_print(stderr, cursor->index);
+ fprintf(stderr, " fold %lu\n", ins_fold);
*/
} else {
ha_insert_for_fold(table, next_fold, next_rec);
@@ -1543,7 +1544,6 @@ btr_search_validate(void)
ulint n_page_dumps = 0;
ibool ok = TRUE;
ulint i;
- char rec_str[500];
rw_lock_x_lock(&btr_search_latch);
@@ -1564,9 +1564,9 @@ btr_search_validate(void)
fprintf(stderr,
" InnoDB: Error in an adaptive hash index pointer to page %lu\n"
-"ptr mem address %lu index id %lu %lu, node fold %lu, rec fold %lu\n",
- buf_frame_get_page_no(page),
- (ulint)(node->data),
+"ptr mem address %p index id %lu %lu, node fold %lu, rec fold %lu\n",
+ buf_frame_get_page_no(page),
+ node->data,
ut_dulint_get_high(btr_page_get_index_id(page)),
ut_dulint_get_low(btr_page_get_index_id(page)),
node->fold, rec_fold((rec_t*)(node->data),
@@ -1574,16 +1574,12 @@ btr_search_validate(void)
block->curr_n_bytes,
btr_page_get_index_id(page)));
- rec_sprintf(rec_str, 450, (rec_t*)(node->data));
-
- fprintf(stderr,
- "InnoDB: Record %s\n"
- "InnoDB: on that page.", rec_str);
-
- fprintf(stderr,
-"Page mem address %lu, is hashed %lu, n fields %lu, n bytes %lu\n"
+ fputs("InnoDB: Record ", stderr);
+ rec_print(stderr, (rec_t*)(node->data));
+ fprintf(stderr, "\nInnoDB: on that page."
+"Page mem address %p, is hashed %lu, n fields %lu, n bytes %lu\n"
"side %lu\n",
- (ulint)page, block->is_hashed, block->curr_n_fields,
+ page, block->is_hashed, block->curr_n_fields,
block->curr_n_bytes, block->curr_side);
if (n_page_dumps < 20) {