1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

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
This commit is contained in:
unknown
2004-04-06 16:14:43 +03:00
parent d809c4413e
commit 80fe399fee
73 changed files with 2235 additions and 2570 deletions

View File

@ -588,28 +588,29 @@ btr_page_get_father_for_rec(
if (btr_node_ptr_get_child_page_no(node_ptr) != if (btr_node_ptr_get_child_page_no(node_ptr) !=
buf_frame_get_page_no(page)) { buf_frame_get_page_no(page)) {
fprintf(stderr, fputs("InnoDB: Dump of the child page:\n", stderr);
"InnoDB: Dump of the child page:\n");
buf_page_print(buf_frame_align(page)); buf_page_print(buf_frame_align(page));
fprintf(stderr, fputs("InnoDB: Dump of the parent page:\n", stderr);
"InnoDB: Dump of the parent page:\n");
buf_page_print(buf_frame_align(node_ptr)); buf_page_print(buf_frame_align(node_ptr));
fprintf(stderr, fputs("InnoDB: Corruption of an index tree: table ", stderr);
"InnoDB: Corruption of an index tree: table %s, index %s,\n" 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", "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), btr_node_ptr_get_child_page_no(node_ptr),
buf_frame_get_page_no(page)); buf_frame_get_page_no(page));
page_rec_print(page_rec_get_next(page_get_infimum_rec(page))); page_rec_print(page_rec_get_next(page_get_infimum_rec(page)));
page_rec_print(node_ptr); page_rec_print(node_ptr);
fprintf(stderr, fputs(
"InnoDB: You should dump + drop + reimport the table to fix the\n" "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: 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: section 6.1 of http://www.innodb.com/ibman.php about forcing\n"
"InnoDB: recovery. Then dump + drop + reimport.\n"); "InnoDB: recovery. Then dump + drop + reimport.\n", stderr);
} }
ut_a(btr_node_ptr_get_child_page_no(node_ptr) == 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 */ /* 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)); */ buf_frame_get_page_no(new_page)); */
ibuf_reset_free_bits(UT_LIST_GET_FIRST(tree->tree_indexes), 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 */ /* 5. Move then the records to the new page */
if (direction == FSP_DOWN) { if (direction == FSP_DOWN) {
/* printf("Split left\n"); */ /* fputs("Split left\n", stderr); */
page_move_rec_list_start(new_page, page, move_limit, mtr); page_move_rec_list_start(new_page, page, move_limit, mtr);
left_page = new_page; left_page = new_page;
@ -1607,7 +1608,7 @@ func_start:
lock_update_split_left(right_page, left_page); lock_update_split_left(right_page, left_page);
} else { } else {
/* printf("Split right\n"); */ /* fputs("Split right\n", stderr); */
page_move_rec_list_end(new_page, page, move_limit, mtr); page_move_rec_list_end(new_page, page, move_limit, mtr);
left_page = page; left_page = page;
@ -1643,7 +1644,7 @@ func_start:
ibuf_update_free_bits_for_two_pages_low(cursor->index, ibuf_update_free_bits_for_two_pages_low(cursor->index,
left_page, left_page,
right_page, mtr); 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(left_page),
buf_frame_get_page_no(right_page)); */ buf_frame_get_page_no(right_page)); */
return(rec); return(rec);
@ -1663,7 +1664,7 @@ func_start:
/* We play safe and reset the free bits for new_page */ /* We play safe and reset the free bits for new_page */
ibuf_reset_free_bits(cursor->index, 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)); */ buf_frame_get_page_no(page)); */
n_iterations++; n_iterations++;
ut_ad(n_iterations < 2); ut_ad(n_iterations < 2);
@ -1677,7 +1678,7 @@ func_start:
ibuf_update_free_bits_for_two_pages_low(cursor->index, left_page, ibuf_update_free_bits_for_two_pages_low(cursor->index, left_page,
right_page, mtr); 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(left_page),
buf_frame_get_page_no(right_page)); */ buf_frame_get_page_no(right_page)); */
@ -1924,7 +1925,7 @@ btr_compress(
left_page_no = btr_page_get_prev(page, mtr); left_page_no = btr_page_get_prev(page, mtr);
right_page_no = btr_page_get_next(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); */ right_page_no); */
node_ptr = btr_page_get_father_node_ptr(tree, page, mtr); node_ptr = btr_page_get_father_node_ptr(tree, page, mtr);
@ -2174,8 +2175,9 @@ btr_print_size(
mtr_t mtr; mtr_t mtr;
if (tree->type & DICT_IBUF) { if (tree->type & DICT_IBUF) {
printf( fputs(
"Sorry, cannot print info of an ibuf tree: use ibuf functions\n"); "Sorry, cannot print info of an ibuf tree: use ibuf functions\n",
stderr);
return; return;
} }
@ -2186,14 +2188,14 @@ btr_print_size(
seg = root + PAGE_HEADER + PAGE_BTR_SEG_TOP; 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); fseg_print(seg, &mtr);
if (!(tree->type & DICT_UNIVERSAL)) { if (!(tree->type & DICT_UNIVERSAL)) {
seg = root + PAGE_HEADER + PAGE_BTR_SEG_LEAF; 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); fseg_print(seg, &mtr);
} }
@ -2221,7 +2223,7 @@ btr_print_recursive(
ut_ad(mtr_memo_contains(mtr, buf_block_align(page), ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
MTR_MEMO_PAGE_X_FIX)); 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)); btr_page_get_level(page, mtr), buf_frame_get_page_no(page));
page_print(page, width, width); page_print(page, width, width);
@ -2267,8 +2269,8 @@ btr_print_tree(
mtr_t mtr; mtr_t mtr;
page_t* root; page_t* root;
printf("--------------------------\n"); fputs("--------------------------\n"
printf("INDEX TREE PRINT\n"); "INDEX TREE PRINT\n", stderr);
mtr_start(&mtr); mtr_start(&mtr);
@ -2324,6 +2326,22 @@ btr_check_node_ptr(
return(TRUE); return(TRUE);
} }
/****************************************************************
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 Checks the size and number of fields in a record based on the definition of
the index. */ the index. */
@ -2338,13 +2356,10 @@ btr_index_rec_validate(
should print hex dump of record should print hex dump of record
and page on error */ and page on error */
{ {
dtype_t* type;
byte* data;
ulint len; ulint len;
ulint n; ulint n;
ulint i; ulint i;
page_t* page; page_t* page;
char err_buf[1000];
page = buf_frame_align(rec); page = buf_frame_align(rec);
@ -2359,11 +2374,8 @@ btr_index_rec_validate(
n = dict_index_get_n_fields(index); n = dict_index_get_n_fields(index);
if (rec_get_n_fields(rec) != n) { if (rec_get_n_fields(rec) != n) {
fprintf(stderr, btr_index_rec_validate_report(page, rec, index);
"InnoDB: Record in index %s in table %s, page %lu, at offset %lu\n" fprintf(stderr, "InnoDB: has %lu fields, should have %lu\n",
"InnoDB: has %lu fields, should have %lu\n",
index->name, index->table_name,
buf_frame_get_page_no(page), (ulint)(rec - page),
rec_get_n_fields(rec), n); rec_get_n_fields(rec), n);
if (!dump_on_error) { if (!dump_on_error) {
@ -2373,16 +2385,17 @@ btr_index_rec_validate(
buf_page_print(page); buf_page_print(page);
rec_sprintf(err_buf, 900, rec); fputs("InnoDB: corrupt record ", stderr);
fprintf(stderr, "InnoDB: corrupt record %s\n", err_buf); rec_print(stderr, rec);
putc('\n', stderr);
return(FALSE); return(FALSE);
} }
for (i = 0; i < n; i++) { 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 if ((dict_index_get_nth_field(index, i)->prefix_len == 0
&& len != UNIV_SQL_NULL && dtype_is_fixed_size(type) && len != UNIV_SQL_NULL && dtype_is_fixed_size(type)
@ -2393,12 +2406,9 @@ btr_index_rec_validate(
&& len != && len !=
dict_index_get_nth_field(index, i)->prefix_len)) { dict_index_get_nth_field(index, i)->prefix_len)) {
btr_index_rec_validate_report(page, rec, index);
fprintf(stderr, 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", "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)); i, len, dtype_get_fixed_size(type));
if (!dump_on_error) { if (!dump_on_error) {
@ -2408,9 +2418,9 @@ btr_index_rec_validate(
buf_page_print(page); buf_page_print(page);
rec_sprintf(err_buf, 900, rec); fputs("InnoDB: corrupt record ", stderr);
fprintf(stderr, rec_print(stderr, rec);
"InnoDB: corrupt record %s\n", err_buf); putc('\n', stderr);
return(FALSE); return(FALSE);
} }
@ -2430,7 +2440,6 @@ btr_index_page_validate(
page_t* page, /* in: index page */ page_t* page, /* in: index page */
dict_index_t* index) /* in: index */ dict_index_t* index) /* in: index */
{ {
rec_t* rec;
page_cur_t cur; page_cur_t cur;
ibool ret = TRUE; ibool ret = TRUE;
@ -2438,14 +2447,12 @@ btr_index_page_validate(
page_cur_move_to_next(&cur); page_cur_move_to_next(&cur);
for (;;) { for (;;) {
rec = (&cur)->rec;
if (page_cur_is_after_last(&cur)) { if (page_cur_is_after_last(&cur)) {
break; break;
} }
if (!btr_index_rec_validate(rec, index, TRUE)) { if (!btr_index_rec_validate(cur.rec, index, TRUE)) {
return(FALSE); return(FALSE);
} }
@ -2456,6 +2463,46 @@ btr_index_page_validate(
return(ret); return(ret);
} }
/****************************************************************
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. */ Validates index tree level. */
static static
@ -2481,7 +2528,6 @@ btr_validate_level(
ibool ret = TRUE; ibool ret = TRUE;
dict_index_t* index; dict_index_t* index;
mtr_t mtr; mtr_t mtr;
char err_buf[1000];
mtr_start(&mtr); mtr_start(&mtr);
@ -2512,10 +2558,7 @@ loop:
/* Check ordering etc. of records */ /* Check ordering etc. of records */
if (!page_validate(page, index)) { if (!page_validate(page, index)) {
fprintf(stderr, btr_validate_report1(index, level, page);
"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);
ret = FALSE; ret = FALSE;
} else if (level == 0) { } else if (level == 0) {
@ -2545,25 +2588,22 @@ loop:
page_rec_get_next(page_get_infimum_rec(right_page)), page_rec_get_next(page_get_infimum_rec(right_page)),
UT_LIST_GET_FIRST(tree->tree_indexes)) >= 0) { UT_LIST_GET_FIRST(tree->tree_indexes)) >= 0) {
fprintf(stderr, btr_validate_report2(index, level, page, right_page);
"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);
fprintf(stderr, fputs("InnoDB: records in wrong order"
"InnoDB: records in wrong order on adjacent pages\n"); " on adjacent pages\n", stderr);
buf_page_print(page); buf_page_print(page);
buf_page_print(right_page); buf_page_print(right_page);
rec_sprintf(err_buf, 900, fputs("InnoDB: record ", stderr);
page_rec_get_prev(page_get_supremum_rec(page))); rec_print(stderr, page_rec_get_prev(
fprintf(stderr, "InnoDB: record %s\n", err_buf); page_get_supremum_rec(page)));
putc('\n', stderr);
rec_sprintf(err_buf, 900, fputs("InnoDB: record ", stderr);
page_rec_get_next(page_get_infimum_rec(right_page))); rec_print(stderr, page_rec_get_next(
fprintf(stderr, "InnoDB: record %s\n", err_buf); page_get_infimum_rec(right_page)));
putc('\n', stderr);
ret = FALSE; ret = FALSE;
} }
@ -2586,32 +2626,27 @@ loop:
|| node_ptr != btr_page_get_father_for_rec(tree, page, || node_ptr != btr_page_get_father_for_rec(tree, page,
page_rec_get_prev(page_get_supremum_rec(page)), page_rec_get_prev(page_get_supremum_rec(page)),
&mtr)) { &mtr)) {
fprintf(stderr, btr_validate_report1(index, level, page);
"InnoDB: Error on page %lu in index %s table %s\n",
buf_frame_get_page_no(page),
index->name, index->table_name);
fprintf(stderr, fputs("InnoDB: node pointer to the page is wrong\n",
"InnoDB: node pointer to the page is wrong\n"); stderr);
buf_page_print(father_page); buf_page_print(father_page);
buf_page_print(page); buf_page_print(page);
rec_sprintf(err_buf, 900, node_ptr); fputs("InnoDB: node ptr ", stderr);
rec_print(stderr, node_ptr);
fprintf(stderr, "InnoDB: node ptr %s\n", err_buf); fprintf(stderr, "\n"
fprintf(stderr,
"InnoDB: node ptr child page n:o %lu\n", "InnoDB: node ptr child page n:o %lu\n",
btr_node_ptr_get_child_page_no(node_ptr)); 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, btr_page_get_father_for_rec(tree, page,
page_rec_get_prev(page_get_supremum_rec(page)), page_rec_get_prev(page_get_supremum_rec(page)),
&mtr)); &mtr));
putc('\n', stderr);
fprintf(stderr, "InnoDB: record on page %s\n",
err_buf);
ret = FALSE; ret = FALSE;
goto node_ptr_fails; goto node_ptr_fails;
@ -2629,27 +2664,19 @@ loop:
if (cmp_dtuple_rec(node_ptr_tuple, node_ptr) != 0) { if (cmp_dtuple_rec(node_ptr_tuple, node_ptr) != 0) {
fprintf(stderr, btr_validate_report1(index, level, page);
"InnoDB: Error on page %lu in index %s table %s\n",
buf_frame_get_page_no(page),
index->name, index->table_name);
buf_page_print(father_page); buf_page_print(father_page);
buf_page_print(page); buf_page_print(page);
fprintf(stderr, fputs("InnoDB: Error: node ptrs differ"
"InnoDB: Error: node ptrs differ on levels > 0\n"); " on levels > 0\n"
"InnoDB: node ptr ", stderr);
rec_sprintf(err_buf, 900, node_ptr); rec_print(stderr, node_ptr);
fputs("InnoDB: first rec ", stderr);
fprintf(stderr, "InnoDB: node ptr %s\n", rec_print(stderr, page_rec_get_next(
err_buf);
rec_sprintf(err_buf, 900,
page_rec_get_next(
page_get_infimum_rec(page))); page_get_infimum_rec(page)));
putc('\n', stderr);
fprintf(stderr, "InnoDB: first rec %s\n",
err_buf);
ret = FALSE; ret = FALSE;
mem_heap_free(heap); mem_heap_free(heap);
@ -2681,13 +2708,12 @@ loop:
if (right_node_ptr != if (right_node_ptr !=
page_rec_get_next(node_ptr)) { page_rec_get_next(node_ptr)) {
ret = FALSE; ret = FALSE;
fprintf(stderr, fputs(
"InnoDB: node pointer to the right page is wrong\n"); "InnoDB: node pointer to the right page is wrong\n",
stderr);
fprintf(stderr, btr_validate_report1(index, level,
"InnoDB: Error on page %lu in index %s table %s\n", page);
buf_frame_get_page_no(page),
index->name, index->table_name);
buf_page_print(father_page); buf_page_print(father_page);
buf_page_print(page); buf_page_print(page);
@ -2701,13 +2727,12 @@ loop:
page_get_infimum_rec( page_get_infimum_rec(
right_father_page))) { right_father_page))) {
ret = FALSE; ret = FALSE;
fprintf(stderr, fputs(
"InnoDB: node pointer 2 to the right page is wrong\n"); "InnoDB: node pointer 2 to the right page is wrong\n",
stderr);
fprintf(stderr, btr_validate_report1(index, level,
"InnoDB: Error on page %lu in index %s table %s\n", page);
buf_frame_get_page_no(page),
index->name, index->table_name);
buf_page_print(father_page); buf_page_print(father_page);
buf_page_print(right_father_page); buf_page_print(right_father_page);
@ -2719,13 +2744,12 @@ loop:
!= btr_page_get_next(father_page, &mtr)) { != btr_page_get_next(father_page, &mtr)) {
ret = FALSE; ret = FALSE;
fprintf(stderr, fputs(
"InnoDB: node pointer 3 to the right page is wrong\n"); "InnoDB: node pointer 3 to the right page is wrong\n",
stderr);
fprintf(stderr, btr_validate_report1(index, level,
"InnoDB: Error on page %lu in index %s table %s\n", page);
buf_frame_get_page_no(page),
index->name, index->table_name);
buf_page_print(father_page); buf_page_print(father_page);
buf_page_print(right_father_page); buf_page_print(right_father_page);

View File

@ -830,6 +830,24 @@ btr_cur_ins_lock_and_undo(
return(DB_SUCCESS); return(DB_SUCCESS);
} }
/*****************************************************************
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. 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 It is assumed that mtr holds an x-latch on the page. The operation does
@ -877,18 +895,13 @@ btr_cur_optimistic_insert(
index = cursor->index; index = cursor->index;
if (!dtuple_check_typed_no_assert(entry)) { if (!dtuple_check_typed_no_assert(entry)) {
fprintf(stderr, fputs("InnoDB: Error in a tuple to insert into ", stderr);
"InnoDB: Error in a tuple to insert into table %s index %s\n", dict_index_name_print(stderr, index);
index->table_name, index->name);
} }
if (btr_cur_print_record_ops && thr) { if (btr_cur_print_record_ops && thr) {
printf( btr_cur_trx_report(thr_get_trx(thr), index, "insert into ");
"Trx with id %lu %lu going to insert to table %s index %s\n", dtuple_print(stderr, entry);
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);
} }
ut_ad(mtr_memo_contains(mtr, buf_block_align(page), 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); *rec = page_cur_tuple_insert(page_cursor, entry, mtr);
if (!(*rec)) { if (!*rec) {
char* err_buf = mem_alloc(1000); fputs("InnoDB: Error: cannot insert tuple ", stderr);
dtuple_print(stderr, entry);
dtuple_sprintf(err_buf, 900, entry); fputs(" into ", stderr);
dict_index_name_print(stderr, index);
fprintf(stderr, fprintf(stderr, "\nInnoDB: max insert size %lu\n",
"InnoDB: Error: cannot insert tuple %s to index %s of table %s\n" max_size);
"InnoDB: max insert size %lu\n", ut_error;
err_buf, index->name, index->table->name, max_size);
mem_free(err_buf);
} }
ut_a(*rec); /* <- We calculated above the record would fit */
} }
#ifdef BTR_CUR_HASH_ADAPT #ifdef BTR_CUR_HASH_ADAPT
@ -1010,7 +1018,8 @@ calculate_sizes_again:
lock_update_insert(*rec); 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, buf_frame_get_page_no(page), max_size,
rec_size + PAGE_DIR_SLOT_SIZE, type); rec_size + PAGE_DIR_SLOT_SIZE, type);
*/ */
@ -1361,12 +1370,8 @@ btr_cur_update_in_place(
trx = thr_get_trx(thr); trx = thr_get_trx(thr);
if (btr_cur_print_record_ops && thr) { if (btr_cur_print_record_ops && thr) {
printf( btr_cur_trx_report(trx, index, "update ");
"Trx with id %lu %lu going to update table %s index %s\n", rec_print(stderr, rec);
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);
} }
/* Do lock checking and undo logging */ /* Do lock checking and undo logging */
@ -1465,12 +1470,8 @@ btr_cur_optimistic_update(
index = cursor->index; index = cursor->index;
if (btr_cur_print_record_ops && thr) { if (btr_cur_print_record_ops && thr) {
printf( btr_cur_trx_report(thr_get_trx(thr), index, "update ");
"Trx with id %lu %lu going to update table %s index %s\n", rec_print(stderr, rec);
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);
} }
ut_ad(mtr_memo_contains(mtr, buf_block_align(page), ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
@ -2012,12 +2013,8 @@ btr_cur_del_mark_set_clust_rec(
index = cursor->index; index = cursor->index;
if (btr_cur_print_record_ops && thr) { if (btr_cur_print_record_ops && thr) {
printf( btr_cur_trx_report(thr_get_trx(thr), index, "del mark ");
"Trx with id %lu %lu going to del mark table %s index %s\n", rec_print(stderr, rec);
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);
} }
ut_ad(index->type & DICT_CLUSTERED); ut_ad(index->type & DICT_CLUSTERED);
@ -2152,12 +2149,9 @@ btr_cur_del_mark_set_sec_rec(
rec = btr_cur_get_rec(cursor); rec = btr_cur_get_rec(cursor);
if (btr_cur_print_record_ops && thr) { if (btr_cur_print_record_ops && thr) {
printf( btr_cur_trx_report(thr_get_trx(thr), cursor->index,
"Trx with id %lu %lu going to del mark table %s index %s\n", "del mark ");
ut_dulint_get_high(thr_get_trx(thr)->id), rec_print(stderr, rec);
ut_dulint_get_low(thr_get_trx(thr)->id),
cursor->index->table_name, cursor->index->name);
rec_print(rec);
} }
err = lock_sec_rec_modify_check_and_lock(flags, rec, cursor->index, err = lock_sec_rec_modify_check_and_lock(flags, rec, cursor->index,

View File

@ -803,7 +803,7 @@ btr_search_guess_on_hash(
success = FALSE; 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(tree_id),
ut_dulint_get_low(btr_page_get_index_id(page)), ut_dulint_get_low(btr_page_get_index_id(page)),
fold); fold);
@ -1045,7 +1045,7 @@ btr_search_drop_page_hash_when_freed(
/* We assume that if the caller has a latch on the page, /* We assume that if the caller has a latch on the page,
then the caller has already dropped the hash index for 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 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); 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); ha_insert_for_fold(table, ins_fold, ins_rec);
/* /*
printf("Hash insert for %s, fold %lu\n", fputs("Hash insert for ", stderr);
cursor->index->name, ins_fold); dict_index_name_print(stderr, cursor->index);
fprintf(stderr, " fold %lu\n", ins_fold);
*/ */
} else { } else {
ha_insert_for_fold(table, next_fold, next_rec); ha_insert_for_fold(table, next_fold, next_rec);
@ -1543,7 +1544,6 @@ btr_search_validate(void)
ulint n_page_dumps = 0; ulint n_page_dumps = 0;
ibool ok = TRUE; ibool ok = TRUE;
ulint i; ulint i;
char rec_str[500];
rw_lock_x_lock(&btr_search_latch); rw_lock_x_lock(&btr_search_latch);
@ -1564,9 +1564,9 @@ btr_search_validate(void)
fprintf(stderr, fprintf(stderr,
" InnoDB: Error in an adaptive hash index pointer to page %lu\n" " 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", "ptr mem address %p index id %lu %lu, node fold %lu, rec fold %lu\n",
buf_frame_get_page_no(page), buf_frame_get_page_no(page),
(ulint)(node->data), node->data,
ut_dulint_get_high(btr_page_get_index_id(page)), ut_dulint_get_high(btr_page_get_index_id(page)),
ut_dulint_get_low(btr_page_get_index_id(page)), ut_dulint_get_low(btr_page_get_index_id(page)),
node->fold, rec_fold((rec_t*)(node->data), node->fold, rec_fold((rec_t*)(node->data),
@ -1574,16 +1574,12 @@ btr_search_validate(void)
block->curr_n_bytes, block->curr_n_bytes,
btr_page_get_index_id(page))); btr_page_get_index_id(page)));
rec_sprintf(rec_str, 450, (rec_t*)(node->data)); fputs("InnoDB: Record ", stderr);
rec_print(stderr, (rec_t*)(node->data));
fprintf(stderr, fprintf(stderr, "\nInnoDB: on that page."
"InnoDB: Record %s\n" "Page mem address %p, is hashed %lu, n fields %lu, n bytes %lu\n"
"InnoDB: on that page.", rec_str);
fprintf(stderr,
"Page mem address %lu, is hashed %lu, n fields %lu, n bytes %lu\n"
"side %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); block->curr_n_bytes, block->curr_side);
if (n_page_dumps < 20) { if (n_page_dumps < 20) {

View File

@ -348,19 +348,12 @@ buf_page_print(
dict_index_t* index; dict_index_t* index;
ulint checksum; ulint checksum;
ulint old_checksum; ulint old_checksum;
char* buf;
buf = mem_alloc(4 * UNIV_PAGE_SIZE);
ut_sprintf_buf(buf, read_buf, UNIV_PAGE_SIZE);
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr, " InnoDB: Page dump in ascii and hex (%lu bytes):\n",
" InnoDB: Page dump in ascii and hex (%lu bytes):\n%s", (ulint)UNIV_PAGE_SIZE);
(ulint)UNIV_PAGE_SIZE, buf); ut_print_buf(stderr, read_buf, UNIV_PAGE_SIZE);
fprintf(stderr, "InnoDB: End of page dump\n"); fputs("InnoDB: End of page dump\n", stderr);
mem_free(buf);
checksum = buf_calc_page_new_checksum(read_buf); checksum = buf_calc_page_new_checksum(read_buf);
old_checksum = buf_calc_page_old_checksum(read_buf); old_checksum = buf_calc_page_old_checksum(read_buf);
@ -407,18 +400,17 @@ buf_page_print(
index = dict_index_find_on_id_low( index = dict_index_find_on_id_low(
btr_page_get_index_id(read_buf)); btr_page_get_index_id(read_buf));
if (index) { if (index) {
fprintf(stderr, fputs("InnoDB: (", stderr);
"InnoDB: and table %s index %s\n", dict_index_name_print(stderr, index);
index->table_name, fputs(")\n", stderr);
index->name);
} }
} }
} else if (fil_page_get_type(read_buf) == FIL_PAGE_INODE) { } else if (fil_page_get_type(read_buf) == FIL_PAGE_INODE) {
fprintf(stderr, "InnoDB: Page may be an 'inode' page\n"); fputs("InnoDB: Page may be an 'inode' page\n", stderr);
} else if (fil_page_get_type(read_buf) == FIL_PAGE_IBUF_FREE_LIST) { } else if (fil_page_get_type(read_buf) == FIL_PAGE_IBUF_FREE_LIST) {
fprintf(stderr, fputs("InnoDB: Page may be an insert buffer free list page\n",
"InnoDB: Page may be an insert buffer free list page\n"); stderr);
} }
} }
@ -1464,8 +1456,8 @@ buf_page_create(
/* If we get here, the page was not in buf_pool: init it there */ /* If we get here, the page was not in buf_pool: init it there */
if (buf_debug_prints) { if (buf_debug_prints) {
printf("Creating space %lu page %lu to buffer\n", space, fprintf(stderr, "Creating space %lu page %lu to buffer\n",
offset); space, offset);
} }
block = free_block; block = free_block;
@ -1519,8 +1511,6 @@ buf_page_io_complete(
/*=================*/ /*=================*/
buf_block_t* block) /* in: pointer to the block in question */ buf_block_t* block) /* in: pointer to the block in question */
{ {
dict_index_t* index;
dulint id;
ulint io_type; ulint io_type;
ulint read_page_no; ulint read_page_no;
@ -1551,17 +1541,17 @@ buf_page_io_complete(
"InnoDB: Database page corruption on disk or a failed\n" "InnoDB: Database page corruption on disk or a failed\n"
"InnoDB: file read of page %lu.\n", block->offset); "InnoDB: file read of page %lu.\n", block->offset);
fprintf(stderr, fputs(
"InnoDB: You may have to recover from a backup.\n"); "InnoDB: You may have to recover from a backup.\n", stderr);
buf_page_print(block->frame); buf_page_print(block->frame);
fprintf(stderr, fprintf(stderr,
"InnoDB: Database page corruption on disk or a failed\n" "InnoDB: Database page corruption on disk or a failed\n"
"InnoDB: file read of page %lu.\n", block->offset); "InnoDB: file read of page %lu.\n", block->offset);
fprintf(stderr, fputs(
"InnoDB: You may have to recover from a backup.\n"); "InnoDB: You may have to recover from a backup.\n", stderr);
fprintf(stderr, fputs(
"InnoDB: It is also possible that your operating\n" "InnoDB: It is also possible that your operating\n"
"InnoDB: system has corrupted its own file cache\n" "InnoDB: system has corrupted its own file cache\n"
"InnoDB: and rebooting your computer removes the\n" "InnoDB: and rebooting your computer removes the\n"
@ -1572,12 +1562,13 @@ buf_page_io_complete(
"InnoDB: the corrupt table. You can use CHECK\n" "InnoDB: the corrupt table. You can use CHECK\n"
"InnoDB: TABLE to scan your table for corruption.\n" "InnoDB: TABLE to scan your table for corruption.\n"
"InnoDB: Look also at section 6.1 of\n" "InnoDB: Look also at section 6.1 of\n"
"InnoDB: http://www.innodb.com/ibman.html about\n" "InnoDB: http://www.innodb.com/ibman.php about\n"
"InnoDB: forcing recovery.\n"); "InnoDB: forcing recovery.\n", stderr);
if (srv_force_recovery < SRV_FORCE_IGNORE_CORRUPT) { if (srv_force_recovery < SRV_FORCE_IGNORE_CORRUPT) {
fprintf(stderr, fputs(
"InnoDB: Ending processing because of a corrupt database page.\n"); "InnoDB: Ending processing because of a corrupt database page.\n",
stderr);
exit(1); exit(1);
} }
} }
@ -1619,7 +1610,7 @@ buf_page_io_complete(
rw_lock_x_unlock_gen(&(block->read_lock), BUF_IO_READ); rw_lock_x_unlock_gen(&(block->read_lock), BUF_IO_READ);
if (buf_debug_prints) { if (buf_debug_prints) {
printf("Has read "); fputs("Has read ", stderr);
} }
} else { } else {
ut_ad(io_type == BUF_IO_WRITE); ut_ad(io_type == BUF_IO_WRITE);
@ -1634,29 +1625,15 @@ buf_page_io_complete(
buf_pool->n_pages_written++; buf_pool->n_pages_written++;
if (buf_debug_prints) { if (buf_debug_prints) {
printf("Has written "); fputs("Has written ", stderr);
} }
} }
mutex_exit(&(buf_pool->mutex)); mutex_exit(&(buf_pool->mutex));
if (buf_debug_prints) { if (buf_debug_prints) {
printf("page space %lu page no %lu", block->space, fprintf(stderr, "page space %lu page no %lu\n",
block->offset); block->space, block->offset);
id = btr_page_get_index_id(block->frame);
index = NULL;
/* The following can cause deadlocks if used: */
/*
index = dict_index_get_if_in_cache(id);
if (index) {
printf(" index name %s table %s", index->name,
index->table->name);
}
*/
printf("\n");
} }
} }
@ -1757,13 +1734,13 @@ buf_validate(void)
} }
if (n_lru + n_free > buf_pool->curr_size) { if (n_lru + n_free > buf_pool->curr_size) {
printf("n LRU %lu, n free %lu\n", n_lru, n_free); fprintf(stderr, "n LRU %lu, n free %lu\n", n_lru, n_free);
ut_error; ut_error;
} }
ut_a(UT_LIST_GET_LEN(buf_pool->LRU) == n_lru); ut_a(UT_LIST_GET_LEN(buf_pool->LRU) == n_lru);
if (UT_LIST_GET_LEN(buf_pool->free) != n_free) { if (UT_LIST_GET_LEN(buf_pool->free) != n_free) {
printf("Free list len %lu, free blocks %lu\n", fprintf(stderr, "Free list len %lu, free blocks %lu\n",
UT_LIST_GET_LEN(buf_pool->free), n_free); UT_LIST_GET_LEN(buf_pool->free), n_free);
ut_error; ut_error;
} }
@ -1807,20 +1784,22 @@ buf_print(void)
mutex_enter(&(buf_pool->mutex)); mutex_enter(&(buf_pool->mutex));
printf("buf_pool size %lu \n", size); fprintf(stderr,
printf("database pages %lu \n", UT_LIST_GET_LEN(buf_pool->LRU)); "buf_pool size %lu \n"
printf("free pages %lu \n", UT_LIST_GET_LEN(buf_pool->free)); "database pages %lu \n"
printf("modified database pages %lu \n", "free pages %lu \n"
UT_LIST_GET_LEN(buf_pool->flush_list)); "modified database pages %lu \n"
"n pending reads %lu \n"
printf("n pending reads %lu \n", buf_pool->n_pend_reads); "n pending flush LRU %lu list %lu single page %lu\n"
"pages read %lu, created %lu, written %lu\n",
printf("n pending flush LRU %lu list %lu single page %lu\n", size,
UT_LIST_GET_LEN(buf_pool->LRU),
UT_LIST_GET_LEN(buf_pool->free),
UT_LIST_GET_LEN(buf_pool->flush_list),
buf_pool->n_pend_reads,
buf_pool->n_flush[BUF_FLUSH_LRU], buf_pool->n_flush[BUF_FLUSH_LRU],
buf_pool->n_flush[BUF_FLUSH_LIST], buf_pool->n_flush[BUF_FLUSH_LIST],
buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]); buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE],
printf("pages read %lu, created %lu, written %lu\n",
buf_pool->n_pages_read, buf_pool->n_pages_created, buf_pool->n_pages_read, buf_pool->n_pages_created,
buf_pool->n_pages_written); buf_pool->n_pages_written);
@ -1865,15 +1844,16 @@ buf_print(void)
for (i = 0; i < n_found; i++) { for (i = 0; i < n_found; i++) {
index = dict_index_get_if_in_cache(index_ids[i]); index = dict_index_get_if_in_cache(index_ids[i]);
printf("Block count for index %lu in buffer is about %lu", fprintf(stderr,
"Block count for index %lu in buffer is about %lu",
ut_dulint_get_low(index_ids[i]), counts[i]); ut_dulint_get_low(index_ids[i]), counts[i]);
if (index) { if (index) {
printf(" index name %s table %s", index->name, putc(' ', stderr);
index->table->name); dict_index_name_print(stderr, index);
} }
printf("\n"); putc('\n', stderr);
} }
mem_free(index_ids); mem_free(index_ids);
@ -1924,44 +1904,29 @@ Prints info of the buffer i/o. */
void void
buf_print_io( buf_print_io(
/*=========*/ /*=========*/
char* buf, /* in/out: buffer where to print */ FILE* file) /* in/out: buffer where to print */
char* buf_end)/* in: buffer end */
{ {
time_t current_time; time_t current_time;
double time_elapsed; double time_elapsed;
ulint size; ulint size;
ut_ad(buf_pool); ut_ad(buf_pool);
if (buf_end - buf < 400) {
return;
}
size = buf_pool_get_curr_size() / UNIV_PAGE_SIZE; size = buf_pool_get_curr_size() / UNIV_PAGE_SIZE;
mutex_enter(&(buf_pool->mutex)); mutex_enter(&(buf_pool->mutex));
buf += sprintf(buf, fprintf(file,
"Buffer pool size %lu\n", size); "Buffer pool size %lu\n"
buf += sprintf(buf, "Free buffers %lu\n"
"Free buffers %lu\n", UT_LIST_GET_LEN(buf_pool->free)); "Database pages %lu\n"
buf += sprintf(buf, "Modified db pages %lu\n"
"Database pages %lu\n", UT_LIST_GET_LEN(buf_pool->LRU)); "Pending reads %lu \n"
/*
buf += sprintf(buf,
"Lock heap buffers %lu\n", buf_pool->n_lock_heap_pages);
buf += sprintf(buf,
"Hash index buffers %lu\n", buf_pool->n_adaptive_hash_pages);
*/
buf += sprintf(buf,
"Modified db pages %lu\n",
UT_LIST_GET_LEN(buf_pool->flush_list));
buf += sprintf(buf, "Pending reads %lu \n", buf_pool->n_pend_reads);
buf += sprintf(buf,
"Pending writes: LRU %lu, flush list %lu, single page %lu\n", "Pending writes: LRU %lu, flush list %lu, single page %lu\n",
size,
UT_LIST_GET_LEN(buf_pool->free),
UT_LIST_GET_LEN(buf_pool->LRU),
UT_LIST_GET_LEN(buf_pool->flush_list),
buf_pool->n_pend_reads,
buf_pool->n_flush[BUF_FLUSH_LRU] buf_pool->n_flush[BUF_FLUSH_LRU]
+ buf_pool->init_flush[BUF_FLUSH_LRU], + buf_pool->init_flush[BUF_FLUSH_LRU],
buf_pool->n_flush[BUF_FLUSH_LIST] buf_pool->n_flush[BUF_FLUSH_LIST]
@ -1973,10 +1938,11 @@ buf_print_io(
buf_pool->last_printout_time); buf_pool->last_printout_time);
buf_pool->last_printout_time = current_time; buf_pool->last_printout_time = current_time;
buf += sprintf(buf, "Pages read %lu, created %lu, written %lu\n", fprintf(file,
"Pages read %lu, created %lu, written %lu\n"
"%.2f reads/s, %.2f creates/s, %.2f writes/s\n",
buf_pool->n_pages_read, buf_pool->n_pages_created, buf_pool->n_pages_read, buf_pool->n_pages_created,
buf_pool->n_pages_written); buf_pool->n_pages_written,
buf += sprintf(buf, "%.2f reads/s, %.2f creates/s, %.2f writes/s\n",
(buf_pool->n_pages_read - buf_pool->n_pages_read_old) (buf_pool->n_pages_read - buf_pool->n_pages_read_old)
/ time_elapsed, / time_elapsed,
(buf_pool->n_pages_created - buf_pool->n_pages_created_old) (buf_pool->n_pages_created - buf_pool->n_pages_created_old)
@ -1985,14 +1951,14 @@ buf_print_io(
/ time_elapsed); / time_elapsed);
if (buf_pool->n_page_gets > buf_pool->n_page_gets_old) { if (buf_pool->n_page_gets > buf_pool->n_page_gets_old) {
buf += sprintf(buf, "Buffer pool hit rate %lu / 1000\n", fprintf(file, "Buffer pool hit rate %lu / 1000\n",
1000 1000
- ((1000 * - ((1000 *
(buf_pool->n_pages_read - buf_pool->n_pages_read_old)) (buf_pool->n_pages_read - buf_pool->n_pages_read_old))
/ (buf_pool->n_page_gets - buf_pool->n_page_gets_old))); / (buf_pool->n_page_gets - buf_pool->n_page_gets_old)));
} else { } else {
buf += sprintf(buf, fputs("No buffer pool page gets since the last printout\n",
"No buffer pool page gets since the last printout\n"); file);
} }
buf_pool->n_page_gets_old = buf_pool->n_page_gets; buf_pool->n_page_gets_old = buf_pool->n_page_gets;
@ -2039,8 +2005,9 @@ buf_all_freed(void)
if (!buf_flush_ready_for_replace(block)) { if (!buf_flush_ready_for_replace(block)) {
/* printf("Page %lu %lu still fixed or dirty\n", fprintf(stderr,
block->space, block->offset); */ "Page %lu %lu still fixed or dirty\n",
block->space, block->offset);
ut_error; ut_error;
} }
} }

View File

@ -189,7 +189,7 @@ buf_flush_write_complete(
buf_pool->LRU_flush_ended++; buf_pool->LRU_flush_ended++;
} }
/* printf("n pending flush %lu\n", /* fprintf(stderr, "n pending flush %lu\n",
buf_pool->n_flush[block->flush_type]); */ buf_pool->n_flush[block->flush_type]); */
if ((buf_pool->n_flush[block->flush_type] == 0) if ((buf_pool->n_flush[block->flush_type] == 0)
@ -411,8 +411,8 @@ buf_flush_write_block_low(
ut_ad(!ut_dulint_is_zero(block->newest_modification)); ut_ad(!ut_dulint_is_zero(block->newest_modification));
#ifdef UNIV_LOG_DEBUG #ifdef UNIV_LOG_DEBUG
printf( fputs("Warning: cannot force log to disk in the log debug version!\n",
"Warning: cannot force log to disk in the log debug version!\n"); stderr);
#else #else
/* Force the log to the disk before writing the modified block */ /* Force the log to the disk before writing the modified block */
log_write_up_to(block->newest_modification, LOG_WAIT_ALL_GROUPS, TRUE); log_write_up_to(block->newest_modification, LOG_WAIT_ALL_GROUPS, TRUE);
@ -489,7 +489,8 @@ buf_flush_try_page(
} }
if (buf_debug_prints) { if (buf_debug_prints) {
printf("Flushing page space %lu, page no %lu \n", fprintf(stderr,
"Flushing page space %lu, page no %lu \n",
block->space, block->offset); block->space, block->offset);
} }
@ -548,7 +549,7 @@ buf_flush_try_page(
rw_lock_s_lock_gen(&(block->lock), BUF_IO_WRITE); rw_lock_s_lock_gen(&(block->lock), BUF_IO_WRITE);
if (buf_debug_prints) { if (buf_debug_prints) {
printf( fprintf(stderr,
"Flushing single page space %lu, page no %lu \n", "Flushing single page space %lu, page no %lu \n",
block->space, block->offset); block->space, block->offset);
} }
@ -592,7 +593,7 @@ buf_flush_try_neighbors(
high = offset + 1; high = offset + 1;
} }
/* printf("Flush area: low %lu high %lu\n", low, high); */ /* fprintf(stderr, "Flush area: low %lu high %lu\n", low, high); */
if (high > fil_space_get_size(space)) { if (high > fil_space_get_size(space)) {
high = fil_space_get_size(space); high = fil_space_get_size(space);
@ -739,7 +740,7 @@ buf_flush_batch(
page_count += page_count +=
buf_flush_try_neighbors(space, offset, buf_flush_try_neighbors(space, offset,
flush_type); flush_type);
/* printf( /* fprintf(stderr,
"Flush type %lu, page no %lu, neighb %lu\n", "Flush type %lu, page no %lu, neighb %lu\n",
flush_type, offset, flush_type, offset,
page_count - old_page_count); */ page_count - old_page_count); */
@ -779,15 +780,12 @@ buf_flush_batch(
buf_flush_buffered_writes(); buf_flush_buffered_writes();
if (buf_debug_prints && page_count > 0) { if (buf_debug_prints && page_count > 0) {
if (flush_type == BUF_FLUSH_LRU) { ut_a(flush_type == BUF_FLUSH_LRU
printf("Flushed %lu pages in LRU flush\n", || flush_type == BUF_FLUSH_LIST);
fprintf(stderr, flush_type == BUF_FLUSH_LRU
? "Flushed %lu pages in LRU flush\n"
: "Flushed %lu pages in flush list flush\n",
page_count); page_count);
} else if (flush_type == BUF_FLUSH_LIST) {
printf("Flushed %lu pages in flush list flush\n",
page_count);
} else {
ut_error;
}
} }
return(page_count); return(page_count);

View File

@ -126,7 +126,7 @@ buf_LRU_search_and_free_block(
if (buf_flush_ready_for_replace(block)) { if (buf_flush_ready_for_replace(block)) {
if (buf_debug_prints) { if (buf_debug_prints) {
printf( fprintf(stderr,
"Putting space %lu page %lu to free list\n", "Putting space %lu page %lu to free list\n",
block->space, block->offset); block->space, block->offset);
} }
@ -301,26 +301,20 @@ loop:
fprintf(stderr, fprintf(stderr,
"InnoDB: Warning: difficult to find free blocks from\n" "InnoDB: Warning: difficult to find free blocks from\n"
"InnoDB: the buffer pool (%lu search iterations)! Consider\n" "InnoDB: the buffer pool (%lu search iterations)! Consider\n"
"InnoDB: increasing the buffer pool size.\n", "InnoDB: increasing the buffer pool size.\n"
n_iterations);
fprintf(stderr,
"InnoDB: It is also possible that in your Unix version\n" "InnoDB: It is also possible that in your Unix version\n"
"InnoDB: fsync is very slow, or completely frozen inside\n" "InnoDB: fsync is very slow, or completely frozen inside\n"
"InnoDB: the OS kernel. Then upgrading to a newer version\n" "InnoDB: the OS kernel. Then upgrading to a newer version\n"
"InnoDB: of your operating system may help. Look at the\n" "InnoDB: of your operating system may help. Look at the\n"
"InnoDB: number of fsyncs in diagnostic info below.\n"); "InnoDB: number of fsyncs in diagnostic info below.\n"
"InnoDB: Pending flushes (fsync) log: %lu; buffer pool: %lu\n"
fprintf(stderr, "InnoDB: %lu OS file reads, %lu OS file writes, %lu OS fsyncs\n"
"InnoDB: Pending flushes (fsync) log: %lu; buffer pool: %lu\n",
fil_n_pending_log_flushes,
fil_n_pending_tablespace_flushes);
fprintf(stderr,
"InnoDB: %lu OS file reads, %lu OS file writes, %lu OS fsyncs\n",
os_n_file_reads, os_n_file_writes, os_n_fsyncs);
fprintf(stderr,
"InnoDB: Starting InnoDB Monitor to print further\n" "InnoDB: Starting InnoDB Monitor to print further\n"
"InnoDB: diagnostics to the standard output.\n"); "InnoDB: diagnostics to the standard output.\n",
n_iterations,
fil_n_pending_log_flushes,
fil_n_pending_tablespace_flushes,
os_n_file_reads, os_n_file_writes, os_n_fsyncs);
mon_value_was = srv_print_innodb_monitor; mon_value_was = srv_print_innodb_monitor;
started_monitor = TRUE; started_monitor = TRUE;
@ -797,7 +791,7 @@ buf_LRU_print(void)
ut_ad(buf_pool); ut_ad(buf_pool);
mutex_enter(&(buf_pool->mutex)); mutex_enter(&(buf_pool->mutex));
printf("Pool ulint clock %lu\n", buf_pool->ulint_clock); fprintf(stderr, "Pool ulint clock %lu\n", buf_pool->ulint_clock);
block = UT_LIST_GET_FIRST(buf_pool->LRU); block = UT_LIST_GET_FIRST(buf_pool->LRU);
@ -805,37 +799,37 @@ buf_LRU_print(void)
while (block != NULL) { while (block != NULL) {
printf("BLOCK %lu ", block->offset); fprintf(stderr, "BLOCK %lu ", block->offset);
if (block->old) { if (block->old) {
printf("old "); fputs("old ", stderr);
} }
if (block->buf_fix_count) { if (block->buf_fix_count) {
printf("buffix count %lu ", block->buf_fix_count); fprintf(stderr, "buffix count %lu ",
block->buf_fix_count);
} }
if (block->io_fix) { if (block->io_fix) {
printf("io_fix %lu ", block->io_fix); fprintf(stderr, "io_fix %lu ", block->io_fix);
} }
if (ut_dulint_cmp(block->oldest_modification, if (ut_dulint_cmp(block->oldest_modification,
ut_dulint_zero) > 0) { ut_dulint_zero) > 0) {
printf("modif. "); fputs("modif. ", stderr);
} }
printf("LRU pos %lu ", block->LRU_position);
frame = buf_block_get_frame(block); frame = buf_block_get_frame(block);
printf("type %lu ", fil_page_get_type(frame)); fprintf(stderr, "LRU pos %lu type %lu index id %lu ",
printf("index id %lu ", ut_dulint_get_low( block->LRU_position,
btr_page_get_index_id(frame))); fil_page_get_type(frame),
ut_dulint_get_low(btr_page_get_index_id(frame)));
block = UT_LIST_GET_NEXT(LRU, block); block = UT_LIST_GET_NEXT(LRU, block);
len++; if (++len == 10) {
if (len % 10 == 0) { len = 0;
printf("\n"); putc('\n', stderr);
} }
} }

View File

@ -81,7 +81,8 @@ buf_read_page_low(
log mutex: the read must be handled before other reads log mutex: the read must be handled before other reads
which might incur ibuf operations and thus write to the log */ which might incur ibuf operations and thus write to the log */
printf("Log debug: reading replicate page in sync mode\n"); fputs("Log debug: reading replicate page in sync mode\n",
stderr);
sync = TRUE; sync = TRUE;
} }
@ -101,7 +102,8 @@ buf_read_page_low(
if (block != NULL) { if (block != NULL) {
if (buf_debug_prints) { if (buf_debug_prints) {
printf("Posting read request for page %lu, sync %lu\n", fprintf(stderr,
"Posting read request for page %lu, sync %lu\n",
offset, sync); offset, sync);
} }
@ -241,8 +243,8 @@ buf_read_ahead_random(
os_aio_simulated_wake_handler_threads(); os_aio_simulated_wake_handler_threads();
if (buf_debug_prints && (count > 0)) { if (buf_debug_prints && (count > 0)) {
fprintf(stderr,
printf("Random read-ahead space %lu offset %lu pages %lu\n", "Random read-ahead space %lu offset %lu pages %lu\n",
space, offset, count); space, offset, count);
} }
@ -499,7 +501,7 @@ buf_read_ahead_linear(
buf_flush_free_margin(); buf_flush_free_margin();
if (buf_debug_prints && (count > 0)) { if (buf_debug_prints && (count > 0)) {
printf( fprintf(stderr,
"LINEAR read-ahead space %lu offset %lu pages %lu\n", "LINEAR read-ahead space %lu offset %lu pages %lu\n",
space, offset, count); space, offset, count);
} }
@ -548,7 +550,8 @@ buf_read_ibuf_merge_pages(
buf_flush_free_margin(); buf_flush_free_margin();
if (buf_debug_prints) { if (buf_debug_prints) {
printf("Ibuf merge read-ahead space %lu pages %lu\n", fprintf(stderr,
"Ibuf merge read-ahead space %lu pages %lu\n",
space, n_stored); space, n_stored);
} }
} }
@ -611,6 +614,7 @@ buf_read_recv_pages(
buf_flush_free_margin(); buf_flush_free_margin();
if (buf_debug_prints) { if (buf_debug_prints) {
printf("Recovery applies read-ahead pages %lu\n", n_stored); fprintf(stderr,
"Recovery applies read-ahead pages %lu\n", n_stored);
} }
} }

View File

@ -12,7 +12,6 @@ Created 5/30/1994 Heikki Tuuri
#include "data0data.ic" #include "data0data.ic"
#endif #endif
#include "ut0rnd.h"
#include "rem0rec.h" #include "rem0rec.h"
#include "rem0cmp.h" #include "rem0cmp.h"
#include "page0page.h" #include "page0page.h"
@ -22,8 +21,10 @@ Created 5/30/1994 Heikki Tuuri
byte data_error; /* data pointers of tuple fields are initialized byte data_error; /* data pointers of tuple fields are initialized
to point here for error checking */ to point here for error checking */
#ifdef UNIV_DEBUG
ulint data_dummy; /* this is used to fool the compiler in ulint data_dummy; /* this is used to fool the compiler in
dtuple_validate */ dtuple_validate */
#endif /* UNIV_DEBUG */
/* Some non-inlined functions used in the MySQL interface: */ /* Some non-inlined functions used in the MySQL interface: */
void void
@ -210,16 +211,15 @@ dtuple_check_typed_no_assert(
{ {
dfield_t* field; dfield_t* field;
ulint i; ulint i;
char err_buf[1000];
if (dtuple_get_n_fields(tuple) > REC_MAX_N_FIELDS) { if (dtuple_get_n_fields(tuple) > REC_MAX_N_FIELDS) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: index entry has %lu fields\n", "InnoDB: Error: index entry has %lu fields\n",
dtuple_get_n_fields(tuple)); dtuple_get_n_fields(tuple));
dump:
dtuple_sprintf(err_buf, 900, tuple); fputs("InnoDB: Tuple contents: ", stderr);
fprintf(stderr, dtuple_print(stderr, tuple);
"InnoDB: Tuple contents: %s\n", err_buf); putc('\n', stderr);
return(FALSE); return(FALSE);
} }
@ -229,12 +229,7 @@ dtuple_check_typed_no_assert(
field = dtuple_get_nth_field(tuple, i); field = dtuple_get_nth_field(tuple, i);
if (!dfield_check_typed_no_assert(field)) { if (!dfield_check_typed_no_assert(field)) {
goto dump;
dtuple_sprintf(err_buf, 900, tuple);
fprintf(stderr,
"InnoDB: Tuple contents: %s\n", err_buf);
return(FALSE);
} }
} }
@ -285,6 +280,7 @@ dtuple_check_typed(
return(TRUE); return(TRUE);
} }
#ifdef UNIV_DEBUG
/************************************************************** /**************************************************************
Validates the consistency of a tuple which must be complete, i.e, Validates the consistency of a tuple which must be complete, i.e,
all fields must have been set. */ all fields must have been set. */
@ -332,6 +328,7 @@ dtuple_validate(
return(TRUE); return(TRUE);
} }
#endif /* UNIV_DEBUG */
/***************************************************************** /*****************************************************************
Pretty prints a dfield value according to its data type. */ Pretty prints a dfield value according to its data type. */
@ -350,7 +347,7 @@ dfield_print(
data = dfield_get_data(dfield); data = dfield_get_data(dfield);
if (len == UNIV_SQL_NULL) { if (len == UNIV_SQL_NULL) {
printf("NULL"); fputs("NULL", stderr);
return; return;
} }
@ -360,18 +357,12 @@ dfield_print(
if ((mtype == DATA_CHAR) || (mtype == DATA_VARCHAR)) { if ((mtype == DATA_CHAR) || (mtype == DATA_VARCHAR)) {
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
int c = *data++;
if (isprint((char)(*data))) { putc(isprint(c) ? c : ' ', stderr);
printf("%c", (char)*data);
} else {
printf(" ");
}
data++;
} }
} else if (mtype == DATA_INT) { } else if (mtype == DATA_INT) {
ut_a(len == 4); /* only works for 32-bit integers */ ut_a(len == 4); /* only works for 32-bit integers */
printf("%i", (int)mach_read_from_4(data)); fprintf(stderr, "%d", (int)mach_read_from_4(data));
} else { } else {
ut_error; ut_error;
} }
@ -396,7 +387,7 @@ dfield_print_also_hex(
data = dfield_get_data(dfield); data = dfield_get_data(dfield);
if (len == UNIV_SQL_NULL) { if (len == UNIV_SQL_NULL) {
printf("NULL"); fputs("NULL", stderr);
return; return;
} }
@ -408,15 +399,12 @@ dfield_print_also_hex(
print_also_hex = FALSE; print_also_hex = FALSE;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
int c = *data++;
if (isprint((char)(*data))) { if (!isprint(c)) {
printf("%c", (char)*data);
} else {
print_also_hex = TRUE; print_also_hex = TRUE;
printf(" "); c = ' ';
} }
putc(c, stderr);
data++;
} }
if (!print_also_hex) { if (!print_also_hex) {
@ -424,18 +412,18 @@ dfield_print_also_hex(
return; return;
} }
printf(" Hex: "); fputs(" Hex: ", stderr);
data = dfield_get_data(dfield); data = dfield_get_data(dfield);
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
printf("%02lx", (ulint)*data); fprintf(stderr, "%02lx", (ulint)*data);
data++; data++;
} }
} else if (mtype == DATA_INT) { } else if (mtype == DATA_INT) {
ut_a(len == 4); /* inly works for 32-bit integers */ ut_a(len == 4); /* only works for 32-bit integers */
printf("%i", (int)mach_read_from_4(data)); fprintf(stderr, "%d", (int)mach_read_from_4(data));
} else { } else {
ut_error; ut_error;
} }
@ -447,6 +435,7 @@ The following function prints the contents of a tuple. */
void void
dtuple_print( dtuple_print(
/*=========*/ /*=========*/
FILE* f, /* in: output stream */
dtuple_t* tuple) /* in: tuple */ dtuple_t* tuple) /* in: tuple */
{ {
dfield_t* field; dfield_t* field;
@ -455,73 +444,24 @@ dtuple_print(
n_fields = dtuple_get_n_fields(tuple); n_fields = dtuple_get_n_fields(tuple);
printf("DATA TUPLE: %lu fields;\n", n_fields); fprintf(f, "DATA TUPLE: %lu fields;\n", n_fields);
for (i = 0; i < n_fields; i++) { for (i = 0; i < n_fields; i++) {
printf(" %lu:", i); fprintf(f, " %lu:", i);
field = dtuple_get_nth_field(tuple, i); field = dtuple_get_nth_field(tuple, i);
if (field->len != UNIV_SQL_NULL) { if (field->len != UNIV_SQL_NULL) {
ut_print_buf(field->data, field->len); ut_print_buf(f, field->data, field->len);
} else { } else {
printf(" SQL NULL"); fputs(" SQL NULL", f);
} }
printf(";"); putc(';', f);
} }
printf("\n"); putc('\n', f);
ut_ad(dtuple_validate(tuple));
dtuple_validate(tuple);
}
/**************************************************************
The following function prints the contents of a tuple to a buffer. */
ulint
dtuple_sprintf(
/*===========*/
/* out: printed length in bytes */
char* buf, /* in: print buffer */
ulint buf_len,/* in: buf length in bytes */
dtuple_t* tuple) /* in: tuple */
{
dfield_t* field;
ulint n_fields;
ulint len;
ulint i;
len = 0;
n_fields = dtuple_get_n_fields(tuple);
for (i = 0; i < n_fields; i++) {
if (len + 30 > buf_len) {
return(len);
}
len += sprintf(buf + len, " %lu:", i);
field = dtuple_get_nth_field(tuple, i);
if (field->len != UNIV_SQL_NULL) {
if (5 * field->len + len + 30 > buf_len) {
return(len);
}
len += ut_sprintf_buf(buf + len, field->data,
field->len);
} else {
len += sprintf(buf + len, " SQL NULL");
}
len += sprintf(buf + len, ";");
}
return(len);
} }
/****************************************************************** /******************************************************************
@ -555,7 +495,6 @@ dtuple_convert_big_rec(
ibool is_externally_stored; ibool is_externally_stored;
ulint i; ulint i;
ulint j; ulint j;
char err_buf[1000];
ut_a(dtuple_check_typed_no_assert(entry)); ut_a(dtuple_check_typed_no_assert(entry));
@ -564,10 +503,9 @@ dtuple_convert_big_rec(
if (size > 1000000000) { if (size > 1000000000) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Warning: tuple size very big: %lu\n", size); "InnoDB: Warning: tuple size very big: %lu\n", size);
fputs("InnoDB: Tuple contents: ", stderr);
dtuple_sprintf(err_buf, 900, entry); dtuple_print(stderr, entry);
fprintf(stderr, putc('\n', stderr);
"InnoDB: Tuple contents: %s\n", err_buf);
} }
heap = mem_heap_create(size + dtuple_get_n_fields(entry) heap = mem_heap_create(size + dtuple_get_n_fields(entry)

View File

@ -51,19 +51,19 @@ dtype_print(
mtype = type->mtype; mtype = type->mtype;
prtype = type->prtype; prtype = type->prtype;
if (mtype == DATA_VARCHAR) { if (mtype == DATA_VARCHAR) {
printf("DATA_VARCHAR"); fputs("DATA_VARCHAR", stderr);
} else if (mtype == DATA_CHAR) { } else if (mtype == DATA_CHAR) {
printf("DATA_CHAR"); fputs("DATA_CHAR", stderr);
} else if (mtype == DATA_BINARY) { } else if (mtype == DATA_BINARY) {
printf("DATA_BINARY"); fputs("DATA_BINARY", stderr);
} else if (mtype == DATA_INT) { } else if (mtype == DATA_INT) {
printf("DATA_INT"); fputs("DATA_INT", stderr);
} else if (mtype == DATA_MYSQL) { } else if (mtype == DATA_MYSQL) {
printf("DATA_MYSQL"); fputs("DATA_MYSQL", stderr);
} else if (mtype == DATA_SYS) { } else if (mtype == DATA_SYS) {
printf("DATA_SYS"); fputs("DATA_SYS", stderr);
} else { } else {
printf("type %lu", mtype); fprintf(stderr, "type %lu", mtype);
} }
len = type->len; len = type->len;
@ -71,24 +71,24 @@ dtype_print(
if ((type->mtype == DATA_SYS) if ((type->mtype == DATA_SYS)
|| (type->mtype == DATA_VARCHAR) || (type->mtype == DATA_VARCHAR)
|| (type->mtype == DATA_CHAR)) { || (type->mtype == DATA_CHAR)) {
printf(" "); putc(' ', stderr);
if (prtype == DATA_ROW_ID) { if (prtype == DATA_ROW_ID) {
printf("DATA_ROW_ID"); fputs("DATA_ROW_ID", stderr);
len = DATA_ROW_ID_LEN; len = DATA_ROW_ID_LEN;
} else if (prtype == DATA_ROLL_PTR) { } else if (prtype == DATA_ROLL_PTR) {
printf("DATA_ROLL_PTR"); fputs("DATA_ROLL_PTR", stderr);
len = DATA_ROLL_PTR_LEN; len = DATA_ROLL_PTR_LEN;
} else if (prtype == DATA_TRX_ID) { } else if (prtype == DATA_TRX_ID) {
printf("DATA_TRX_ID"); fputs("DATA_TRX_ID", stderr);
len = DATA_TRX_ID_LEN; len = DATA_TRX_ID_LEN;
} else if (prtype == DATA_MIX_ID) { } else if (prtype == DATA_MIX_ID) {
printf("DATA_MIX_ID"); fputs("DATA_MIX_ID", stderr);
} else if (prtype == DATA_ENGLISH) { } else if (prtype == DATA_ENGLISH) {
printf("DATA_ENGLISH"); fputs("DATA_ENGLISH", stderr);
} else { } else {
printf("prtype %lu", mtype); fprintf(stderr, "prtype %lu", mtype);
} }
} }
printf(" len %lu prec %lu", len, type->prec); fprintf(stderr, " len %lu prec %lu", len, type->prec);
} }

View File

@ -71,7 +71,8 @@ dict_hdr_get_new_id(
compile wrong */ compile wrong */
if (0 == ut_dulint_cmp(id, ut_dulint_max)) { if (0 == ut_dulint_cmp(id, ut_dulint_max)) {
printf("Max id\n"); /* TO DO: remove this code, or make it conditional */
ut_dbg_null_ptr = 0;
} }
id = ut_dulint_add(id, 1); id = ut_dulint_add(id, 1);

View File

@ -25,11 +25,6 @@ Created 1/8/1996 Heikki Tuuri
#include "trx0roll.h" #include "trx0roll.h"
#include "usr0sess.h" #include "usr0sess.h"
/* Maximum lengths of identifiers in MySQL, in bytes */
#define MAX_TABLE_NAME_LEN 64
#define MAX_COLUMN_NAME_LEN 64
#define MAX_IDENTIFIER_LEN 255
/********************************************************************* /*********************************************************************
Based on a table object, this function builds the entry to be inserted Based on a table object, this function builds the entry to be inserted
in the SYS_TABLES system table. */ in the SYS_TABLES system table. */
@ -1105,7 +1100,7 @@ dict_create_add_foreigns_to_dictionary(
ulint number = start_id + 1; ulint number = start_id + 1;
ulint len; ulint len;
ulint error; ulint error;
char* ebuf = dict_foreign_err_buf; FILE* ef = dict_foreign_err_file;
ulint i; ulint i;
char* sql; char* sql;
char* sqlend; char* sqlend;
@ -1223,14 +1218,17 @@ loop:
if (error == DB_DUPLICATE_KEY) { if (error == DB_DUPLICATE_KEY) {
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
ut_sprintf_timestamp(ebuf); rewind(ef);
ut_a(strlen(ebuf) < DICT_FOREIGN_ERR_BUF_LEN ut_print_timestamp(ef);
- MAX_TABLE_NAME_LEN - MAX_IDENTIFIER_LEN - 201); fputs(" Error in foreign key constraint creation for table ",
sprintf(ebuf + strlen(ebuf), ef);
" Error in foreign key constraint creation for table %s.\n" ut_print_name(ef, table->name);
"A foreign key constraint of name %s\n" fputs(".\nA foreign key constraint of name ", ef);
"already exists (note that internally InnoDB adds 'databasename/'\n" ut_print_name(ef, foreign->id);
"in front of the user-defined constraint name).\n", table->name, foreign->id); fputs("\nalready exists."
" (Note that internally InnoDB adds 'databasename/'\n"
"in front of the user-defined constraint name).\n",
ef);
mutex_exit(&dict_foreign_err_mutex); mutex_exit(&dict_foreign_err_mutex);
@ -1243,12 +1241,12 @@ loop:
"InnoDB: internal error number %lu\n", error); "InnoDB: internal error number %lu\n", error);
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
ut_sprintf_timestamp(ebuf); ut_print_timestamp(ef);
ut_a(strlen(ebuf) < DICT_FOREIGN_ERR_BUF_LEN fputs(" Internal error in foreign key constraint creation"
- MAX_TABLE_NAME_LEN - 124); " for table ", ef);
sprintf(ebuf + strlen(ebuf), ut_print_name(ef, table->name);
" Internal error in foreign key constraint creation for table %s.\n" fputs(".\n"
"See the MySQL .err log in the datadir for more information.\n", table->name); "See the MySQL .err log in the datadir for more information.\n", ef);
mutex_exit(&dict_foreign_err_mutex); mutex_exit(&dict_foreign_err_mutex);
return(error); return(error);

View File

@ -132,7 +132,7 @@ dict_index_build_internal_non_clust(
dict_index_t* index); /* in: user representation of a non-clustered dict_index_t* index); /* in: user representation of a non-clustered
index */ index */
/************************************************************************** /**************************************************************************
Removes a foreign constraint struct from the dictionary cache. */ Removes a foreign constraint struct from the dictionet cache. */
static static
void void
dict_foreign_remove_from_cache( dict_foreign_remove_from_cache(
@ -167,10 +167,9 @@ dict_foreign_free(
/*==============*/ /*==============*/
dict_foreign_t* foreign); /* in, own: foreign key struct */ dict_foreign_t* foreign); /* in, own: foreign key struct */
/* Buffers for storing detailed information about the latest foreign key /* Stream for storing detailed information about the latest foreign key
and unique key errors */ and unique key errors */
char* dict_foreign_err_buf = NULL; FILE* dict_foreign_err_file = NULL;
char* dict_unique_err_buf = NULL;
mutex_t dict_foreign_err_mutex; /* mutex protecting the foreign mutex_t dict_foreign_err_mutex; /* mutex protecting the foreign
and unique error buffers */ and unique error buffers */
@ -643,10 +642,7 @@ dict_init(void)
rw_lock_create(&dict_operation_lock); rw_lock_create(&dict_operation_lock);
rw_lock_set_level(&dict_operation_lock, SYNC_DICT_OPERATION); rw_lock_set_level(&dict_operation_lock, SYNC_DICT_OPERATION);
dict_foreign_err_buf = mem_alloc(DICT_FOREIGN_ERR_BUF_LEN); dict_foreign_err_file = tmpfile();
dict_foreign_err_buf[0] = '\0';
dict_unique_err_buf = mem_alloc(DICT_FOREIGN_ERR_BUF_LEN);
dict_unique_err_buf[0] = '\0';
mutex_create(&dict_foreign_err_mutex); mutex_create(&dict_foreign_err_mutex);
mutex_set_level(&dict_foreign_err_mutex, SYNC_ANY_LATCH); mutex_set_level(&dict_foreign_err_mutex, SYNC_ANY_LATCH);
} }
@ -1064,7 +1060,11 @@ dict_table_remove_from_cache(
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
/* printf("Removing table %s from dictionary cache\n", table->name); */ #if 0
fputs("Removing table ", stderr);
ut_print_name(stderr, table->name, ULINT_UNDEFINED);
fputs(" from dictionary cache\n", stderr);
#endif
/* Remove the foreign constraints from the cache */ /* Remove the foreign constraints from the cache */
foreign = UT_LIST_GET_LAST(table->foreign_list); foreign = UT_LIST_GET_LAST(table->foreign_list);
@ -1986,6 +1986,45 @@ dict_foreign_find_index(
return(NULL); return(NULL);
} }
/**************************************************************************
Report an error in a foreign key definition. */
static
void
dict_foreign_error_report_low(
FILE* file, /* in: output stream */
const char* name) /* in: table name */
{
rewind(file);
ut_print_timestamp(file);
fputs(" Error in foreign key constraint of table ", file);
ut_print_name(file, name);
fputs(":\n", file);
}
/**************************************************************************
Report an error in a foreign key definition. */
static
void
dict_foreign_error_report(
FILE* file, /* in: output stream */
dict_foreign_t* fk, /* in: foreign key constraint */
const char* msg) /* in: the error message */
{
mutex_enter(&dict_foreign_err_mutex);
dict_foreign_error_report_low(file, fk->foreign_table_name);
fputs(msg, file);
fputs(" Constraint:\n", file);
dict_print_info_on_foreign_key_in_create_format(file, fk);
if (fk->foreign_index) {
fputs("\nThe index in the foreign key in table is ", file);
ut_print_name(file, fk->foreign_index->name);
fputs(
"See http://www.innodb.com/ibman.php for correct foreign key definition.\n",
file);
}
mutex_exit(&dict_foreign_err_mutex);
}
/************************************************************************** /**************************************************************************
Adds a foreign key constraint object to the dictionary cache. May free Adds a foreign key constraint object to the dictionary cache. May free
the object if there already is an object with the same identifier in. the object if there already is an object with the same identifier in.
@ -2003,7 +2042,7 @@ dict_foreign_add_to_cache(
dict_foreign_t* for_in_cache = NULL; dict_foreign_t* for_in_cache = NULL;
dict_index_t* index; dict_index_t* index;
ibool added_to_referenced_list= FALSE; ibool added_to_referenced_list= FALSE;
char* buf = dict_foreign_err_buf; FILE* ef = dict_foreign_err_file;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&(dict_sys->mutex))); ut_ad(mutex_own(&(dict_sys->mutex)));
@ -2038,24 +2077,10 @@ dict_foreign_add_to_cache(
for_in_cache->foreign_index); for_in_cache->foreign_index);
if (index == NULL) { if (index == NULL) {
mutex_enter(&dict_foreign_err_mutex); dict_foreign_error_report(ef, for_in_cache,
ut_sprintf_timestamp(buf);
sprintf(buf + strlen(buf),
" Error in foreign key constraint of table %.500s:\n"
"there is no index in referenced table which would contain\n" "there is no index in referenced table which would contain\n"
"the columns as the first columns, or the data types in the\n" "the columns as the first columns, or the data types in the\n"
"referenced table do not match to the ones in table. Constraint:\n", "referenced table do not match to the ones in table.");
for_in_cache->foreign_table_name);
dict_print_info_on_foreign_key_in_create_format(
for_in_cache, buf + strlen(buf));
if (for_in_cache->foreign_index) {
sprintf(buf + strlen(buf),
"\nThe index in the foreign key in table is %.500s\n"
"See http://www.innodb.com/ibman.html about correct foreign key definition.\n",
for_in_cache->foreign_index->name);
}
ut_a(strlen(buf) < DICT_FOREIGN_ERR_BUF_LEN);
mutex_exit(&dict_foreign_err_mutex);
if (for_in_cache == foreign) { if (for_in_cache == foreign) {
mem_heap_free(foreign->heap); mem_heap_free(foreign->heap);
@ -2079,24 +2104,10 @@ dict_foreign_add_to_cache(
for_in_cache->referenced_index); for_in_cache->referenced_index);
if (index == NULL) { if (index == NULL) {
mutex_enter(&dict_foreign_err_mutex); dict_foreign_error_report(ef, for_in_cache,
ut_sprintf_timestamp(buf);
sprintf(buf + strlen(buf),
" Error in foreign key constraint of table %.500s:\n"
"there is no index in the table which would contain\n" "there is no index in the table which would contain\n"
"the columns as the first columns, or the data types in the\n" "the columns as the first columns, or the data types in the\n"
"table do not match to the ones in the referenced table. Constraint:\n", "table do not match to the ones in the referenced table.");
for_in_cache->foreign_table_name);
dict_print_info_on_foreign_key_in_create_format(
for_in_cache, buf + strlen(buf));
if (for_in_cache->foreign_index) {
sprintf(buf + strlen(buf),
"\nIndex of the foreign key in the referenced table is %.500s\n"
"See http://www.innodb.com/ibman.html about correct foreign key definition.\n",
for_in_cache->referenced_index->name);
}
ut_a(strlen(buf) < DICT_FOREIGN_ERR_BUF_LEN);
mutex_exit(&dict_foreign_err_mutex);
if (for_in_cache == foreign) { if (for_in_cache == foreign) {
if (added_to_referenced_list) { if (added_to_referenced_list) {
@ -2600,17 +2611,12 @@ dict_foreign_report_syntax_err(
in the SQL string */ in the SQL string */
const char* ptr) /* in: place of the syntax error */ const char* ptr) /* in: place of the syntax error */
{ {
char* buf = dict_foreign_err_buf; FILE* ef = dict_foreign_err_file;
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
dict_foreign_error_report_low(ef, name);
ut_sprintf_timestamp(buf); fprintf(ef, "%s:\nSyntax error close to:\n%s\n",
start_of_latest_foreign, ptr);
sprintf(buf + strlen(buf),
" Error in foreign key constraint of table %.500s,\n%.500s.\n"
"Syntax error close to:\n%.500s\n", name, start_of_latest_foreign, ptr);
ut_a(strlen(buf) < DICT_FOREIGN_ERR_BUF_LEN);
mutex_exit(&dict_foreign_err_mutex); mutex_exit(&dict_foreign_err_mutex);
} }
@ -2645,7 +2651,7 @@ dict_create_foreign_constraints_low(
dict_foreign_t* foreign; dict_foreign_t* foreign;
const char* ptr = sql_string; const char* ptr = sql_string;
const char* start_of_latest_foreign = sql_string; const char* start_of_latest_foreign = sql_string;
char* buf = dict_foreign_err_buf; FILE* ef = dict_foreign_err_file;
const char* constraint_name; const char* constraint_name;
ibool success; ibool success;
ulint error; ulint error;
@ -2668,12 +2674,10 @@ dict_create_foreign_constraints_low(
if (table == NULL) { if (table == NULL) {
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
ut_sprintf_timestamp(buf); dict_foreign_error_report_low(ef, name);
sprintf(buf + strlen(buf), fprintf(ef,
" Error in foreign key constraint of table %.500s.\n" "Cannot find the table in the internal data dictionary of InnoDB.\n"
"Cannot find the table from the internal data dictionary of InnoDB.\n" "Create table statement:\n%s\n", sql_string);
"Create table statement:\n%.2000s\n", name, sql_string);
ut_a(strlen(buf) < DICT_FOREIGN_ERR_BUF_LEN);
mutex_exit(&dict_foreign_err_mutex); mutex_exit(&dict_foreign_err_mutex);
return(DB_ERROR); return(DB_ERROR);
@ -2682,23 +2686,21 @@ dict_create_foreign_constraints_low(
/* First check if we are actually doing an ALTER TABLE, and in that /* First check if we are actually doing an ALTER TABLE, and in that
case look for the table being altered */ case look for the table being altered */
ptr = dict_accept(ptr, (char*) "ALTER", &success); ptr = dict_accept(ptr, "ALTER", &success);
if (!success) { if (!success) {
goto loop; goto loop;
} }
ptr = dict_accept(ptr, (char*) "TABLE", &success); ptr = dict_accept(ptr, "TABLE", &success);
if (!success) { if (!success) {
goto loop; goto loop;
} }
/* We are doing an ALTER TABLE: scan the table name we are altering; /* We are doing an ALTER TABLE: scan the table name we are altering */
in the call below we use the buffer 'referenced_table_name' as a dummy
buffer */
ptr = dict_scan_table_name(ptr, &table_to_alter, name, ptr = dict_scan_table_name(ptr, &table_to_alter, name,
&success, heap, &referenced_table_name); &success, heap, &referenced_table_name);
@ -2817,12 +2819,9 @@ col_loop1:
heap, column_names + i); heap, column_names + i);
if (!success) { if (!success) {
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
ut_sprintf_timestamp(buf); dict_foreign_error_report_low(ef, name);
sprintf(buf + strlen(buf), fprintf(ef, "%s:\nCannot resolve column name close to:\n%s\n",
" Error in foreign key constraint of table %.500s,\n%.500s.\n"
"Cannot resolve column name close to:\n%.500s\n", name,
start_of_latest_foreign, ptr); start_of_latest_foreign, ptr);
ut_a(strlen(buf) < DICT_FOREIGN_ERR_BUF_LEN);
mutex_exit(&dict_foreign_err_mutex); mutex_exit(&dict_foreign_err_mutex);
return(DB_CANNOT_ADD_CONSTRAINT); return(DB_CANNOT_ADD_CONSTRAINT);
@ -2851,19 +2850,18 @@ col_loop1:
if (!index) { if (!index) {
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
ut_sprintf_timestamp(buf); dict_foreign_error_report_low(ef, name);
sprintf(buf + strlen(buf), fputs("There is no index in table ", ef);
" Error in foreign key constraint of table %.500s:\n" ut_print_name(ef, name);
"There is no index in the table %.500s where the columns appear\n" fprintf(ef, " where the columns appear\n"
"as the first columns. Constraint:\n%.500s\n" "as the first columns. Constraint:\n%s\n"
"See http://www.innodb.com/ibman.html for correct foreign key definition.\n", "See http://www.innodb.com/ibman.php for correct foreign key definition.\n",
name, name, start_of_latest_foreign); start_of_latest_foreign);
ut_a(strlen(buf) < DICT_FOREIGN_ERR_BUF_LEN);
mutex_exit(&dict_foreign_err_mutex); mutex_exit(&dict_foreign_err_mutex);
return(DB_CANNOT_ADD_CONSTRAINT); return(DB_CANNOT_ADD_CONSTRAINT);
} }
ptr = dict_accept(ptr, (char *) "REFERENCES", &success); ptr = dict_accept(ptr, "REFERENCES", &success);
if (!success || !isspace(*ptr)) { if (!success || !isspace(*ptr)) {
dict_foreign_report_syntax_err(name, start_of_latest_foreign, dict_foreign_report_syntax_err(name, start_of_latest_foreign,
@ -2914,18 +2912,16 @@ col_loop1:
dict_foreign_free(foreign); dict_foreign_free(foreign);
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
ut_sprintf_timestamp(buf); dict_foreign_error_report_low(ef, name);
sprintf(buf + strlen(buf), fprintf(ef, "%s:\nCannot resolve table name close to:\n"
" Error in foreign key constraint of table %.500s,\n%.500s.\n" "%s\n",
"Cannot resolve table name close to:\n" start_of_latest_foreign, ptr);
"%.500s\n", name, start_of_latest_foreign, ptr);
ut_a(strlen(buf) < DICT_FOREIGN_ERR_BUF_LEN);
mutex_exit(&dict_foreign_err_mutex); mutex_exit(&dict_foreign_err_mutex);
return(DB_CANNOT_ADD_CONSTRAINT); return(DB_CANNOT_ADD_CONSTRAINT);
} }
ptr = dict_accept(ptr, (char *) "(", &success); ptr = dict_accept(ptr, "(", &success);
if (!success) { if (!success) {
dict_foreign_free(foreign); dict_foreign_free(foreign);
@ -2946,24 +2942,22 @@ col_loop2:
dict_foreign_free(foreign); dict_foreign_free(foreign);
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
ut_sprintf_timestamp(buf); dict_foreign_error_report_low(ef, name);
sprintf(buf + strlen(buf), fprintf(ef, "%s:\nCannot resolve column name close to:\n"
" Error in foreign key constraint of table %.500s,\n%.500s\n" "%s\n",
"Cannot resolve column name close to:\n" start_of_latest_foreign, ptr);
"%.500s\n", name, start_of_latest_foreign, ptr);
ut_a(strlen(buf) < DICT_FOREIGN_ERR_BUF_LEN);
mutex_exit(&dict_foreign_err_mutex); mutex_exit(&dict_foreign_err_mutex);
return(DB_CANNOT_ADD_CONSTRAINT); return(DB_CANNOT_ADD_CONSTRAINT);
} }
ptr = dict_accept(ptr, (char *) ",", &success); ptr = dict_accept(ptr, ",", &success);
if (success) { if (success) {
goto col_loop2; goto col_loop2;
} }
ptr = dict_accept(ptr, (char *) ")", &success); ptr = dict_accept(ptr, ")", &success);
if (!success || foreign->n_fields != i) { if (!success || foreign->n_fields != i) {
dict_foreign_free(foreign); dict_foreign_free(foreign);
@ -3075,12 +3069,10 @@ scan_on_conditions:
dict_foreign_free(foreign); dict_foreign_free(foreign);
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
ut_sprintf_timestamp(buf); dict_foreign_error_report_low(ef, name);
sprintf(buf + strlen(buf), fprintf(ef, "%s:\n"
" Error in foreign key constraint of table %.500s,\n%.500s.\n"
"You have defined a SET NULL condition though some of the\n" "You have defined a SET NULL condition though some of the\n"
"columns is defined as NOT NULL.\n", name, start_of_latest_foreign); "columns are defined as NOT NULL.\n", start_of_latest_foreign);
ut_a(strlen(buf) < DICT_FOREIGN_ERR_BUF_LEN);
mutex_exit(&dict_foreign_err_mutex); mutex_exit(&dict_foreign_err_mutex);
return(DB_CANNOT_ADD_CONSTRAINT); return(DB_CANNOT_ADD_CONSTRAINT);
@ -3102,12 +3094,10 @@ try_find_index:
dict_foreign_free(foreign); dict_foreign_free(foreign);
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
ut_sprintf_timestamp(buf); dict_foreign_error_report_low(ef, name);
sprintf(buf + strlen(buf), fprintf(ef, "%s:\n"
" Error in foreign key constraint of table %.500s,\n%.500s.\n"
"You have twice an ON DELETE clause or twice an ON UPDATE clause.\n", "You have twice an ON DELETE clause or twice an ON UPDATE clause.\n",
name, start_of_latest_foreign); start_of_latest_foreign);
ut_a(strlen(buf) < DICT_FOREIGN_ERR_BUF_LEN);
mutex_exit(&dict_foreign_err_mutex); mutex_exit(&dict_foreign_err_mutex);
return(DB_CANNOT_ADD_CONSTRAINT); return(DB_CANNOT_ADD_CONSTRAINT);
@ -3124,15 +3114,13 @@ try_find_index:
if (!index) { if (!index) {
dict_foreign_free(foreign); dict_foreign_free(foreign);
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
ut_sprintf_timestamp(buf); dict_foreign_error_report_low(ef, name);
sprintf(buf + strlen(buf), fprintf(ef, "%s:\n"
" Error in foreign key constraint of table %.500s:\n"
"Cannot find an index in the referenced table where the\n" "Cannot find an index in the referenced table where the\n"
"referenced columns appear as the first columns, or column types\n" "referenced columns appear as the first columns, or column types\n"
"in the table and the referenced table do not match for constraint:\n%.500s\n" "in the table and the referenced table do not match for constraint.\n"
"See http://www.innodb.com/ibman.html for correct foreign key definition.\n", "See http://www.innodb.com/ibman.php for correct foreign key definition.\n",
name, start_of_latest_foreign); start_of_latest_foreign);
ut_a(strlen(buf) < DICT_FOREIGN_ERR_BUF_LEN);
mutex_exit(&dict_foreign_err_mutex); mutex_exit(&dict_foreign_err_mutex);
return(DB_CANNOT_ADD_CONSTRAINT); return(DB_CANNOT_ADD_CONSTRAINT);
@ -3227,8 +3215,8 @@ dict_foreign_parse_drop_constraints(
ibool success; ibool success;
char* str; char* str;
const char* ptr; const char* ptr;
char* buf = dict_foreign_err_buf;
const char* id; const char* id;
FILE* ef = dict_foreign_err_file;
*n = 0; *n = 0;
@ -3299,12 +3287,17 @@ loop:
if (foreign == NULL) { if (foreign == NULL) {
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
ut_sprintf_timestamp(buf); rewind(ef);
sprintf(buf + strlen(buf), ut_print_timestamp(ef);
" Error in dropping of a foreign key constraint of table %.500s,\n" fputs(
"in SQL command\n%s\nCannot find a constraint with the\n" " Error in dropping of a foreign key constraint of table ", ef);
"given id %s.\n", table->name, str, id); ut_print_name(ef, table->name);
ut_a(strlen(buf) < DICT_FOREIGN_ERR_BUF_LEN); fputs(",\n"
"in SQL command\n", ef);
fputs(str, ef);
fputs("\nCannot find a constraint with the given id ", ef);
ut_print_name(ef, id);
fputs(".\n", ef);
mutex_exit(&dict_foreign_err_mutex); mutex_exit(&dict_foreign_err_mutex);
mem_free(str); mem_free(str);
@ -3316,11 +3309,13 @@ loop:
syntax_error: syntax_error:
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
ut_sprintf_timestamp(buf); rewind(ef);
sprintf(buf + strlen(buf), ut_print_timestamp(ef);
" Syntax error in dropping of a foreign key constraint of table %.500s,\n" fputs(
"close to:\n%s\n in SQL command\n%s\n", table->name, ptr, str); " Syntax error in dropping of a foreign key constraint of table ", ef);
ut_a(strlen(buf) < DICT_FOREIGN_ERR_BUF_LEN); ut_print_name(ef, table->name);
fprintf(ef, ",\n"
"close to:\n%s\n in SQL command\n%s\n", ptr, str);
mutex_exit(&dict_foreign_err_mutex); mutex_exit(&dict_foreign_err_mutex);
mem_free(str); mem_free(str);
@ -3800,22 +3795,28 @@ dict_foreign_print_low(
ut_ad(mutex_own(&(dict_sys->mutex))); ut_ad(mutex_own(&(dict_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
printf(" FOREIGN KEY CONSTRAINT %s: %s (", foreign->id, fputs(" FOREIGN KEY CONSTRAINT ", stderr);
foreign->foreign_table_name); ut_print_name(stderr, foreign->id);
fputs(": ", stderr);
ut_print_name(stderr, foreign->foreign_table_name);
fputs(" (", stderr);
for (i = 0; i < foreign->n_fields; i++) { for (i = 0; i < foreign->n_fields; i++) {
printf(" %s", foreign->foreign_col_names[i]); putc(' ', stderr);
ut_print_name(stderr, foreign->foreign_col_names[i]);
} }
printf(" )\n"); fputs(" )\n"
" REFERENCES ", stderr);
printf(" REFERENCES %s (", foreign->referenced_table_name); ut_print_name(stderr, foreign->referenced_table_name);
fputs(" (", stderr);
for (i = 0; i < foreign->n_fields; i++) { for (i = 0; i < foreign->n_fields; i++) {
printf(" %s", foreign->referenced_col_names[i]); putc(' ', stderr);
ut_print_name(stderr, foreign->referenced_col_names[i]);
} }
printf(" )\n"); fputs(" )\n", stderr);
} }
/************************************************************************** /**************************************************************************
@ -3869,22 +3870,23 @@ dict_table_print_low(
dict_update_statistics_low(table, TRUE); dict_update_statistics_low(table, TRUE);
printf("--------------------------------------\n"); fputs("--------------------------------------\n"
printf( "TABLE: name ", stderr);
"TABLE: name %s, id %lu %lu, columns %lu, indexes %lu, appr.rows %lu\n", ut_print_name(stderr, table->name);
table->name, fprintf(stderr,
", id %lu %lu, columns %lu, indexes %lu, appr.rows %lu\n"
" COLUMNS: ",
ut_dulint_get_high(table->id), ut_dulint_get_high(table->id),
ut_dulint_get_low(table->id), ut_dulint_get_low(table->id),
table->n_cols, UT_LIST_GET_LEN(table->indexes), table->n_cols, UT_LIST_GET_LEN(table->indexes),
(ulint)table->stat_n_rows); (ulint)table->stat_n_rows);
printf(" COLUMNS: ");
for (i = 0; i < table->n_cols - 1; i++) { for (i = 0; i < table->n_cols - 1; i++) {
dict_col_print_low(dict_table_get_nth_col(table, i)); dict_col_print_low(dict_table_get_nth_col(table, i));
printf("; "); fputs("; ", stderr);
} }
printf("\n"); putc('\n', stderr);
index = UT_LIST_GET_FIRST(table->indexes); index = UT_LIST_GET_FIRST(table->indexes);
@ -3923,7 +3925,8 @@ dict_col_print_low(
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
type = dict_col_get_type(col); type = dict_col_get_type(col);
printf("%s: ", col->name); ut_print_name(stderr, col->name);
fputs(": ", stderr);
dtype_print(type); dtype_print(type);
} }
@ -3953,27 +3956,27 @@ dict_index_print_low(
n_vals = index->stat_n_diff_key_vals[1]; n_vals = index->stat_n_diff_key_vals[1];
} }
printf( fputs(" INDEX: ", stderr);
" INDEX: name %s, table name %s, id %lu %lu, fields %lu/%lu, type %lu\n", dict_index_name_print(stderr, index);
index->name, index->table_name, fprintf(stderr,
", id %lu %lu, fields %lu/%lu, type %lu\n"
" root page %lu, appr.key vals %lu,"
" leaf pages %lu, size pages %lu\n"
" FIELDS: ",
ut_dulint_get_high(tree->id), ut_dulint_get_high(tree->id),
ut_dulint_get_low(tree->id), ut_dulint_get_low(tree->id),
index->n_user_defined_cols, index->n_user_defined_cols,
index->n_fields, index->type); index->n_fields, index->type,
printf(
" root page %lu, appr.key vals %lu, leaf pages %lu, size pages %lu\n",
tree->page, tree->page,
(ulint)n_vals, (ulint)n_vals,
index->stat_n_leaf_pages, index->stat_n_leaf_pages,
index->stat_index_size); index->stat_index_size);
printf(" FIELDS: ");
for (i = 0; i < index->n_fields; i++) { for (i = 0; i < index->n_fields; i++) {
dict_field_print_low(dict_index_get_nth_field(index, i)); dict_field_print_low(dict_index_get_nth_field(index, i));
} }
printf("\n"); putc('\n', stderr);
/* btr_print_size(tree); */ /* btr_print_size(tree); */
@ -3991,28 +3994,25 @@ dict_field_print_low(
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&(dict_sys->mutex))); ut_ad(mutex_own(&(dict_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
putc(' ', stderr);
printf(" %s", field->name); ut_print_name(stderr, field->name);
if (field->prefix_len != 0) { if (field->prefix_len != 0) {
printf("(%lu)", field->prefix_len); fprintf(stderr, "(%lu)", field->prefix_len);
} }
} }
/************************************************************************** /**************************************************************************
Sprintfs to a string info on a foreign key of a table in a format suitable Outputs info on a foreign key of a table in a format suitable for
for CREATE TABLE. */ CREATE TABLE. */
char* void
dict_print_info_on_foreign_key_in_create_format( dict_print_info_on_foreign_key_in_create_format(
/*============================================*/ /*============================================*/
/* out: how far in buf we printed */ FILE* file, /* in: file where to print */
dict_foreign_t* foreign,/* in: foreign key constraint */ dict_foreign_t* foreign)/* in: foreign key constraint */
char* buf) /* in: buffer of at least 5000 bytes */
{ {
char* buf2 = buf; const char* stripped_id;
char* stripped_id;
ulint cpy_len;
ulint i; ulint i;
if (strchr(foreign->id, '/')) { if (strchr(foreign->id, '/')) {
@ -4023,30 +4023,27 @@ dict_print_info_on_foreign_key_in_create_format(
stripped_id = foreign->id; stripped_id = foreign->id;
} }
buf2 += sprintf(buf2, ",\n CONSTRAINT `%s` FOREIGN KEY (", fputs(",\n CONSTRAINT ", file);
stripped_id); ut_print_name(file, stripped_id);
for (i = 0; i < foreign->n_fields; i++) { fputs(" FOREIGN KEY (", file);
if ((ulint)(buf2 - buf) >= 4000) {
goto no_space; for (i = 0;;) {
ut_print_name(file, foreign->foreign_col_names[i]);
if (++i < foreign->n_fields) {
fputs(", ", file);
} else {
break;
}
} }
buf2 += sprintf(buf2, "`%.250s`",
foreign->foreign_col_names[i]);
if (i + 1 < foreign->n_fields) { fputs(") REFERENCES ", file);
buf2 += sprintf(buf2, ", ");
}
}
if (dict_tables_have_same_db(foreign->foreign_table_name, if (dict_tables_have_same_db(foreign->foreign_table_name,
foreign->referenced_table_name)) { foreign->referenced_table_name)) {
/* Do not print the database name of the referenced table */ /* Do not print the database name of the referenced table */
buf2 += sprintf(buf2, ") REFERENCES `%.500s` (", ut_print_name(file, dict_remove_db_name(
dict_remove_db_name(
foreign->referenced_table_name)); foreign->referenced_table_name));
} else { } else {
buf2 += sprintf(buf2, ") REFERENCES `");
/* Look for the '/' in the table name */ /* Look for the '/' in the table name */
i = 0; i = 0;
@ -4054,109 +4051,52 @@ dict_print_info_on_foreign_key_in_create_format(
i++; i++;
} }
cpy_len = i; ut_print_namel(file, foreign->referenced_table_name, i);
putc('.', file);
if (cpy_len > 500) { ut_print_name(file, foreign->referenced_table_name + i + 1);
cpy_len = 500;
} }
memcpy(buf2, foreign->referenced_table_name, cpy_len); putc(' ', file);
buf2 += cpy_len; putc('(', file);
buf2 += sprintf(buf2, "`.`%.500s` (", for (i = 0;;) {
foreign->referenced_table_name + i + 1); ut_print_name(file, foreign->referenced_col_names[i]);
} if (++i < foreign->n_fields) {
fputs(", ", file);
for (i = 0; i < foreign->n_fields; i++) { } else {
if ((ulint)(buf2 - buf) >= 4000) { break;
goto no_space;
}
buf2 += sprintf(buf2, "`%.250s`",
foreign->referenced_col_names[i]);
if (i + 1 < foreign->n_fields) {
buf2 += sprintf(buf2, ", ");
} }
} }
buf2 += sprintf(buf2, ")"); putc(')', file);
if (foreign->type & DICT_FOREIGN_ON_DELETE_CASCADE) { if (foreign->type & DICT_FOREIGN_ON_DELETE_CASCADE) {
buf2 += sprintf(buf2, " ON DELETE CASCADE"); fputs(" ON DELETE CASCADE", file);
} }
if (foreign->type & DICT_FOREIGN_ON_DELETE_SET_NULL) { if (foreign->type & DICT_FOREIGN_ON_DELETE_SET_NULL) {
buf2 += sprintf(buf2, " ON DELETE SET NULL"); fputs(" ON DELETE SET NULL", file);
} }
if (foreign->type & DICT_FOREIGN_ON_DELETE_NO_ACTION) { if (foreign->type & DICT_FOREIGN_ON_DELETE_NO_ACTION) {
buf2 += sprintf(buf2, " ON DELETE NO ACTION"); fputs(" ON DELETE NO ACTION", file);
} }
if (foreign->type & DICT_FOREIGN_ON_UPDATE_CASCADE) { if (foreign->type & DICT_FOREIGN_ON_UPDATE_CASCADE) {
buf2 += sprintf(buf2, " ON UPDATE CASCADE"); fputs(" ON UPDATE CASCADE", file);
} }
if (foreign->type & DICT_FOREIGN_ON_UPDATE_SET_NULL) { if (foreign->type & DICT_FOREIGN_ON_UPDATE_SET_NULL) {
buf2 += sprintf(buf2, " ON UPDATE SET NULL"); fputs(" ON UPDATE SET NULL", file);
} }
if (foreign->type & DICT_FOREIGN_ON_UPDATE_NO_ACTION) { if (foreign->type & DICT_FOREIGN_ON_UPDATE_NO_ACTION) {
buf2 += sprintf(buf2, " ON UPDATE NO ACTION"); fputs(" ON UPDATE NO ACTION", file);
} }
no_space:
return(buf2);
} }
/************************************************************************** /**************************************************************************
Sprintfs to a string info on foreign keys of a table in a format suitable Outputs info on foreign keys of a table. */
for CREATE TABLE. */
static
void
dict_print_info_on_foreign_keys_in_create_format(
/*=============================================*/
char* buf, /* in: auxiliary buffer */
char* str, /* in/out: pointer to a string */
ulint len, /* in: buf has to be a buffer of at least
len + 5000 bytes; str must have at least
len + 1 bytes */
dict_table_t* table) /* in: table */
{
dict_foreign_t* foreign;
char* buf2;
buf2 = buf;
mutex_enter(&(dict_sys->mutex));
foreign = UT_LIST_GET_FIRST(table->foreign_list);
if (foreign == NULL) {
mutex_exit(&(dict_sys->mutex));
return;
}
while (foreign != NULL) {
if ((ulint)(buf2 - buf) >= len) {
goto no_space;
}
buf2 = dict_print_info_on_foreign_key_in_create_format(
foreign, buf2);
foreign = UT_LIST_GET_NEXT(foreign_list, foreign);
}
no_space:
mutex_exit(&(dict_sys->mutex));
buf[len - 1] = '\0';
ut_memcpy(str, buf, len);
}
/**************************************************************************
Sprintfs to a string info on foreign keys of a table. */
void void
dict_print_info_on_foreign_keys( dict_print_info_on_foreign_keys(
@ -4165,23 +4105,10 @@ dict_print_info_on_foreign_keys(
a format suitable to be inserted into a format suitable to be inserted into
a CREATE TABLE, otherwise in the format a CREATE TABLE, otherwise in the format
of SHOW TABLE STATUS */ of SHOW TABLE STATUS */
char* str, /* in/out: pointer to a string */ FILE* file, /* in: file where to print */
ulint len, /* in: space in str available for info */
dict_table_t* table) /* in: table */ dict_table_t* table) /* in: table */
{ {
dict_foreign_t* foreign; dict_foreign_t* foreign;
ulint i;
char* buf2;
char* buf;
buf = mem_alloc(len + 5000);
if (create_table_format) {
dict_print_info_on_foreign_keys_in_create_format(
buf, str, len, table);
mem_free(buf);
return;
}
mutex_enter(&(dict_sys->mutex)); mutex_enter(&(dict_sys->mutex));
@ -4190,76 +4117,81 @@ dict_print_info_on_foreign_keys(
if (foreign == NULL) { if (foreign == NULL) {
mutex_exit(&(dict_sys->mutex)); mutex_exit(&(dict_sys->mutex));
mem_free(buf);
return; return;
} }
buf2 = buf;
while (foreign != NULL) { while (foreign != NULL) {
if (create_table_format) {
buf2 += sprintf(buf2, "; ("); dict_print_info_on_foreign_key_in_create_format(
file, foreign);
} else {
ulint i;
fputs("; (", file);
for (i = 0; i < foreign->n_fields; i++) { for (i = 0; i < foreign->n_fields; i++) {
if ((ulint)(buf2 - buf) >= len) { if (i) {
goto no_space; putc(' ', file);
} }
buf2 += sprintf(buf2, "%.500s", ut_print_name(file,
foreign->foreign_col_names[i]); foreign->foreign_col_names[i]);
if (i + 1 < foreign->n_fields) {
buf2 += sprintf(buf2, " ");
}
} }
buf2 += sprintf(buf2, ") REFER %.500s(", fputs(") REFER ", file);
foreign->referenced_table_name); ut_print_name(file, foreign->referenced_table_name);
putc('(', file);
for (i = 0; i < foreign->n_fields; i++) { for (i = 0; i < foreign->n_fields; i++) {
if ((ulint)(buf2 - buf) >= len) { if (i) {
goto no_space; putc(' ', file);
} }
buf2 += sprintf(buf2, "%.500s", ut_print_name(file,
foreign->referenced_col_names[i]); foreign->referenced_col_names[i]);
if (i + 1 < foreign->n_fields) {
buf2 += sprintf(buf2, " ");
}
} }
buf2 += sprintf(buf2, ")"); putc(')', file);
if (foreign->type == DICT_FOREIGN_ON_DELETE_CASCADE) { if (foreign->type == DICT_FOREIGN_ON_DELETE_CASCADE) {
buf2 += sprintf(buf2, " ON DELETE CASCADE"); fputs(" ON DELETE CASCADE", file);
} }
if (foreign->type == DICT_FOREIGN_ON_DELETE_SET_NULL) { if (foreign->type == DICT_FOREIGN_ON_DELETE_SET_NULL) {
buf2 += sprintf(buf2, " ON DELETE SET NULL"); fputs(" ON DELETE SET NULL", file);
} }
if (foreign->type & DICT_FOREIGN_ON_DELETE_NO_ACTION) { if (foreign->type & DICT_FOREIGN_ON_DELETE_NO_ACTION) {
buf2 += sprintf(buf2, " ON DELETE NO ACTION"); fputs(" ON DELETE NO ACTION", file);
} }
if (foreign->type & DICT_FOREIGN_ON_UPDATE_CASCADE) { if (foreign->type & DICT_FOREIGN_ON_UPDATE_CASCADE) {
buf2 += sprintf(buf2, " ON UPDATE CASCADE"); fputs(" ON UPDATE CASCADE", file);
} }
if (foreign->type & DICT_FOREIGN_ON_UPDATE_SET_NULL) { if (foreign->type & DICT_FOREIGN_ON_UPDATE_SET_NULL) {
buf2 += sprintf(buf2, " ON UPDATE SET NULL"); fputs(" ON UPDATE SET NULL", file);
} }
if (foreign->type & DICT_FOREIGN_ON_UPDATE_NO_ACTION) { if (foreign->type & DICT_FOREIGN_ON_UPDATE_NO_ACTION) {
buf2 += sprintf(buf2, " ON UPDATE NO ACTION"); fputs(" ON UPDATE NO ACTION", file);
}
} }
foreign = UT_LIST_GET_NEXT(foreign_list, foreign); foreign = UT_LIST_GET_NEXT(foreign_list, foreign);
} }
no_space:
mutex_exit(&(dict_sys->mutex)); mutex_exit(&(dict_sys->mutex));
}
buf[len - 1] = '\0';
ut_memcpy(str, buf, len); /************************************************************************
Displays the names of the index and the table. */
mem_free(buf); void
dict_index_name_print(
/*==================*/
FILE* file, /* in: output stream */
const dict_index_t* index) /* in: index to print */
{
fputs("index ", file);
ut_print_name(file, index->name);
fputs(" of table ", file);
ut_print_name(stderr, index->table_name);
} }

View File

@ -162,8 +162,9 @@ loop:
mem_free(table_name); mem_free(table_name);
if (table == NULL) { if (table == NULL) {
fprintf(stderr, "InnoDB: Failed to load table %s\n", fputs("InnoDB: Failed to load table ", stderr);
table_name); ut_print_namel(stderr, field, len);
putc('\n', stderr);
} else { } else {
/* The table definition was corrupt if there /* The table definition was corrupt if there
is no index */ is no index */
@ -279,6 +280,27 @@ dict_load_columns(
mtr_commit(&mtr); mtr_commit(&mtr);
} }
/************************************************************************
Report that an index field or index for a table has been delete marked. */
static
void
dict_load_report_deleted_index(
char* name, /* in: table name */
ulint field) /* in: index field, or ULINT_UNDEFINED */
{
fputs("InnoDB: Error: data dictionary entry"
" for table ", stderr);
ut_print_name(stderr, name);
fputs(" is corrupt!\n", stderr);
if (field != ULINT_UNDEFINED) {
fprintf(stderr,
"InnoDB: Index field %lu is delete marked.\n", field);
}
else {
fputs("InnoDB: An index is delete marked.\n", stderr);
}
}
/************************************************************************ /************************************************************************
Loads definitions for index fields. */ Loads definitions for index fields. */
static static
@ -331,10 +353,7 @@ dict_load_fields(
ut_a(btr_pcur_is_on_user_rec(&pcur, &mtr)); ut_a(btr_pcur_is_on_user_rec(&pcur, &mtr));
if (rec_get_deleted_flag(rec)) { if (rec_get_deleted_flag(rec)) {
fprintf(stderr, dict_load_report_deleted_index(table->name, i);
"InnoDB: Error: data dictionary entry for table %s is corrupt!\n"
"InnoDB: An index field is delete marked.\n",
table->name);
} }
field = rec_get_nth_field(rec, 0, &len); field = rec_get_nth_field(rec, 0, &len);
@ -457,10 +476,8 @@ dict_load_indexes(
} }
if (rec_get_deleted_flag(rec)) { if (rec_get_deleted_flag(rec)) {
fprintf(stderr, dict_load_report_deleted_index(table->name,
"InnoDB: Error: data dictionary entry for table %s is corrupt!\n" ULINT_UNDEFINED);
"InnoDB: An index is delete marked.\n",
table->name);
btr_pcur_close(&pcur); btr_pcur_close(&pcur);
mtr_commit(&mtr); mtr_commit(&mtr);
@ -499,10 +516,12 @@ dict_load_indexes(
if (page_no == FIL_NULL) { if (page_no == FIL_NULL) {
fprintf(stderr, fputs("InnoDB: Error: trying to load index ", stderr);
"InnoDB: Error: trying to load index %s for table %s\n" ut_print_name(stderr, name_buf);
"InnoDB: but the index tree has been freed!\n", fputs(" for table ", stderr);
name_buf, table->name); ut_print_name(stderr, table->name);
fputs("\n"
"InnoDB: but the index tree has been freed!\n", stderr);
btr_pcur_close(&pcur); btr_pcur_close(&pcur);
mtr_commit(&mtr); mtr_commit(&mtr);
@ -513,10 +532,12 @@ dict_load_indexes(
if ((type & DICT_CLUSTERED) == 0 if ((type & DICT_CLUSTERED) == 0
&& NULL == dict_table_get_first_index(table)) { && NULL == dict_table_get_first_index(table)) {
fprintf(stderr, fputs("InnoDB: Error: trying to load index ", stderr);
"InnoDB: Error: trying to load index %s for table %s\n" ut_print_namel(stderr, name_buf, name_len);
"InnoDB: but the first index was not clustered!\n", fputs(" for table ", stderr);
name_buf, table->name); ut_print_name(stderr, table->name);
fputs("\n"
"InnoDB: but the first index is not clustered!\n", stderr);
btr_pcur_close(&pcur); btr_pcur_close(&pcur);
mtr_commit(&mtr); mtr_commit(&mtr);
@ -947,8 +968,10 @@ dict_load_foreign(
|| rec_get_deleted_flag(rec)) { || rec_get_deleted_flag(rec)) {
/* Not found */ /* Not found */
fprintf(stderr, fputs("InnoDB: Error A: cannot load foreign constraint ",
"InnoDB: Error A: cannot load foreign constraint %s\n", id); stderr);
ut_print_name(stderr, id);
putc('\n', stderr);
btr_pcur_close(&pcur); btr_pcur_close(&pcur);
mtr_commit(&mtr); mtr_commit(&mtr);
@ -962,8 +985,10 @@ dict_load_foreign(
/* Check if the id in record is the searched one */ /* Check if the id in record is the searched one */
if (len != ut_strlen(id) || ut_memcmp(id, field, len) != 0) { if (len != ut_strlen(id) || ut_memcmp(id, field, len) != 0) {
fprintf(stderr, fputs("InnoDB: Error B: cannot load foreign constraint ",
"InnoDB: Error B: cannot load foreign constraint %s\n", id); stderr);
ut_print_name(stderr, id);
putc('\n', stderr);
btr_pcur_close(&pcur); btr_pcur_close(&pcur);
mtr_commit(&mtr); mtr_commit(&mtr);

View File

@ -311,12 +311,13 @@ eval_predefined_2(
arg = que_node_get_next(arg); arg = que_node_get_next(arg);
} }
printf("\n"); putc('\n', stderr);
} else if (func == PARS_ASSERT_TOKEN) { } else if (func == PARS_ASSERT_TOKEN) {
if (!eval_node_get_ibool_val(arg1)) { if (!eval_node_get_ibool_val(arg1)) {
printf("SQL assertion fails in a stored procedure!\n"); fputs("SQL assertion fails in a stored procedure!\n",
stderr);
} }
ut_a(eval_node_get_ibool_val(arg1)); ut_a(eval_node_get_ibool_val(arg1));

View File

@ -1408,7 +1408,8 @@ fil_flush(
will not crash or trap even if we pass a handle will not crash or trap even if we pass a handle
to a closed file below in os_file_flush! */ to a closed file below in os_file_flush! */
/* printf("Flushing to file %s\n", node->name); */ /* fprintf(stderr, "Flushing to file %s\n",
node->name); */
os_file_flush(file); os_file_flush(file);

View File

@ -1273,7 +1273,7 @@ fsp_alloc_free_page(
hint % FSP_EXTENT_SIZE, mtr); hint % FSP_EXTENT_SIZE, mtr);
if (free == ULINT_UNDEFINED) { if (free == ULINT_UNDEFINED) {
ut_print_buf(((byte*)descr) - 500, 1000); ut_print_buf(stderr, ((byte*)descr) - 500, 1000);
ut_error; ut_error;
} }
@ -1332,11 +1332,10 @@ fsp_free_page(
xdes_t* descr; xdes_t* descr;
ulint state; ulint state;
ulint frag_n_used; ulint frag_n_used;
char buf[1000];
ut_ad(mtr); ut_ad(mtr);
/* printf("Freeing page %lu in space %lu\n", page, space); */ /* fprintf(stderr, "Freeing page %lu in space %lu\n", page, space); */
header = fsp_get_space_header(space, mtr); header = fsp_get_space_header(space, mtr);
@ -1348,9 +1347,9 @@ fsp_free_page(
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: File space extent descriptor of page %lu has state %lu\n", "InnoDB: Error: File space extent descriptor of page %lu has state %lu\n",
page, state); page, state);
ut_sprintf_buf(buf, ((byte*)descr) - 50, 200); fputs("InnoDB: Dump of descriptor: ", stderr);
ut_print_buf(stderr, ((byte*)descr) - 50, 200);
fprintf(stderr, "InnoDB: Dump of descriptor: %s\n", buf); putc('\n', stderr);
if (state == XDES_FREE) { if (state == XDES_FREE) {
/* We put here some fault tolerance: if the page /* We put here some fault tolerance: if the page
@ -1362,14 +1361,12 @@ fsp_free_page(
ut_error; ut_error;
} }
if (xdes_get_bit(descr, XDES_FREE_BIT, page % FSP_EXTENT_SIZE, mtr) if (xdes_get_bit(descr, XDES_FREE_BIT, page % FSP_EXTENT_SIZE, mtr)) {
== TRUE) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: File space extent descriptor of page %lu says it is free\n", "InnoDB: Error: File space extent descriptor of page %lu says it is free\n"
page); "InnoDB: Dump of descriptor: ", page);
ut_sprintf_buf(buf, ((byte*)descr) - 50, 200); ut_print_buf(stderr, ((byte*)descr) - 50, 200);
putc('\n', stderr);
fprintf(stderr, "InnoDB: Dump of descriptor: %s\n", buf);
/* We put here some fault tolerance: if the page /* We put here some fault tolerance: if the page
is already free, return without doing anything! */ is already free, return without doing anything! */
@ -1427,7 +1424,7 @@ fsp_free_extent(
if (xdes_get_state(descr, mtr) == XDES_FREE) { if (xdes_get_state(descr, mtr) == XDES_FREE) {
ut_print_buf(((byte*)descr) - 500, 1000); ut_print_buf(stderr, (byte*)descr - 500, 1000);
ut_error; ut_error;
} }
@ -2672,7 +2669,6 @@ fseg_free_page_low(
ulint not_full_n_used; ulint not_full_n_used;
ulint state; ulint state;
ulint i; ulint i;
char errbuf[200];
#ifdef __WIN__ #ifdef __WIN__
dulint desm; dulint desm;
@ -2692,22 +2688,22 @@ fseg_free_page_low(
descr = xdes_get_descriptor(space, page, mtr); descr = xdes_get_descriptor(space, page, mtr);
ut_a(descr); ut_a(descr);
if (xdes_get_bit(descr, XDES_FREE_BIT, page % FSP_EXTENT_SIZE, mtr) if (xdes_get_bit(descr, XDES_FREE_BIT, page % FSP_EXTENT_SIZE, mtr)) {
!= FALSE) { fputs("InnoDB: Dump of the tablespace extent descriptor: ",
ut_sprintf_buf(errbuf, descr, 40); stderr);
fprintf(stderr, ut_print_buf(stderr, descr, 40);
"InnoDB: Dump of the tablespace extent descriptor: %s\n", errbuf);
fprintf(stderr, fprintf(stderr, "\n"
"InnoDB: Serious error! InnoDB is trying to free page %lu\n" "InnoDB: Serious error! InnoDB is trying to free page %lu\n"
"InnoDB: though it is already marked as free in the tablespace!\n" "InnoDB: though it is already marked as free in the tablespace!\n"
"InnoDB: The tablespace free space info is corrupt.\n" "InnoDB: The tablespace free space info is corrupt.\n"
"InnoDB: You may need to dump your InnoDB tables and recreate the whole\n" "InnoDB: You may need to dump your InnoDB tables and recreate the whole\n"
"InnoDB: database!\n", page); "InnoDB: database!\n", page);
crash:
fprintf(stderr, fputs(
"InnoDB: If the InnoDB recovery crashes here, see section 6.1\n" "InnoDB: If the InnoDB recovery crashes here, see section 6.1\n"
"InnoDB: of http://www.innodb.com/ibman.html about forcing recovery.\n"); "InnoDB: of http://www.innodb.com/ibman.php about forcing recovery.\n",
stderr);
ut_error; ut_error;
} }
@ -2751,12 +2747,12 @@ fseg_free_page_low(
mtr_read_dulint(descr + XDES_ID, mtr), mtr_read_dulint(descr + XDES_ID, mtr),
mtr_read_dulint(seg_inode + FSEG_ID, mtr))) { mtr_read_dulint(seg_inode + FSEG_ID, mtr))) {
ut_sprintf_buf(errbuf, descr, 40); fputs("InnoDB: Dump of the tablespace extent descriptor: ",
fprintf(stderr, stderr);
"InnoDB: Dump of the tablespace extent descriptor: %s\n", errbuf); ut_print_buf(stderr, descr, 40);
ut_sprintf_buf(errbuf, seg_inode, 40); fputs("\nInnoDB: Dump of the segment inode: ", stderr);
fprintf(stderr, ut_print_buf(stderr, seg_inode, 40);
"InnoDB: Dump of the segment inode: %s\n", errbuf); putc('\n', stderr);
#ifndef __WIN__ #ifndef __WIN__
@ -2794,11 +2790,7 @@ fseg_free_page_low(
ut_dulint_get_low(segm)); ut_dulint_get_low(segm));
#endif #endif
goto crash;
fprintf(stderr,
"InnoDB: If the InnoDB recovery crashes here, see section 6.1\n"
"InnoDB: of http://www.innodb.com/ibman.html about forcing recovery.\n");
ut_error;
} }
not_full_n_used = mtr_read_ulint(seg_inode + FSEG_NOT_FULL_N_USED, not_full_n_used = mtr_read_ulint(seg_inode + FSEG_NOT_FULL_N_USED,
@ -3311,12 +3303,11 @@ fseg_print_low(
n_not_full = flst_get_len(inode + FSEG_NOT_FULL, mtr); n_not_full = flst_get_len(inode + FSEG_NOT_FULL, mtr);
n_full = flst_get_len(inode + FSEG_FULL, mtr); n_full = flst_get_len(inode + FSEG_FULL, mtr);
printf( fprintf(stderr,
"SEGMENT id %lu %lu space %lu; page %lu; res %lu used %lu; full ext %lu\n", "SEGMENT id %lu %lu space %lu; page %lu; res %lu used %lu; full ext %lu\n"
seg_id_high, seg_id_low, space, page_no, reserved, used,
n_full);
printf(
"fragm pages %lu; free extents %lu; not full extents %lu: pages %lu\n", "fragm pages %lu; free extents %lu; not full extents %lu: pages %lu\n",
seg_id_high, seg_id_low, space, page_no, reserved, used,
n_full,
n_frag, n_free, n_not_full, n_used); n_frag, n_free, n_not_full, n_used);
} }
@ -3620,15 +3611,15 @@ fsp_print(
seg_id_low = ut_dulint_get_low(d_var); seg_id_low = ut_dulint_get_low(d_var);
seg_id_high = ut_dulint_get_high(d_var); seg_id_high = ut_dulint_get_high(d_var);
printf("FILE SPACE INFO: id %lu\n", space); fprintf(stderr,
"FILE SPACE INFO: id %lu\n"
printf("size %lu, free limit %lu, free extents %lu\n", "size %lu, free limit %lu, free extents %lu\n"
size, free_limit, n_free); "not full frag extents %lu: used pages %lu, full frag extents %lu\n"
printf( "first seg id not used %lu %lu\n",
"not full frag extents %lu: used pages %lu, full frag extents %lu\n", space,
n_free_frag, frag_n_used, n_full_frag); size, free_limit, n_free,
n_free_frag, frag_n_used, n_full_frag,
printf("first seg id not used %lu %lu\n", seg_id_high, seg_id_low); seg_id_high, seg_id_low);
mtr_commit(&mtr); mtr_commit(&mtr);
@ -3707,5 +3698,5 @@ fsp_print(
mtr_commit(&mtr2); mtr_commit(&mtr2);
printf("NUMBER of file segments: %lu\n", n_segs); fprintf(stderr, "NUMBER of file segments: %lu\n", n_segs);
} }

View File

@ -509,8 +509,9 @@ flst_print(
len = flst_get_len(base, mtr); len = flst_get_len(base, mtr);
printf("FILE-BASED LIST:\n"); fprintf(stderr,
printf("Base node in space %lu page %lu byte offset %lu; len %lu\n", "FILE-BASED LIST:\n"
"Base node in space %lu page %lu byte offset %lu; len %lu\n",
buf_frame_get_space_id(frame), buf_frame_get_page_no(frame), buf_frame_get_space_id(frame), buf_frame_get_page_no(frame),
(ulint) (base - frame), len); (ulint) (base - frame), len);
} }

View File

@ -264,8 +264,7 @@ Prints info of a hash table. */
void void
ha_print_info( ha_print_info(
/*==========*/ /*==========*/
char* buf, /* in/out: buffer where to print */ FILE* file, /* in: file where to print */
char* buf_end,/* in: buffer end */
hash_table_t* table) /* in: hash table */ hash_table_t* table) /* in: hash table */
{ {
hash_cell_t* cell; hash_cell_t* cell;
@ -273,10 +272,6 @@ ha_print_info(
ulint n_bufs; ulint n_bufs;
ulint i; ulint i;
if (buf_end - buf < 200) {
return;
}
for (i = 0; i < hash_get_n_cells(table); i++) { for (i = 0; i < hash_get_n_cells(table); i++) {
cell = hash_get_nth_cell(table, i); cell = hash_get_nth_cell(table, i);
@ -287,8 +282,9 @@ ha_print_info(
} }
} }
buf += sprintf(buf, fprintf(file,
"Hash table size %lu, used cells %lu", hash_get_n_cells(table), cells); "Hash table size %lu, used cells %lu",
hash_get_n_cells(table), cells);
if (table->heaps == NULL && table->heap != NULL) { if (table->heaps == NULL && table->heap != NULL) {
@ -301,6 +297,6 @@ ha_print_info(
n_bufs++; n_bufs++;
} }
buf += sprintf(buf, ", node heap has %lu buffer(s)\n", n_bufs); fprintf(file, ", node heap has %lu buffer(s)\n", n_bufs);
} }
} }

View File

@ -409,7 +409,7 @@ ibuf_data_sizes_update(
ibuf->size = ibuf->size + data->size - old_size; ibuf->size = ibuf->size + data->size - old_size;
/* printf("ibuf size %lu, space ibuf size %lu\n", ibuf->size, /* fprintf(stderr, "ibuf size %lu, space ibuf size %lu\n", ibuf->size,
data->size); */ data->size); */
} }
@ -438,7 +438,7 @@ ibuf_data_init_for_space(
#ifdef UNIV_LOG_DEBUG #ifdef UNIV_LOG_DEBUG
if (space % 2 == 1) { if (space % 2 == 1) {
printf("No ibuf op in replicate space\n"); fputs("No ibuf op in replicate space\n", stderr);
return(NULL); return(NULL);
} }
@ -728,7 +728,8 @@ ibuf_set_free_bits_low(
bitmap_page = ibuf_bitmap_get_map_page(buf_frame_get_space_id(page), bitmap_page = ibuf_bitmap_get_map_page(buf_frame_get_space_id(page),
buf_frame_get_page_no(page), mtr); buf_frame_get_page_no(page), mtr);
#ifdef UNIV_IBUF_DEBUG #ifdef UNIV_IBUF_DEBUG
/* printf("Setting page no %lu free bits to %lu should be %lu\n", /* fprintf(stderr,
"Setting page no %lu free bits to %lu should be %lu\n",
buf_frame_get_page_no(page), val, buf_frame_get_page_no(page), val,
ibuf_index_page_calc_free(page)); */ ibuf_index_page_calc_free(page)); */
@ -782,7 +783,7 @@ ibuf_set_free_bits(
buf_frame_get_page_no(page), buf_frame_get_page_no(page),
IBUF_BITMAP_FREE, &mtr); IBUF_BITMAP_FREE, &mtr);
if (old_val != max_val) { if (old_val != max_val) {
/* printf( /* fprintf(stderr,
"Ibuf: page %lu old val %lu max val %lu\n", "Ibuf: page %lu old val %lu max val %lu\n",
buf_frame_get_page_no(page), old_val, max_val); */ buf_frame_get_page_no(page), old_val, max_val); */
} }
@ -791,7 +792,7 @@ ibuf_set_free_bits(
#endif #endif
} }
#ifdef UNIV_IBUF_DEBUG #ifdef UNIV_IBUF_DEBUG
/* printf("Setting page no %lu free bits to %lu should be %lu\n", /* fprintf(stderr, "Setting page no %lu free bits to %lu should be %lu\n",
buf_frame_get_page_no(page), val, buf_frame_get_page_no(page), val,
ibuf_index_page_calc_free(page)); */ ibuf_index_page_calc_free(page)); */
@ -970,7 +971,7 @@ ibuf_page_low(
#ifdef UNIV_LOG_DEBUG #ifdef UNIV_LOG_DEBUG
if (space % 2 != 0) { if (space % 2 != 0) {
printf("No ibuf in a replicate space\n"); fputs("No ibuf in a replicate space\n", stderr);
return(FALSE); return(FALSE);
} }
@ -1481,7 +1482,8 @@ ibuf_free_excess_pages(
/* Not yet initialized */ /* Not yet initialized */
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
/*printf("Ibuf for space %lu not yet initialized\n", space); */ /*fprintf(stderr,
"Ibuf for space %lu not yet initialized\n", space); */
#endif #endif
return; return;
@ -1645,7 +1647,7 @@ ibuf_get_merge_page_nos(
#ifdef UNIV_IBUF_DEBUG #ifdef UNIV_IBUF_DEBUG
ut_a(*n_stored <= IBUF_MAX_N_PAGES_MERGED); ut_a(*n_stored <= IBUF_MAX_N_PAGES_MERGED);
#endif #endif
/* printf("Ibuf merge batch %lu pages %lu volume\n", *n_stored, /* fprintf(stderr, "Ibuf merge batch %lu pages %lu volume\n", *n_stored,
sum_volumes); */ sum_volumes); */
return(sum_volumes); return(sum_volumes);
} }
@ -1751,8 +1753,8 @@ loop:
page_nos, &n_stored); page_nos, &n_stored);
#ifdef UNIV_IBUF_DEBUG #ifdef UNIV_IBUF_DEBUG
/* printf("Ibuf contract sync %lu pages %lu volume %lu\n", sync, /* fprintf(stderr, "Ibuf contract sync %lu pages %lu volume %lu\n",
n_stored, sum_sizes); */ sync, n_stored, sum_sizes); */
#endif #endif
ibuf_exit(); ibuf_exit();
@ -2074,7 +2076,7 @@ ibuf_insert_low(
mutex_exit(&ibuf_mutex); mutex_exit(&ibuf_mutex);
#ifdef UNIV_IBUF_DEBUG #ifdef UNIV_IBUF_DEBUG
printf("Ibuf too big\n"); fputs("Ibuf too big\n", stderr);
#endif #endif
/* Use synchronous contract (== TRUE) */ /* Use synchronous contract (== TRUE) */
ibuf_contract(TRUE); ibuf_contract(TRUE);
@ -2302,8 +2304,8 @@ ibuf_insert(
if (err == DB_SUCCESS) { if (err == DB_SUCCESS) {
#ifdef UNIV_IBUF_DEBUG #ifdef UNIV_IBUF_DEBUG
/* printf("Ibuf insert for page no %lu of index %s\n", page_no, /* fprintf(stderr, "Ibuf insert for page no %lu of index %s\n",
index->name); */ page_no, index->name); */
#endif #endif
return(TRUE); return(TRUE);
@ -2331,7 +2333,6 @@ ibuf_insert_to_index_page(
rec_t* rec; rec_t* rec;
page_t* bitmap_page; page_t* bitmap_page;
ulint old_bits; ulint old_bits;
char errbuf[1000];
ut_ad(ibuf_inside()); ut_ad(ibuf_inside());
ut_ad(dtuple_check_typed(entry)); ut_ad(dtuple_check_typed(entry));
@ -2361,16 +2362,13 @@ ibuf_insert_to_index_page(
"InnoDB: Error: Insert buffer insert fails; page free %lu, dtuple size %lu\n", "InnoDB: Error: Insert buffer insert fails; page free %lu, dtuple size %lu\n",
page_get_max_insert_size(page, 1), page_get_max_insert_size(page, 1),
rec_get_converted_size(entry)); rec_get_converted_size(entry));
fputs("InnoDB: Cannot insert index record ",
dtuple_sprintf(errbuf, 900, entry); stderr);
dtuple_print(stderr, entry);
fprintf(stderr, fputs(
"InnoDB: Cannot insert index record %s\n", errbuf); "\nInnoDB: The table where where this index record belongs\n"
fprintf(stderr,
"InnoDB: The table where where this index record belongs\n"
"InnoDB: is now probably corrupt. Please run CHECK TABLE on\n" "InnoDB: is now probably corrupt. Please run CHECK TABLE on\n"
"InnoDB: that table.\n"); "InnoDB: that table.\n", stderr);
bitmap_page = ibuf_bitmap_get_map_page( bitmap_page = ibuf_bitmap_get_map_page(
buf_frame_get_space_id(page), buf_frame_get_space_id(page),
@ -2384,8 +2382,8 @@ ibuf_insert_to_index_page(
fprintf(stderr, "Bitmap bits %lu\n", old_bits); fprintf(stderr, "Bitmap bits %lu\n", old_bits);
fprintf(stderr, fputs(
"InnoDB: Send a detailed bug report to mysql@lists.mysql.com!\n"); "InnoDB: Send a detailed bug report to mysql@lists.mysql.com!\n", stderr);
} }
} }
@ -2443,22 +2441,21 @@ ibuf_delete_rec(
if (!success) { if (!success) {
fprintf(stderr, fprintf(stderr,
"InnoDB: ERROR: Send the output to heikki.tuuri@innodb.com\n"); "InnoDB: ERROR: Send the output to mysql@lists.mysql.com\n"
fprintf(stderr, "InnoDB: ibuf cursor restoration fails!\n"); "InnoDB: ibuf cursor restoration fails!\n"
fprintf(stderr, "InnoDB: ibuf record inserted to page %lu\n", "InnoDB: ibuf record inserted to page %lu\n", page_no);
page_no);
fflush(stderr); fflush(stderr);
rec_print(btr_pcur_get_rec(pcur)); rec_print(stderr, btr_pcur_get_rec(pcur));
rec_print(pcur->old_rec); rec_print(stderr, pcur->old_rec);
dtuple_print(search_tuple); dtuple_print(stderr, search_tuple);
rec_print(page_rec_get_next(btr_pcur_get_rec(pcur))); rec_print(stderr, page_rec_get_next(btr_pcur_get_rec(pcur)));
fflush(stdout); fflush(stderr);
mtr_commit(mtr); mtr_commit(mtr);
fprintf(stderr, "InnoDB: Validating insert buffer tree:\n"); fputs("InnoDB: Validating insert buffer tree:\n", stderr);
ut_a(btr_validate_tree(ibuf_data->index->tree)); ut_a(btr_validate_tree(ibuf_data->index->tree));
fprintf(stderr, "InnoDB: ibuf tree ok\n"); fprintf(stderr, "InnoDB: ibuf tree ok\n");
@ -2519,7 +2516,6 @@ ibuf_merge_or_delete_for_page(
#endif #endif
ibool corruption_noticed = FALSE; ibool corruption_noticed = FALSE;
mtr_t mtr; mtr_t mtr;
char err_buf[500];
if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) { if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {
@ -2529,7 +2525,7 @@ ibuf_merge_or_delete_for_page(
#ifdef UNIV_LOG_DEBUG #ifdef UNIV_LOG_DEBUG
if (space % 2 != 0) { if (space % 2 != 0) {
printf("No ibuf operation in a replicate space\n"); fputs("No ibuf operation in a replicate space\n", stderr);
return; return;
} }
@ -2579,8 +2575,8 @@ ibuf_merge_or_delete_for_page(
mtr_start(&mtr); mtr_start(&mtr);
fprintf(stderr, fputs(" InnoDB: Dump of the ibuf bitmap page:\n",
" InnoDB: Dump of the ibuf bitmap page:\n"); stderr);
bitmap_page = ibuf_bitmap_get_map_page(space, page_no, bitmap_page = ibuf_bitmap_get_map_page(space, page_no,
&mtr); &mtr);
@ -2588,7 +2584,7 @@ ibuf_merge_or_delete_for_page(
mtr_commit(&mtr); mtr_commit(&mtr);
fprintf(stderr, "\nInnoDB: Dump of the page:\n"); fputs("\nInnoDB: Dump of the page:\n", stderr);
buf_page_print(page); buf_page_print(page);
@ -2651,18 +2647,16 @@ loop:
/* Do NOT merge to the 4.1 code base! */ /* Do NOT merge to the 4.1 code base! */
if (trx_sys_downgrading_from_4_1_1) { if (trx_sys_downgrading_from_4_1_1) {
fprintf(stderr, fputs(
"InnoDB: Fatal error: you are downgrading from >= 4.1.1 to 4.0, but\n" "InnoDB: Fatal error: you are downgrading from >= 4.1.1 to 4.0, but\n"
"InnoDB: the insert buffer was not empty.\n"); "InnoDB: the insert buffer was not empty.\n", stderr);
ut_error; ut_error;
} }
if (corruption_noticed) { if (corruption_noticed) {
rec_sprintf(err_buf, 450, ibuf_rec); fputs("InnoDB: Discarding record\n ", stderr);
rec_print(stderr, ibuf_rec);
fprintf(stderr, fputs("\n from the insert buffer!\n\n", stderr);
"InnoDB: Discarding record\n %s\n from the insert buffer!\n\n", err_buf);
} else if (page) { } else if (page) {
/* Now we have at pcur a record which should be /* Now we have at pcur a record which should be
inserted to the index page; NOTE that the call below inserted to the index page; NOTE that the call below
@ -2723,8 +2717,8 @@ reset_bit:
page_no, IBUF_BITMAP_FREE, &mtr); page_no, IBUF_BITMAP_FREE, &mtr);
ulint new_bits = ibuf_index_page_calc_free(page); ulint new_bits = ibuf_index_page_calc_free(page);
#ifdef UNIV_IBUF_DEBUG #ifdef UNIV_IBUF_DEBUG
/* printf("Old bits %lu new bits %lu max size %lu\n", old_bits, /* fprintf(stderr, "Old bits %lu new bits %lu max size %lu\n",
new_bits, old_bits, new_bits,
page_get_max_insert_size_after_reorganize(page, 1)); */ page_get_max_insert_size_after_reorganize(page, 1)); */
#endif #endif
if (old_bits != new_bits) { if (old_bits != new_bits) {
@ -2736,7 +2730,8 @@ reset_bit:
} }
#ifdef UNIV_IBUF_DEBUG #ifdef UNIV_IBUF_DEBUG
/* printf("Ibuf merge %lu records volume %lu to page no %lu\n", /* fprintf(stderr,
"Ibuf merge %lu records volume %lu to page no %lu\n",
n_inserts, volume, page_no); */ n_inserts, volume, page_no); */
#endif #endif
mtr_commit(&mtr); mtr_commit(&mtr);
@ -2794,34 +2789,29 @@ Prints info of ibuf. */
void void
ibuf_print( ibuf_print(
/*=======*/ /*=======*/
char* buf, /* in/out: buffer where to print */ FILE* file) /* in: file where to print */
char* buf_end)/* in: buffer end */
{ {
ibuf_data_t* data; ibuf_data_t* data;
#ifdef UNIV_IBUF_DEBUG #ifdef UNIV_IBUF_DEBUG
ulint i; ulint i;
#endif #endif
if (buf_end - buf < 500) {
return;
}
mutex_enter(&ibuf_mutex); mutex_enter(&ibuf_mutex);
data = UT_LIST_GET_FIRST(ibuf->data_list); data = UT_LIST_GET_FIRST(ibuf->data_list);
while (data) { while (data) {
buf += sprintf(buf, fprintf(file,
"Ibuf for space %lu: size %lu, free list len %lu, seg size %lu,\n", "Ibuf for space %lu: size %lu, free list len %lu, seg size %lu,\n"
data->space, data->size, data->free_list_len, data->seg_size);
buf += sprintf(buf,
"%lu inserts, %lu merged recs, %lu merges\n", "%lu inserts, %lu merged recs, %lu merges\n",
data->space, data->size, data->free_list_len, data->seg_size,
data->n_inserts, data->n_merged_recs, data->n_merges); data->n_inserts, data->n_merged_recs, data->n_merges);
#ifdef UNIV_IBUF_DEBUG #ifdef UNIV_IBUF_DEBUG
for (i = 0; i < IBUF_COUNT_N_PAGES; i++) { for (i = 0; i < IBUF_COUNT_N_PAGES; i++) {
if (ibuf_count_get(data->space, i) > 0) { if (ibuf_count_get(data->space, i) > 0) {
printf("Ibuf count for page %lu is %lu\n", fprintf(stderr,
"Ibuf count for page %lu is %lu\n",
i, ibuf_count_get(data->space, i)); i, ibuf_count_get(data->space, i));
} }
} }

View File

@ -483,8 +483,7 @@ Prints info of the buffer i/o. */
void void
buf_print_io( buf_print_io(
/*=========*/ /*=========*/
char* buf, /* in/out: buffer where to print */ FILE* file); /* in: file where to print */
char* buf_end);/* in: buffer end */
/************************************************************************* /*************************************************************************
Returns the ratio in percents of modified pages in the buffer pool / Returns the ratio in percents of modified pages in the buffer pool /
database pages in the buffer pool. */ database pages in the buffer pool. */

View File

@ -217,9 +217,9 @@ buf_block_align(
|| block >= buf_pool->blocks + buf_pool->max_size) { || block >= buf_pool->blocks + buf_pool->max_size) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: trying to access a stray pointer %lx\n" "InnoDB: Error: trying to access a stray pointer %p\n"
"InnoDB: buf pool start is at %lx, number of pages %lu\n", (ulint)ptr, "InnoDB: buf pool start is at %p, number of pages %lu\n", ptr,
(ulint)frame_zero, buf_pool->max_size); frame_zero, buf_pool->max_size);
ut_error; ut_error;
} }
@ -251,9 +251,9 @@ buf_block_align_low(
|| block >= buf_pool->blocks + buf_pool->max_size) { || block >= buf_pool->blocks + buf_pool->max_size) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: trying to access a stray pointer %lx\n" "InnoDB: Error: trying to access a stray pointer %p\n"
"InnoDB: buf pool start is at %lx, number of pages %lu\n", (ulint)ptr, "InnoDB: buf pool start is at %p, number of pages %lu\n", ptr,
(ulint)frame_zero, buf_pool->max_size); frame_zero, buf_pool->max_size);
ut_error; ut_error;
} }
@ -280,9 +280,9 @@ buf_frame_align(
|| ((ulint)frame > (ulint)(buf_pool_get_nth_block(buf_pool, || ((ulint)frame > (ulint)(buf_pool_get_nth_block(buf_pool,
buf_pool->max_size - 1)->frame))) { buf_pool->max_size - 1)->frame))) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: trying to access a stray pointer %lx\n" "InnoDB: Error: trying to access a stray pointer %p\n"
"InnoDB: buf pool start is at %lx, number of pages %lu\n", (ulint)ptr, "InnoDB: buf pool start is at %p, number of pages %lu\n", ptr,
(ulint)(buf_pool->frame_zero), buf_pool->max_size); buf_pool->frame_zero, buf_pool->max_size);
ut_error; ut_error;
} }

View File

@ -326,16 +326,7 @@ The following function prints the contents of a tuple. */
void void
dtuple_print( dtuple_print(
/*=========*/ /*=========*/
dtuple_t* tuple); /* in: tuple */ FILE* f, /* in: output stream */
/**************************************************************
The following function prints the contents of a tuple to a buffer. */
ulint
dtuple_sprintf(
/*===========*/
/* out: printed length in bytes */
char* buf, /* in: print buffer */
ulint buf_len,/* in: buf length in bytes */
dtuple_t* tuple); /* in: tuple */ dtuple_t* tuple); /* in: tuple */
/****************************************************************** /******************************************************************
Moves parts of long fields in entry to the big record vector so that Moves parts of long fields in entry to the big record vector so that

View File

@ -331,19 +331,23 @@ dict_print_info_on_foreign_keys(
a format suitable to be inserted into a format suitable to be inserted into
a CREATE TABLE, otherwise in the format a CREATE TABLE, otherwise in the format
of SHOW TABLE STATUS */ of SHOW TABLE STATUS */
char* str, /* in/out: pointer to a string */ FILE* file, /* in: file where to print */
ulint len, /* in: space in str available for info */
dict_table_t* table); /* in: table */ dict_table_t* table); /* in: table */
/************************************************************************** /**************************************************************************
Sprintfs to a string info on a foreign key of a table in a format suitable Outputs info on a foreign key of a table in a format suitable for
for CREATE TABLE. */ CREATE TABLE. */
void
char*
dict_print_info_on_foreign_key_in_create_format( dict_print_info_on_foreign_key_in_create_format(
/*============================================*/ /*============================================*/
/* out: how far in buf we printed */ FILE* file, /* in: file where to print */
dict_foreign_t* foreign,/* in: foreign key constraint */ dict_foreign_t* foreign);/* in: foreign key constraint */
char* buf); /* in: buffer of at least 5000 bytes */ /************************************************************************
Displays the names of the index and the table. */
void
dict_index_name_print(
/*==================*/
FILE* file, /* in: output stream */
const dict_index_t* index); /* in: index to print */
/************************************************************************ /************************************************************************
Gets the first index on the table (the clustered index). */ Gets the first index on the table (the clustered index). */
UNIV_INLINE UNIV_INLINE
@ -846,13 +850,9 @@ dict_tables_have_same_db(
const char* name2); /* in: table name in the form const char* name2); /* in: table name in the form
dbname '/' tablename */ dbname '/' tablename */
/* The following len must be at least 10000 bytes! */
#define DICT_FOREIGN_ERR_BUF_LEN 10000
/* Buffers for storing detailed information about the latest foreign key /* Buffers for storing detailed information about the latest foreign key
and unique key errors */ and unique key errors */
extern char* dict_foreign_err_buf; extern FILE* dict_foreign_err_file;
extern char* dict_unique_err_buf;
extern mutex_t dict_foreign_err_mutex; /* mutex protecting the buffers */ extern mutex_t dict_foreign_err_mutex; /* mutex protecting the buffers */
extern dict_sys_t* dict_sys; /* the dictionary system */ extern dict_sys_t* dict_sys; /* the dictionary system */

View File

@ -127,8 +127,7 @@ Prints info of a hash table. */
void void
ha_print_info( ha_print_info(
/*==========*/ /*==========*/
char* buf, /* in/out: buffer where to print */ FILE* file, /* in: file where to print */
char* buf_end,/* in: buffer end */
hash_table_t* table); /* in: hash table */ hash_table_t* table); /* in: hash table */
/* The hash table external chain node */ /* The hash table external chain node */

View File

@ -262,8 +262,7 @@ Prints info of ibuf. */
void void
ibuf_print( ibuf_print(
/*=======*/ /*=======*/
char* buf, /* in/out: buffer where to print */ FILE* file); /* in: file where to print */
char* buf_end);/* in: buffer end */
#define IBUF_HEADER_PAGE_NO FSP_IBUF_HEADER_PAGE_NO #define IBUF_HEADER_PAGE_NO FSP_IBUF_HEADER_PAGE_NO
#define IBUF_TREE_ROOT_PAGE_NO FSP_IBUF_TREE_ROOT_PAGE_NO #define IBUF_TREE_ROOT_PAGE_NO FSP_IBUF_TREE_ROOT_PAGE_NO

View File

@ -20,6 +20,8 @@ Created 5/7/1996 Heikki Tuuri
#include "hash0hash.h" #include "hash0hash.h"
extern ibool lock_print_waits; extern ibool lock_print_waits;
/* Buffer for storing information about the most recent deadlock error */
extern FILE* lock_latest_err_file;
/************************************************************************* /*************************************************************************
Gets the size of a lock struct. */ Gets the size of a lock struct. */
@ -468,8 +470,7 @@ Prints info of a table lock. */
void void
lock_table_print( lock_table_print(
/*=============*/ /*=============*/
char* buf, /* in/out: buffer where to print, must be at least FILE* file, /* in: file where to print */
500 bytes */
lock_t* lock); /* in: table type lock */ lock_t* lock); /* in: table type lock */
/************************************************************************* /*************************************************************************
Prints info of a record lock. */ Prints info of a record lock. */
@ -477,8 +478,7 @@ Prints info of a record lock. */
void void
lock_rec_print( lock_rec_print(
/*===========*/ /*===========*/
char* buf, /* in/out: buffer where to print, must be at least FILE* file, /* in: file where to print */
500 bytes */
lock_t* lock); /* in: record type lock */ lock_t* lock); /* in: record type lock */
/************************************************************************* /*************************************************************************
Prints info of locks for all transactions. */ Prints info of locks for all transactions. */
@ -486,8 +486,7 @@ Prints info of locks for all transactions. */
void void
lock_print_info( lock_print_info(
/*============*/ /*============*/
char* buf, /* in/out: buffer where to print */ FILE* file); /* in: file where to print */
char* buf_end);/* in: buffer end */
/************************************************************************* /*************************************************************************
Validates the lock queue on a table. */ Validates the lock queue on a table. */

View File

@ -512,8 +512,7 @@ Prints info of the log. */
void void
log_print( log_print(
/*======*/ /*======*/
char* buf, /* in/out: buffer where to print */ FILE* file); /* in: file where to print */
char* buf_end);/* in: buffer end */
/********************************************************** /**********************************************************
Peeks the current lsn. */ Peeks the current lsn. */

View File

@ -165,8 +165,8 @@ mlog_write_initial_log_record_fast(
if (space != 0 || offset > 0x8FFFFFFF) { if (space != 0 || offset > 0x8FFFFFFF) {
fprintf(stderr, fprintf(stderr,
"InnoDB: error: buffer page pointer %lx has nonsensical space id %lu\n" "InnoDB: error: buffer page pointer %p has nonsensical space id %lu\n"
"InnoDB: or page no %lu\n", (ulint)ptr, space, offset); "InnoDB: or page no %lu\n", ptr, space, offset);
ut_error; ut_error;
} }
@ -178,7 +178,8 @@ mlog_write_initial_log_record_fast(
mtr->n_log_recs++; mtr->n_log_recs++;
#ifdef UNIV_LOG_DEBUG #ifdef UNIV_LOG_DEBUG
/* printf("Adding to mtr log record type %lu space %lu page no %lu\n", /* fprintf(stderr,
"Adding to mtr log record type %lu space %lu page no %lu\n",
type, space, offset); */ type, space, offset); */
#endif #endif

View File

@ -443,8 +443,7 @@ Prints info of the aio arrays. */
void void
os_aio_print( os_aio_print(
/*=========*/ /*=========*/
char* buf, /* in/out: buffer where to print */ FILE* file); /* in: file where to print */
char* buf_end);/* in: buffer end */
/************************************************************************** /**************************************************************************
Refreshes the statistics used to print per-second averages. */ Refreshes the statistics used to print per-second averages. */

View File

@ -390,16 +390,7 @@ Prints a physical record. */
void void
rec_print( rec_print(
/*======*/ /*======*/
rec_t* rec); /* in: physical record */ FILE* file, /* in: file where to print */
/*******************************************************************
Prints a physical record to a buffer. */
ulint
rec_sprintf(
/*========*/
/* out: printed length in bytes */
char* buf, /* in: buffer to print to */
ulint buf_len,/* in: buffer length */
rec_t* rec); /* in: physical record */ rec_t* rec); /* in: physical record */
#define REC_INFO_BITS 6 /* This is single byte bit-field */ #define REC_INFO_BITS 6 /* This is single byte bit-field */

View File

@ -190,7 +190,7 @@ rec_set_bit_field_2(
+ (REC_N_OWNED_MASK << (8 * (REC_N_OWNED - 3))) + (REC_N_OWNED_MASK << (8 * (REC_N_OWNED - 3)))
+ (REC_INFO_BITS_MASK << (8 * (REC_INFO_BITS - 3)))); + (REC_INFO_BITS_MASK << (8 * (REC_INFO_BITS - 3))));
if (m != ut_dbg_zero + 0xFFFFFFFF) { if (m != ut_dbg_zero + 0xFFFFFFFF) {
printf("Sum of masks %lx\n", m); fprintf(stderr, "Sum of masks %lx\n", m);
ut_error; ut_error;
} }
} }

View File

@ -77,12 +77,9 @@ open_step(
if (err != DB_SUCCESS) { if (err != DB_SUCCESS) {
/* SQL error detected */ /* SQL error detected */
printf("SQL error %lu\n", err); fprintf(stderr, "SQL error %lu\n", err);
ut_error; ut_error;
que_thr_handle_error(thr, err, NULL, 0);
return(NULL);
} }
thr->run_node = que_node_get_parent(node); thr->run_node = que_node_get_parent(node);

View File

@ -84,9 +84,11 @@ upd_field_set_field_no(
if (field_no >= dict_index_get_n_fields(index)) { if (field_no >= dict_index_get_n_fields(index)) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: trying to access field %lu in table %s\n" "InnoDB: Error: trying to access field %lu in ",
"InnoDB: index %s, but index has only %lu fields\n", field_no);
field_no, index->table_name, index->name, dict_index_name_print(stderr, index);
fprintf(stderr, "\n"
"InnoDB: but index only has %lu fields\n",
dict_index_get_n_fields(index)); dict_index_get_n_fields(index));
} }

View File

@ -32,6 +32,11 @@ at a time */
/* This is set to TRUE if the MySQL user has set it in MySQL */ /* This is set to TRUE if the MySQL user has set it in MySQL */
extern ibool srv_lower_case_table_names; extern ibool srv_lower_case_table_names;
/* Mutex for locking srv_monitor_file */
extern mutex_t srv_monitor_file_mutex;
/* Temporary file for innodb monitor output */
extern FILE* srv_monitor_file;
/* Server parameters which are read from the initfile */ /* Server parameters which are read from the initfile */
extern char* srv_data_home; extern char* srv_data_home;
@ -368,13 +373,12 @@ srv_error_monitor_thread(
void* arg); /* in: a dummy parameter required by void* arg); /* in: a dummy parameter required by
os_thread_create */ os_thread_create */
/********************************************************************** /**********************************************************************
Sprintfs to a buffer the output of the InnoDB Monitor. */ Outputs to a file the output of the InnoDB Monitor. */
void void
srv_sprintf_innodb_monitor( srv_printf_innodb_monitor(
/*=======================*/ /*======================*/
char* buf, /* in/out: buffer which must be at least 4 kB */ FILE* file); /* in: output stream */
ulint len); /* in: length of the buffer */
/* Types for the threads existing in the system. Threads of types 4 - 9 /* Types for the threads existing in the system. Threads of types 4 - 9

View File

@ -114,8 +114,7 @@ Prints info of the wait array. */
void void
sync_array_print_info( sync_array_print_info(
/*==================*/ /*==================*/
char* buf, /* in/out: buffer where to print */ FILE* file, /* in: file where to print */
char* buf_end,/* in: buffer end */
sync_array_t* arr); /* in: wait array */ sync_array_t* arr); /* in: wait array */

View File

@ -119,16 +119,14 @@ Prints wait info of the sync system. */
void void
sync_print_wait_info( sync_print_wait_info(
/*=================*/ /*=================*/
char* buf, /* in/out: buffer where to print */ FILE* file); /* in: file where to print */
char* buf_end); /* in: buffer end */
/*********************************************************************** /***********************************************************************
Prints info of the sync system. */ Prints info of the sync system. */
void void
sync_print( sync_print(
/*=======*/ /*=======*/
char* buf, /* in/out: buffer where to print */ FILE* file); /* in: file where to print */
char* buf_end); /* in: buffer end */
/********************************************************************** /**********************************************************************
Checks that the mutex has been initialized. */ Checks that the mutex has been initialized. */

View File

@ -269,7 +269,7 @@ void
trx_sys_print_mysql_binlog_offset(void); trx_sys_print_mysql_binlog_offset(void);
/*===================================*/ /*===================================*/
/********************************************************************* /*********************************************************************
Prints to stdout the MySQL binlog info in the system header if the Prints to stderr the MySQL binlog info in the system header if the
magic number shows it valid. */ magic number shows it valid. */
void void

View File

@ -280,8 +280,7 @@ own the kernel mutex. */
void void
trx_print( trx_print(
/*======*/ /*======*/
char* buf, /* in/out: buffer where to print, must be at least FILE* f, /* in: output stream */
800 bytes */
trx_t* trx); /* in: transaction */ trx_t* trx); /* in: transaction */

View File

@ -169,7 +169,7 @@ ut_print_timestamp(
/*===============*/ /*===============*/
FILE* file); /* in: file where to print */ FILE* file); /* in: file where to print */
/************************************************************** /**************************************************************
Sprintfs a timestamp to a buffer. */ Sprintfs a timestamp to a buffer, 13..14 chars plus terminating NUL. */
void void
ut_sprintf_timestamp( ut_sprintf_timestamp(
@ -199,19 +199,37 @@ Prints the contents of a memory buffer in hex and ascii. */
void void
ut_print_buf( ut_print_buf(
/*=========*/ /*=========*/
byte* buf, /* in: memory buffer */ FILE* file, /* in: file where to print */
ulint len); /* in: length of the buffer */ const byte* buf, /* in: memory buffer */
/*****************************************************************
Prints the contents of a memory buffer in hex and ascii. */
ulint
ut_sprintf_buf(
/*===========*/
/* out: printed length in bytes */
char* str, /* in: buffer to print to */
byte* buf, /* in: memory buffer */
ulint len); /* in: length of the buffer */ ulint len); /* in: length of the buffer */
/**************************************************************************
Outputs a NUL-terminated string, quoted as an SQL identifier. */
void
ut_print_name(
/*==========*/
FILE* f, /* in: output stream */
const char* name); /* in: name to print */
/**************************************************************************
Outputs a fixed-length string, quoted as an SQL identifier. */
void
ut_print_namel(
/*==========*/
FILE* f, /* in: output stream */
const char* name, /* in: name to print */
ulint namelen);/* in: length of name */
/**************************************************************************
Catenate files. */
void
ut_copy_file(
/*=========*/
FILE* dest, /* in: output file */
FILE* src); /* in: input file to be appended to output */
#ifndef UNIV_NONINL #ifndef UNIV_NONINL
#include "ut0ut.ic" #include "ut0ut.ic"

View File

@ -310,7 +310,7 @@ struct lock_struct{
/* We store info on the latest deadlock error to this buffer. InnoDB /* We store info on the latest deadlock error to this buffer. InnoDB
Monitor will then fetch it and print */ Monitor will then fetch it and print */
ibool lock_deadlock_found = FALSE; ibool lock_deadlock_found = FALSE;
char* lock_latest_err_buf; /* We allocate 5000 bytes for this */ FILE* lock_latest_err_file;
/* Flags for recursive deadlock search */ /* Flags for recursive deadlock search */
#define LOCK_VICTIM_IS_START 1 #define LOCK_VICTIM_IS_START 1
@ -356,7 +356,6 @@ lock_check_trx_id_sanity(
ibool has_kernel_mutex)/* in: TRUE if the caller owns the ibool has_kernel_mutex)/* in: TRUE if the caller owns the
kernel mutex */ kernel mutex */
{ {
char err_buf[500];
ibool is_ok = TRUE; ibool is_ok = TRUE;
if (!has_kernel_mutex) { if (!has_kernel_mutex) {
@ -367,14 +366,16 @@ lock_check_trx_id_sanity(
trx id counter */ trx id counter */
if (ut_dulint_cmp(trx_id, trx_sys->max_trx_id) >= 0) { if (ut_dulint_cmp(trx_id, trx_sys->max_trx_id) >= 0) {
rec_sprintf(err_buf, 400, rec);
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fputs(" InnoDB: Error: transaction id associated"
"InnoDB: Error: transaction id associated with record\n%s\n" " with record\n",
"InnoDB: in table %s index %s\n" stderr);
rec_print(stderr, rec);
fputs("InnoDB: in ", stderr);
dict_index_name_print(stderr, index);
fprintf(stderr, "\n"
"InnoDB: is %lu %lu which is higher than the global trx id counter %lu %lu!\n" "InnoDB: is %lu %lu which is higher than the global trx id counter %lu %lu!\n"
"InnoDB: The table is corrupt. You have to do dump + drop + reimport.\n", "InnoDB: The table is corrupt. You have to do dump + drop + reimport.\n",
err_buf, index->table_name, index->name,
ut_dulint_get_high(trx_id), ut_dulint_get_high(trx_id),
ut_dulint_get_low(trx_id), ut_dulint_get_low(trx_id),
ut_dulint_get_high(trx_sys->max_trx_id), ut_dulint_get_high(trx_sys->max_trx_id),
@ -481,7 +482,7 @@ lock_sys_create(
/* hash_create_mutexes(lock_sys->rec_hash, 2, SYNC_REC_LOCK); */ /* hash_create_mutexes(lock_sys->rec_hash, 2, SYNC_REC_LOCK); */
lock_latest_err_buf = mem_alloc(5000); lock_latest_err_file = tmpfile();
} }
/************************************************************************* /*************************************************************************
@ -1620,11 +1621,12 @@ lock_rec_enqueue_waiting(
if (trx->dict_operation) { if (trx->dict_operation) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fputs(
fprintf(stderr,
" InnoDB: Error: a record lock wait happens in a dictionary operation!\n" " InnoDB: Error: a record lock wait happens in a dictionary operation!\n"
"InnoDB: Table name %s. Send a bug report to mysql@lists.mysql.com\n", "InnoDB: Table name ", stderr);
index->table_name); ut_print_name(stderr, index->table_name);
fputs(". Send a bug report to mysql@lists.mysql.com\n",
stderr);
} }
/* Enqueue the lock request that will wait to be granted */ /* Enqueue the lock request that will wait to be granted */
@ -1656,8 +1658,9 @@ index->table_name);
ut_a(que_thr_stop(thr)); ut_a(que_thr_stop(thr));
if (lock_print_waits) { if (lock_print_waits) {
printf("Lock wait for trx %lu in index %s\n", fprintf(stderr, "Lock wait for trx %lu in index ",
ut_dulint_get_low(trx->id), index->name); ut_dulint_get_low(trx->id));
ut_print_name(stderr, index->name);
} }
return(DB_LOCK_WAIT); return(DB_LOCK_WAIT);
@ -1995,7 +1998,7 @@ lock_grant(
} }
if (lock_print_waits) { if (lock_print_waits) {
printf("Lock wait for trx %lu ends\n", fprintf(stderr, "Lock wait for trx %lu ends\n",
ut_dulint_get_low(lock->trx->id)); ut_dulint_get_low(lock->trx->id));
} }
@ -2385,7 +2388,7 @@ lock_move_reorganize_page(
/* if ((page_cur_get_rec(&cur1) == sup) /* if ((page_cur_get_rec(&cur1) == sup)
&& lock_get_wait(lock)) { && lock_get_wait(lock)) {
printf( fprintf(stderr,
"---\n--\n!!!Lock reorg: supr type %lu\n", "---\n--\n!!!Lock reorg: supr type %lu\n",
lock->type_mode); lock->type_mode);
} */ } */
@ -2901,7 +2904,6 @@ lock_deadlock_occurs(
trx_t* mark_trx; trx_t* mark_trx;
ulint ret; ulint ret;
ulint cost = 0; ulint cost = 0;
char* err_buf;
ut_ad(trx && lock); ut_ad(trx && lock);
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
@ -2939,14 +2941,8 @@ retry:
lock_deadlock_found = TRUE; lock_deadlock_found = TRUE;
err_buf = lock_latest_err_buf + strlen(lock_latest_err_buf); fputs("*** WE ROLL BACK TRANSACTION (2)\n",
lock_latest_err_file);
ut_a(err_buf <= lock_latest_err_buf + 4000);
err_buf += sprintf(err_buf,
"*** WE ROLL BACK TRANSACTION (2)\n");
ut_a(strlen(lock_latest_err_buf) < 4100);
return(TRUE); return(TRUE);
} }
@ -2978,7 +2974,6 @@ lock_deadlock_recursive(
lock_t* lock; lock_t* lock;
ulint bit_no = ULINT_UNDEFINED; ulint bit_no = ULINT_UNDEFINED;
trx_t* lock_trx; trx_t* lock_trx;
char* err_buf;
ulint ret; ulint ret;
ut_a(trx && start && wait_lock); ut_a(trx && start && wait_lock);
@ -3036,71 +3031,48 @@ lock_deadlock_recursive(
if (lock_trx == start) { if (lock_trx == start) {
/* We came back to the recursion starting /* We came back to the recursion starting
point: a deadlock detected */ point: a deadlock detected */
FILE* ef = lock_latest_err_file;
err_buf = lock_latest_err_buf; rewind(ef);
ut_print_timestamp(ef);
ut_sprintf_timestamp(err_buf); fputs("\n*** (1) TRANSACTION:\n", ef);
err_buf += strlen(err_buf);
err_buf += sprintf(err_buf, trx_print(ef, wait_lock->trx);
"\n*** (1) TRANSACTION:\n");
trx_print(err_buf, wait_lock->trx); fputs(
err_buf += strlen(err_buf); "*** (1) WAITING FOR THIS LOCK TO BE GRANTED:\n", ef);
err_buf += sprintf(err_buf,
"*** (1) WAITING FOR THIS LOCK TO BE GRANTED:\n");
ut_a(err_buf <= lock_latest_err_buf + 4000);
if (lock_get_type(wait_lock) == LOCK_REC) { if (lock_get_type(wait_lock) == LOCK_REC) {
lock_rec_print(err_buf, wait_lock); lock_rec_print(ef, wait_lock);
err_buf += strlen(err_buf);
} else { } else {
lock_table_print(err_buf, wait_lock); lock_table_print(ef, wait_lock);
err_buf += strlen(err_buf);
} }
ut_a(err_buf <= lock_latest_err_buf + 4000); fputs("*** (2) TRANSACTION:\n", ef);
err_buf += sprintf(err_buf,
"*** (2) TRANSACTION:\n");
trx_print(err_buf, lock->trx); trx_print(ef, lock->trx);
err_buf += strlen(err_buf);
err_buf += sprintf(err_buf, fputs("*** (2) HOLDS THE LOCK(S):\n", ef);
"*** (2) HOLDS THE LOCK(S):\n");
ut_a(err_buf <= lock_latest_err_buf + 4000);
if (lock_get_type(lock) == LOCK_REC) { if (lock_get_type(lock) == LOCK_REC) {
lock_rec_print(err_buf, lock); lock_rec_print(ef, lock);
err_buf += strlen(err_buf);
} else { } else {
lock_table_print(err_buf, lock); lock_table_print(ef, lock);
err_buf += strlen(err_buf);
} }
ut_a(err_buf <= lock_latest_err_buf + 4000); fputs(
"*** (2) WAITING FOR THIS LOCK TO BE GRANTED:\n", ef);
err_buf += sprintf(err_buf,
"*** (2) WAITING FOR THIS LOCK TO BE GRANTED:\n");
ut_a(err_buf <= lock_latest_err_buf + 4000);
if (lock_get_type(start->wait_lock) if (lock_get_type(start->wait_lock)
== LOCK_REC) { == LOCK_REC) {
lock_rec_print(err_buf, lock_rec_print(ef, start->wait_lock);
start->wait_lock);
err_buf += strlen(err_buf);
} else { } else {
lock_table_print(err_buf, lock_table_print(ef, start->wait_lock);
start->wait_lock);
err_buf += strlen(err_buf);
} }
if (lock_print_waits) { if (lock_print_waits) {
printf("Deadlock detected\n"); fputs("Deadlock detected\n", stderr);
} }
if (ut_dulint_cmp(wait_lock->trx->undo_no, if (ut_dulint_cmp(wait_lock->trx->undo_no,
@ -3115,14 +3087,12 @@ lock_deadlock_recursive(
lock_deadlock_found = TRUE; lock_deadlock_found = TRUE;
ut_a(err_buf <= lock_latest_err_buf + 4000);
/* Let us choose the transaction of wait_lock /* Let us choose the transaction of wait_lock
as a victim to try to avoid deadlocking our as a victim to try to avoid deadlocking our
recursion starting point transaction */ recursion starting point transaction */
err_buf += sprintf(err_buf, fputs("*** WE ROLL BACK TRANSACTION (1)\n",
"*** WE ROLL BACK TRANSACTION (1)\n"); ef);
wait_lock->trx->was_chosen_as_deadlock_victim wait_lock->trx->was_chosen_as_deadlock_victim
= TRUE; = TRUE;
@ -3281,11 +3251,12 @@ lock_table_enqueue_waiting(
if (trx->dict_operation) { if (trx->dict_operation) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fputs(
fprintf(stderr,
" InnoDB: Error: a table lock wait happens in a dictionary operation!\n" " InnoDB: Error: a table lock wait happens in a dictionary operation!\n"
"InnoDB: Table name %s. Send a bug report to mysql@lists.mysql.com\n", "InnoDB: Table name ", stderr);
table->name); ut_print_name(stderr, table->name);
fputs(". Send a bug report to mysql@lists.mysql.com\n",
stderr);
} }
/* Enqueue the lock request that will wait to be granted */ /* Enqueue the lock request that will wait to be granted */
@ -3702,8 +3673,7 @@ Prints info of a table lock. */
void void
lock_table_print( lock_table_print(
/*=============*/ /*=============*/
char* buf, /* in/out: buffer where to print, must be at least FILE* file, /* in: file where to print */
500 bytes */
lock_t* lock) /* in: table type lock */ lock_t* lock) /* in: table type lock */
{ {
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
@ -3711,30 +3681,30 @@ lock_table_print(
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
ut_a(lock_get_type(lock) == LOCK_TABLE); ut_a(lock_get_type(lock) == LOCK_TABLE);
buf += sprintf(buf, "TABLE LOCK table %s trx id %lu %lu", fputs("TABLE LOCK table ", file);
lock->un_member.tab_lock.table->name, ut_print_name(file, lock->un_member.tab_lock.table->name);
fprintf(file, " trx id %lu %lu",
(lock->trx)->id.high, (lock->trx)->id.low); (lock->trx)->id.high, (lock->trx)->id.low);
if (lock_get_mode(lock) == LOCK_S) { if (lock_get_mode(lock) == LOCK_S) {
buf += sprintf(buf, " lock mode S"); fputs(" lock mode S", file);
} else if (lock_get_mode(lock) == LOCK_X) { } else if (lock_get_mode(lock) == LOCK_X) {
buf += sprintf(buf, " lock_mode X"); fputs(" lock mode X", file);
} else if (lock_get_mode(lock) == LOCK_IS) { } else if (lock_get_mode(lock) == LOCK_IS) {
buf += sprintf(buf, " lock_mode IS"); fputs(" lock mode IS", file);
} else if (lock_get_mode(lock) == LOCK_IX) { } else if (lock_get_mode(lock) == LOCK_IX) {
buf += sprintf(buf, " lock_mode IX"); fputs(" lock mode IX", file);
} else if (lock_get_mode(lock) == LOCK_AUTO_INC) { } else if (lock_get_mode(lock) == LOCK_AUTO_INC) {
buf += sprintf(buf, " lock_mode AUTO-INC"); fputs(" lock mode AUTO-INC", file);
} else { } else {
buf += sprintf(buf, fprintf(file, " unknown lock mode %lu", lock_get_mode(lock));
" unknown lock_mode %lu", lock_get_mode(lock));
} }
if (lock_get_wait(lock)) { if (lock_get_wait(lock)) {
buf += sprintf(buf, " waiting"); fputs(" waiting", file);
} }
buf += sprintf(buf, "\n"); putc('\n', file);
} }
/************************************************************************* /*************************************************************************
@ -3743,16 +3713,13 @@ Prints info of a record lock. */
void void
lock_rec_print( lock_rec_print(
/*===========*/ /*===========*/
char* buf, /* in/out: buffer where to print, must be at least FILE* file, /* in: file where to print */
500 bytes */
lock_t* lock) /* in: record type lock */ lock_t* lock) /* in: record type lock */
{ {
page_t* page; page_t* page;
ulint space; ulint space;
ulint page_no; ulint page_no;
ulint i; ulint i;
ulint count = 0;
char* buf_start = buf;
mtr_t mtr; mtr_t mtr;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
@ -3763,40 +3730,39 @@ lock_rec_print(
space = lock->un_member.rec_lock.space; space = lock->un_member.rec_lock.space;
page_no = lock->un_member.rec_lock.page_no; page_no = lock->un_member.rec_lock.page_no;
buf += sprintf(buf, "RECORD LOCKS space id %lu page no %lu n bits %lu", fprintf(file, "RECORD LOCKS space id %lu page no %lu n bits %lu ",
space, page_no, lock_rec_get_n_bits(lock)); space, page_no, lock_rec_get_n_bits(lock));
dict_index_name_print(file, lock->index);
buf += sprintf(buf, " table %s index %s trx id %lu %lu", fprintf(file, " trx id %lu %lu",
lock->index->table->name, lock->index->name,
(lock->trx)->id.high, (lock->trx)->id.low); (lock->trx)->id.high, (lock->trx)->id.low);
if (lock_get_mode(lock) == LOCK_S) { if (lock_get_mode(lock) == LOCK_S) {
buf += sprintf(buf, " lock mode S"); fputs(" lock mode S", file);
} else if (lock_get_mode(lock) == LOCK_X) { } else if (lock_get_mode(lock) == LOCK_X) {
buf += sprintf(buf, " lock_mode X"); fputs(" lock_mode X", file);
} else { } else {
ut_error; ut_error;
} }
if (lock_rec_get_gap(lock)) { if (lock_rec_get_gap(lock)) {
buf += sprintf(buf, " locks gap before rec"); fputs(" locks gap before rec", file);
} }
if (lock_rec_get_rec_not_gap(lock)) { if (lock_rec_get_rec_not_gap(lock)) {
buf += sprintf(buf, " locks rec but not gap"); fputs(" locks rec but not gap", file);
} }
if (lock_rec_get_insert_intention(lock)) { if (lock_rec_get_insert_intention(lock)) {
buf += sprintf(buf, " insert intention"); fputs(" insert intention", file);
} }
if (lock_get_wait(lock)) { if (lock_get_wait(lock)) {
buf += sprintf(buf, " waiting"); fputs(" waiting", file);
} }
mtr_start(&mtr); mtr_start(&mtr);
buf += sprintf(buf, "\n"); putc('\n', file);
/* If the page is not in the buffer pool, we cannot load it /* If the page is not in the buffer pool, we cannot load it
because we have the kernel mutex and ibuf operations would because we have the kernel mutex and ibuf operations would
@ -3826,28 +3792,16 @@ lock_rec_print(
for (i = 0; i < lock_rec_get_n_bits(lock); i++) { for (i = 0; i < lock_rec_get_n_bits(lock); i++) {
if (buf - buf_start > 300) {
buf += sprintf(buf,
"Suppressing further record lock prints for this page\n");
mtr_commit(&mtr);
return;
}
if (lock_rec_get_nth_bit(lock, i)) { if (lock_rec_get_nth_bit(lock, i)) {
buf += sprintf(buf, "Record lock, heap no %lu ", i); fprintf(file, "Record lock, heap no %lu ", i);
if (page) { if (page) {
buf += rec_sprintf(buf, 120, rec_print(file,
page_find_rec_with_heap_no(page, i)); page_find_rec_with_heap_no(page, i));
*buf = '\0';
} }
buf += sprintf(buf, "\n"); putc('\n', file);
count++;
} }
} }
@ -3889,8 +3843,7 @@ Prints info of locks for all transactions. */
void void
lock_print_info( lock_print_info(
/*============*/ /*============*/
char* buf, /* in/out: buffer where to print */ FILE* file) /* in: file where to print */
char* buf_end)/* in: buffer end */
{ {
lock_t* lock; lock_t* lock;
trx_t* trx; trx_t* trx;
@ -3903,79 +3856,47 @@ lock_print_info(
ulint i; ulint i;
mtr_t mtr; mtr_t mtr;
if (buf_end - buf < 600) {
sprintf(buf, "... output truncated!\n");
return;
}
lock_mutex_enter_kernel(); lock_mutex_enter_kernel();
if (lock_deadlock_found) { if (lock_deadlock_found) {
fputs(
buf += sprintf(buf,
"------------------------\n" "------------------------\n"
"LATEST DETECTED DEADLOCK\n" "LATEST DETECTED DEADLOCK\n"
"------------------------\n"); "------------------------\n", file);
if ((ulint)(buf_end - buf) ut_copy_file(file, lock_latest_err_file);
< 100 + strlen(lock_latest_err_buf)) {
lock_mutex_exit_kernel();
sprintf(buf, "... output truncated!\n");
return;
} }
buf += sprintf(buf, "%s", lock_latest_err_buf); fputs(
}
if (buf_end - buf < 600) {
lock_mutex_exit_kernel();
sprintf(buf, "... output truncated!\n");
return;
}
buf += sprintf(buf,
"------------\n" "------------\n"
"TRANSACTIONS\n" "TRANSACTIONS\n"
"------------\n"); "------------\n", file);
buf += sprintf(buf, "Trx id counter %lu %lu\n", fprintf(file, "Trx id counter %lu %lu\n",
ut_dulint_get_high(trx_sys->max_trx_id), ut_dulint_get_high(trx_sys->max_trx_id),
ut_dulint_get_low(trx_sys->max_trx_id)); ut_dulint_get_low(trx_sys->max_trx_id));
buf += sprintf(buf, fprintf(file,
"Purge done for trx's n:o < %lu %lu undo n:o < %lu %lu\n", "Purge done for trx's n:o < %lu %lu undo n:o < %lu %lu\n",
ut_dulint_get_high(purge_sys->purge_trx_no), ut_dulint_get_high(purge_sys->purge_trx_no),
ut_dulint_get_low(purge_sys->purge_trx_no), ut_dulint_get_low(purge_sys->purge_trx_no),
ut_dulint_get_high(purge_sys->purge_undo_no), ut_dulint_get_high(purge_sys->purge_undo_no),
ut_dulint_get_low(purge_sys->purge_undo_no)); ut_dulint_get_low(purge_sys->purge_undo_no));
buf += sprintf(buf, fprintf(file,
"Total number of lock structs in row lock hash table %lu\n", "Total number of lock structs in row lock hash table %lu\n",
lock_get_n_rec_locks()); lock_get_n_rec_locks());
buf += sprintf(buf, "LIST OF TRANSACTIONS FOR EACH SESSION:\n"); fprintf(file, "LIST OF TRANSACTIONS FOR EACH SESSION:\n");
/* First print info on non-active transactions */ /* First print info on non-active transactions */
trx = UT_LIST_GET_FIRST(trx_sys->mysql_trx_list); trx = UT_LIST_GET_FIRST(trx_sys->mysql_trx_list);
while (trx) { while (trx) {
if (buf_end - buf < 900) {
lock_mutex_exit_kernel();
sprintf(buf, "... output truncated!\n");
return;
}
if (trx->conc_state == TRX_NOT_STARTED) { if (trx->conc_state == TRX_NOT_STARTED) {
buf += sprintf(buf, "---"); fputs("---", file);
trx_print(buf, trx); trx_print(file, trx);
buf += strlen(buf);
} }
trx = UT_LIST_GET_NEXT(mysql_trx_list, trx); trx = UT_LIST_GET_NEXT(mysql_trx_list, trx);
@ -4004,28 +3925,12 @@ loop:
return; return;
} }
if (buf_end - buf < 900) {
lock_mutex_exit_kernel();
sprintf(buf, "... output truncated!\n");
return;
}
if (nth_lock == 0) { if (nth_lock == 0) {
buf += sprintf(buf, "---"); fputs("---", file);
trx_print(buf, trx); trx_print(file, trx);
buf += strlen(buf);
if (buf_end - buf < 500) {
lock_mutex_exit_kernel();
sprintf(buf, "... output truncated!\n");
return;
}
if (trx->read_view) { if (trx->read_view) {
buf += sprintf(buf, fprintf(file,
"Trx read view will not see trx with id >= %lu %lu, sees < %lu %lu\n", "Trx read view will not see trx with id >= %lu %lu, sees < %lu %lu\n",
ut_dulint_get_high(trx->read_view->low_limit_id), ut_dulint_get_high(trx->read_view->low_limit_id),
ut_dulint_get_low(trx->read_view->low_limit_id), ut_dulint_get_low(trx->read_view->low_limit_id),
@ -4034,19 +3939,17 @@ loop:
} }
if (trx->que_state == TRX_QUE_LOCK_WAIT) { if (trx->que_state == TRX_QUE_LOCK_WAIT) {
buf += sprintf(buf, fprintf(file,
"------- TRX HAS BEEN WAITING %lu SEC FOR THIS LOCK TO BE GRANTED:\n", "------- TRX HAS BEEN WAITING %lu SEC FOR THIS LOCK TO BE GRANTED:\n",
(ulint)difftime(time(NULL), trx->wait_started)); (ulint)difftime(time(NULL), trx->wait_started));
if (lock_get_type(trx->wait_lock) == LOCK_REC) { if (lock_get_type(trx->wait_lock) == LOCK_REC) {
lock_rec_print(buf, trx->wait_lock); lock_rec_print(file, trx->wait_lock);
} else { } else {
lock_table_print(buf, trx->wait_lock); lock_table_print(file, trx->wait_lock);
} }
buf += strlen(buf); fputs("------------------\n", file);
buf += sprintf(buf,
"------------------\n");
} }
} }
@ -4074,13 +3977,6 @@ loop:
goto loop; goto loop;
} }
if (buf_end - buf < 500) {
lock_mutex_exit_kernel();
sprintf(buf, "... output truncated!\n");
return;
}
if (lock_get_type(lock) == LOCK_REC) { if (lock_get_type(lock) == LOCK_REC) {
space = lock->un_member.rec_lock.space; space = lock->un_member.rec_lock.space;
page_no = lock->un_member.rec_lock.page_no; page_no = lock->un_member.rec_lock.page_no;
@ -4101,22 +3997,21 @@ loop:
goto loop; goto loop;
} }
lock_rec_print(buf, lock); lock_rec_print(file, lock);
} else { } else {
ut_ad(lock_get_type(lock) == LOCK_TABLE); ut_ad(lock_get_type(lock) == LOCK_TABLE);
lock_table_print(buf, lock); lock_table_print(file, lock);
} }
buf += strlen(buf);
load_page_first = TRUE; load_page_first = TRUE;
nth_lock++; nth_lock++;
if (nth_lock >= 10) { if (nth_lock >= 10) {
buf += sprintf(buf, fputs(
"10 LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n"); "10 LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n",
file);
nth_trx++; nth_trx++;
nth_lock = 0; nth_lock = 0;
@ -4333,7 +4228,8 @@ loop:
index = lock->index; index = lock->index;
rec = page_find_rec_with_heap_no(page, i); rec = page_find_rec_with_heap_no(page, i);
printf("Validating %lu %lu\n", space, page_no); fprintf(stderr,
"Validating %lu %lu\n", space, page_no);
lock_mutex_exit_kernel(); lock_mutex_exit_kernel();

View File

@ -517,7 +517,8 @@ log_group_calc_lsn_offset(
ut_a(offset < (((ib_longlong) 1) << 32)); /* offset must be < 4 GB */ ut_a(offset < (((ib_longlong) 1) << 32)); /* offset must be < 4 GB */
/* printf("Offset is %lu gr_lsn_offset is %lu difference is %lu\n", /* fprintf(stderr,
"Offset is %lu gr_lsn_offset is %lu difference is %lu\n",
(ulint)offset,(ulint)gr_lsn_size_offset, (ulint)difference); (ulint)offset,(ulint)gr_lsn_size_offset, (ulint)difference);
*/ */
@ -934,7 +935,8 @@ log_group_check_flush_completion(
if (!log_sys->one_flushed && group->n_pending_writes == 0) { if (!log_sys->one_flushed && group->n_pending_writes == 0) {
#ifdef UNIV_LOG_DEBUG #ifdef UNIV_LOG_DEBUG
if (log_debug_writes) { if (log_debug_writes) {
printf("Log flushed first to group %lu\n", group->id); fprintf(stderr,
"Log flushed first to group %lu\n", group->id);
} }
#endif /* UNIV_LOG_DEBUG */ #endif /* UNIV_LOG_DEBUG */
@ -947,7 +949,7 @@ log_group_check_flush_completion(
#ifdef UNIV_LOG_DEBUG #ifdef UNIV_LOG_DEBUG
if (log_debug_writes && (group->n_pending_writes == 0)) { if (log_debug_writes && (group->n_pending_writes == 0)) {
printf("Log flushed to group %lu\n", group->id); fprintf(stderr, "Log flushed to group %lu\n", group->id);
} }
#endif /* UNIV_LOG_DEBUG */ #endif /* UNIV_LOG_DEBUG */
@ -1096,9 +1098,9 @@ log_group_file_header_flush(
#ifdef UNIV_LOG_DEBUG #ifdef UNIV_LOG_DEBUG
if (log_debug_writes) { if (log_debug_writes) {
printf( fprintf(stderr,
"Writing log file header to group %lu file %lu\n", group->id, "Writing log file header to group %lu file %lu\n",
nth_file); group->id, nth_file);
} }
#endif /* UNIV_LOG_DEBUG */ #endif /* UNIV_LOG_DEBUG */
@ -1186,14 +1188,13 @@ loop:
#ifdef UNIV_LOG_DEBUG #ifdef UNIV_LOG_DEBUG
if (log_debug_writes) { if (log_debug_writes) {
printf( fprintf(stderr,
"Writing log file segment to group %lu offset %lu len %lu\n" "Writing log file segment to group %lu offset %lu len %lu\n"
"start lsn %lu %lu\n", "start lsn %lu %lu\n"
"First block n:o %lu last block n:o %lu\n",
group->id, next_offset, write_len, group->id, next_offset, write_len,
ut_dulint_get_high(start_lsn), ut_dulint_get_high(start_lsn),
ut_dulint_get_low(start_lsn)); ut_dulint_get_low(start_lsn),
printf(
"First block n:o %lu last block n:o %lu\n",
log_block_get_hdr_no(buf), log_block_get_hdr_no(buf),
log_block_get_hdr_no( log_block_get_hdr_no(
buf + write_len - OS_FILE_LOG_BLOCK_SIZE)); buf + write_len - OS_FILE_LOG_BLOCK_SIZE));
@ -1274,7 +1275,7 @@ loop:
ut_ad(loop_count < 5); ut_ad(loop_count < 5);
if (loop_count > 2) { if (loop_count > 2) {
/* printf("Log loop count %lu\n", loop_count); */ /* fprintf(stderr, "Log loop count %lu\n", loop_count); */
} }
mutex_enter(&(log_sys->mutex)); mutex_enter(&(log_sys->mutex));
@ -1337,7 +1338,8 @@ loop:
#ifdef UNIV_LOG_DEBUG #ifdef UNIV_LOG_DEBUG
if (log_debug_writes) { if (log_debug_writes) {
printf("Writing log from %lu %lu up to lsn %lu %lu\n", fprintf(stderr,
"Writing log from %lu %lu up to lsn %lu %lu\n",
ut_dulint_get_high(log_sys->written_to_all_lsn), ut_dulint_get_high(log_sys->written_to_all_lsn),
ut_dulint_get_low(log_sys->written_to_all_lsn), ut_dulint_get_low(log_sys->written_to_all_lsn),
ut_dulint_get_high(log_sys->lsn), ut_dulint_get_high(log_sys->lsn),
@ -1757,11 +1759,11 @@ log_reset_first_header_and_checkpoint(
lsn = ut_dulint_add(start, LOG_BLOCK_HDR_SIZE); lsn = ut_dulint_add(start, LOG_BLOCK_HDR_SIZE);
/* Write the label of ibbackup --restore */ /* Write the label of ibbackup --restore */
sprintf((char*) hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP, strcpy((char*) hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP,
"ibbackup "); "ibbackup ");
ut_sprintf_timestamp( ut_sprintf_timestamp(
(char*) hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP (char*) hdr_buf + (LOG_FILE_WAS_CREATED_BY_HOT_BACKUP
+ strlen("ibbackup ")); + (sizeof "ibbackup ") - 1));
buf = hdr_buf + LOG_CHECKPOINT_1; buf = hdr_buf + LOG_CHECKPOINT_1;
mach_write_to_8(buf + LOG_CHECKPOINT_NO, ut_dulint_zero); mach_write_to_8(buf + LOG_CHECKPOINT_NO, ut_dulint_zero);
@ -1904,7 +1906,7 @@ log_checkpoint(
#ifdef UNIV_LOG_DEBUG #ifdef UNIV_LOG_DEBUG
if (log_debug_writes) { if (log_debug_writes) {
printf("Making checkpoint no %lu at lsn %lu %lu\n", fprintf(stderr, "Making checkpoint no %lu at lsn %lu %lu\n",
ut_dulint_get_low(log_sys->next_checkpoint_no), ut_dulint_get_low(log_sys->next_checkpoint_no),
ut_dulint_get_high(oldest_lsn), ut_dulint_get_high(oldest_lsn),
ut_dulint_get_low(oldest_lsn)); ut_dulint_get_low(oldest_lsn));
@ -2280,18 +2282,17 @@ loop:
if (!ret) { if (!ret) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Cannot create or open archive log file %s.\n", "InnoDB: Cannot create or open archive log file %s.\n"
name); "InnoDB: Cannot continue operation.\n"
fprintf(stderr, "InnoDB: Cannot continue operation.\n"
"InnoDB: Check that the log archive directory exists,\n" "InnoDB: Check that the log archive directory exists,\n"
"InnoDB: you have access rights to it, and\n" "InnoDB: you have access rights to it, and\n"
"InnoDB: there is space available.\n"); "InnoDB: there is space available.\n", name);
exit(1); exit(1);
} }
#ifdef UNIV_LOG_DEBUG #ifdef UNIV_LOG_DEBUG
if (log_debug_writes) { if (log_debug_writes) {
printf("Created archive file %s\n", name); fprintf(stderr, "Created archive file %s\n", name);
} }
#endif /* UNIV_LOG_DEBUG */ #endif /* UNIV_LOG_DEBUG */
@ -2324,7 +2325,7 @@ loop:
#ifdef UNIV_LOG_DEBUG #ifdef UNIV_LOG_DEBUG
if (log_debug_writes) { if (log_debug_writes) {
printf( fprintf(stderr,
"Archiving starting at lsn %lu %lu, len %lu to group %lu\n", "Archiving starting at lsn %lu %lu, len %lu to group %lu\n",
ut_dulint_get_high(start_lsn), ut_dulint_get_high(start_lsn),
ut_dulint_get_low(start_lsn), ut_dulint_get_low(start_lsn),
@ -2423,7 +2424,8 @@ log_archive_write_complete_groups(void)
#ifdef UNIV_LOG_DEBUG #ifdef UNIV_LOG_DEBUG
if (log_debug_writes && trunc_files) { if (log_debug_writes && trunc_files) {
printf("Complete file(s) archived to group %lu\n", fprintf(stderr,
"Complete file(s) archived to group %lu\n",
group->id); group->id);
} }
#endif /* UNIV_LOG_DEBUG */ #endif /* UNIV_LOG_DEBUG */
@ -2451,7 +2453,7 @@ log_archive_write_complete_groups(void)
#ifdef UNIV_LOG_DEBUG #ifdef UNIV_LOG_DEBUG
if (log_debug_writes) { if (log_debug_writes) {
printf("Archiving writes completed\n"); fputs("Archiving writes completed\n", stderr);
} }
#endif /* UNIV_LOG_DEBUG */ #endif /* UNIV_LOG_DEBUG */
} }
@ -2472,7 +2474,7 @@ log_archive_check_completion_low(void)
#ifdef UNIV_LOG_DEBUG #ifdef UNIV_LOG_DEBUG
if (log_debug_writes) { if (log_debug_writes) {
printf("Archiving read completed\n"); fputs("Archiving read completed\n", stderr);
} }
#endif /* UNIV_LOG_DEBUG */ #endif /* UNIV_LOG_DEBUG */
@ -2620,7 +2622,8 @@ loop:
#ifdef UNIV_LOG_DEBUG #ifdef UNIV_LOG_DEBUG
if (log_debug_writes) { if (log_debug_writes) {
printf("Archiving from lsn %lu %lu to lsn %lu %lu\n", fprintf(stderr,
"Archiving from lsn %lu %lu to lsn %lu %lu\n",
ut_dulint_get_high(log_sys->archived_lsn), ut_dulint_get_high(log_sys->archived_lsn),
ut_dulint_get_low(log_sys->archived_lsn), ut_dulint_get_low(log_sys->archived_lsn),
ut_dulint_get_high(limit_lsn), ut_dulint_get_high(limit_lsn),
@ -2727,7 +2730,7 @@ log_archive_close_groups(
#ifdef UNIV_LOG_DEBUG #ifdef UNIV_LOG_DEBUG
if (log_debug_writes) { if (log_debug_writes) {
printf( fprintf(stderr,
"Incrementing arch file no to %lu in log group %lu\n", "Incrementing arch file no to %lu in log group %lu\n",
group->archived_file_no + 2, group->id); group->archived_file_no + 2, group->id);
} }
@ -3262,20 +3265,15 @@ Prints info of the log. */
void void
log_print( log_print(
/*======*/ /*======*/
char* buf, /* in/out: buffer where to print */ FILE* file) /* in: file where to print */
char* buf_end)/* in: buffer end */
{ {
double time_elapsed; double time_elapsed;
time_t current_time; time_t current_time;
if (buf_end - buf < 300) {
return;
}
mutex_enter(&(log_sys->mutex)); mutex_enter(&(log_sys->mutex));
buf += sprintf(buf, "Log sequence number %lu %lu\n" fprintf(file,
"Log sequence number %lu %lu\n"
"Log flushed up to %lu %lu\n" "Log flushed up to %lu %lu\n"
"Last checkpoint at %lu %lu\n", "Last checkpoint at %lu %lu\n",
ut_dulint_get_high(log_sys->lsn), ut_dulint_get_high(log_sys->lsn),
@ -3289,7 +3287,7 @@ log_print(
time_elapsed = 0.001 + difftime(current_time, time_elapsed = 0.001 + difftime(current_time,
log_sys->last_printout_time); log_sys->last_printout_time);
buf += sprintf(buf, fprintf(file,
"%lu pending log writes, %lu pending chkp writes\n" "%lu pending log writes, %lu pending chkp writes\n"
"%lu log i/o's done, %.2f log i/o's/second\n", "%lu log i/o's done, %.2f log i/o's/second\n",
log_sys->n_pending_writes, log_sys->n_pending_writes,

View File

@ -589,7 +589,7 @@ recv_read_cp_info_for_backup(
*fsp_limit = 1000000000; *fsp_limit = 1000000000;
} }
/* printf("fsp limit %lu MB\n", *fsp_limit); */ /* fprintf(stderr, "fsp limit %lu MB\n", *fsp_limit); */
*cp_no = mach_read_from_8(cp_buf + LOG_CHECKPOINT_NO); *cp_no = mach_read_from_8(cp_buf + LOG_CHECKPOINT_NO);
@ -665,7 +665,7 @@ recv_scan_log_seg_for_backup(
if (no != log_block_convert_lsn_to_no(*scanned_lsn) if (no != log_block_convert_lsn_to_no(*scanned_lsn)
|| !log_block_checksum_is_ok_or_old_format(log_block)) { || !log_block_checksum_is_ok_or_old_format(log_block)) {
/* /*
printf( fprintf(stderr,
"Log block n:o %lu, scanned lsn n:o %lu\n", "Log block n:o %lu, scanned lsn n:o %lu\n",
no, log_block_convert_lsn_to_no(*scanned_lsn)); no, log_block_convert_lsn_to_no(*scanned_lsn));
*/ */
@ -673,7 +673,7 @@ recv_scan_log_seg_for_backup(
log_block += OS_FILE_LOG_BLOCK_SIZE; log_block += OS_FILE_LOG_BLOCK_SIZE;
/* /*
printf( fprintf(stderr,
"Next log block n:o %lu\n", "Next log block n:o %lu\n",
log_block_get_hdr_no(log_block)); log_block_get_hdr_no(log_block));
*/ */
@ -690,7 +690,8 @@ recv_scan_log_seg_for_backup(
/* Garbage from a log buffer flush which was made /* Garbage from a log buffer flush which was made
before the most recent database recovery */ before the most recent database recovery */
/* /*
printf("Scanned cp n:o %lu, block cp n:o %lu\n", fprintf(stderr,
"Scanned cp n:o %lu, block cp n:o %lu\n",
*scanned_checkpoint_no, *scanned_checkpoint_no,
log_block_get_checkpoint_no(log_block)); log_block_get_checkpoint_no(log_block));
*/ */
@ -708,7 +709,8 @@ recv_scan_log_seg_for_backup(
if (data_len < OS_FILE_LOG_BLOCK_SIZE) { if (data_len < OS_FILE_LOG_BLOCK_SIZE) {
/* Log data ends here */ /* Log data ends here */
/* printf("Log block data len %lu\n", data_len); */ /* fprintf(stderr, "Log block data len %lu\n",
data_len); */
break; break;
} }
@ -1211,7 +1213,7 @@ recv_read_in_area(
buf_read_recv_pages(FALSE, space, page_nos, n); buf_read_recv_pages(FALSE, space, page_nos, n);
/* /*
printf("Recv pages at %lu n %lu\n", page_nos[0], n); fprintf(stderr, "Recv pages at %lu n %lu\n", page_nos[0], n);
*/ */
return(n); return(n);
} }
@ -1398,16 +1400,16 @@ recv_apply_log_recs_for_backup(
} }
if (recv_max_parsed_page_no >= n_pages_total) { if (recv_max_parsed_page_no >= n_pages_total) {
printf( fprintf(stderr,
"InnoDB: Error: tablespace size %lu pages, but a log record on page %lu!\n" "InnoDB: Error: tablespace size %lu pages, but a log record on page %lu!\n"
"InnoDB: Are you sure you have specified all the ibdata files right in\n" "InnoDB: Are you sure you have specified all the ibdata files right in\n"
"InnoDB: the my.cnf file you gave as the argument to ibbackup --restore?\n", "InnoDB: the my.cnf file you gave as the argument to ibbackup --restore?\n",
n_pages_total, recv_max_parsed_page_no); n_pages_total, recv_max_parsed_page_no);
} }
printf( fputs(
"InnoDB: Starting an apply batch of log records to the database...\n" "InnoDB: Starting an apply batch of log records to the database...\n"
"InnoDB: Progress in percents: "); "InnoDB: Progress in percents: ", stderr);
for (i = 0; i < n_pages_total; i++) { for (i = 0; i < n_pages_total; i++) {
@ -1424,7 +1426,7 @@ recv_apply_log_recs_for_backup(
OS_FILE_READ_WRITE, OS_FILE_READ_WRITE,
&success); &success);
if (!success) { if (!success) {
printf( fprintf(stderr,
"InnoDB: Error: cannot open %lu'th data file\n", nth_file); "InnoDB: Error: cannot open %lu'th data file\n", nth_file);
exit(1); exit(1);
@ -1440,7 +1442,7 @@ recv_apply_log_recs_for_backup(
nth_page_in_file >> (32 - UNIV_PAGE_SIZE_SHIFT), nth_page_in_file >> (32 - UNIV_PAGE_SIZE_SHIFT),
UNIV_PAGE_SIZE); UNIV_PAGE_SIZE);
if (!success) { if (!success) {
printf( fprintf(stderr,
"InnoDB: Error: cannot read page no %lu from %lu'th data file\n", "InnoDB: Error: cannot read page no %lu from %lu'th data file\n",
nth_page_in_file, nth_file); nth_page_in_file, nth_file);
@ -1468,7 +1470,7 @@ recv_apply_log_recs_for_backup(
nth_page_in_file >> (32 - UNIV_PAGE_SIZE_SHIFT), nth_page_in_file >> (32 - UNIV_PAGE_SIZE_SHIFT),
UNIV_PAGE_SIZE); UNIV_PAGE_SIZE);
if (!success) { if (!success) {
printf( fprintf(stderr,
"InnoDB: Error: cannot write page no %lu to %lu'th data file\n", "InnoDB: Error: cannot write page no %lu to %lu'th data file\n",
nth_page_in_file, nth_file); nth_page_in_file, nth_file);
@ -1478,8 +1480,8 @@ recv_apply_log_recs_for_backup(
if ((100 * i) / n_pages_total if ((100 * i) / n_pages_total
!= (100 * (i + 1)) / n_pages_total) { != (100 * (i + 1)) / n_pages_total) {
printf("%lu ", (100 * i) / n_pages_total); fprintf(stderr, "%lu ", (100 * i) / n_pages_total);
fflush(stdout); fflush(stderr);
} }
nth_page_in_file++; nth_page_in_file++;
@ -1821,21 +1823,15 @@ recv_report_corrupt_log(
ulint space, /* in: space id, this may also be garbage */ ulint space, /* in: space id, this may also be garbage */
ulint page_no)/* in: page number, this may also be garbage */ ulint page_no)/* in: page number, this may also be garbage */
{ {
char* err_buf;
fprintf(stderr, fprintf(stderr,
"InnoDB: ############### CORRUPT LOG RECORD FOUND\n" "InnoDB: ############### CORRUPT LOG RECORD FOUND\n"
"InnoDB: Log record type %lu, space id %lu, page number %lu\n" "InnoDB: Log record type %lu, space id %lu, page number %lu\n"
"InnoDB: Log parsing proceeded successfully up to %lu %lu\n", "InnoDB: Log parsing proceeded successfully up to %lu %lu\n"
(ulint)type, space, page_no,
ut_dulint_get_high(recv_sys->recovered_lsn),
ut_dulint_get_low(recv_sys->recovered_lsn));
err_buf = ut_malloc(1000000);
fprintf(stderr,
"InnoDB: Previous log record type %lu, is multi %lu\n" "InnoDB: Previous log record type %lu, is multi %lu\n"
"InnoDB: Recv offset %lu, prev %lu\n", "InnoDB: Recv offset %lu, prev %lu\n",
(ulint)type, space, page_no,
ut_dulint_get_high(recv_sys->recovered_lsn),
ut_dulint_get_low(recv_sys->recovered_lsn),
recv_previous_parsed_rec_type, recv_previous_parsed_rec_type,
recv_previous_parsed_rec_is_multi, recv_previous_parsed_rec_is_multi,
(ulint)(ptr - recv_sys->buf), (ulint)(ptr - recv_sys->buf),
@ -1846,28 +1842,27 @@ recv_report_corrupt_log(
&& (ulint)(ptr - recv_sys->buf + 100 && (ulint)(ptr - recv_sys->buf + 100
- recv_previous_parsed_rec_offset) - recv_previous_parsed_rec_offset)
< 200000) { < 200000) {
fputs(
"InnoDB: Hex dump of corrupt log starting 100 bytes before the start\n"
"InnoDB: of the previous log rec,\n"
"InnoDB: and ending 100 bytes after the start of the corrupt rec:\n",
stderr);
ut_sprintf_buf(err_buf, ut_print_buf(stderr,
recv_sys->buf + recv_previous_parsed_rec_offset - 100, recv_sys->buf + recv_previous_parsed_rec_offset - 100,
ptr - recv_sys->buf + 200 - ptr - recv_sys->buf + 200 -
recv_previous_parsed_rec_offset); recv_previous_parsed_rec_offset);
fprintf(stderr, putc('\n', stderr);
"InnoDB: Hex dump of corrupt log starting 100 bytes before the start\n"
"InnoDB: of the previous log rec,\n"
"InnoDB: and ending 100 bytes after the start of the corrupt rec:\n%s\n",
err_buf);
} }
ut_free(err_buf); fputs(
fprintf(stderr,
"InnoDB: WARNING: the log file may have been corrupt and it\n" "InnoDB: WARNING: the log file may have been corrupt and it\n"
"InnoDB: is possible that the log scan did not proceed\n" "InnoDB: is possible that the log scan did not proceed\n"
"InnoDB: far enough in recovery! Please run CHECK TABLE\n" "InnoDB: far enough in recovery! Please run CHECK TABLE\n"
"InnoDB: on your InnoDB tables to check that they are ok!\n" "InnoDB: on your InnoDB tables to check that they are ok!\n"
"InnoDB: If mysqld crashes after this recovery, look at\n" "InnoDB: If mysqld crashes after this recovery, look at\n"
"InnoDB: section 6.1 of http://www.innodb.com/ibman.html\n" "InnoDB: section 6.1 of http://www.innodb.com/ibman.php\n"
"InnoDB: about forcing recovery.\n"); "InnoDB: about forcing recovery.\n", stderr);
fflush(stderr); fflush(stderr);
} }
@ -2517,7 +2512,7 @@ recv_recovery_from_checkpoint_start(
log_hdr_buf, max_cp_group); log_hdr_buf, max_cp_group);
if (0 == ut_memcmp(log_hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP, if (0 == ut_memcmp(log_hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP,
(byte*)"ibbackup", ut_strlen((char*)"ibbackup"))) { (byte*)"ibbackup", (sizeof "ibbackup") - 1)) {
/* This log file was created by ibbackup --restore: print /* This log file was created by ibbackup --restore: print
a note to the user about it */ a note to the user about it */
@ -2865,25 +2860,35 @@ recv_reset_log_files_for_backup(
ibool success; ibool success;
byte* buf; byte* buf;
ulint i; ulint i;
char name[5000]; ulint log_dir_len;
char* name;
static
char logfilename[] = "ib_logfile";
log_dir_len = strlen(log_dir);
/* reserve space for log_dir, "ib_logfile" and a number */
name = memcpy(mem_alloc(log_dir_len + ((sizeof logfilename) + 11)),
log_dir, log_dir_len);
memcpy(name + log_dir_len, logfilename, sizeof logfilename);
buf = ut_malloc(LOG_FILE_HDR_SIZE + OS_FILE_LOG_BLOCK_SIZE); buf = ut_malloc(LOG_FILE_HDR_SIZE + OS_FILE_LOG_BLOCK_SIZE);
for (i = 0; i < n_log_files; i++) { for (i = 0; i < n_log_files; i++) {
sprintf(name, "%sib_logfile%lu", log_dir, i); sprintf(name + log_dir_len + sizeof logfilename, "%lu", i);
log_file = os_file_create_simple(name, OS_FILE_CREATE, log_file = os_file_create_simple(name, OS_FILE_CREATE,
OS_FILE_READ_WRITE, &success); OS_FILE_READ_WRITE, &success);
if (!success) { if (!success) {
printf( fprintf(stderr,
"InnoDB: Cannot create %s. Check that the file does not exist yet.\n", name); "InnoDB: Cannot create %s. Check that the file does not exist yet.\n", name);
exit(1); exit(1);
} }
printf( fprintf(stderr,
"Setting log file size to %lu %lu\n", ut_get_high32(log_file_size), "Setting log file size to %lu %lu\n",
ut_get_high32(log_file_size),
log_file_size & 0xFFFFFFFF); log_file_size & 0xFFFFFFFF);
success = os_file_set_size(name, log_file, success = os_file_set_size(name, log_file,
@ -2891,7 +2896,7 @@ recv_reset_log_files_for_backup(
ut_get_high32(log_file_size)); ut_get_high32(log_file_size));
if (!success) { if (!success) {
printf( fprintf(stderr,
"InnoDB: Cannot set %s size to %lu %lu\n", name, ut_get_high32(log_file_size), "InnoDB: Cannot set %s size to %lu %lu\n", name, ut_get_high32(log_file_size),
log_file_size & 0xFFFFFFFF); log_file_size & 0xFFFFFFFF);
exit(1); exit(1);
@ -2908,12 +2913,12 @@ recv_reset_log_files_for_backup(
log_block_init_in_old_format(buf + LOG_FILE_HDR_SIZE, lsn); log_block_init_in_old_format(buf + LOG_FILE_HDR_SIZE, lsn);
log_block_set_first_rec_group(buf + LOG_FILE_HDR_SIZE, log_block_set_first_rec_group(buf + LOG_FILE_HDR_SIZE,
LOG_BLOCK_HDR_SIZE); LOG_BLOCK_HDR_SIZE);
sprintf(name, "%sib_logfile%lu", log_dir, 0); strcpy(name + log_dir_len + sizeof logfilename, "0");
log_file = os_file_create_simple(name, OS_FILE_OPEN, log_file = os_file_create_simple(name, OS_FILE_OPEN,
OS_FILE_READ_WRITE, &success); OS_FILE_READ_WRITE, &success);
if (!success) { if (!success) {
printf("InnoDB: Cannot open %s.\n", name); fprintf(stderr, "InnoDB: Cannot open %s.\n", name);
exit(1); exit(1);
} }
@ -2923,6 +2928,7 @@ recv_reset_log_files_for_backup(
os_file_flush(log_file); os_file_flush(log_file);
os_file_close(log_file); os_file_close(log_file);
mem_free(name);
ut_free(buf); ut_free(buf);
} }

View File

@ -336,7 +336,7 @@ mem_hash_remove(
} }
if (node == NULL) { if (node == NULL) {
printf( fprintf(stderr,
"Memory heap or buffer freed in %s line %lu did not exist.\n", "Memory heap or buffer freed in %s line %lu did not exist.\n",
file_name, line); file_name, line);
ut_error; ut_error;
@ -351,20 +351,18 @@ mem_hash_remove(
mem_heap_validate_or_print(node->heap, NULL, FALSE, &error, &size, mem_heap_validate_or_print(node->heap, NULL, FALSE, &error, &size,
NULL, NULL); NULL, NULL);
if (error) { if (error) {
printf("Inconsistency in memory heap or buffer n:o %lu created\n", fprintf(stderr,
node->nth_heap); "Inconsistency in memory heap or buffer n:o %lu created\n"
printf("in %s line %lu and tried to free in %s line %lu.\n", "in %s line %lu and tried to free in %s line %lu.\n"
node->file_name, node->line, file_name, line); "Hex dump of 400 bytes around memory heap first block start:\n",
node->nth_heap, node->file_name, node->line,
file_name, line);
ut_print_buf(stderr, (byte*)node->heap - 200, 400);
printf( fputs("\nDump of the mem heap:\n", stderr);
"Hex dump of 400 bytes around memory heap first block start:\n");
ut_print_buf((byte*)(node->heap) - 200, 400); mem_heap_validate_or_print(node->heap, NULL, TRUE, &error,
&size, NULL, NULL);
printf("\nDump of the mem heap:\n");
mem_heap_validate_or_print(node->heap, NULL, TRUE, &error, &size,
NULL, NULL);
ut_error; ut_error;
} }
@ -438,7 +436,7 @@ mem_heap_validate_or_print(
} }
if (print) { if (print) {
printf("Memory heap:"); fputs("Memory heap:", stderr);
} }
while (block != NULL) { while (block != NULL) {
@ -456,7 +454,7 @@ mem_heap_validate_or_print(
/* We can trace the fields of the block only in the debug /* We can trace the fields of the block only in the debug
version */ version */
if (print) { if (print) {
printf(" Block %ld:", block_count); fprintf(stderr, " Block %ld:", block_count);
} }
field = (byte*)block + mem_block_get_start(block); field = (byte*)block + mem_block_get_start(block);
@ -476,7 +474,7 @@ mem_heap_validate_or_print(
len = mem_field_header_get_len(user_field); len = mem_field_header_get_len(user_field);
if (print) { if (print) {
ut_print_buf(user_field, len); ut_print_buf(stderr, user_field, len);
} }
total_len += len; total_len += len;
@ -545,7 +543,7 @@ mem_heap_print(
mem_heap_validate_or_print(heap, NULL, TRUE, &error, mem_heap_validate_or_print(heap, NULL, TRUE, &error,
&us_size, &phys_size, &n_blocks); &us_size, &phys_size, &n_blocks);
printf( fprintf(stderr,
"\nheap type: %lu; size: user size %lu; physical size %lu; blocks %lu.\n", "\nheap type: %lu; size: user size %lu; physical size %lu; blocks %lu.\n",
heap->type, us_size, phys_size, n_blocks); heap->type, us_size, phys_size, n_blocks);
ut_a(!error); ut_a(!error);
@ -659,9 +657,11 @@ mem_validate_no_assert(void)
&ph_size, &n_blocks); &ph_size, &n_blocks);
if (error) { if (error) {
printf("\nERROR!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n"); fprintf(stderr,
printf("Inconsistency in memory heap or buffer created\n"); "\nERROR!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n"
printf("in %s line %lu.\n", node->file_name, node->line); "Inconsistency in memory heap or buffer created\n"
"in %s line %lu.\n",
node->file_name, node->line);
mutex_exit(&mem_hash_mutex); mutex_exit(&mem_hash_mutex);
@ -721,12 +721,10 @@ mem_analyze_corruption(
ulint i; ulint i;
ulint dist; ulint dist;
ut_sprintf_buf(srv_fatal_errbuf, ptr - 250, 500); fputs("InnoDB: Apparent memory corruption: mem dump ", stderr);
fprintf(stderr, ut_print_buf(stderr, ptr - 250, 500);
"InnoDB: Apparent memory corruption: mem dump %s\n", srv_fatal_errbuf);
fprintf(stderr, fputs("\nInnoDB: Scanning backward trying to find previous allocated mem blocks\n", stderr);
"InnoDB: Scanning backward trying to find previous allocated mem blocks\n");
p = ptr; p = ptr;
dist = 0; dist = 0;

View File

@ -54,15 +54,15 @@ mlog_write_initial_log_record(
byte* log_ptr; byte* log_ptr;
ut_ad(type <= MLOG_BIGGEST_TYPE); ut_ad(type <= MLOG_BIGGEST_TYPE);
ut_ad(type > MLOG_8BYTES);
if (ptr < buf_pool->frame_zero || ptr >= buf_pool->high_end) { if (ptr < buf_pool->frame_zero || ptr >= buf_pool->high_end) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: trying to write to a stray memory location %lx\n", "InnoDB: Error: trying to write to a stray memory location %p\n", ptr);
(ulint)ptr);
ut_error; ut_error;
} }
log_ptr = mlog_open(mtr, 20); log_ptr = mlog_open(mtr, 11);
/* If no logging is requested, we may return now */ /* If no logging is requested, we may return now */
if (log_ptr == NULL) { if (log_ptr == NULL) {
@ -221,8 +221,7 @@ mlog_write_ulint(
if (ptr < buf_pool->frame_zero || ptr >= buf_pool->high_end) { if (ptr < buf_pool->frame_zero || ptr >= buf_pool->high_end) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: trying to write to a stray memory location %lx\n", "InnoDB: Error: trying to write to a stray memory location %p\n", ptr);
(ulint)ptr);
ut_error; ut_error;
} }
@ -268,8 +267,7 @@ mlog_write_dulint(
if (ptr < buf_pool->frame_zero || ptr >= buf_pool->high_end) { if (ptr < buf_pool->frame_zero || ptr >= buf_pool->high_end) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: trying to write to a stray memory location %lx\n", "InnoDB: Error: trying to write to a stray memory location %p\n", ptr);
(ulint)ptr);
ut_error; ut_error;
} }
@ -312,8 +310,7 @@ mlog_write_string(
if (ptr < buf_pool->frame_zero || ptr >= buf_pool->high_end) { if (ptr < buf_pool->frame_zero || ptr >= buf_pool->high_end) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: trying to write to a stray memory location %lx\n", "InnoDB: Error: trying to write to a stray memory location %p\n", ptr);
(ulint)ptr);
ut_error; ut_error;
} }
ut_ad(ptr && mtr); ut_ad(ptr && mtr);

View File

@ -262,7 +262,8 @@ mtr_first_to_modify_page_after_backup(
block->frame), block->frame),
backup_lsn) <= 0) { backup_lsn) <= 0) {
printf("Page %lu newest %lu backup %lu\n", fprintf(stderr,
"Page %lu newest %lu backup %lu\n",
block->offset, block->offset,
ut_dulint_get_low( ut_dulint_get_low(
buf_frame_get_newest_modification( buf_frame_get_newest_modification(
@ -515,7 +516,7 @@ mtr_print(
/*======*/ /*======*/
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
printf( fprintf(stderr,
"Mini-transaction handle: memo size %lu bytes log size %lu bytes\n", "Mini-transaction handle: memo size %lu bytes log size %lu bytes\n",
dyn_array_get_data_size(&(mtr->memo)), dyn_array_get_data_size(&(mtr->memo)),
dyn_array_get_data_size(&(mtr->log))); dyn_array_get_data_size(&(mtr->log)));

View File

@ -212,7 +212,7 @@ os_file_get_last_error(void)
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: Operating system error number %lu in a file operation.\n" " InnoDB: Operating system error number %lu in a file operation.\n"
"InnoDB: See http://www.innodb.com/ibman.html for installation help.\n", "InnoDB: See http://www.innodb.com/ibman.php for installation help.\n",
err); err);
if (err == ERROR_PATH_NOT_FOUND) { if (err == ERROR_PATH_NOT_FOUND) {
@ -227,7 +227,7 @@ os_file_get_last_error(void)
"InnoDB: of the same name as a data file.\n"); "InnoDB: of the same name as a data file.\n");
} else { } else {
fprintf(stderr, fprintf(stderr,
"InnoDB: See section 13.2 at http://www.innodb.com/ibman.html\n" "InnoDB: See section 13.2 at http://www.innodb.com/ibman.php\n"
"InnoDB: about operating system error numbers.\n"); "InnoDB: about operating system error numbers.\n");
} }
} }
@ -251,7 +251,7 @@ os_file_get_last_error(void)
fprintf(stderr, fprintf(stderr,
" InnoDB: Operating system error number %lu in a file operation.\n" " InnoDB: Operating system error number %lu in a file operation.\n"
"InnoDB: See http://www.innodb.com/ibman.html for installation help.\n", "InnoDB: See http://www.innodb.com/ibman.php for installation help.\n",
err); err);
if (err == ENOENT) { if (err == ENOENT) {
@ -270,7 +270,7 @@ os_file_get_last_error(void)
} }
fprintf(stderr, fprintf(stderr,
"InnoDB: See also section 13.2 at http://www.innodb.com/ibman.html\n" "InnoDB: See also section 13.2 at http://www.innodb.com/ibman.php\n"
"InnoDB: about operating system error numbers.\n"); "InnoDB: about operating system error numbers.\n");
} }
} }
@ -733,7 +733,7 @@ try_again:
ut_error; ut_error;
} }
/* printf("Opening file %s, mode %s, type %s, purpose %s\n", /* fprintf(stderr, "Opening file %s, mode %s, type %s, purpose %s\n",
name, mode_str, type_str, purpose_str); */ name, mode_str, type_str, purpose_str); */
#ifdef O_SYNC #ifdef O_SYNC
/* We let O_SYNC only affect log files; note that we map O_DSYNC to /* We let O_SYNC only affect log files; note that we map O_DSYNC to
@ -742,7 +742,7 @@ try_again:
if (type == OS_LOG_FILE if (type == OS_LOG_FILE
&& srv_unix_file_flush_method == SRV_UNIX_O_DSYNC) { && srv_unix_file_flush_method == SRV_UNIX_O_DSYNC) {
/* printf("Using O_SYNC for file %s\n", name); */ /* fprintf(stderr, "Using O_SYNC for file %s\n", name); */
create_flag = create_flag | O_SYNC; create_flag = create_flag | O_SYNC;
} }
@ -752,7 +752,7 @@ try_again:
if (type != OS_LOG_FILE if (type != OS_LOG_FILE
&& srv_unix_file_flush_method == SRV_UNIX_O_DIRECT) { && srv_unix_file_flush_method == SRV_UNIX_O_DIRECT) {
/* printf("Using O_DIRECT for file %s\n", name); */ /* fprintf(stderr, "Using O_DIRECT for file %s\n", name); */
create_flag = create_flag | O_DIRECT; create_flag = create_flag | O_DIRECT;
} }
@ -1025,7 +1025,7 @@ os_file_flush(
#ifdef HAVE_FDATASYNC #ifdef HAVE_FDATASYNC
ret = fdatasync(file); ret = fdatasync(file);
#else #else
/* printf("Flushing to file %lu\n", (ulint)file); */ /* fprintf(stderr, "Flushing to file %p\n", file); */
ret = fsync(file); ret = fsync(file);
#endif #endif
os_n_fsyncs++; os_n_fsyncs++;
@ -1382,7 +1382,7 @@ retry:
fprintf(stderr, fprintf(stderr,
" InnoDB: Error: File pointer positioning to file %s failed at\n" " InnoDB: Error: File pointer positioning to file %s failed at\n"
"InnoDB: offset %lu %lu. Operating system error number %lu.\n" "InnoDB: offset %lu %lu. Operating system error number %lu.\n"
"InnoDB: Look from section 13.2 at http://www.innodb.com/ibman.html\n" "InnoDB: Look from section 13.2 at http://www.innodb.com/ibman.php\n"
"InnoDB: what the error number means.\n", "InnoDB: what the error number means.\n",
name, offset_high, offset, name, offset_high, offset,
(ulint)GetLastError()); (ulint)GetLastError());
@ -1440,7 +1440,7 @@ retry:
} }
fprintf(stderr, fprintf(stderr,
"InnoDB: See also section 13.2 at http://www.innodb.com/ibman.html\n" "InnoDB: See also section 13.2 at http://www.innodb.com/ibman.php\n"
"InnoDB: about operating system error numbers.\n"); "InnoDB: about operating system error numbers.\n");
os_has_said_disk_full = TRUE; os_has_said_disk_full = TRUE;
@ -1475,7 +1475,7 @@ retry:
} }
fprintf(stderr, fprintf(stderr,
"InnoDB: See also section 13.2 at http://www.innodb.com/ibman.html\n" "InnoDB: See also section 13.2 at http://www.innodb.com/ibman.php\n"
"InnoDB: about operating system error numbers.\n"); "InnoDB: about operating system error numbers.\n");
os_has_said_disk_full = TRUE; os_has_said_disk_full = TRUE;
@ -1593,7 +1593,7 @@ os_aio_init(
n_write_segs = (n_segments - 2) / 2; n_write_segs = (n_segments - 2) / 2;
n_read_segs = n_segments - 2 - n_write_segs; n_read_segs = n_segments - 2 - n_write_segs;
/* printf("Array n per seg %lu\n", n_per_seg); */ /* fprintf(stderr, "Array n per seg %lu\n", n_per_seg); */
os_aio_ibuf_array = os_aio_array_create(n_per_seg, 1); os_aio_ibuf_array = os_aio_array_create(n_per_seg, 1);
@ -1944,7 +1944,8 @@ loop:
SIGRTMIN + 1 + os_aio_get_array_no(array); SIGRTMIN + 1 + os_aio_get_array_no(array);
/* TODO: How to choose the signal numbers? */ /* TODO: How to choose the signal numbers? */
/* /*
printf("AIO signal number %lu\n", (ulint) control->aio_sigevent.sigev_signo); fprintf(stderr, "AIO signal number %lu\n",
(ulint) control->aio_sigevent.sigev_signo);
*/ */
control->aio_sigevent.sigev_value.sival_ptr = slot; control->aio_sigevent.sigev_value.sival_ptr = slot;
#endif #endif
@ -2198,7 +2199,7 @@ try_again:
#elif defined(POSIX_ASYNC_IO) #elif defined(POSIX_ASYNC_IO)
slot->control.aio_lio_opcode = LIO_READ; slot->control.aio_lio_opcode = LIO_READ;
err = (ulint) aio_read(&(slot->control)); err = (ulint) aio_read(&(slot->control));
printf("Starting Posix aio read %lu\n", err); fprintf(stderr, "Starting POSIX aio read %lu\n", err);
#endif #endif
} else { } else {
if (!wake_later) { if (!wake_later) {
@ -2215,7 +2216,7 @@ try_again:
#elif defined(POSIX_ASYNC_IO) #elif defined(POSIX_ASYNC_IO)
slot->control.aio_lio_opcode = LIO_WRITE; slot->control.aio_lio_opcode = LIO_WRITE;
err = (ulint) aio_write(&(slot->control)); err = (ulint) aio_write(&(slot->control));
printf("Starting Posix aio write %lu\n", err); fprintf(stderr, "Starting POSIX aio write %lu\n", err);
#endif #endif
} else { } else {
if (!wake_later) { if (!wake_later) {
@ -2411,7 +2412,7 @@ os_aio_posix_handle(
pthread_sigmask(0, NULL, &thr_sigset); pthread_sigmask(0, NULL, &thr_sigset);
for (i = 32 ; i < 40; i++) { for (i = 32 ; i < 40; i++) {
printf("%lu : %lu %lu\n", (ulint)i, fprintf(stderr, "%lu : %lu %lu\n", (ulint)i,
(ulint)sigismember(&proc_sigset, i), (ulint)sigismember(&proc_sigset, i),
(ulint)sigismember(&thr_sigset, i)); (ulint)sigismember(&thr_sigset, i));
} }
@ -2426,7 +2427,7 @@ os_aio_posix_handle(
return(FALSE); return(FALSE);
} }
printf("Handling Posix aio\n"); fputs("Handling POSIX aio\n", stderr);
array = os_aio_get_array_from_no(array_no); array = os_aio_get_array_from_no(array_no);
@ -2719,9 +2720,9 @@ consecutive_loop:
ut_a(ret); ut_a(ret);
srv_set_io_thread_op_info(global_segment, "file i/o done"); srv_set_io_thread_op_info(global_segment, "file i/o done");
/* printf("aio: %lu consecutive %lu:th segment, first offs %lu blocks\n", /* fprintf(stderr,
n_consecutive, global_segment, slot->offset "aio: %lu consecutive %lu:th segment, first offs %lu blocks\n",
/ UNIV_PAGE_SIZE); */ n_consecutive, global_segment, slot->offset / UNIV_PAGE_SIZE); */
if (slot->type == OS_FILE_READ && n_consecutive > 1) { if (slot->type == OS_FILE_READ && n_consecutive > 1) {
/* Copy the combined buffer to individual buffers */ /* Copy the combined buffer to individual buffers */
@ -2847,8 +2848,7 @@ Prints info of the aio arrays. */
void void
os_aio_print( os_aio_print(
/*=========*/ /*=========*/
char* buf, /* in/out: buffer where to print */ FILE* file) /* in: file where to print */
char* buf_end)/* in: buffer end */
{ {
os_aio_array_t* array; os_aio_array_t* array;
os_aio_slot_t* slot; os_aio_slot_t* slot;
@ -2858,18 +2858,13 @@ os_aio_print(
double avg_bytes_read; double avg_bytes_read;
ulint i; ulint i;
if (buf_end - buf < 1200) {
return;
}
for (i = 0; i < srv_n_file_io_threads; i++) { for (i = 0; i < srv_n_file_io_threads; i++) {
buf += sprintf(buf, "I/O thread %lu state: %s (%s)\n", i, fprintf(file, "I/O thread %lu state: %s (%s)\n", i,
srv_io_thread_op_info[i], srv_io_thread_op_info[i],
srv_io_thread_function[i]); srv_io_thread_function[i]);
} }
buf += sprintf(buf, "Pending normal aio reads:"); fputs("Pending normal aio reads:", file);
array = os_aio_read_array; array = os_aio_read_array;
loop: loop:
@ -2887,21 +2882,20 @@ loop:
if (slot->reserved) { if (slot->reserved) {
n_reserved++; n_reserved++;
/* printf("Reserved slot, messages %lx %lx\n", /* fprintf(stderr, "Reserved slot, messages %p %p\n",
(ulint)slot->message1, slot->message1, slot->message2); */
(ulint)slot->message2); ut_a(slot->len > 0);
*/ ut_a(slot->len > 0);
} }
} }
ut_a(array->n_reserved == n_reserved); ut_a(array->n_reserved == n_reserved);
buf += sprintf(buf, " %lu", n_reserved); fprintf(file, " %lu", n_reserved);
os_mutex_exit(array->mutex); os_mutex_exit(array->mutex);
if (array == os_aio_read_array) { if (array == os_aio_read_array) {
buf += sprintf(buf, ", aio writes:"); fputs(", aio writes:", file);
array = os_aio_write_array; array = os_aio_write_array;
@ -2909,40 +2903,38 @@ loop:
} }
if (array == os_aio_write_array) { if (array == os_aio_write_array) {
buf += sprintf(buf, ",\n ibuf aio reads:"); fputs(",\n ibuf aio reads:", file);
array = os_aio_ibuf_array; array = os_aio_ibuf_array;
goto loop; goto loop;
} }
if (array == os_aio_ibuf_array) { if (array == os_aio_ibuf_array) {
buf += sprintf(buf, ", log i/o's:"); fputs(", log i/o's:", file);
array = os_aio_log_array; array = os_aio_log_array;
goto loop; goto loop;
} }
if (array == os_aio_log_array) { if (array == os_aio_log_array) {
buf += sprintf(buf, ", sync i/o's:"); fputs(", sync i/o's:", file);
array = os_aio_sync_array; array = os_aio_sync_array;
goto loop; goto loop;
} }
buf += sprintf(buf, "\n"); putc('\n', file);
current_time = time(NULL); current_time = time(NULL);
time_elapsed = 0.001 + difftime(current_time, os_last_printout); time_elapsed = 0.001 + difftime(current_time, os_last_printout);
buf += sprintf(buf, fprintf(file,
"Pending flushes (fsync) log: %lu; buffer pool: %lu\n", "Pending flushes (fsync) log: %lu; buffer pool: %lu\n"
fil_n_pending_log_flushes, fil_n_pending_tablespace_flushes);
buf += sprintf(buf,
"%lu OS file reads, %lu OS file writes, %lu OS fsyncs\n", "%lu OS file reads, %lu OS file writes, %lu OS fsyncs\n",
fil_n_pending_log_flushes, fil_n_pending_tablespace_flushes,
os_n_file_reads, os_n_file_writes, os_n_fsyncs); os_n_file_reads, os_n_file_writes, os_n_fsyncs);
if (os_file_n_pending_preads != 0 || os_file_n_pending_pwrites != 0) { if (os_file_n_pending_preads != 0 || os_file_n_pending_pwrites != 0) {
buf += sprintf(buf, fprintf(file,
"%lu pending preads, %lu pending pwrites\n", "%lu pending preads, %lu pending pwrites\n",
os_file_n_pending_preads, os_file_n_pending_pwrites); os_file_n_pending_preads, os_file_n_pending_pwrites);
} }
@ -2954,7 +2946,7 @@ loop:
(os_n_file_reads - os_n_file_reads_old); (os_n_file_reads - os_n_file_reads_old);
} }
buf += sprintf(buf, fprintf(file,
"%.2f reads/s, %lu avg bytes/read, %.2f writes/s, %.2f fsyncs/s\n", "%.2f reads/s, %lu avg bytes/read, %.2f writes/s, %.2f fsyncs/s\n",
(os_n_file_reads - os_n_file_reads_old) (os_n_file_reads - os_n_file_reads_old)
/ time_elapsed, / time_elapsed,

View File

@ -81,9 +81,8 @@ os_process_set_priority_boost(
/* Does not do anything currently! /* Does not do anything currently!
SetProcessPriorityBoost(GetCurrentProcess(), no_boost); SetProcessPriorityBoost(GetCurrentProcess(), no_boost);
*/ */
printf( fputs("Warning: process priority boost setting currently not functional!\n",
"Warning: process priority boost setting currently not functional!\n" stderr);
);
#else #else
UT_NOT_USED(do_boost); UT_NOT_USED(do_boost);
#endif #endif

View File

@ -187,7 +187,7 @@ os_thread_exit(
is cast as a DWORD */ is cast as a DWORD */
{ {
#ifdef UNIV_DEBUG_THREAD_CREATION #ifdef UNIV_DEBUG_THREAD_CREATION
printf("Thread exits, id %lu\n", fprintf(stderr, "Thread exits, id %lu\n",
os_thread_pf(os_thread_get_curr_id())); os_thread_pf(os_thread_get_curr_id()));
#endif #endif
os_mutex_enter(os_sync_mutex); os_mutex_enter(os_sync_mutex);

View File

@ -704,14 +704,16 @@ page_cur_parse_insert_rec(
/* Build the inserted record to buf */ /* Build the inserted record to buf */
if (mismatch_index >= UNIV_PAGE_SIZE) { if (mismatch_index >= UNIV_PAGE_SIZE) {
printf("Is short %lu, info_bits %lu, offset %lu, o_offset %lu\n" fprintf(stderr,
"Is short %lu, info_bits %lu, offset %lu, "
"o_offset %lu\n"
"mismatch index %lu, end_seg_len %lu\n" "mismatch index %lu, end_seg_len %lu\n"
"parsed len %lu\n", "parsed len %lu\n",
is_short, info_bits, offset, origin_offset, is_short, info_bits, offset, origin_offset,
mismatch_index, end_seg_len, (ulint)(ptr - ptr2)); mismatch_index, end_seg_len, (ulint)(ptr - ptr2));
printf("Dump of 300 bytes of log:\n"); fputs("Dump of 300 bytes of log:\n", stderr);
ut_print_buf(ptr2, 300); ut_print_buf(stderr, ptr2, 300);
buf_page_print(page); buf_page_print(page);

View File

@ -75,7 +75,6 @@ page_dir_find_owner_slot(
page_t* page; page_t* page;
page_dir_slot_t* slot; page_dir_slot_t* slot;
rec_t* original_rec = rec; rec_t* original_rec = rec;
char err_buf[1000];
ut_ad(page_rec_check(rec)); ut_ad(page_rec_check(rec));
@ -93,20 +92,21 @@ page_dir_find_owner_slot(
if (i == 0) { if (i == 0) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Probable data corruption on page %lu\n", "InnoDB: Probable data corruption on page %lu\n"
"InnoDB: Original record ",
buf_frame_get_page_no(page)); buf_frame_get_page_no(page));
rec_sprintf(err_buf, 900, original_rec); rec_print(stderr, original_rec);
fprintf(stderr, fprintf(stderr, "\n"
"InnoDB: Original record %s\n" "InnoDB: on that page. Steps %lu.\n", steps);
"InnoDB: on that page. Steps %lu.\n", err_buf, steps);
rec_sprintf(err_buf, 900, rec); fputs(
"InnoDB: Cannot find the dir slot for record ",
fprintf(stderr, stderr);
"InnoDB: Cannot find the dir slot for record %s\n" rec_print(stderr, rec);
"InnoDB: on that page!\n", err_buf); fputs("\n"
"InnoDB: on that page!\n", stderr);
buf_page_print(page); buf_page_print(page);
@ -1120,8 +1120,8 @@ page_rec_print(
/*===========*/ /*===========*/
rec_t* rec) rec_t* rec)
{ {
rec_print(rec); rec_print(stderr, rec);
printf( fprintf(stderr,
" n_owned: %lu; heap_no: %lu; next rec: %lu\n", " n_owned: %lu; heap_no: %lu; next rec: %lu\n",
rec_get_n_owned(rec), rec_get_n_owned(rec),
rec_get_heap_no(rec), rec_get_heap_no(rec),
@ -1147,25 +1147,26 @@ page_dir_print(
n = page_dir_get_n_slots(page); n = page_dir_get_n_slots(page);
printf("--------------------------------\n"); fprintf(stderr, "--------------------------------\n"
printf("PAGE DIRECTORY\n"); "PAGE DIRECTORY\n"
printf("Page address %lx\n", (ulint)page); "Page address %p\n"
printf("Directory stack top at offs: %lu; number of slots: %lu\n", "Directory stack top at offs: %lu; number of slots: %lu\n",
(ulint)(page_dir_get_nth_slot(page, n - 1) - page), n); page, (ulint)(page_dir_get_nth_slot(page, n - 1) - page), n);
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
slot = page_dir_get_nth_slot(page, i); slot = page_dir_get_nth_slot(page, i);
if ((i == pr_n) && (i < n - pr_n)) { if ((i == pr_n) && (i < n - pr_n)) {
printf(" ... \n"); fputs(" ... \n", stderr);
} }
if ((i < pr_n) || (i >= n - pr_n)) { if ((i < pr_n) || (i >= n - pr_n)) {
printf( fprintf(stderr,
"Contents of slot: %lu: n_owned: %lu, rec offs: %lu\n", "Contents of slot: %lu: n_owned: %lu, rec offs: %lu\n",
i, page_dir_slot_get_n_owned(slot), i, page_dir_slot_get_n_owned(slot),
(ulint)(page_dir_slot_get_rec(slot) - page)); (ulint)(page_dir_slot_get_rec(slot) - page));
} }
} }
printf("Total of %lu records\n", 2 + page_get_n_recs(page)); fprintf(stderr, "Total of %lu records\n"
printf("--------------------------------\n"); "--------------------------------\n",
2 + page_get_n_recs(page));
} }
/******************************************************************* /*******************************************************************
@ -1179,21 +1180,20 @@ page_print_list(
ulint pr_n) /* in: print n first and n last entries */ ulint pr_n) /* in: print n first and n last entries */
{ {
page_cur_t cur; page_cur_t cur;
rec_t* rec;
ulint count; ulint count;
ulint n_recs; ulint n_recs;
printf("--------------------------------\n"); fprintf(stderr,
printf("PAGE RECORD LIST\n"); "--------------------------------\n"
printf("Page address %lu\n", (ulint)page); "PAGE RECORD LIST\n"
"Page address %p\n", page);
n_recs = page_get_n_recs(page); n_recs = page_get_n_recs(page);
page_cur_set_before_first(page, &cur); page_cur_set_before_first(page, &cur);
count = 0; count = 0;
for (;;) { for (;;) {
rec = (&cur)->rec; page_rec_print(cur.rec);
page_rec_print(rec);
if (count == pr_n) { if (count == pr_n) {
break; break;
@ -1206,24 +1206,22 @@ page_print_list(
} }
if (n_recs > 2 * pr_n) { if (n_recs > 2 * pr_n) {
printf(" ... \n"); fputs(" ... \n", stderr);
} }
for (;;) { while (!page_cur_is_after_last(&cur)) {
if (page_cur_is_after_last(&cur)) {
break;
}
page_cur_move_to_next(&cur); page_cur_move_to_next(&cur);
if (count + pr_n >= n_recs) { if (count + pr_n >= n_recs) {
rec = (&cur)->rec; page_rec_print(cur.rec);
page_rec_print(rec);
} }
count++; count++;
} }
printf("Total of %lu records \n", count + 1); fprintf(stderr,
printf("--------------------------------\n"); "Total of %lu records \n"
"--------------------------------\n",
count + 1);
} }
/******************************************************************* /*******************************************************************
@ -1234,21 +1232,19 @@ page_header_print(
/*==============*/ /*==============*/
page_t* page) page_t* page)
{ {
printf("--------------------------------\n"); fprintf(stderr,
printf("PAGE HEADER INFO\n"); "--------------------------------\n"
printf("Page address %lx, n records %lu\n", (ulint)page, "PAGE HEADER INFO\n"
page_header_get_field(page, PAGE_N_RECS)); "Page address %p, n records %lu\n"
"n dir slots %lu, heap top %lu\n"
printf("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, page_header_get_field(page, PAGE_N_RECS),
page_header_get_field(page, PAGE_N_DIR_SLOTS), page_header_get_field(page, PAGE_N_DIR_SLOTS),
page_header_get_field(page, PAGE_HEAP_TOP)); page_header_get_field(page, PAGE_HEAP_TOP),
printf("Page n heap %lu, free %lu, garbage %lu\n",
page_header_get_field(page, PAGE_N_HEAP), page_header_get_field(page, PAGE_N_HEAP),
page_header_get_field(page, PAGE_FREE), page_header_get_field(page, PAGE_FREE),
page_header_get_field(page, PAGE_GARBAGE)); page_header_get_field(page, PAGE_GARBAGE),
printf("Page last insert %lu, direction %lu, n direction %lu\n",
page_header_get_field(page, PAGE_LAST_INSERT), page_header_get_field(page, PAGE_LAST_INSERT),
page_header_get_field(page, PAGE_DIRECTION), page_header_get_field(page, PAGE_DIRECTION),
page_header_get_field(page, PAGE_N_DIRECTION)); page_header_get_field(page, PAGE_N_DIRECTION));
@ -1555,17 +1551,9 @@ page_validate(
ulint n_slots; ulint n_slots;
ibool ret = FALSE; ibool ret = FALSE;
ulint i; ulint i;
char err_buf[1000];
if (!page_simple_validate(page)) { if (!page_simple_validate(page)) {
fprintf(stderr, goto func_exit2;
"InnoDB: Apparent corruption in page %lu in index %s in table %s\n",
buf_frame_get_page_no(page), index->name,
index->table_name);
buf_page_print(page);
return(FALSE);
} }
heap = mem_heap_create(UNIV_PAGE_SIZE); heap = mem_heap_create(UNIV_PAGE_SIZE);
@ -1585,10 +1573,13 @@ page_validate(
if (!(page_header_get_ptr(page, PAGE_HEAP_TOP) <= if (!(page_header_get_ptr(page, PAGE_HEAP_TOP) <=
page_dir_get_nth_slot(page, n_slots - 1))) { 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", fputs("InnoDB: Record heap and dir overlap on a page ",
index->name, (ulint)page_header_get_ptr(page, PAGE_HEAP_TOP), stderr);
(ulint)page_dir_get_nth_slot(page, n_slots - 1)); 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; goto func_exit;
} }
@ -1614,18 +1605,14 @@ page_validate(
if ((count >= 2) && (!page_cur_is_after_last(&cur))) { if ((count >= 2) && (!page_cur_is_after_last(&cur))) {
if (!(1 == cmp_rec_rec(rec, old_rec, index))) { if (!(1 == cmp_rec_rec(rec, old_rec, index))) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Records in wrong order on page %lu index %s table %s\n", "InnoDB: Records in wrong order on page %lu",
buf_frame_get_page_no(page), buf_frame_get_page_no(page));
index->name, dict_index_name_print(stderr, index);
index->table_name); fputs("\nInnoDB: previous record ", stderr);
rec_print(stderr, old_rec);
rec_sprintf(err_buf, 900, old_rec); fputs("\nInnoDB: record ", stderr);
fprintf(stderr, rec_print(stderr, rec);
"InnoDB: previous record %s\n", err_buf); putc('\n', stderr);
rec_sprintf(err_buf, 900, rec);
fprintf(stderr,
"InnoDB: record %s\n", err_buf);
goto func_exit; goto func_exit;
} }
@ -1643,10 +1630,8 @@ page_validate(
if (!buf[offs + i] == 0) { if (!buf[offs + i] == 0) {
/* No other record may overlap this */ /* No other record may overlap this */
fprintf(stderr, fputs("InnoDB: Record overlaps another\n",
"InnoDB: Record overlaps another in index %s \n", stderr);
index->name);
goto func_exit; goto func_exit;
} }
@ -1657,18 +1642,15 @@ page_validate(
/* This is a record pointed to by a dir slot */ /* This is a record pointed to by a dir slot */
if (rec_get_n_owned(rec) != own_count) { if (rec_get_n_owned(rec) != own_count) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Wrong owned count %lu, %lu, in index %s\n", "InnoDB: Wrong owned count %lu, %lu\n",
rec_get_n_owned(rec), own_count, rec_get_n_owned(rec), own_count);
index->name);
goto func_exit; goto func_exit;
} }
if (page_dir_slot_get_rec(slot) != rec) { if (page_dir_slot_get_rec(slot) != rec) {
fprintf(stderr, fputs(
"InnoDB: Dir slot does not point to right rec in %s\n", "InnoDB: Dir slot does not point to right rec\n",
index->name); stderr);
goto func_exit; goto func_exit;
} }
@ -1688,9 +1670,8 @@ page_validate(
if (rec_get_next_offs(rec) < FIL_PAGE_DATA if (rec_get_next_offs(rec) < FIL_PAGE_DATA
|| rec_get_next_offs(rec) >= UNIV_PAGE_SIZE) { || rec_get_next_offs(rec) >= UNIV_PAGE_SIZE) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Next record offset wrong %lu in index %s\n", "InnoDB: Next record offset wrong %lu\n",
rec_get_next_offs(rec), index->name); rec_get_next_offs(rec));
goto func_exit; goto func_exit;
} }
@ -1701,23 +1682,19 @@ page_validate(
} }
if (rec_get_n_owned(rec) == 0) { if (rec_get_n_owned(rec) == 0) {
fprintf(stderr, fputs("InnoDB: n owned is zero\n", stderr);
"InnoDB: n owned is zero in index %s\n", index->name);
goto func_exit; goto func_exit;
} }
if (slot_no != n_slots - 1) { if (slot_no != n_slots - 1) {
fprintf(stderr, "InnoDB: n slots wrong %lu %lu in index %s\n", fprintf(stderr, "InnoDB: n slots wrong %lu %lu\n",
slot_no, n_slots - 1, index->name); slot_no, n_slots - 1);
goto func_exit; goto func_exit;
} }
if (page_header_get_field(page, PAGE_N_RECS) + 2 != count + 1) { 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",
page_header_get_field(page, PAGE_N_RECS) + 2, count + 1, page_header_get_field(page, PAGE_N_RECS) + 2, count + 1);
index->name);
goto func_exit; goto func_exit;
} }
@ -1743,10 +1720,8 @@ page_validate(
for (i = 0; i < rec_get_size(rec); i++) { for (i = 0; i < rec_get_size(rec); i++) {
if (buf[offs + i] != 0) { if (buf[offs + i] != 0) {
fprintf(stderr, fputs(
"InnoDB: Record overlaps another in free list, index %s \n", "InnoDB: Record overlaps another in free list\n", stderr);
index->name);
goto func_exit; goto func_exit;
} }
@ -1757,11 +1732,8 @@ page_validate(
} }
if (page_header_get_field(page, PAGE_N_HEAP) != count + 1) { if (page_header_get_field(page, PAGE_N_HEAP) != count + 1) {
fprintf(stderr, "InnoDB: N heap is wrong %lu %lu\n",
fprintf(stderr, page_header_get_field(page, PAGE_N_HEAP), count + 1);
"InnoDB: N heap is wrong %lu %lu in index %s\n",
page_header_get_field(page, PAGE_N_HEAP), count + 1,
index->name);
goto func_exit; goto func_exit;
} }
@ -1771,11 +1743,11 @@ func_exit:
mem_heap_free(heap); mem_heap_free(heap);
if (ret == FALSE) { if (ret == FALSE) {
fprintf(stderr, func_exit2:
"InnoDB: Apparent corruption in page %lu in index %s in table %s\n", fprintf(stderr, "InnoDB: Apparent corruption in page %lu in ",
buf_frame_get_page_no(page), index->name, buf_frame_get_page_no(page));
index->table_name); dict_index_name_print(stderr, index);
putc('\n', stderr);
buf_page_print(page); buf_page_print(page);
} }

View File

@ -1202,26 +1202,22 @@ opt_print_query_plan(
ulint n_fields; ulint n_fields;
ulint i; ulint i;
printf("QUERY PLAN FOR A SELECT NODE\n"); fputs("QUERY PLAN FOR A SELECT NODE\n", stderr);
if (sel_node->asc) { fputs(sel_node->asc ? "Asc. search; " : "Desc. search; ", stderr);
printf("Asc. search; ");
} else {
printf("Desc. search; ");
}
if (sel_node->set_x_locks) { if (sel_node->set_x_locks) {
printf("sets row x-locks; "); fputs("sets row x-locks; ", stderr);
ut_a(sel_node->row_lock_mode == LOCK_X); ut_a(sel_node->row_lock_mode == LOCK_X);
ut_a(!sel_node->consistent_read); ut_a(!sel_node->consistent_read);
} else if (sel_node->consistent_read) { } else if (sel_node->consistent_read) {
printf("consistent read; "); fputs("consistent read; ", stderr);
} else { } else {
ut_a(sel_node->row_lock_mode == LOCK_S); ut_a(sel_node->row_lock_mode == LOCK_S);
printf("sets row s-locks; "); fputs("sets row s-locks; ", stderr);
} }
printf("\n"); putc('\n', stderr);
for (i = 0; i < sel_node->n_tables; i++) { for (i = 0; i < sel_node->n_tables; i++) {
plan = sel_node_get_nth_plan(sel_node, i); plan = sel_node_get_nth_plan(sel_node, i);
@ -1232,9 +1228,9 @@ opt_print_query_plan(
n_fields = 0; n_fields = 0;
} }
printf( fputs("Table ", stderr);
"Table %s index %s; exact m. %lu, match %lu, end conds %lu\n", dict_index_name_print(stderr, plan->index);
plan->table->name, plan->index->name, fprintf(stderr,"; exact m. %lu, match %lu, end conds %lu\n",
plan->n_exact_match, n_fields, plan->n_exact_match, n_fields,
UT_LIST_GET_LEN(plan->end_conds)); UT_LIST_GET_LEN(plan->end_conds));
} }

View File

@ -112,7 +112,7 @@ rec_get_nth_field(
} }
if (rec == NULL) { if (rec == NULL) {
fprintf(stderr, "Error: rec is NULL pointer\n"); fputs("Error: rec is NULL pointer\n", stderr);
ut_error; ut_error;
} }
@ -517,109 +517,47 @@ Prints a physical record. */
void void
rec_print( rec_print(
/*======*/ /*======*/
FILE* file, /* in: file where to print */
rec_t* rec) /* in: physical record */ rec_t* rec) /* in: physical record */
{ {
byte* data; byte* data;
ulint len; ulint len;
char* offs;
ulint n; ulint n;
ulint i; ulint i;
ut_ad(rec); ut_ad(rec);
if (rec_get_1byte_offs_flag(rec)) {
offs = (char *) "TRUE";
} else {
offs = (char *) "FALSE";
}
n = rec_get_n_fields(rec); n = rec_get_n_fields(rec);
printf( fprintf(file, "PHYSICAL RECORD: n_fields %lu;"
"PHYSICAL RECORD: n_fields %lu; 1-byte offs %s; info bits %lu\n", " 1-byte offs %s; info bits %lu\n",
n, offs, rec_get_info_bits(rec)); n, rec_get_1byte_offs_flag(rec) ? "TRUE" : "FALSE",
rec_get_info_bits(rec));
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
data = rec_get_nth_field(rec, i, &len); data = rec_get_nth_field(rec, i, &len);
printf(" %lu:", i); fprintf(file, " %lu:", i);
if (len != UNIV_SQL_NULL) { if (len != UNIV_SQL_NULL) {
if (len <= 30) { if (len <= 30) {
ut_print_buf(data, len); ut_print_buf(file, data, len);
} else { } else {
ut_print_buf(data, 30); ut_print_buf(file, data, 30);
printf("...(truncated)"); fputs("...(truncated)", file);
} }
} else { } else {
printf(" SQL NULL, size %lu ", fprintf(file, " SQL NULL, size %lu ",
rec_get_nth_field_size(rec, i)); rec_get_nth_field_size(rec, i));
} }
printf(";"); putc(';', file);
} }
printf("\n"); putc('\n', file);
rec_validate(rec); rec_validate(rec);
} }
/*******************************************************************
Prints a physical record to a buffer. */
ulint
rec_sprintf(
/*========*/
/* out: printed length in bytes */
char* buf, /* in: buffer to print to */
ulint buf_len,/* in: buffer length */
rec_t* rec) /* in: physical record */
{
byte* data;
ulint len;
ulint k;
ulint n;
ulint i;
ut_ad(rec);
n = rec_get_n_fields(rec);
k = 0;
if (k + 30 > buf_len) {
return(k);
}
k += sprintf(buf + k, "RECORD: info bits %lu", rec_get_info_bits(rec));
for (i = 0; i < n; i++) {
if (k + 30 > buf_len) {
return(k);
}
data = rec_get_nth_field(rec, i, &len);
k += sprintf(buf + k, " %lu:", i);
if (len != UNIV_SQL_NULL) {
if (k + 30 + 5 * len > buf_len) {
return(k);
}
k += ut_sprintf_buf(buf + k, data, len);
} else {
k += sprintf(buf + k, " SQL NULL");
}
k += sprintf(buf + k, ";");
}
return(k);
}

View File

@ -528,34 +528,37 @@ row_ins_foreign_report_err(
dtuple_t* entry) /* in: index entry in the parent dtuple_t* entry) /* in: index entry in the parent
table */ table */
{ {
char* buf = dict_foreign_err_buf; FILE* ef = dict_foreign_err_file;
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
ut_sprintf_timestamp(buf); rewind(ef);
sprintf(buf + strlen(buf), " Transaction:\n"); ut_print_timestamp(ef);
trx_print(buf + strlen(buf), thr_get_trx(thr)); fputs(" Transaction:\n", ef);
trx_print(ef, thr_get_trx(thr));
sprintf(buf + strlen(buf), fputs("Foreign key constraint fails for table ", ef);
"Foreign key constraint fails for table %.500s:\n", ut_print_name(ef, foreign->foreign_table_name);
foreign->foreign_table_name); fputs(":\n", ef);
dict_print_info_on_foreign_key_in_create_format( dict_print_info_on_foreign_key_in_create_format(ef, foreign);
foreign, buf + strlen(buf)); putc('\n', ef);
sprintf(buf + strlen(buf), "\n%s", errstr); fputs(errstr, ef);
sprintf(buf + strlen(buf), fputs(" in parent table, in index ", ef);
" in parent table, in index %.500s tuple:\n", ut_print_name(ef, foreign->referenced_index->name);
foreign->referenced_index->name);
if (entry) { if (entry) {
dtuple_sprintf(buf + strlen(buf), 1000, entry); fputs(" tuple:\n", ef);
dtuple_print(ef, entry);
} }
sprintf(buf + strlen(buf), fputs("\nBut in child table ", ef);
"\nBut in child table %.500s, in index %.500s, there is a record:\n", ut_print_name(ef, foreign->foreign_table_name);
foreign->foreign_table_name, foreign->foreign_index->name); fputs(", in index ", ef);
ut_print_name(ef, foreign->foreign_index->name);
if (rec) { if (rec) {
rec_sprintf(buf + strlen(buf), 1000, rec); fputs(", there is a record:\n", ef);
rec_print(ef, rec);
} else {
fputs(", the record is not available\n", ef);
} }
sprintf(buf + strlen(buf), "\n"); putc('\n', ef);
ut_a(strlen(buf) < DICT_FOREIGN_ERR_BUF_LEN);
mutex_exit(&dict_foreign_err_mutex); mutex_exit(&dict_foreign_err_mutex);
} }
@ -576,28 +579,28 @@ row_ins_foreign_report_add_err(
dtuple_t* entry) /* in: index entry to insert in the dtuple_t* entry) /* in: index entry to insert in the
child table */ child table */
{ {
char* buf = dict_foreign_err_buf; FILE* ef = dict_foreign_err_file;
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
ut_sprintf_timestamp(buf); rewind(ef);
sprintf(buf + strlen(buf), " Transaction:\n"); ut_print_timestamp(ef);
trx_print(buf + strlen(buf), trx); fputs(" Transaction:\n", ef);
sprintf(buf + strlen(buf), trx_print(ef, trx);
"Foreign key constraint fails for table %.500s:\n", fputs("Foreign key constraint fails for table ", ef);
foreign->foreign_table_name); ut_print_name(ef, foreign->foreign_table_name);
dict_print_info_on_foreign_key_in_create_format( fputs(":\n", ef);
foreign, buf + strlen(buf)); dict_print_info_on_foreign_key_in_create_format(ef, foreign);
sprintf(buf + strlen(buf), fputs("\nTrying to add in child table, in index ", ef);
"\nTrying to add in child table, in index %.500s tuple:\n", ut_print_name(ef, foreign->foreign_index->name);
foreign->foreign_index->name);
if (entry) { if (entry) {
dtuple_sprintf(buf + strlen(buf), 1000, entry); fputs(" tuple:\n", ef);
dtuple_print(ef, entry);
} }
sprintf(buf + strlen(buf), fputs("\nBut in parent table ", ef);
"\nBut in parent table %.500s, in index %.500s,\n" ut_print_name(ef, foreign->referenced_table_name);
"the closest match we can find is record:\n", fputs(", in index ", ef);
foreign->referenced_table_name, ut_print_name(ef, foreign->referenced_index->name);
foreign->referenced_index->name); fputs(",\nthe closest match we can find is record:\n", ef);
if (rec && page_rec_is_supremum(rec)) { if (rec && page_rec_is_supremum(rec)) {
/* If the cursor ended on a supremum record, it is better /* If the cursor ended on a supremum record, it is better
to report the previous record in the error message, so that to report the previous record in the error message, so that
@ -606,11 +609,9 @@ row_ins_foreign_report_add_err(
} }
if (rec) { if (rec) {
rec_sprintf(buf + strlen(buf), 1000, rec); rec_print(ef, rec);
} }
sprintf(buf + strlen(buf), "\n"); putc('\n', ef);
ut_a(strlen(buf) < DICT_FOREIGN_ERR_BUF_LEN);
mutex_exit(&dict_foreign_err_mutex); mutex_exit(&dict_foreign_err_mutex);
} }
@ -652,7 +653,6 @@ row_ins_foreign_check_on_constraint(
ulint i; ulint i;
char* ptr; char* ptr;
char table_name_buf[1000]; char table_name_buf[1000];
char err_buf[1000];
ut_a(thr && foreign && pcur && mtr); ut_a(thr && foreign && pcur && mtr);
@ -791,20 +791,20 @@ row_ins_foreign_check_on_constraint(
|| btr_pcur_get_low_match(cascade->pcur) || btr_pcur_get_low_match(cascade->pcur)
< dict_index_get_n_unique(clust_index)) { < dict_index_get_n_unique(clust_index)) {
fprintf(stderr, fputs(
"InnoDB: error in cascade of a foreign key op\n" "InnoDB: error in cascade of a foreign key op\n"
"InnoDB: index %s table %s\n", index->name, "InnoDB: ", stderr);
index->table->name); dict_index_name_print(stderr, index);
rec_sprintf(err_buf, 900, rec); fputs("\n"
fprintf(stderr, "InnoDB: record %s\n", err_buf); "InnoDB: record ", stderr);
rec_print(stderr, rec);
rec_sprintf(err_buf, 900, clust_rec); fputs("\n"
fprintf(stderr, "InnoDB: clustered record %s\n", "InnoDB: clustered record ", stderr);
err_buf); rec_print(stderr, clust_rec);
fprintf(stderr, fputs("\n"
"InnoDB: Make a detailed bug report and send it\n"); "InnoDB: Make a detailed bug report and send it\n"
fprintf(stderr, "InnoDB: to mysql@lists.mysql.com\n"); "InnoDB: to mysql@lists.mysql.com\n", stderr);
err = DB_SUCCESS; err = DB_SUCCESS;
@ -834,24 +834,6 @@ row_ins_foreign_check_on_constraint(
/* This can happen if there is a circular reference of /* This can happen if there is a circular reference of
rows such that cascading delete comes to delete a row rows such that cascading delete comes to delete a row
already in the process of being delete marked */ already in the process of being delete marked */
/*
fprintf(stderr,
"InnoDB: error 2 in cascade of a foreign key op\n"
"InnoDB: index %s table %s\n", index->name,
index->table->name);
rec_sprintf(err_buf, 900, rec);
fprintf(stderr, "InnoDB: record %s\n", err_buf);
rec_sprintf(err_buf, 900, clust_rec);
fprintf(stderr, "InnoDB: clustered record %s\n", err_buf);
fprintf(stderr,
"InnoDB: Make a detailed bug report and send it\n");
fprintf(stderr, "InnoDB: to mysql@lists.mysql.com\n");
ut_error;
*/
err = DB_SUCCESS; err = DB_SUCCESS;
goto nonstandard_exit_func; goto nonstandard_exit_func;
@ -1022,7 +1004,6 @@ row_ins_check_foreign_constraint(
int cmp; int cmp;
ulint err; ulint err;
ulint i; ulint i;
char* buf = dict_foreign_err_buf;
mtr_t mtr; mtr_t mtr;
run_again: run_again:
@ -1085,23 +1066,24 @@ run_again:
if (check_table == NULL) { if (check_table == NULL) {
if (check_ref) { if (check_ref) {
FILE* ef = dict_foreign_err_file;
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
ut_sprintf_timestamp(buf); rewind(ef);
sprintf(buf + strlen(buf), " Transaction:\n"); ut_print_timestamp(ef);
trx_print(buf + strlen(buf), thr_get_trx(thr)); fputs(" Transaction:\n", ef);
sprintf(buf + strlen(buf), trx_print(ef, thr_get_trx(thr));
"Foreign key constraint fails for table %.500s:\n", fputs("Foreign key constraint fails for table ", ef);
foreign->foreign_table_name); ut_print_name(ef, foreign->foreign_table_name);
dict_print_info_on_foreign_key_in_create_format( fputs(":\n", ef);
foreign, buf + strlen(buf)); dict_print_info_on_foreign_key_in_create_format(ef,
sprintf(buf + strlen(buf), foreign);
"\nTrying to add to index %.500s tuple:\n", foreign->foreign_index->name); fputs("\nTrying to add to index ", ef);
dtuple_sprintf(buf + strlen(buf), 1000, entry); ut_print_name(ef, foreign->foreign_index->name);
sprintf(buf + strlen(buf), fputs(" tuple:\n", ef);
"\nBut the parent table %.500s does not currently exist!\n", dtuple_print(ef, entry);
foreign->referenced_table_name); fputs("\nBut the parent table ", ef);
ut_print_name(ef, foreign->referenced_table_name);
ut_a(strlen(buf) < DICT_FOREIGN_ERR_BUF_LEN); fputs(" does not currently exist!\n", ef);
mutex_exit(&dict_foreign_err_mutex); mutex_exit(&dict_foreign_err_mutex);
return(DB_NO_REFERENCED_ROW); return(DB_NO_REFERENCED_ROW);

View File

@ -296,22 +296,22 @@ handle_new_error:
} else if (err == DB_MUST_GET_MORE_FILE_SPACE) { } else if (err == DB_MUST_GET_MORE_FILE_SPACE) {
fprintf(stderr, fputs(
"InnoDB: The database cannot continue operation because of\n" "InnoDB: The database cannot continue operation because of\n"
"InnoDB: lack of space. You must add a new data file to\n" "InnoDB: lack of space. You must add a new data file to\n"
"InnoDB: my.cnf and restart the database.\n"); "InnoDB: my.cnf and restart the database.\n", stderr);
exit(1); exit(1);
} else if (err == DB_CORRUPTION) { } else if (err == DB_CORRUPTION) {
fprintf(stderr, fputs(
"InnoDB: We detected index corruption in an InnoDB type table.\n" "InnoDB: We detected index corruption in an InnoDB type table.\n"
"InnoDB: You have to dump + drop + reimport the table or, in\n" "InnoDB: You have to dump + drop + reimport the table or, in\n"
"InnoDB: a case of widespread corruption, dump all InnoDB\n" "InnoDB: a case of widespread corruption, dump all InnoDB\n"
"InnoDB: tables and recreate the whole InnoDB tablespace.\n" "InnoDB: tables and recreate the whole InnoDB tablespace.\n"
"InnoDB: If the mysqld server crashes after the startup or when\n" "InnoDB: If the mysqld server crashes after the startup or when\n"
"InnoDB: you dump the tables, look at section 6.1 of\n" "InnoDB: you dump the tables, look at section 6.1 of\n"
"InnoDB: http://www.innodb.com/ibman.html for help.\n"); "InnoDB: http://www.innodb.com/ibman.php for help.\n", stderr);
} else { } else {
fprintf(stderr, "InnoDB: unknown error code %lu\n", err); fprintf(stderr, "InnoDB: unknown error code %lu\n", err);
@ -423,8 +423,10 @@ row_prebuilt_free(
|| prebuilt->magic_n2 != ROW_PREBUILT_ALLOCATED) { || prebuilt->magic_n2 != ROW_PREBUILT_ALLOCATED) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: trying to free a corrupt\n" "InnoDB: Error: trying to free a corrupt\n"
"InnoDB: table handle. Magic n %lu, magic n2 %lu, table name %s\n", "InnoDB: table handle. Magic n %lu, magic n2 %lu, table name ",
prebuilt->magic_n, prebuilt->magic_n2, prebuilt->table->name); prebuilt->magic_n, prebuilt->magic_n2);
ut_print_name(stderr, prebuilt->table->name);
putc('\n', stderr);
mem_analyze_corruption((byte*)prebuilt); mem_analyze_corruption((byte*)prebuilt);
@ -469,9 +471,9 @@ row_prebuilt_free(
|| (ROW_PREBUILT_FETCH_MAGIC_N != || (ROW_PREBUILT_FETCH_MAGIC_N !=
mach_read_from_4((prebuilt->fetch_cache[i]) mach_read_from_4((prebuilt->fetch_cache[i])
+ prebuilt->mysql_row_len))) { + prebuilt->mysql_row_len))) {
fprintf(stderr, fputs(
"InnoDB: Error: trying to free a corrupt\n" "InnoDB: Error: trying to free a corrupt\n"
"InnoDB: fetch buffer.\n"); "InnoDB: fetch buffer.\n", stderr);
mem_analyze_corruption( mem_analyze_corruption(
prebuilt->fetch_cache[i]); prebuilt->fetch_cache[i]);
@ -514,8 +516,10 @@ row_update_prebuilt_trx(
if (prebuilt->magic_n != ROW_PREBUILT_ALLOCATED) { if (prebuilt->magic_n != ROW_PREBUILT_ALLOCATED) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: trying to use a corrupt\n" "InnoDB: Error: trying to use a corrupt\n"
"InnoDB: table handle. Magic n %lu, table name %s\n", "InnoDB: table handle. Magic n %lu, table name ",
prebuilt->magic_n, prebuilt->table->name); prebuilt->magic_n);
ut_print_name(stderr, prebuilt->table->name);
putc('\n', stderr);
mem_analyze_corruption((byte*)prebuilt); mem_analyze_corruption((byte*)prebuilt);
@ -741,8 +745,10 @@ row_insert_for_mysql(
if (prebuilt->magic_n != ROW_PREBUILT_ALLOCATED) { if (prebuilt->magic_n != ROW_PREBUILT_ALLOCATED) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: trying to free a corrupt\n" "InnoDB: Error: trying to free a corrupt\n"
"InnoDB: table handle. Magic n %lu, table name %s\n", "InnoDB: table handle. Magic n %lu, table name ",
prebuilt->magic_n, prebuilt->table->name); prebuilt->magic_n);
ut_print_name(stderr, prebuilt->table->name);
putc('\n', stderr);
mem_analyze_corruption((byte*)prebuilt); mem_analyze_corruption((byte*)prebuilt);
@ -750,12 +756,13 @@ row_insert_for_mysql(
} }
if (srv_created_new_raw || srv_force_recovery) { if (srv_created_new_raw || srv_force_recovery) {
fprintf(stderr, fputs(
"InnoDB: A new raw disk partition was initialized or\n" "InnoDB: A new raw disk partition was initialized or\n"
"InnoDB: innodb_force_recovery is on: we do not allow\n" "InnoDB: innodb_force_recovery is on: we do not allow\n"
"InnoDB: database modifications by the user. Shut down\n" "InnoDB: database modifications by the user. Shut down\n"
"InnoDB: mysqld and edit my.cnf so that newraw is replaced\n" "InnoDB: mysqld and edit my.cnf so that newraw is replaced\n"
"InnoDB: with raw, and innodb_force_... is removed.\n"); "InnoDB: with raw, and innodb_force_... is removed.\n",
stderr);
return(DB_ERROR); return(DB_ERROR);
} }
@ -953,8 +960,10 @@ row_update_for_mysql(
if (prebuilt->magic_n != ROW_PREBUILT_ALLOCATED) { if (prebuilt->magic_n != ROW_PREBUILT_ALLOCATED) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: trying to free a corrupt\n" "InnoDB: Error: trying to free a corrupt\n"
"InnoDB: table handle. Magic n %lu, table name %s\n", "InnoDB: table handle. Magic n %lu, table name ",
prebuilt->magic_n, prebuilt->table->name); prebuilt->magic_n);
ut_print_name(stderr, prebuilt->table->name);
putc('\n', stderr);
mem_analyze_corruption((byte*)prebuilt); mem_analyze_corruption((byte*)prebuilt);
@ -962,12 +971,13 @@ row_update_for_mysql(
} }
if (srv_created_new_raw || srv_force_recovery) { if (srv_created_new_raw || srv_force_recovery) {
fprintf(stderr, fputs(
"InnoDB: A new raw disk partition was initialized or\n" "InnoDB: A new raw disk partition was initialized or\n"
"InnoDB: innodb_force_recovery is on: we do not allow\n" "InnoDB: innodb_force_recovery is on: we do not allow\n"
"InnoDB: database modifications by the user. Shut down\n" "InnoDB: database modifications by the user. Shut down\n"
"InnoDB: mysqld and edit my.cnf so that newraw is replaced\n" "InnoDB: mysqld and edit my.cnf so that newraw is replaced\n"
"InnoDB: with raw, and innodb_force_... is removed.\n"); "InnoDB: with raw, and innodb_force_... is removed.\n",
stderr);
return(DB_ERROR); return(DB_ERROR);
} }
@ -1310,12 +1320,13 @@ row_create_table_for_mysql(
ut_ad(trx->dict_operation_lock_mode == RW_X_LATCH); ut_ad(trx->dict_operation_lock_mode == RW_X_LATCH);
if (srv_created_new_raw) { if (srv_created_new_raw) {
fprintf(stderr, fputs(
"InnoDB: A new raw disk partition was initialized or\n" "InnoDB: A new raw disk partition was initialized or\n"
"InnoDB: innodb_force_recovery is on: we do not allow\n" "InnoDB: innodb_force_recovery is on: we do not allow\n"
"InnoDB: database modifications by the user. Shut down\n" "InnoDB: database modifications by the user. Shut down\n"
"InnoDB: mysqld and edit my.cnf so that newraw is replaced\n" "InnoDB: mysqld and edit my.cnf so that newraw is replaced\n"
"InnoDB: with raw, and innodb_force_... is removed.\n"); "InnoDB: with raw, and innodb_force_... is removed.\n",
stderr);
trx_commit_for_mysql(trx); trx_commit_for_mysql(trx);
@ -1390,16 +1401,17 @@ row_create_table_for_mysql(
/* We define here a debugging feature intended for /* We define here a debugging feature intended for
developers */ developers */
printf("Validating InnoDB memory:\n" fputs("Validating InnoDB memory:\n"
"to use this feature you must compile InnoDB with\n" "to use this feature you must compile InnoDB with\n"
"UNIV_MEM_DEBUG defined in univ.i and the server must be\n" "UNIV_MEM_DEBUG defined in univ.i and the server must be\n"
"quiet because allocation from a mem heap is not protected\n" "quiet because allocation from a mem heap is not protected\n"
"by any semaphore.\n"); "by any semaphore.\n", stderr);
#ifdef UNIV_MEM_DEBUG #ifdef UNIV_MEM_DEBUG
ut_a(mem_validate()); ut_a(mem_validate());
printf("Memory validated\n"); fputs("Memory validated\n", stderr);
#else /* UNIV_MEM_DEBUG */ #else /* UNIV_MEM_DEBUG */
puts("Memory NOT validated (recompile with UNIV_MEM_DEBUG)"); fputs("Memory NOT validated (recompile with UNIV_MEM_DEBUG)\n",
stderr);
#endif /* UNIV_MEM_DEBUG */ #endif /* UNIV_MEM_DEBUG */
} }
@ -1424,30 +1436,29 @@ row_create_table_for_mysql(
trx_general_rollback_for_mysql(trx, FALSE, NULL); trx_general_rollback_for_mysql(trx, FALSE, NULL);
if (err == DB_OUT_OF_FILE_SPACE) { if (err == DB_OUT_OF_FILE_SPACE) {
fprintf(stderr, fputs("InnoDB: Warning: cannot create table ", stderr);
"InnoDB: Warning: cannot create table %s because tablespace full\n", ut_print_name(stderr, table->name);
table->name); fputs(" because tablespace full\n", stderr);
row_drop_table_for_mysql(table->name, trx, FALSE); row_drop_table_for_mysql(table->name, trx, FALSE);
} else { } else {
ut_a(err == DB_DUPLICATE_KEY); ut_a(err == DB_DUPLICATE_KEY);
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fputs(" InnoDB: Error: table ", stderr);
" InnoDB: Error: table %s already exists in InnoDB internal\n" ut_print_name(stderr, table->name);
fputs(" already exists in InnoDB internal\n"
"InnoDB: data dictionary. Have you deleted the .frm file\n" "InnoDB: data dictionary. Have you deleted the .frm file\n"
"InnoDB: and not used DROP TABLE? Have you used DROP DATABASE\n" "InnoDB: and not used DROP TABLE? Have you used DROP DATABASE\n"
"InnoDB: for InnoDB tables in MySQL version <= 3.23.43?\n" "InnoDB: for InnoDB tables in MySQL version <= 3.23.43?\n"
"InnoDB: See the Restrictions section of the InnoDB manual.\n", "InnoDB: See the Restrictions section of the InnoDB manual.\n"
table->name);
fprintf(stderr,
"InnoDB: You can drop the orphaned table inside InnoDB by\n" "InnoDB: You can drop the orphaned table inside InnoDB by\n"
"InnoDB: creating an InnoDB table with the same name in another\n" "InnoDB: creating an InnoDB table with the same name in another\n"
"InnoDB: database and moving the .frm file to the current database.\n" "InnoDB: database and moving the .frm file to the current database.\n"
"InnoDB: Then MySQL thinks the table exists, and DROP TABLE will\n" "InnoDB: Then MySQL thinks the table exists, and DROP TABLE will\n"
"InnoDB: succeed.\n" "InnoDB: succeed.\n"
"InnoDB: You can look further help from section 15.1 of\n" "InnoDB: You can look for further help from section 15.1 of\n"
"InnoDB: http://www.innodb.com/ibman.html\n"); "InnoDB: http://www.innodb.com/ibman.php\n", stderr);
} }
trx->error_state = DB_SUCCESS; trx->error_state = DB_SUCCESS;
@ -1498,11 +1509,14 @@ row_create_index_for_mysql(
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fputs(" InnoDB: Error: column ", stderr);
" InnoDB: Error: column %s appears twice in index %s of table %s\n" ut_print_name(stderr,
dict_index_get_nth_field(index, i)->name);
fputs(" appears twice in ", stderr);
dict_index_name_print(stderr, index);
fputs("\n"
"InnoDB: This is not allowed in InnoDB.\n", "InnoDB: This is not allowed in InnoDB.\n",
dict_index_get_nth_field(index, i)->name, stderr);
index->name, index->table_name);
err = DB_COL_APPEARS_TWICE_IN_INDEX; err = DB_COL_APPEARS_TWICE_IN_INDEX;
@ -1634,16 +1648,19 @@ row_drop_table_for_mysql_in_background(
trx = trx_allocate_for_background(); trx = trx_allocate_for_background();
/* fprintf(stderr, "InnoDB: Dropping table %s in background drop list\n", /* fputs("InnoDB: Error: Dropping table ", stderr);
name); */ ut_print_name(stderr, name);
fputs(" in background drop list\n", stderr); */
/* Drop the table in InnoDB */ /* Drop the table in InnoDB */
error = row_drop_table_for_mysql(name, trx, FALSE); error = row_drop_table_for_mysql(name, trx, FALSE);
if (error != DB_SUCCESS) { if (error != DB_SUCCESS) {
fprintf(stderr, ut_print_timestamp(stderr);
"InnoDB: Error: Dropping table %s in background drop list failed\n", fputs(" InnoDB: Error: Dropping table ", stderr);
name); ut_print_name(stderr, name);
fputs(" in background drop list failed\n", stderr);
} }
/* Flush the log to reduce probability that the .frm files and /* Flush the log to reduce probability that the .frm files and
@ -1721,9 +1738,9 @@ already_dropped:
UT_LIST_REMOVE(row_mysql_drop_list, row_mysql_drop_list, drop); UT_LIST_REMOVE(row_mysql_drop_list, row_mysql_drop_list, drop);
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fputs(" InnoDB: Dropped table ", stderr);
" InnoDB: Dropped table %s in background drop queue.\n", ut_print_name(stderr, drop->table_name);
drop->table_name); fputs(" in background drop queue.\n", stderr);
mem_free(drop->table_name); mem_free(drop->table_name);
@ -1782,15 +1799,17 @@ row_add_table_to_background_drop_list(
UT_LIST_ADD_LAST(row_mysql_drop_list, row_mysql_drop_list, drop); UT_LIST_ADD_LAST(row_mysql_drop_list, row_mysql_drop_list, drop);
/* fprintf(stderr, "InnoDB: Adding table %s to background drop list\n", /* fputs("InnoDB: Adding table ", stderr);
drop->table_name); */ ut_print_name(stderr, drop->table_name);
fputs(" to background drop list\n", stderr); */
mutex_exit(&kernel_mutex); mutex_exit(&kernel_mutex);
} }
/************************************************************************* /*************************************************************************
Drops a table for MySQL. If the name of the dropped table ends to Drops a table for MySQL. If the name of the table to be dropped is equal
characters INNODB_MONITOR, then this also stops printing of monitor with one of the predefined magic table names, then this also stops printing
output by the master thread. */ the corresponding monitor output by the master thread. */
int int
row_drop_table_for_mysql( row_drop_table_for_mysql(
@ -1962,14 +1981,14 @@ row_drop_table_for_mysql(
err = DB_TABLE_NOT_FOUND; err = DB_TABLE_NOT_FOUND;
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fputs(" InnoDB: Error: table ", stderr);
" InnoDB: Error: table %s does not exist in the InnoDB internal\n" ut_print_name(stderr, name);
fputs(" does not exist in the InnoDB internal\n"
"InnoDB: data dictionary though MySQL is trying to drop it.\n" "InnoDB: data dictionary though MySQL is trying to drop it.\n"
"InnoDB: Have you copied the .frm file of the table to the\n" "InnoDB: Have you copied the .frm file of the table to the\n"
"InnoDB: MySQL database directory from another database?\n" "InnoDB: MySQL database directory from another database?\n"
"InnoDB: You can look further help from section 15.1 of\n" "InnoDB: You can look for further help from section 15.1 of\n"
"InnoDB: http://www.innodb.com/ibman.html\n", "InnoDB: http://www.innodb.com/ibman.php\n", stderr);
name);
goto funct_exit; goto funct_exit;
} }
@ -1985,7 +2004,7 @@ row_drop_table_for_mysql(
if (foreign && trx->check_foreigns && if (foreign && trx->check_foreigns &&
!(drop_db && dict_tables_have_same_db( !(drop_db && dict_tables_have_same_db(
name, foreign->foreign_table_name))) { name, foreign->foreign_table_name))) {
char* buf = dict_foreign_err_buf; FILE* ef = dict_foreign_err_file;
/* We only allow dropping a referenced table if /* We only allow dropping a referenced table if
FOREIGN_KEY_CHECKS is set to 0 */ FOREIGN_KEY_CHECKS is set to 0 */
@ -1993,15 +2012,15 @@ row_drop_table_for_mysql(
err = DB_CANNOT_DROP_CONSTRAINT; err = DB_CANNOT_DROP_CONSTRAINT;
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
ut_sprintf_timestamp(buf); rewind(ef);
ut_print_timestamp(ef);
sprintf(buf + strlen(buf),
" Cannot drop table %.500s\n", name);
sprintf(buf + strlen(buf),
"because it is referenced by %.500s\n", foreign->foreign_table_name);
ut_a(strlen(buf) < DICT_FOREIGN_ERR_BUF_LEN);
fputs(" Cannot drop table ", ef);
ut_print_name(ef, name);
fputs("\n"
"because it is referenced by ", ef);
ut_print_name(ef, foreign->foreign_table_name);
putc('\n', ef);
mutex_exit(&dict_foreign_err_mutex); mutex_exit(&dict_foreign_err_mutex);
goto funct_exit; goto funct_exit;
@ -2010,11 +2029,13 @@ row_drop_table_for_mysql(
if (table->n_mysql_handles_opened > 0) { if (table->n_mysql_handles_opened > 0) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fputs(" InnoDB: Warning: MySQL is trying to drop table ",
" InnoDB: Warning: MySQL is trying to drop table %s\n" stderr);
ut_print_name(stderr, table->name);
fputs("\n"
"InnoDB: though there are still open handles to it.\n" "InnoDB: though there are still open handles to it.\n"
"InnoDB: Adding the table to the background drop queue.\n", "InnoDB: Adding the table to the background drop queue.\n",
table->name); stderr);
row_add_table_to_background_drop_list(table); row_add_table_to_background_drop_list(table);
@ -2026,11 +2047,12 @@ row_drop_table_for_mysql(
if (table->n_foreign_key_checks_running > 0) { if (table->n_foreign_key_checks_running > 0) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fputs(" InnoDB: You are trying to drop table ", stderr);
" InnoDB: You are trying to drop table %s\n" ut_print_name(stderr, table->name);
fputs("\n"
"InnoDB: though there are foreign key check running on it.\n" "InnoDB: though there are foreign key check running on it.\n"
"InnoDB: Adding the table to the background drop queue.\n", "InnoDB: Adding the table to the background drop queue.\n",
table->name); stderr);
row_add_table_to_background_drop_list(table); row_add_table_to_background_drop_list(table);
@ -2065,9 +2087,11 @@ row_drop_table_for_mysql(
if (dict_load_table(name) != NULL) { if (dict_load_table(name) != NULL) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fputs(" InnoDB: Error: dropping of table ",
" InnoDB: Error: dropping of table %s failed!\n", name); stderr);
ut_print_name(stderr, name);
fputs(" failed!\n", stderr);
err = DB_ERROR;
} }
} }
funct_exit: funct_exit:
@ -2125,10 +2149,13 @@ loop:
row_mysql_unlock_data_dictionary(trx); row_mysql_unlock_data_dictionary(trx);
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fputs(
" InnoDB: Warning: MySQL is trying to drop database %s\n" " InnoDB: Warning: MySQL is trying to drop database ", stderr);
"InnoDB: though there are still open handles to table %s.\n", ut_print_name(stderr, name);
name, table_name); fputs("\n"
"InnoDB: though there are still open handles to table ", stderr);
ut_print_name(stderr, table_name);
fputs(".\n", stderr);
os_thread_sleep(1000000); os_thread_sleep(1000000);
@ -2142,9 +2169,12 @@ loop:
mem_free(table_name); mem_free(table_name);
if (err != DB_SUCCESS) { if (err != DB_SUCCESS) {
fprintf(stderr, fputs("InnoDB: DROP DATABASE ", stderr);
"InnoDB: DROP DATABASE %s failed with error %lu for table %s\n", ut_print_name(stderr, name);
name, (ulint)err, table_name); fprintf(stderr, " failed with error %lu for table ",
(ulint) err);
ut_print_name(stderr, table_name);
putc('\n', stderr);
break; break;
} }
} }
@ -2309,12 +2339,10 @@ row_rename_table_for_mysql(
if (row_mysql_is_recovered_tmp_table(new_name)) { if (row_mysql_is_recovered_tmp_table(new_name)) {
recovering_temp_table = TRUE; recovering_temp_table = TRUE;
} } else {
/* Serialize data dictionary operations with dictionary mutex: /* Serialize data dictionary operations with dictionary mutex:
no deadlocks can occur then in these operations */ no deadlocks can occur then in these operations */
if (!recovering_temp_table) {
row_mysql_lock_data_dictionary(trx); row_mysql_lock_data_dictionary(trx);
} }
@ -2450,25 +2478,26 @@ row_rename_table_for_mysql(
if (err == DB_DUPLICATE_KEY) { if (err == DB_DUPLICATE_KEY) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fputs(" InnoDB: Error: table ", stderr);
" InnoDB: Error: table %s exists in the InnoDB internal data\n" ut_print_name(stderr, new_name);
"InnoDB: dictionary though MySQL is trying rename table %s to it.\n" fputs(" exists in the InnoDB internal data\n"
"InnoDB: dictionary though MySQL is trying rename table ", stderr);
ut_print_name(stderr, old_name);
fputs(" to it.\n"
"InnoDB: Have you deleted the .frm file and not used DROP TABLE?\n" "InnoDB: Have you deleted the .frm file and not used DROP TABLE?\n"
"InnoDB: You can look further help from section 15.1 of\n" "InnoDB: You can look for further help from section 15.1 of\n"
"InnoDB: http://www.innodb.com/ibman.html\n", "InnoDB: http://www.innodb.com/ibman.php\n"
new_name, old_name); "InnoDB: If table ", stderr);
ut_print_name(stderr, new_name);
fprintf(stderr, fputs(
"InnoDB: If table %s is a temporary table #sql..., then it can be that\n" " is a temporary table #sql..., then it can be that\n"
"InnoDB: there are still queries running on the table, and it will be\n" "InnoDB: there are still queries running on the table, and it will be\n"
"InnoDB: dropped automatically when the queries end.\n", new_name); "InnoDB: dropped automatically when the queries end.\n"
fprintf(stderr,
"InnoDB: You can drop the orphaned table inside InnoDB by\n" "InnoDB: You can drop the orphaned table inside InnoDB by\n"
"InnoDB: creating an InnoDB table with the same name in another\n" "InnoDB: creating an InnoDB table with the same name in another\n"
"InnoDB: database and moving the .frm file to the current database.\n" "InnoDB: database and moving the .frm file to the current database.\n"
"InnoDB: Then MySQL thinks the table exists, and DROP TABLE will\n" "InnoDB: Then MySQL thinks the table exists, and DROP TABLE will\n"
"InnoDB: succeed.\n"); "InnoDB: succeed.\n", stderr);
} }
trx->error_state = DB_SUCCESS; trx->error_state = DB_SUCCESS;
@ -2493,11 +2522,13 @@ row_rename_table_for_mysql(
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fputs(" InnoDB: Error: in ALTER TABLE table ",
" InnoDB: Error: in ALTER TABLE table %s\n" stderr);
ut_print_name(stderr, new_name);
fputs("\n"
"InnoDB: has or is referenced in foreign key constraints\n" "InnoDB: has or is referenced in foreign key constraints\n"
"InnoDB: which are not compatible with the new table definition.\n", "InnoDB: which are not compatible with the new table definition.\n",
new_name); stderr);
ut_a(dict_table_rename_in_cache(table, ut_a(dict_table_rename_in_cache(table,
old_name, FALSE)); old_name, FALSE));
@ -2554,7 +2585,6 @@ row_scan_and_check_index(
int cmp; int cmp;
ibool contains_null; ibool contains_null;
ulint i; ulint i;
char err_buf[1000];
*n_rows = 0; *n_rows = 0;
@ -2615,32 +2645,25 @@ loop:
} }
if (cmp > 0) { if (cmp > 0) {
fprintf(stderr, fputs("InnoDB: index records in a wrong order in ",
"Error: index records in a wrong order in index %s\n", stderr);
index->name); not_ok:
dict_index_name_print(stderr, index);
dtuple_sprintf(err_buf, 900, prev_entry); fputs("\n"
fprintf(stderr, "InnoDB: prev record %s\n", err_buf); "InnoDB: prev record ", stderr);
dtuple_print(stderr, prev_entry);
rec_sprintf(err_buf, 900, rec); fputs("\n"
fprintf(stderr, "InnoDB: record %s\n", err_buf); "InnoDB: record ", stderr);
rec_print(stderr, rec);
putc('\n', stderr);
is_ok = FALSE; is_ok = FALSE;
} else if ((index->type & DICT_UNIQUE) } else if ((index->type & DICT_UNIQUE)
&& !contains_null && !contains_null
&& matched_fields >= && matched_fields >=
dict_index_get_n_ordering_defined_by_user(index)) { dict_index_get_n_ordering_defined_by_user(index)) {
fprintf(stderr, "Error: duplicate key in index %s\n", fputs("InnoDB: duplicate key in ", stderr);
index->name); goto not_ok;
dtuple_sprintf(err_buf, 900, prev_entry);
fprintf(stderr, "InnoDB: prev record %s\n", err_buf);
rec_sprintf(err_buf, 900, rec);
fprintf(stderr, "InnoDB: record %s\n", err_buf);
is_ok = FALSE;
} }
} }
@ -2684,7 +2707,9 @@ row_check_table_for_mysql(
index = dict_table_get_first_index(table); index = dict_table_get_first_index(table);
while (index != NULL) { while (index != NULL) {
/* fprintf(stderr, "Validating index %s\n", index->name); */ /* fputs("Validating index ", stderr);
ut_print_name(stderr, index->name);
putc('\n', stderr); */
if (!btr_validate_tree(index->tree)) { if (!btr_validate_tree(index->tree)) {
ret = DB_ERROR; ret = DB_ERROR;
@ -2694,8 +2719,9 @@ row_check_table_for_mysql(
ret = DB_ERROR; ret = DB_ERROR;
} }
/* fprintf(stderr, "%lu entries in index %s\n", n_rows, /* fprintf(stderr, "%lu entries in index ", n_rows);
index->name); */ ut_print_name(stderr, index->name);
putc('\n', stderr); */
if (index == dict_table_get_first_index(table)) { if (index == dict_table_get_first_index(table)) {
n_rows_in_table = n_rows; n_rows_in_table = n_rows;
@ -2703,9 +2729,11 @@ row_check_table_for_mysql(
ret = DB_ERROR; ret = DB_ERROR;
fputs("InnoDB: Error: ", stderr);
dict_index_name_print(stderr, index);
fprintf(stderr, fprintf(stderr,
"Error: index %s contains %lu entries, should be %lu\n", " contains %lu entries, should be %lu\n",
index->name, n_rows, n_rows_in_table); n_rows, n_rows_in_table);
} }
} }

View File

@ -158,7 +158,7 @@ row_purge_remove_clust_if_poss(
ibool success; ibool success;
ulint n_tries = 0; ulint n_tries = 0;
/* printf("Purge: Removing clustered record\n"); */ /* fputs("Purge: Removing clustered record\n", stderr); */
success = row_purge_remove_clust_if_poss_low(node, BTR_MODIFY_LEAF); success = row_purge_remove_clust_if_poss_low(node, BTR_MODIFY_LEAF);
if (success) { if (success) {
@ -212,7 +212,7 @@ row_purge_remove_sec_if_poss_low(
if (!found) { if (!found) {
/* Not found */ /* Not found */
/* printf("PURGE:........sec entry not found\n"); */ /* fputs("PURGE:........sec entry not found\n", stderr); */
/* dtuple_print(entry); */ /* dtuple_print(entry); */
btr_pcur_close(&pcur); btr_pcur_close(&pcur);
@ -281,7 +281,7 @@ row_purge_remove_sec_if_poss(
ibool success; ibool success;
ulint n_tries = 0; ulint n_tries = 0;
/* printf("Purge: Removing secondary record\n"); */ /* fputs("Purge: Removing secondary record\n", stderr); */
success = row_purge_remove_sec_if_poss_low(node, index, entry, success = row_purge_remove_sec_if_poss_low(node, index, entry,
BTR_MODIFY_LEAF); BTR_MODIFY_LEAF);

View File

@ -390,7 +390,6 @@ row_build_row_ref_in_tuple(
at least s-latched and the latch held at least s-latched and the latch held
as long as the row reference is used! */ as long as the row reference is used! */
{ {
dict_table_t* table;
dict_index_t* clust_index; dict_index_t* clust_index;
dfield_t* dfield; dfield_t* dfield;
byte* field; byte* field;
@ -401,21 +400,21 @@ row_build_row_ref_in_tuple(
ut_a(ref && index && rec); ut_a(ref && index && rec);
table = index->table; if (!index->table) {
fputs("InnoDB: table ", stderr);
if (!table) { notfound:
fprintf(stderr, "InnoDB: table %s for index %s not found\n", ut_print_name(stderr, index->table_name);
index->table_name, index->name); fputs(" for index ", stderr);
ut_print_name(stderr, index->name);
fputs(" not found\n", stderr);
ut_error; ut_error;
} }
clust_index = dict_table_get_first_index(table); clust_index = dict_table_get_first_index(index->table);
if (!clust_index) { if (!clust_index) {
fprintf(stderr, fputs("InnoDB: clust index for table ", stderr);
"InnoDB: clust index for table %s for index %s not found\n", goto notfound;
index->table_name, index->name);
ut_error;
} }
ref_len = dict_index_get_n_unique(clust_index); ref_len = dict_index_get_n_unique(clust_index);

View File

@ -1756,7 +1756,7 @@ row_sel_step(
return(NULL); return(NULL);
} else { } else {
/* SQL error detected */ /* SQL error detected */
printf("SQL error %lu\n", err); fprintf(stderr, "SQL error %lu\n", err);
que_thr_handle_error(thr, DB_ERROR, NULL, 0); que_thr_handle_error(thr, DB_ERROR, NULL, 0);
@ -1806,7 +1806,7 @@ fetch_step(
if (sel_node->state == SEL_NODE_CLOSED) { if (sel_node->state == SEL_NODE_CLOSED) {
/* SQL error detected */ /* SQL error detected */
printf("SQL error %lu\n", (ulint)DB_ERROR); fprintf(stderr, "SQL error %lu\n", (ulint)DB_ERROR);
que_thr_handle_error(thr, DB_ERROR, NULL, 0); que_thr_handle_error(thr, DB_ERROR, NULL, 0);
@ -1867,12 +1867,12 @@ row_printf_step(
while (arg) { while (arg) {
dfield_print_also_hex(que_node_get_val(arg)); dfield_print_also_hex(que_node_get_val(arg));
printf(" ::: "); fputs(" ::: ", stderr);
arg = que_node_get_next(arg); arg = que_node_get_next(arg);
} }
printf("\n"); putc('\n', stderr);
/* Fetch next row to print */ /* Fetch next row to print */
@ -1980,9 +1980,10 @@ row_sel_convert_mysql_key_to_innobase(
MySQL */ MySQL */
if (key_ptr[data_offset + 1] != 0) { if (key_ptr[data_offset + 1] != 0) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fputs(
" InnoDB: Error: BLOB or TEXT prefix > 255 bytes in query to table %s\n", " InnoDB: Error: BLOB or TEXT prefix > 255 bytes in query to table ", stderr);
index->table_name); ut_print_name(stderr, index->table_name);
putc('\n', stderr);
} }
data_len = key_ptr[data_offset]; data_len = key_ptr[data_offset];
@ -2058,20 +2059,18 @@ row_sel_store_row_id_to_prebuilt(
{ {
byte* data; byte* data;
ulint len; ulint len;
char err_buf[1000];
data = rec_get_nth_field(index_rec, data = rec_get_nth_field(index_rec,
dict_index_get_sys_col_pos(index, DATA_ROW_ID), &len); dict_index_get_sys_col_pos(index, DATA_ROW_ID), &len);
if (len != DATA_ROW_ID_LEN) { if (len != DATA_ROW_ID_LEN) {
rec_sprintf(err_buf, 900, index_rec);
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: Row id field is wrong length %lu in table %s index %s\n" "InnoDB: Error: Row id field is wrong length %lu in ", len);
"InnoDB: Field number %lu, record:\n%s\n", dict_index_name_print(stderr, index);
len, index->table_name, index->name, fprintf(stderr, "\n"
dict_index_get_sys_col_pos(index, DATA_ROW_ID), "InnoDB: Field number %lu, record:\n",
err_buf); dict_index_get_sys_col_pos(index, DATA_ROW_ID));
rec_print(stderr, index_rec);
putc('\n', stderr);
ut_error; ut_error;
} }
@ -2239,9 +2238,11 @@ row_sel_store_mysql_rec(
templ->mysql_col_len); templ->mysql_col_len);
if (!templ->mysql_null_bit_mask) { if (!templ->mysql_null_bit_mask) {
fprintf(stderr, fputs(
"InnoDB: Error: trying to return an SQL NULL field in a non-null\n" "InnoDB: Error: trying to return an SQL NULL field in a non-null\n"
"innoDB: column! Table name %s\n", prebuilt->table->name); "innoDB: column! Table name ", stderr);
ut_print_name(stderr, prebuilt->table->name);
putc('\n', stderr);
} else { } else {
mysql_rec[templ->mysql_null_byte_offset] |= mysql_rec[templ->mysql_null_byte_offset] |=
(byte) (templ->mysql_null_bit_mask); (byte) (templ->mysql_null_bit_mask);
@ -2310,7 +2311,6 @@ row_sel_get_clust_rec_for_mysql(
rec_t* old_vers; rec_t* old_vers;
ulint err; ulint err;
trx_t* trx; trx_t* trx;
char err_buf[1000];
*out_rec = NULL; *out_rec = NULL;
@ -2344,26 +2344,22 @@ row_sel_get_clust_rec_for_mysql(
|| prebuilt->select_lock_type != LOCK_NONE) { || prebuilt->select_lock_type != LOCK_NONE) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fputs(" InnoDB: error clustered record"
" InnoDB: error clustered record for sec rec not found\n" " for sec rec not found\n"
"InnoDB: index %s table %s\n", sec_index->name, "InnoDB: ", stderr);
sec_index->table->name); dict_index_name_print(stderr, sec_index);
fputs("\n"
"InnoDB: sec index record ", stderr);
rec_print(stderr, rec);
fputs("\n"
"InnoDB: clust index record ", stderr);
rec_print(stderr, clust_rec);
putc('\n', stderr);
trx_print(stderr, thr_get_trx(thr));
rec_sprintf(err_buf, 900, rec); fputs("\n"
fprintf(stderr, "InnoDB: Make a detailed bug report and send it\n"
"InnoDB: sec index record %s\n", err_buf); "InnoDB: to mysql@lists.mysql.com\n", stderr);
rec_sprintf(err_buf, 900, clust_rec);
fprintf(stderr,
"InnoDB: clust index record %s\n", err_buf);
trx = thr_get_trx(thr);
trx_print(err_buf, trx);
fprintf(stderr,
"%s\nInnoDB: Make a detailed bug report and send it\n",
err_buf);
fprintf(stderr, "InnoDB: to mysql@lists.mysql.com\n");
} }
clust_rec = NULL; clust_rec = NULL;
@ -2711,18 +2707,20 @@ row_search_for_mysql(
if (prebuilt->magic_n != ROW_PREBUILT_ALLOCATED) { if (prebuilt->magic_n != ROW_PREBUILT_ALLOCATED) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: trying to free a corrupt\n" "InnoDB: Error: trying to free a corrupt\n"
"InnoDB: table handle. Magic n %lu, table name %s\n", "InnoDB: table handle. Magic n %lu, table name ",
prebuilt->magic_n, prebuilt->table->name); prebuilt->magic_n);
ut_print_name(stderr, prebuilt->table->name);
putc('\n', stderr);
mem_analyze_corruption((byte*)prebuilt); mem_analyze_corruption((byte*)prebuilt);
ut_error; ut_error;
} }
/* printf("Match mode %lu\n search tuple ", match_mode); /* fprintf(stderr, "Match mode %lu\n search tuple ", match_mode);
dtuple_print(search_tuple); dtuple_print(search_tuple);
printf("N tables locked %lu\n", trx->mysql_n_tables_locked); fprintf(stderr, "N tables locked %lu\n", trx->mysql_n_tables_locked);
*/ */
/*-------------------------------------------------------------*/ /*-------------------------------------------------------------*/
/* PHASE 0: Release a possible s-latch we are holding on the /* PHASE 0: Release a possible s-latch we are holding on the
@ -2899,7 +2897,8 @@ row_search_for_mysql(
mtr_commit(&mtr); mtr_commit(&mtr);
/* printf("%s shortcut\n", index->name); */ /* ut_print_name(stderr, index->name);
fputs(" shortcut\n", stderr); */
srv_n_rows_read++; srv_n_rows_read++;
@ -2923,8 +2922,8 @@ row_search_for_mysql(
mtr_commit(&mtr); mtr_commit(&mtr);
/* printf("%s record not found 2\n", /* ut_print_name(stderr, index->name);
index->name); */ fputs(" record not found 2\n", stderr); */
if (trx->search_latch_timeout > 0 if (trx->search_latch_timeout > 0
&& trx->has_search_latch) { && trx->has_search_latch) {
@ -3044,8 +3043,9 @@ rec_loop:
rec = btr_pcur_get_rec(pcur); rec = btr_pcur_get_rec(pcur);
/* /*
printf("Using index %s cnt %lu ", index->name, cnt); fputs("Using ", stderr);
printf("; Page no %lu\n", dict_index_name_print(stderr, index);
fprintf(stderr, " cnt %lu ; Page no %lu\n", cnt,
buf_frame_get_page_no(buf_frame_align(rec))); buf_frame_get_page_no(buf_frame_align(rec)));
rec_print(rec); rec_print(rec);
*/ */
@ -3091,11 +3091,13 @@ rec_loop:
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: Index corruption: rec offs %lu next offs %lu, page no %lu,\n" " InnoDB: Index corruption: rec offs %lu next offs %lu, page no %lu,\n"
"InnoDB: index %s, table %s. Run CHECK TABLE to table. You may need to\n" "InnoDB: ",
"InnoDB: restore from a backup, or dump + drop + reimport the table.\n",
(ulint)(rec - buf_frame_align(rec)), next_offs, (ulint)(rec - buf_frame_align(rec)), next_offs,
buf_frame_get_page_no(rec), index->name, buf_frame_get_page_no(rec));
index->table_name); dict_index_name_print(stderr, index);
fputs(". Run CHECK TABLE. You may need to\n"
"InnoDB: restore from a backup, or dump + drop + reimport the table.\n",
stderr);
err = DB_CORRUPTION; err = DB_CORRUPTION;
@ -3106,10 +3108,12 @@ rec_loop:
fprintf(stderr, fprintf(stderr,
"InnoDB: Index corruption: rec offs %lu next offs %lu, page no %lu,\n" "InnoDB: Index corruption: rec offs %lu next offs %lu, page no %lu,\n"
"InnoDB: index %s, table %s. We try to skip the rest of the page.\n", "InnoDB: ",
(ulint)(rec - buf_frame_align(rec)), next_offs, (ulint)(rec - buf_frame_align(rec)), next_offs,
buf_frame_get_page_no(rec), index->name, buf_frame_get_page_no(rec));
index->table_name); dict_index_name_print(stderr, index);
fputs(". We try to skip the rest of the page.\n",
stderr);
btr_pcur_move_to_last_on_page(pcur, &mtr); btr_pcur_move_to_last_on_page(pcur, &mtr);
@ -3121,11 +3125,13 @@ rec_loop:
if (!rec_validate(rec) || !btr_index_rec_validate(rec, index, if (!rec_validate(rec) || !btr_index_rec_validate(rec, index,
FALSE)) { FALSE)) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Index record corruption: rec offs %lu next offs %lu, page no %lu,\n" "InnoDB: Index corruption: rec offs %lu next offs %lu, page no %lu,\n"
"InnoDB: index %s, table %s. We try to skip the record.\n", "InnoDB: ",
(ulint)(rec - buf_frame_align(rec)), next_offs, (ulint)(rec - buf_frame_align(rec)), next_offs,
buf_frame_get_page_no(rec), index->name, buf_frame_get_page_no(rec));
index->table_name); dict_index_name_print(stderr, index);
fputs(". We try to skip the record.\n",
stderr);
goto next_rec; goto next_rec;
} }
@ -3142,7 +3148,7 @@ rec_loop:
/* Test if the index record matches completely to search_tuple /* Test if the index record matches completely to search_tuple
in prebuilt: if not, then we return with DB_RECORD_NOT_FOUND */ in prebuilt: if not, then we return with DB_RECORD_NOT_FOUND */
/* printf("Comparing rec and search tuple\n"); */ /* fputs("Comparing rec and search tuple\n", stderr); */
if (0 != cmp_dtuple_rec(search_tuple, rec)) { if (0 != cmp_dtuple_rec(search_tuple, rec)) {
@ -3162,7 +3168,8 @@ rec_loop:
btr_pcur_store_position(pcur, &mtr); btr_pcur_store_position(pcur, &mtr);
ret = DB_RECORD_NOT_FOUND; ret = DB_RECORD_NOT_FOUND;
/* printf("%s record not found 3\n", index->name); */ /* ut_print_name(stderr, index->name);
fputs(" record not found 3\n", stderr); */
goto normal_return; goto normal_return;
} }
@ -3187,7 +3194,8 @@ rec_loop:
btr_pcur_store_position(pcur, &mtr); btr_pcur_store_position(pcur, &mtr);
ret = DB_RECORD_NOT_FOUND; ret = DB_RECORD_NOT_FOUND;
/* printf("%s record not found 4\n", index->name); */ /* ut_print_name(stderr, index->name);
fputs(" record not found 4\n", stderr); */
goto normal_return; goto normal_return;
} }
@ -3453,8 +3461,9 @@ lock_wait_or_error:
goto rec_loop; goto rec_loop;
} }
/* printf("Using index %s cnt %lu ret value %lu err\n", index->name, /* fputs("Using ", stderr);
cnt, err); */ dict_index_name_print(stderr, index);
fprintf(stderr, " cnt %lu ret value %lu err\n", cnt, err); */
trx->op_info = (char *) ""; trx->op_info = (char *) "";
return(err); return(err);
@ -3471,8 +3480,9 @@ normal_return:
ret = DB_SUCCESS; ret = DB_SUCCESS;
} }
/* printf("Using index %s cnt %lu ret value %lu\n", index->name, /* fputs("Using ", stderr);
cnt, err); */ dict_index_name_print(stderr, index);
fprintf(stderr, " cnt %lu ret value %lu err\n", cnt, err); */
if (ret == DB_SUCCESS) { if (ret == DB_SUCCESS) {
srv_n_rows_read++; srv_n_rows_read++;
} }

View File

@ -417,13 +417,11 @@ row_undo_mod_del_unmark_sec_and_undo_update(
{ {
mem_heap_t* heap; mem_heap_t* heap;
btr_pcur_t pcur; btr_pcur_t pcur;
btr_cur_t* btr_cur;
upd_t* update; upd_t* update;
ulint err = DB_SUCCESS; ulint err = DB_SUCCESS;
ibool found; ibool found;
big_rec_t* dummy_big_rec; big_rec_t* dummy_big_rec;
mtr_t mtr; mtr_t mtr;
char err_buf[1000];
log_free_check(); log_free_check();
mtr_start(&mtr); mtr_start(&mtr);
@ -431,23 +429,22 @@ row_undo_mod_del_unmark_sec_and_undo_update(
found = row_search_index_entry(index, entry, mode, &pcur, &mtr); found = row_search_index_entry(index, entry, mode, &pcur, &mtr);
if (!found) { if (!found) {
fprintf(stderr, fputs("InnoDB: error in sec index entry del undo in\n"
"InnoDB: error in sec index entry del undo in\n" "InnoDB: ", stderr);
"InnoDB: index %s table %s\n", index->name, dict_index_name_print(stderr, index);
index->table->name); fputs("\n"
dtuple_sprintf(err_buf, 900, entry); "InnoDB: tuple ", stderr);
fprintf(stderr, "InnoDB: tuple %s\n", err_buf); dtuple_print(stderr, entry);
fputs("\n"
rec_sprintf(err_buf, 900, btr_pcur_get_rec(&pcur)); "InnoDB: record ", stderr);
fprintf(stderr, "InnoDB: record %s\n", err_buf); rec_print(stderr, btr_pcur_get_rec(&pcur));
putc('\n', stderr);
trx_print(err_buf, thr_get_trx(thr)); trx_print(stderr, thr_get_trx(thr));
fprintf(stderr, fputs("\n"
"%s\nInnoDB: Make a detailed bug report and send it\n", "InnoDB: Make a detailed bug report and send it\n"
err_buf); "InnoDB: to mysql@lists.mysql.com\n", stderr);
fprintf(stderr, "InnoDB: to mysql@lists.mysql.com\n");
} else { } else {
btr_cur = btr_pcur_get_btr_cur(&pcur); btr_cur_t* btr_cur = btr_pcur_get_btr_cur(&pcur);
err = btr_cur_del_mark_set_sec_rec(BTR_NO_LOCKING_FLAG, err = btr_cur_del_mark_set_sec_rec(BTR_NO_LOCKING_FLAG,
btr_cur, FALSE, thr, &mtr); btr_cur, FALSE, thr, &mtr);

View File

@ -169,8 +169,8 @@ row_undo_search_clust_to_pcur(
is to make sure that some thread will eventually undo the is to make sure that some thread will eventually undo the
modification corresponding to node->roll_ptr. */ modification corresponding to node->roll_ptr. */
/* printf("--------------------undoing a previous version\n"); /* fputs("--------------------undoing a previous version\n",
*/ stderr); */
ret = FALSE; ret = FALSE;
} else { } else {

View File

@ -1202,7 +1202,6 @@ row_upd_sec_index_entry(
rec_t* rec; rec_t* rec;
ulint err = DB_SUCCESS; ulint err = DB_SUCCESS;
mtr_t mtr; mtr_t mtr;
char err_buf[1000];
index = node->index; index = node->index;
@ -1223,21 +1222,22 @@ row_upd_sec_index_entry(
rec = btr_cur_get_rec(btr_cur); rec = btr_cur_get_rec(btr_cur);
if (!found) { if (!found) {
fprintf(stderr, "InnoDB: error in sec index entry update in\n" fputs("InnoDB: error in sec index entry update in\n"
"InnoDB: index %s table %s\n", index->name, "InnoDB: ", stderr);
index->table->name); dict_index_name_print(stderr, index);
dtuple_sprintf(err_buf, 900, entry); fputs("\n"
fprintf(stderr, "InnoDB: tuple %s\n", err_buf); "InnoDB: tuple ", stderr);
dtuple_print(stderr, entry);
fputs("\n"
"InnoDB: record ", stderr);
rec_print(stderr, rec);
putc('\n', stderr);
rec_sprintf(err_buf, 900, rec); trx_print(stderr, thr_get_trx(thr));
fprintf(stderr, "InnoDB: record %s\n", err_buf);
trx_print(err_buf, thr_get_trx(thr)); fputs("\n"
"InnoDB: Make a detailed bug report and send it\n"
fprintf(stderr, "InnoDB: to mysql@lists.mysql.com\n", stderr);
"%s\nInnoDB: Make a detailed bug report and send it\n",
err_buf);
fprintf(stderr, "InnoDB: to mysql@lists.mysql.com\n");
} else { } else {
/* Delete mark the old index record; it can already be /* Delete mark the old index record; it can already be
delete marked if we return after a lock wait in delete marked if we return after a lock wait in

View File

@ -52,9 +52,6 @@ Created 10/8/1995 Heikki Tuuri
affects only FOREIGN KEY definition parsing */ affects only FOREIGN KEY definition parsing */
ibool srv_lower_case_table_names = FALSE; ibool srv_lower_case_table_names = FALSE;
/* Buffer which can be used in printing fatal error messages */
char srv_fatal_errbuf[5000];
/* The following counter is incremented whenever there is some user activity /* The following counter is incremented whenever there is some user activity
in the server */ in the server */
ulint srv_activity_count = 0; ulint srv_activity_count = 0;
@ -292,6 +289,11 @@ time_t srv_last_monitor_time;
mutex_t srv_innodb_monitor_mutex; mutex_t srv_innodb_monitor_mutex;
/* Mutex for locking srv_monitor_file */
mutex_t srv_monitor_file_mutex;
/* Temporary file for innodb monitor output */
FILE* srv_monitor_file;
ulint srv_main_thread_process_no = 0; ulint srv_main_thread_process_no = 0;
ulint srv_main_thread_id = 0; ulint srv_main_thread_id = 0;
@ -627,9 +629,10 @@ srv_suspend_thread(void)
slot_no = thr_local_get_slot_no(os_thread_get_curr_id()); slot_no = thr_local_get_slot_no(os_thread_get_curr_id());
if (srv_print_thread_releases) { if (srv_print_thread_releases) {
fprintf(stderr,
printf("Suspending thread %lu to slot %lu meter %lu\n", "Suspending thread %lu to slot %lu meter %lu\n",
os_thread_get_curr_id(), slot_no, srv_meter[SRV_RECOVERY]); os_thread_get_curr_id(), slot_no,
srv_meter[SRV_RECOVERY]);
} }
slot = srv_table_get_nth_slot(slot_no); slot = srv_table_get_nth_slot(slot_no);
@ -689,7 +692,7 @@ srv_release_threads(
os_event_set(slot->event); os_event_set(slot->event);
if (srv_print_thread_releases) { if (srv_print_thread_releases) {
printf( fprintf(stderr,
"Releasing thread %lu type %lu from slot %lu meter %lu\n", "Releasing thread %lu type %lu from slot %lu meter %lu\n",
slot->id, type, i, srv_meter[SRV_RECOVERY]); slot->id, type, i, srv_meter[SRV_RECOVERY]);
} }
@ -847,7 +850,6 @@ srv_conc_enter_innodb(
ibool has_slept = FALSE; ibool has_slept = FALSE;
srv_conc_slot_t* slot = NULL; srv_conc_slot_t* slot = NULL;
ulint i; ulint i;
char err_buf[1000];
if (srv_thread_concurrency >= 500) { if (srv_thread_concurrency >= 500) {
/* Disable the concurrency check */ /* Disable the concurrency check */
@ -868,12 +870,11 @@ srv_conc_enter_innodb(
retry: retry:
if (trx->declared_to_be_inside_innodb) { if (trx->declared_to_be_inside_innodb) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fputs(
trx_print(err_buf, trx);
fprintf(stderr,
" InnoDB: Error: trying to declare trx to enter InnoDB, but\n" " InnoDB: Error: trying to declare trx to enter InnoDB, but\n"
"InnoDB: it already is declared.\n%s\n", err_buf); "InnoDB: it already is declared.\n", stderr);
trx_print(stderr, trx);
putc('\n', stderr);
os_fast_mutex_unlock(&srv_conc_mutex); os_fast_mutex_unlock(&srv_conc_mutex);
return; return;
@ -1403,15 +1404,13 @@ srv_refresh_innodb_monitor_stats(void)
} }
/********************************************************************** /**********************************************************************
Sprintfs to a buffer the output of the InnoDB Monitor. */ Outputs to a file the output of the InnoDB Monitor. */
void void
srv_sprintf_innodb_monitor( srv_printf_innodb_monitor(
/*=======================*/ /*======================*/
char* buf, /* in/out: buffer which must be at least 4 kB */ FILE* file) /* in: output stream */
ulint len) /* in: length of the buffer */
{ {
char* buf_end = buf + len - 2000;
double time_elapsed; double time_elapsed;
time_t current_time; time_t current_time;
ulint n_reserved; ulint n_reserved;
@ -1429,28 +1428,20 @@ srv_sprintf_innodb_monitor(
srv_last_monitor_time = time(NULL); srv_last_monitor_time = time(NULL);
ut_a(len >= 4096); rewind(file);
fputs("\n=====================================\n", file);
buf += sprintf(buf, "\n=====================================\n"); ut_print_timestamp(file);
fprintf(file,
ut_sprintf_timestamp(buf); " INNODB MONITOR OUTPUT\n"
buf = buf + strlen(buf); "=====================================\n"
ut_a(buf < buf_end + 1500);
buf += sprintf(buf, " INNODB MONITOR OUTPUT\n"
"=====================================\n");
buf += sprintf(buf,
"Per second averages calculated from the last %lu seconds\n", "Per second averages calculated from the last %lu seconds\n",
(ulint)time_elapsed); (ulong)time_elapsed);
buf += sprintf(buf, "----------\n" fputs("----------\n"
"SEMAPHORES\n" "SEMAPHORES\n"
"----------\n"); "----------\n", file);
sync_print(buf, buf_end); sync_print(file);
buf = buf + strlen(buf);
ut_a(buf < buf_end + 1500);
/* Conceptually, srv_innodb_monitor_mutex has a very high latching /* Conceptually, srv_innodb_monitor_mutex has a very high latching
order level in sync0sync.h, while dict_foreign_err_mutex has a very order level in sync0sync.h, while dict_foreign_err_mutex has a very
@ -1459,43 +1450,29 @@ srv_sprintf_innodb_monitor(
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
if (*dict_foreign_err_buf != '\0') { if (ftell(dict_foreign_err_file) != 0L) {
buf += sprintf(buf, fputs("------------------------\n"
"------------------------\n"
"LATEST FOREIGN KEY ERROR\n" "LATEST FOREIGN KEY ERROR\n"
"------------------------\n"); "------------------------\n", file);
ut_copy_file(file, dict_foreign_err_file);
if (buf_end - buf > 6000) {
buf+= sprintf(buf, "%.4000s", dict_foreign_err_buf);
}
} }
mutex_exit(&dict_foreign_err_mutex); mutex_exit(&dict_foreign_err_mutex);
ut_a(buf < buf_end + 1500); lock_print_info(file);
fputs("--------\n"
lock_print_info(buf, buf_end);
buf = buf + strlen(buf);
buf += sprintf(buf, "--------\n"
"FILE I/O\n" "FILE I/O\n"
"--------\n"); "--------\n", file);
os_aio_print(buf, buf_end); os_aio_print(file);
buf = buf + strlen(buf);
ut_a(buf < buf_end + 1500);
buf += sprintf(buf, "-------------------------------------\n" fputs("-------------------------------------\n"
"INSERT BUFFER AND ADAPTIVE HASH INDEX\n" "INSERT BUFFER AND ADAPTIVE HASH INDEX\n"
"-------------------------------------\n"); "-------------------------------------\n", file);
ibuf_print(buf, buf_end); ibuf_print(file);
buf = buf + strlen(buf);
ut_a(buf < buf_end + 1500);
ha_print_info(buf, buf_end, btr_search_sys->hash_index); ha_print_info(file, btr_search_sys->hash_index);
buf = buf + strlen(buf);
ut_a(buf < buf_end + 1500);
buf += sprintf(buf, fprintf(file,
"%.2f hash searches/s, %.2f non-hash searches/s\n", "%.2f hash searches/s, %.2f non-hash searches/s\n",
(btr_cur_n_sea - btr_cur_n_sea_old) (btr_cur_n_sea - btr_cur_n_sea_old)
/ time_elapsed, / time_elapsed,
@ -1504,57 +1481,50 @@ srv_sprintf_innodb_monitor(
btr_cur_n_sea_old = btr_cur_n_sea; btr_cur_n_sea_old = btr_cur_n_sea;
btr_cur_n_non_sea_old = btr_cur_n_non_sea; btr_cur_n_non_sea_old = btr_cur_n_non_sea;
buf += sprintf(buf,"---\n" fputs("---\n"
"LOG\n" "LOG\n"
"---\n"); "---\n", file);
log_print(buf, buf_end); log_print(file);
buf = buf + strlen(buf);
ut_a(buf < buf_end + 1500);
buf += sprintf(buf, "----------------------\n" fputs("----------------------\n"
"BUFFER POOL AND MEMORY\n" "BUFFER POOL AND MEMORY\n"
"----------------------\n"); "----------------------\n", file);
buf += sprintf(buf, fprintf(file,
"Total memory allocated %lu; in additional pool allocated %lu\n", "Total memory allocated %lu; in additional pool allocated %lu\n",
ut_total_allocated_memory, ut_total_allocated_memory,
mem_pool_get_reserved(mem_comm_pool)); mem_pool_get_reserved(mem_comm_pool));
buf_print_io(buf, buf_end); buf_print_io(file);
buf = buf + strlen(buf);
ut_a(buf < buf_end + 1500);
buf += sprintf(buf, "--------------\n" fputs("--------------\n"
"ROW OPERATIONS\n" "ROW OPERATIONS\n"
"--------------\n"); "--------------\n", file);
buf += sprintf(buf, fprintf(file, "%ld queries inside InnoDB, %lu queries in queue\n",
"%ld queries inside InnoDB, %lu queries in queue\n",
srv_conc_n_threads, srv_conc_n_waiting_threads); srv_conc_n_threads, srv_conc_n_waiting_threads);
n_reserved = fil_space_get_n_reserved_extents(0); n_reserved = fil_space_get_n_reserved_extents(0);
if (n_reserved > 0) { if (n_reserved > 0) {
buf += sprintf(buf, fprintf(file,
"%lu tablespace extents now reserved for B-tree split operations\n", "%lu tablespace extents now reserved for B-tree split operations\n",
n_reserved); n_reserved);
} }
#ifdef UNIV_LINUX #ifdef UNIV_LINUX
buf += sprintf(buf, fprintf(file, "Main thread process no. %lu, id %lu, state: %s\n",
"Main thread process no. %lu, id %lu, state: %.29s\n",
srv_main_thread_process_no, srv_main_thread_process_no,
srv_main_thread_id, srv_main_thread_id,
srv_main_thread_op_info); srv_main_thread_op_info);
#else #else
buf += sprintf(buf, fprintf(file, "Main thread id %lu, state: %s\n",
"Main thread id %lu, state: %.29s\n",
srv_main_thread_id, srv_main_thread_id,
srv_main_thread_op_info); srv_main_thread_op_info);
#endif #endif
buf += sprintf(buf, fprintf(file,
"Number of rows inserted %lu, updated %lu, deleted %lu, read %lu\n", "Number of rows inserted %lu, updated %lu, deleted %lu, read %lu\n",
srv_n_rows_inserted, srv_n_rows_inserted,
srv_n_rows_updated, srv_n_rows_updated,
srv_n_rows_deleted, srv_n_rows_deleted,
srv_n_rows_read); srv_n_rows_read);
buf += sprintf(buf, fprintf(file,
"%.2f inserts/s, %.2f updates/s, %.2f deletes/s, %.2f reads/s\n", "%.2f inserts/s, %.2f updates/s, %.2f deletes/s, %.2f reads/s\n",
(srv_n_rows_inserted - srv_n_rows_inserted_old) (srv_n_rows_inserted - srv_n_rows_inserted_old)
/ time_elapsed, / time_elapsed,
@ -1570,12 +1540,12 @@ srv_sprintf_innodb_monitor(
srv_n_rows_deleted_old = srv_n_rows_deleted; srv_n_rows_deleted_old = srv_n_rows_deleted;
srv_n_rows_read_old = srv_n_rows_read; srv_n_rows_read_old = srv_n_rows_read;
buf += sprintf(buf, "----------------------------\n" fputs("----------------------------\n"
"END OF INNODB MONITOR OUTPUT\n" "END OF INNODB MONITOR OUTPUT\n"
"============================\n"); "============================\n", file);
ut_a(buf < buf_end + 1900);
mutex_exit(&srv_innodb_monitor_mutex); mutex_exit(&srv_innodb_monitor_mutex);
fflush(file);
} }
/************************************************************************* /*************************************************************************
@ -1601,13 +1571,13 @@ srv_lock_timeout_and_monitor_thread(
time_t last_monitor_time; time_t last_monitor_time;
ibool some_waits; ibool some_waits;
double wait_time; double wait_time;
char* buf;
ulint i; ulint i;
#ifdef UNIV_DEBUG_THREAD_CREATION #ifdef UNIV_DEBUG_THREAD_CREATION
printf("Lock timeout thread starts, id %lu\n", fprintf(stderr, "Lock timeout thread starts, id %lu\n",
os_thread_pf(os_thread_get_curr_id())); os_thread_pf(os_thread_get_curr_id()));
#endif #endif
UT_NOT_USED(arg);
srv_last_monitor_time = time(NULL); srv_last_monitor_time = time(NULL);
last_table_monitor_time = time(NULL); last_table_monitor_time = time(NULL);
last_monitor_time = time(NULL); last_monitor_time = time(NULL);
@ -1633,37 +1603,36 @@ loop:
last_monitor_time = time(NULL); last_monitor_time = time(NULL);
if (srv_print_innodb_monitor) { if (srv_print_innodb_monitor) {
srv_printf_innodb_monitor(stderr);
buf = mem_alloc(100000);
srv_sprintf_innodb_monitor(buf, 90000);
ut_a(strlen(buf) < 99000);
printf("%s", buf);
mem_free(buf);
} }
mutex_enter(&srv_monitor_file_mutex);
rewind(srv_monitor_file);
srv_printf_innodb_monitor(srv_monitor_file);
mutex_exit(&srv_monitor_file_mutex);
if (srv_print_innodb_tablespace_monitor if (srv_print_innodb_tablespace_monitor
&& difftime(current_time, last_table_monitor_time) > 60) { && difftime(current_time, last_table_monitor_time) > 60) {
last_table_monitor_time = time(NULL); last_table_monitor_time = time(NULL);
printf("================================================\n"); fputs("================================================\n",
stderr);
ut_print_timestamp(stdout); ut_print_timestamp(stderr);
printf(" INNODB TABLESPACE MONITOR OUTPUT\n" fputs(" INNODB TABLESPACE MONITOR OUTPUT\n"
"================================================\n"); "================================================\n",
stderr);
fsp_print(0); fsp_print(0);
fprintf(stderr, "Validating tablespace\n"); fputs("Validating tablespace\n", stderr);
fsp_validate(0); fsp_validate(0);
fprintf(stderr, "Validation ok\n"); fputs("Validation ok\n"
printf("---------------------------------------\n" "---------------------------------------\n"
"END OF INNODB TABLESPACE MONITOR OUTPUT\n" "END OF INNODB TABLESPACE MONITOR OUTPUT\n"
"=======================================\n"); "=======================================\n",
stderr);
} }
if (srv_print_innodb_table_monitor if (srv_print_innodb_table_monitor
@ -1671,17 +1640,19 @@ loop:
last_table_monitor_time = time(NULL); last_table_monitor_time = time(NULL);
printf("===========================================\n"); fputs("===========================================\n", stderr);
ut_print_timestamp(stdout); ut_print_timestamp(stderr);
printf(" INNODB TABLE MONITOR OUTPUT\n" fputs(" INNODB TABLE MONITOR OUTPUT\n"
"===========================================\n"); "===========================================\n",
stderr);
dict_print(); dict_print();
printf("-----------------------------------\n" fputs("-----------------------------------\n"
"END OF INNODB TABLE MONITOR OUTPUT\n" "END OF INNODB TABLE MONITOR OUTPUT\n"
"==================================\n"); "==================================\n",
stderr);
} }
} }
@ -1740,8 +1711,11 @@ loop:
srv_lock_timeout_and_monitor_active = FALSE; srv_lock_timeout_and_monitor_active = FALSE;
#if 0
/* The following synchronisation is disabled, since
the InnoDB monitor output is to be updated every 15 seconds. */
os_event_wait(srv_lock_timeout_thread_event); os_event_wait(srv_lock_timeout_thread_event);
#endif
goto loop; goto loop;
exit_func: exit_func:
@ -1777,7 +1751,7 @@ srv_error_monitor_thread(
ulint cnt = 0; ulint cnt = 0;
#ifdef UNIV_DEBUG_THREAD_CREATION #ifdef UNIV_DEBUG_THREAD_CREATION
printf("Error monitor thread starts, id %lu\n", fprintf(stderr, "Error monitor thread starts, id %lu\n",
os_thread_pf(os_thread_get_curr_id())); os_thread_pf(os_thread_get_curr_id()));
#endif #endif
loop: loop:
@ -1796,11 +1770,10 @@ loop:
sync_array_print_long_waits(); sync_array_print_long_waits();
/* Flush stdout and stderr so that a database user gets their output /* Flush stderr so that a database user gets the output
to possible MySQL error file */ to possible MySQL error file */
fflush(stderr); fflush(stderr);
fflush(stdout);
if (srv_shutdown_state < SRV_SHUTDOWN_LAST_PHASE) { if (srv_shutdown_state < SRV_SHUTDOWN_LAST_PHASE) {
@ -1892,7 +1865,7 @@ srv_master_thread(
ulint i; ulint i;
#ifdef UNIV_DEBUG_THREAD_CREATION #ifdef UNIV_DEBUG_THREAD_CREATION
printf("Master thread starts, id %lu\n", fprintf(stderr, "Master thread starts, id %lu\n",
os_thread_pf(os_thread_get_curr_id())); os_thread_pf(os_thread_get_curr_id()));
#endif #endif
srv_main_thread_process_no = os_proc_get_number(); srv_main_thread_process_no = os_proc_get_number();

View File

@ -55,13 +55,13 @@ Created 2/16/1996 Heikki Tuuri
#include "srv0start.h" #include "srv0start.h"
#include "que0que.h" #include "que0que.h"
ibool srv_start_has_been_called = FALSE; static ibool srv_start_has_been_called = FALSE;
ulint srv_sizeof_trx_t_in_ha_innodb_cc; ulint srv_sizeof_trx_t_in_ha_innodb_cc;
ibool srv_startup_is_before_trx_rollback_phase = FALSE; ibool srv_startup_is_before_trx_rollback_phase = FALSE;
ibool srv_is_being_started = FALSE; ibool srv_is_being_started = FALSE;
ibool srv_was_started = FALSE; static ibool srv_was_started = FALSE;
/* At a shutdown the value first climbs to SRV_SHUTDOWN_CLEANUP /* At a shutdown the value first climbs to SRV_SHUTDOWN_CLEANUP
and then to SRV_SHUTDOWN_LAST_PHASE */ and then to SRV_SHUTDOWN_LAST_PHASE */
@ -69,19 +69,20 @@ ulint srv_shutdown_state = 0;
ibool measure_cont = FALSE; ibool measure_cont = FALSE;
os_file_t files[1000]; static os_file_t files[1000];
mutex_t ios_mutex; static mutex_t ios_mutex;
ulint ios; static ulint ios;
ulint n[SRV_MAX_N_IO_THREADS + 5]; static ulint n[SRV_MAX_N_IO_THREADS + 5];
os_thread_id_t thread_ids[SRV_MAX_N_IO_THREADS + 5]; static os_thread_id_t thread_ids[SRV_MAX_N_IO_THREADS + 5];
/* We use this mutex to test the return value of pthread_mutex_trylock /* We use this mutex to test the return value of pthread_mutex_trylock
on successful locking. HP-UX does NOT return 0, though Linux et al do. */ on successful locking. HP-UX does NOT return 0, though Linux et al do. */
os_fast_mutex_t srv_os_test_mutex; static os_fast_mutex_t srv_os_test_mutex;
ibool srv_os_test_mutex_is_locked = FALSE; /* Name of srv_monitor_file */
static char* srv_monitor_file_name;
#define SRV_N_PENDING_IOS_PER_THREAD OS_AIO_N_PENDING_IOS_PER_THREAD #define SRV_N_PENDING_IOS_PER_THREAD OS_AIO_N_PENDING_IOS_PER_THREAD
#define SRV_MAX_N_PENDING_SYNC_IOS 100 #define SRV_MAX_N_PENDING_SYNC_IOS 100
@ -400,7 +401,7 @@ io_handler_thread(
segment = *((ulint*)arg); segment = *((ulint*)arg);
#ifdef UNIV_DEBUG_THREAD_CREATION #ifdef UNIV_DEBUG_THREAD_CREATION
printf("Io handler thread %lu starts, id %lu\n", segment, fprintf(stderr, "Io handler thread %lu starts, id %lu\n", segment,
os_thread_pf(os_thread_get_curr_id())); os_thread_pf(os_thread_get_curr_id()));
#endif #endif
for (i = 0;; i++) { for (i = 0;; i++) {
@ -532,6 +533,8 @@ open_or_create_log_file(
srv_log_group_home_dirs[k] = srv_add_path_separator_if_needed( srv_log_group_home_dirs[k] = srv_add_path_separator_if_needed(
srv_log_group_home_dirs[k]); srv_log_group_home_dirs[k]);
ut_a(strlen(srv_log_group_home_dirs[k]) <
(sizeof name) - 10 - sizeof "ib_logfile");
sprintf(name, "%s%s%lu", srv_log_group_home_dirs[k], "ib_logfile", i); sprintf(name, "%s%s%lu", srv_log_group_home_dirs[k], "ib_logfile", i);
files[i] = os_file_create(name, OS_FILE_CREATE, OS_FILE_NORMAL, files[i] = os_file_create(name, OS_FILE_CREATE, OS_FILE_NORMAL,
@ -680,6 +683,8 @@ open_or_create_data_files(
for (i = 0; i < srv_n_data_files; i++) { for (i = 0; i < srv_n_data_files; i++) {
srv_normalize_path_for_win(srv_data_file_names[i]); srv_normalize_path_for_win(srv_data_file_names[i]);
ut_a(strlen(srv_data_home) + strlen(srv_data_file_names[i])
< (sizeof name) - 1);
sprintf(name, "%s%s", srv_data_home, srv_data_file_names[i]); sprintf(name, "%s%s", srv_data_home, srv_data_file_names[i]);
files[i] = os_file_create(name, OS_FILE_CREATE, files[i] = os_file_create(name, OS_FILE_CREATE,
@ -1016,6 +1021,19 @@ NetWare. */
return((int) err); return((int) err);
} }
mutex_create(&srv_monitor_file_mutex);
srv_monitor_file_name = mem_alloc(
strlen(fil_path_to_mysql_datadir) +
20 + sizeof "/innodb_status.");
sprintf(srv_monitor_file_name, "%s/innodb.status.%lu",
fil_path_to_mysql_datadir, os_proc_get_number());
srv_monitor_file = fopen(srv_monitor_file_name, "w+");
if (!srv_monitor_file) {
fprintf(stderr, "InnoDB: unable to create %s: %s\n",
srv_monitor_file_name, strerror(errno));
return(DB_ERROR);
}
/* Restrict the maximum number of file i/o threads */ /* Restrict the maximum number of file i/o threads */
if (srv_n_file_io_threads > SRV_MAX_N_IO_THREADS) { if (srv_n_file_io_threads > SRV_MAX_N_IO_THREADS) {
@ -1505,6 +1523,15 @@ innobase_shutdown_for_mysql(void)
os_thread_count); os_thread_count);
} }
if (srv_monitor_file) {
fclose(srv_monitor_file);
srv_monitor_file = 0;
unlink(srv_monitor_file_name);
mem_free(srv_monitor_file_name);
}
mutex_free(&srv_monitor_file_mutex);
/* 3. Free all InnoDB's own mutexes and the os_fast_mutexes inside /* 3. Free all InnoDB's own mutexes and the os_fast_mutexes inside
them */ them */
@ -1531,6 +1558,13 @@ innobase_shutdown_for_mysql(void)
os_fast_mutex_count); os_fast_mutex_count);
} }
if (dict_foreign_err_file) {
fclose(dict_foreign_err_file);
}
if (lock_latest_err_file) {
fclose(lock_latest_err_file);
}
if (srv_print_verbose_log) { if (srv_print_verbose_log) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, " InnoDB: Shutdown completed\n"); fprintf(stderr, " InnoDB: Shutdown completed\n");

View File

@ -425,7 +425,7 @@ sync_array_wait_event(
if (TRUE == sync_array_detect_deadlock(arr, cell, cell, 0)) { if (TRUE == sync_array_detect_deadlock(arr, cell, cell, 0)) {
printf("########################################\n"); fputs("########################################\n", stderr);
ut_error; ut_error;
} }
@ -444,8 +444,7 @@ static
void void
sync_array_cell_print( sync_array_cell_print(
/*==================*/ /*==================*/
char* buf, /* in: buffer where to print, must be FILE* file, /* in: file where to print */
at least 400 characters */
sync_cell_t* cell) /* in: sync cell */ sync_cell_t* cell) /* in: sync cell */
{ {
mutex_t* mutex; mutex_t* mutex;
@ -455,7 +454,7 @@ sync_array_cell_print(
type = cell->request_type; type = cell->request_type;
buf += sprintf(buf, fprintf(file,
"--Thread %lu has waited at %s line %lu for %.2f seconds the semaphore:\n", "--Thread %lu has waited at %s line %lu for %.2f seconds the semaphore:\n",
os_thread_pf(cell->thread), cell->file, cell->line, os_thread_pf(cell->thread), cell->file, cell->line,
difftime(time(NULL), cell->reservation_time)); difftime(time(NULL), cell->reservation_time));
@ -465,7 +464,7 @@ sync_array_cell_print(
been freed meanwhile */ been freed meanwhile */
mutex = cell->old_wait_mutex; mutex = cell->old_wait_mutex;
buf += sprintf(buf, fprintf(file,
"Mutex at %p created file %s line %lu, lock var %lu\n" "Mutex at %p created file %s line %lu, lock var %lu\n"
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
"Last time reserved in file %s line %lu, " "Last time reserved in file %s line %lu, "
@ -480,48 +479,39 @@ sync_array_cell_print(
} else if (type == RW_LOCK_EX || type == RW_LOCK_SHARED) { } else if (type == RW_LOCK_EX || type == RW_LOCK_SHARED) {
if (type == RW_LOCK_EX) { fputs(type == RW_LOCK_EX ? "X-lock on" : "S-lock on", file);
buf += sprintf(buf, "X-lock on");
} else {
buf += sprintf(buf, "S-lock on");
}
rwlock = cell->old_wait_rw_lock; rwlock = cell->old_wait_rw_lock;
buf += sprintf(buf, fprintf(file,
" RW-latch at %lx created in file %s line %lu\n", " RW-latch at %p created in file %s line %lu\n",
(ulint)rwlock, rwlock->cfile_name, rwlock->cline); rwlock, rwlock->cfile_name, rwlock->cline);
if (rwlock->writer != RW_LOCK_NOT_LOCKED) { if (rwlock->writer != RW_LOCK_NOT_LOCKED) {
buf += sprintf(buf, fprintf(file,
"a writer (thread id %lu) has reserved it in mode", "a writer (thread id %lu) has reserved it in mode %s",
os_thread_pf(rwlock->writer_thread)); os_thread_pf(rwlock->writer_thread),
if (rwlock->writer == RW_LOCK_EX) { rwlock->writer == RW_LOCK_EX
buf += sprintf(buf, " exclusive\n"); ? " exclusive\n"
} else { : " wait exclusive\n");
buf += sprintf(buf, " wait exclusive\n");
}
} }
buf += sprintf(buf, fprintf(file,
"number of readers %lu, waiters flag %lu\n", "number of readers %lu, waiters flag %lu\n"
rwlock->reader_count, rwlock->waiters); "Last time read locked in file %s line %lu\n"
buf += sprintf(buf,
"Last time read locked in file %s line %lu\n",
rwlock->last_s_file_name, rwlock->last_s_line);
buf += sprintf(buf,
"Last time write locked in file %s line %lu\n", "Last time write locked in file %s line %lu\n",
rwlock->reader_count, rwlock->waiters,
rwlock->last_s_file_name, rwlock->last_s_line,
rwlock->last_x_file_name, rwlock->last_x_line); rwlock->last_x_file_name, rwlock->last_x_line);
} else { } else {
ut_error; ut_error;
} }
if (!cell->waiting) { if (!cell->waiting) {
buf += sprintf(buf, "wait has ended\n"); fputs("wait has ended\n", file);
} }
if (cell->event_set) { if (cell->event_set) {
buf += sprintf(buf, "wait is ending\n"); fputs("wait is ending\n", file);
} }
} }
@ -590,8 +580,8 @@ sync_array_deadlock_step(
ut_dbg_stop_threads = TRUE; ut_dbg_stop_threads = TRUE;
/* Deadlock */ /* Deadlock */
printf("########################################\n"); fputs("########################################\n"
printf("DEADLOCK of threads detected!\n"); "DEADLOCK of threads detected!\n", stderr);
return(TRUE); return(TRUE);
@ -623,8 +613,8 @@ sync_array_detect_deadlock(
rw_lock_t* lock; rw_lock_t* lock;
os_thread_id_t thread; os_thread_id_t thread;
ibool ret; ibool ret;
rw_lock_t* lock;
rw_lock_debug_t*debug; rw_lock_debug_t*debug;
char buf[500];
ut_a(arr && start && cell); ut_a(arr && start && cell);
ut_ad(cell->wait_object); ut_ad(cell->wait_object);
@ -657,11 +647,11 @@ sync_array_detect_deadlock(
ret = sync_array_deadlock_step(arr, start, thread, 0, ret = sync_array_deadlock_step(arr, start, thread, 0,
depth); depth);
if (ret) { if (ret) {
sync_array_cell_print(buf, cell); fprintf(stderr,
printf( "Mutex %p owned by thread %lu file %s line %lu\n",
"Mutex %lx owned by thread %lu file %s line %lu\n%s", mutex, os_thread_pf(mutex->thread_id),
(ulint)mutex, os_thread_pf(mutex->thread_id), mutex->file_name, mutex->line);
mutex->file_name, mutex->line, buf); sync_array_cell_print(stderr, cell);
return(TRUE); return(TRUE);
} }
@ -694,8 +684,9 @@ sync_array_detect_deadlock(
debug->pass, debug->pass,
depth); depth);
if (ret) { if (ret) {
sync_array_cell_print(buf, cell); print:
printf("rw-lock %lx %s ", (ulint) lock, buf); fprintf(stderr, "rw-lock %p ", lock);
sync_array_cell_print(stderr, cell);
rw_lock_debug_print(debug); rw_lock_debug_print(debug);
return(TRUE); return(TRUE);
} }
@ -726,11 +717,7 @@ sync_array_detect_deadlock(
debug->pass, debug->pass,
depth); depth);
if (ret) { if (ret) {
sync_array_cell_print(buf, cell); goto print;
printf("rw-lock %lx %s ", (ulint) lock, buf);
rw_lock_debug_print(debug);
return(TRUE);
} }
} }
@ -914,7 +901,6 @@ sync_array_print_long_waits(void)
sync_cell_t* cell; sync_cell_t* cell;
ibool old_val; ibool old_val;
ibool noticed = FALSE; ibool noticed = FALSE;
char buf[500];
ulint i; ulint i;
for (i = 0; i < sync_primary_wait_array->n_cells; i++) { for (i = 0; i < sync_primary_wait_array->n_cells; i++) {
@ -923,22 +909,19 @@ sync_array_print_long_waits(void)
if (cell->wait_object != NULL if (cell->wait_object != NULL
&& difftime(time(NULL), cell->reservation_time) > 240) { && difftime(time(NULL), cell->reservation_time) > 240) {
fputs("InnoDB: Warning: a long semaphore wait:\n",
sync_array_cell_print(buf, cell); stderr);
sync_array_cell_print(stderr, cell);
fprintf(stderr,
"InnoDB: Warning: a long semaphore wait:\n%s", buf);
noticed = TRUE; noticed = TRUE;
} }
if (cell->wait_object != NULL if (cell->wait_object != NULL
&& difftime(time(NULL), cell->reservation_time) > 600) { && difftime(time(NULL), cell->reservation_time) > 600) {
fprintf(stderr, fputs(
"InnoDB: Error: semaphore wait has lasted > 600 seconds\n" "InnoDB: Error: semaphore wait has lasted > 600 seconds\n"
"InnoDB: We intentionally crash the server, because it appears to be hung.\n" "InnoDB: We intentionally crash the server, because it appears to be hung.\n",
); stderr);
ut_error; ut_error;
} }
@ -966,7 +949,7 @@ sync_array_print_long_waits(void)
srv_print_innodb_monitor = old_val; srv_print_innodb_monitor = old_val;
fprintf(stderr, fprintf(stderr,
"InnoDB: ###### Diagnostic info printed to the standard output\n"); "InnoDB: ###### Diagnostic info printed to the standard error stream\n");
} }
} }
@ -976,8 +959,7 @@ static
void void
sync_array_output_info( sync_array_output_info(
/*===================*/ /*===================*/
char* buf, /* in/out: buffer where to print */ FILE* file, /* in: file where to print */
char* buf_end,/* in: buffer end */
sync_array_t* arr) /* in: wait array; NOTE! caller must own the sync_array_t* arr) /* in: wait array; NOTE! caller must own the
mutex */ mutex */
{ {
@ -985,11 +967,7 @@ sync_array_output_info(
ulint count; ulint count;
ulint i; ulint i;
if (buf_end - buf < 500) { fprintf(file,
return;
}
buf += sprintf(buf,
"OS WAIT ARRAY INFO: reservation count %ld, signal count %ld\n", "OS WAIT ARRAY INFO: reservation count %ld, signal count %ld\n",
arr->res_count, arr->sg_count); arr->res_count, arr->sg_count);
i = 0; i = 0;
@ -997,17 +975,11 @@ sync_array_output_info(
while (count < arr->n_reserved) { while (count < arr->n_reserved) {
if (buf_end - buf < 500) {
return;
}
cell = sync_array_get_nth_cell(arr, i); cell = sync_array_get_nth_cell(arr, i);
if (cell->wait_object != NULL) { if (cell->wait_object != NULL) {
count++; count++;
sync_array_cell_print(buf, cell); sync_array_cell_print(file, cell);
buf = buf + strlen(buf);
} }
i++; i++;
@ -1020,13 +992,12 @@ Prints info of the wait array. */
void void
sync_array_print_info( sync_array_print_info(
/*==================*/ /*==================*/
char* buf, /* in/out: buffer where to print */ FILE* file, /* in: file where to print */
char* buf_end,/* in: buffer end */
sync_array_t* arr) /* in: wait array */ sync_array_t* arr) /* in: wait array */
{ {
sync_array_enter(arr); sync_array_enter(arr);
sync_array_output_info(buf, buf_end, arr); sync_array_output_info(file, arr);
sync_array_exit(arr); sync_array_exit(arr);
} }

View File

@ -225,9 +225,9 @@ lock_loop:
} }
if (srv_print_latch_waits) { if (srv_print_latch_waits) {
printf( fprintf(stderr,
"Thread %lu spin wait rw-s-lock at %lx cfile %s cline %lu rnds %lu\n", "Thread %lu spin wait rw-s-lock at %p cfile %s cline %lu rnds %lu\n",
os_thread_pf(os_thread_get_curr_id()), (ulint)lock, os_thread_pf(os_thread_get_curr_id()), lock,
lock->cfile_name, lock->cline, i); lock->cfile_name, lock->cline, i);
} }
@ -255,9 +255,9 @@ lock_loop:
mutex_exit(rw_lock_get_mutex(lock)); mutex_exit(rw_lock_get_mutex(lock));
if (srv_print_latch_waits) { if (srv_print_latch_waits) {
printf( fprintf(stderr,
"Thread %lu OS wait rw-s-lock at %lx cfile %s cline %lu\n", "Thread %lu OS wait rw-s-lock at %p cfile %s cline %lu\n",
os_thread_pf(os_thread_get_curr_id()), (ulint)lock, os_thread_pf(os_thread_get_curr_id()), lock,
lock->cfile_name, lock->cline); lock->cfile_name, lock->cline);
} }
@ -474,9 +474,9 @@ lock_loop:
} }
if (srv_print_latch_waits) { if (srv_print_latch_waits) {
printf( fprintf(stderr,
"Thread %lu spin wait rw-x-lock at %lx cfile %s cline %lu rnds %lu\n", "Thread %lu spin wait rw-x-lock at %p cfile %s cline %lu rnds %lu\n",
os_thread_pf(os_thread_get_curr_id()), (ulint)lock, os_thread_pf(os_thread_get_curr_id()), lock,
lock->cfile_name, lock->cline, i); lock->cfile_name, lock->cline, i);
} }
@ -507,9 +507,9 @@ lock_loop:
mutex_exit(rw_lock_get_mutex(lock)); mutex_exit(rw_lock_get_mutex(lock));
if (srv_print_latch_waits) { if (srv_print_latch_waits) {
printf( fprintf(stderr,
"Thread %lu OS wait for rw-x-lock at %lx cfile %s cline %lu\n", "Thread %lu OS wait for rw-x-lock at %p cfile %s cline %lu\n",
os_thread_pf(os_thread_get_curr_id()), (ulint)lock, os_thread_pf(os_thread_get_curr_id()), lock,
lock->cfile_name, lock->cline); lock->cfile_name, lock->cline);
} }
@ -752,9 +752,9 @@ rw_lock_list_print_info(void)
mutex_enter(&rw_lock_list_mutex); mutex_enter(&rw_lock_list_mutex);
printf("-------------\n"); fputs("-------------\n"
printf("RW-LATCH INFO\n"); "RW-LATCH INFO\n"
printf("-------------\n"); "-------------\n", stderr);
lock = UT_LIST_GET_FIRST(rw_lock_list); lock = UT_LIST_GET_FIRST(rw_lock_list);
@ -768,12 +768,12 @@ rw_lock_list_print_info(void)
|| (rw_lock_get_reader_count(lock) != 0) || (rw_lock_get_reader_count(lock) != 0)
|| (rw_lock_get_waiters(lock) != 0)) { || (rw_lock_get_waiters(lock) != 0)) {
printf("RW-LOCK: %lx ", (ulint)lock); fprintf(stderr, "RW-LOCK: %p ", lock);
if (rw_lock_get_waiters(lock)) { if (rw_lock_get_waiters(lock)) {
printf(" Waiters for the lock exist\n"); fputs(" Waiters for the lock exist\n", stderr);
} else { } else {
printf("\n"); putc('\n', stderr);
} }
info = UT_LIST_GET_FIRST(lock->debug_list); info = UT_LIST_GET_FIRST(lock->debug_list);
@ -787,7 +787,7 @@ rw_lock_list_print_info(void)
lock = UT_LIST_GET_NEXT(list, lock); lock = UT_LIST_GET_NEXT(list, lock);
} }
printf("Total number of rw-locks %ld\n", count); fprintf(stderr, "Total number of rw-locks %ld\n", count);
mutex_exit(&rw_lock_list_mutex); mutex_exit(&rw_lock_list_mutex);
} }
@ -797,22 +797,23 @@ Prints debug info of an rw-lock. */
void void
rw_lock_print( rw_lock_print(
/*==========*/ /*==========*/
rw_lock_t* lock __attribute__((unused))) /* in: rw-lock */ rw_lock_t* lock) /* in: rw-lock */
{ {
rw_lock_debug_t* info; rw_lock_debug_t* info;
printf("-------------\n"); fprintf(stderr,
printf("RW-LATCH INFO\n"); "-------------\n"
printf("RW-LATCH: %lx ", (ulint)lock); "RW-LATCH INFO\n"
"RW-LATCH: %p ", lock);
if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED) if ((rw_lock_get_writer(lock) != RW_LOCK_NOT_LOCKED)
|| (rw_lock_get_reader_count(lock) != 0) || (rw_lock_get_reader_count(lock) != 0)
|| (rw_lock_get_waiters(lock) != 0)) { || (rw_lock_get_waiters(lock) != 0)) {
if (rw_lock_get_waiters(lock)) { if (rw_lock_get_waiters(lock)) {
printf(" Waiters for the lock exist\n"); fputs(" Waiters for the lock exist\n", stderr);
} else { } else {
printf("\n"); putc('\n', stderr);
} }
info = UT_LIST_GET_FIRST(lock->debug_list); info = UT_LIST_GET_FIRST(lock->debug_list);
@ -835,21 +836,21 @@ rw_lock_debug_print(
rwt = info->lock_type; rwt = info->lock_type;
printf("Locked: thread %ld file %s line %ld ", fprintf(stderr, "Locked: thread %ld file %s line %ld ",
os_thread_pf(info->thread_id), info->file_name, info->line); os_thread_pf(info->thread_id), info->file_name, info->line);
if (rwt == RW_LOCK_SHARED) { if (rwt == RW_LOCK_SHARED) {
printf("S-LOCK"); fputs("S-LOCK", stderr);
} else if (rwt == RW_LOCK_EX) { } else if (rwt == RW_LOCK_EX) {
printf("X-LOCK"); fputs("X-LOCK", stderr);
} else if (rwt == RW_LOCK_WAIT_EX) { } else if (rwt == RW_LOCK_WAIT_EX) {
printf("WAIT X-LOCK"); fputs("WAIT X-LOCK", stderr);
} else { } else {
ut_error; ut_error;
} }
if (info->pass != 0) { if (info->pass != 0) {
printf(" pass value %lu", info->pass); fprintf(stderr, " pass value %lu", info->pass);
} }
printf("\n"); putc('\n', stderr);
} }
/******************************************************************* /*******************************************************************

View File

@ -352,9 +352,9 @@ spin_loop:
} }
if (srv_print_latch_waits) { if (srv_print_latch_waits) {
printf( fprintf(stderr,
"Thread %lu spin wait mutex at %lx cfile %s cline %lu rnds %lu\n", "Thread %lu spin wait mutex at %p cfile %s cline %lu rnds %lu\n",
os_thread_pf(os_thread_get_curr_id()), (ulint)mutex, os_thread_pf(os_thread_get_curr_id()), mutex,
mutex->cfile_name, mutex->cline, i); mutex->cfile_name, mutex->cline, i);
} }
@ -412,9 +412,10 @@ spin_loop:
#endif #endif
if (srv_print_latch_waits) { if (srv_print_latch_waits) {
printf( fprintf(stderr,
"Thread %lu spin wait succeeds at 2: mutex at %lx\n", "Thread %lu spin wait succeeds at 2:"
os_thread_pf(os_thread_get_curr_id()), (ulint)mutex); " mutex at %p\n",
os_thread_pf(os_thread_get_curr_id()), mutex);
} }
return; return;
@ -430,9 +431,9 @@ spin_loop:
Now there is no risk of infinite wait on the event. */ Now there is no risk of infinite wait on the event. */
if (srv_print_latch_waits) { if (srv_print_latch_waits) {
printf( fprintf(stderr,
"Thread %lu OS wait mutex at %lx cfile %s cline %lu rnds %lu\n", "Thread %lu OS wait mutex at %p cfile %s cline %lu rnds %lu\n",
os_thread_pf(os_thread_get_curr_id()), (ulint)mutex, os_thread_pf(os_thread_get_curr_id()), mutex,
mutex->cfile_name, mutex->cline, i); mutex->cfile_name, mutex->cline, i);
} }
@ -552,9 +553,9 @@ mutex_list_print_info(void)
os_thread_id_t thread_id; os_thread_id_t thread_id;
ulint count = 0; ulint count = 0;
printf("----------\n"); fputs("----------\n"
printf("MUTEX INFO\n"); "MUTEX INFO\n"
printf("----------\n"); "----------\n", stderr);
mutex_enter(&mutex_list_mutex); mutex_enter(&mutex_list_mutex);
@ -566,16 +567,16 @@ mutex_list_print_info(void)
if (mutex_get_lock_word(mutex) != 0) { if (mutex_get_lock_word(mutex) != 0) {
mutex_get_debug_info(mutex, &file_name, &line, mutex_get_debug_info(mutex, &file_name, &line,
&thread_id); &thread_id);
printf( fprintf(stderr,
"Locked mutex: addr %lx thread %ld file %s line %ld\n", "Locked mutex: addr %p thread %ld file %s line %ld\n",
(ulint)mutex, os_thread_pf(thread_id), mutex, os_thread_pf(thread_id),
file_name, line); file_name, line);
} }
mutex = UT_LIST_GET_NEXT(list, mutex); mutex = UT_LIST_GET_NEXT(list, mutex);
} }
printf("Total number of mutexes %ld\n", count); fprintf(stderr, "Total number of mutexes %ld\n", count);
mutex_exit(&mutex_list_mutex); mutex_exit(&mutex_list_mutex);
} }
@ -733,12 +734,14 @@ sync_thread_levels_g(
lock = slot->latch; lock = slot->latch;
mutex = slot->latch; mutex = slot->latch;
printf( fprintf(stderr,
"InnoDB error: sync levels should be > %lu but a level is %lu\n", "InnoDB error: sync levels should be > %lu but a level is %lu\n",
limit, slot->level); limit, slot->level);
if (mutex->magic_n == MUTEX_MAGIC_N) { if (mutex->magic_n == MUTEX_MAGIC_N) {
printf("Mutex created at %s %lu\n", mutex->cfile_name, fprintf(stderr,
"Mutex created at %s %lu\n",
mutex->cfile_name,
mutex->cline); mutex->cline);
if (mutex_get_lock_word(mutex) != 0) { if (mutex_get_lock_word(mutex) != 0) {
@ -819,9 +822,6 @@ sync_thread_levels_empty_gen(
sync_level_t* arr; sync_level_t* arr;
sync_thread_t* thread_slot; sync_thread_t* thread_slot;
sync_level_t* slot; sync_level_t* slot;
rw_lock_t* lock;
mutex_t* mutex;
char* buf;
ulint i; ulint i;
if (!sync_order_checks_on) { if (!sync_order_checks_on) {
@ -850,13 +850,7 @@ sync_thread_levels_empty_gen(
(slot->level != SYNC_DICT (slot->level != SYNC_DICT
&& slot->level != SYNC_DICT_OPERATION))) { && slot->level != SYNC_DICT_OPERATION))) {
lock = slot->latch;
mutex = slot->latch;
mutex_exit(&sync_thread_mutex); mutex_exit(&sync_thread_mutex);
buf = mem_alloc(20000);
sync_print(buf, buf + 18000);
ut_error; ut_error;
return(FALSE); return(FALSE);
@ -1211,19 +1205,14 @@ Prints wait info of the sync system. */
void void
sync_print_wait_info( sync_print_wait_info(
/*=================*/ /*=================*/
char* buf, /* in/out: buffer where to print */ FILE* file) /* in: file where to print */
char* buf_end) /* in: buffer end */
{ {
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
printf("Mutex exits %lu, rws exits %lu, rwx exits %lu\n", fprintf(stderr, "Mutex exits %lu, rws exits %lu, rwx exits %lu\n",
mutex_exit_count, rw_s_exit_count, rw_x_exit_count); mutex_exit_count, rw_s_exit_count, rw_x_exit_count);
#endif #endif
if (buf_end - buf < 500) {
return; fprintf(file,
}
sprintf(buf,
"Mutex spin waits %lu, rounds %lu, OS waits %lu\n" "Mutex spin waits %lu, rounds %lu, OS waits %lu\n"
"RW-shared spins %lu, OS waits %lu; RW-excl spins %lu, OS waits %lu\n", "RW-shared spins %lu, OS waits %lu; RW-excl spins %lu, OS waits %lu\n",
mutex_spin_wait_count, mutex_spin_round_count, mutex_spin_wait_count, mutex_spin_round_count,
@ -1238,8 +1227,7 @@ Prints info of the sync system. */
void void
sync_print( sync_print(
/*=======*/ /*=======*/
char* buf, /* in/out: buffer where to print */ FILE* file) /* in: file where to print */
char* buf_end) /* in: buffer end */
{ {
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
mutex_list_print_info(); mutex_list_print_info();
@ -1247,9 +1235,7 @@ sync_print(
rw_lock_list_print_info(); rw_lock_list_print_info();
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
sync_array_print_info(buf, buf_end, sync_primary_wait_array); sync_array_print_info(file, sync_primary_wait_array);
buf = buf + strlen(buf); sync_print_wait_info(file);
sync_print_wait_info(buf, buf_end);
} }

View File

@ -337,7 +337,7 @@ trx_purge_free_segment(
ibool marked = FALSE; ibool marked = FALSE;
mtr_t mtr; mtr_t mtr;
/* printf("Freeing an update undo log segment\n"); */ /* fputs("Freeing an update undo log segment\n", stderr); */
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&(purge_sys->mutex))); ut_ad(mutex_own(&(purge_sys->mutex)));
@ -918,7 +918,7 @@ trx_purge_fetch_next_rec(
trx_purge_truncate_if_arr_empty(); trx_purge_truncate_if_arr_empty();
if (srv_print_thread_releases) { if (srv_print_thread_releases) {
printf( fprintf(stderr,
"Purge: No logs left in the history list; pages handled %lu\n", "Purge: No logs left in the history list; pages handled %lu\n",
purge_sys->n_pages_handled); purge_sys->n_pages_handled);
} }
@ -951,7 +951,7 @@ trx_purge_fetch_next_rec(
return(NULL); return(NULL);
} }
/* printf("Thread %lu purging trx %lu undo record %lu\n", /* fprintf(stderr, "Thread %lu purging trx %lu undo record %lu\n",
os_thread_get_curr_id(), os_thread_get_curr_id(),
ut_dulint_get_low(purge_sys->purge_trx_no), ut_dulint_get_low(purge_sys->purge_trx_no),
ut_dulint_get_low(purge_sys->purge_undo_no)); */ ut_dulint_get_low(purge_sys->purge_undo_no)); */
@ -1064,14 +1064,14 @@ trx_purge(void)
if (srv_print_thread_releases) { if (srv_print_thread_releases) {
printf("Starting purge\n"); fputs("Starting purge\n", stderr);
} }
que_run_threads(thr); que_run_threads(thr);
if (srv_print_thread_releases) { if (srv_print_thread_releases) {
printf( fprintf(stderr,
"Purge ends; pages handled %lu\n", purge_sys->n_pages_handled); "Purge ends; pages handled %lu\n", purge_sys->n_pages_handled);
} }

View File

@ -823,17 +823,18 @@ trx_undo_update_rec_get_update(
if (field_no >= dict_index_get_n_fields(index)) { if (field_no >= dict_index_get_n_fields(index)) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: trying to access update undo rec field %lu in table %s\n" "InnoDB: Error: trying to access"
"InnoDB: index %s, but index has only %lu fields\n", " update undo rec field %lu in ", field_no);
field_no, index->table_name, index->name, dict_index_name_print(stderr, index);
fprintf(stderr, "\n"
"InnoDB: but index has only %lu fields\n"
"InnoDB: Send a detailed bug report to mysql@lists.mysql.com\n"
"InnoDB: Run also CHECK TABLE ",
dict_index_get_n_fields(index)); dict_index_get_n_fields(index));
fprintf(stderr, ut_print_name(stderr, index->table_name);
"InnoDB: Send a detailed bug report to mysql@lists.mysql.com"); fprintf(stderr, "\n"
"InnoDB: n_fields = %lu, i = %lu, ptr %p\n",
fprintf(stderr, n_fields, i, ptr);
"InnoDB: Run also CHECK TABLE on table %s\n", index->table_name);
fprintf(stderr,
"InnoDB: n_fields = %lu, i = %lu, ptr %lx\n", n_fields, i, (ulint)ptr);
return(NULL); return(NULL);
} }
@ -1258,8 +1259,6 @@ trx_undo_prev_version_build(
byte* buf; byte* buf;
ulint err; ulint err;
ulint i; ulint i;
char err_buf[1000];
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
ut_ad(rw_lock_own(&(purge_sys->latch), RW_LOCK_SHARED)); ut_ad(rw_lock_own(&(purge_sys->latch), RW_LOCK_SHARED));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
@ -1268,19 +1267,18 @@ trx_undo_prev_version_build(
mtr_memo_contains(index_mtr, buf_block_align(index_rec), mtr_memo_contains(index_mtr, buf_block_align(index_rec),
MTR_MEMO_PAGE_X_FIX)); MTR_MEMO_PAGE_X_FIX));
if (!(index->type & DICT_CLUSTERED)) { if (!(index->type & DICT_CLUSTERED)) {
fprintf(stderr, fputs("InnoDB: Error: trying to access"
"InnoDB: Error: trying to access update undo rec for table %s\n" " update undo rec for non-clustered ", stderr);
"InnoDB: index %s which is not a clustered index\n", dict_index_name_print(stderr, index);
index->table_name, index->name); fputs("\n"
fprintf(stderr, "InnoDB: Send a detailed bug report to"
"InnoDB: Send a detailed bug report to mysql@lists.mysql.com"); " mysql@lists.mysql.com\n"
"InnoDB: index record ", stderr);
rec_sprintf(err_buf, 900, index_rec); rec_print(stderr, index_rec);
fprintf(stderr, "InnoDB: index record %s\n", err_buf); fputs("\n"
"InnoDB: record version ", stderr);
rec_sprintf(err_buf, 900, rec); rec_print(stderr, rec);
fprintf(stderr, "InnoDB: record version %s\n", err_buf); putc('\n', stderr);
return(DB_ERROR); return(DB_ERROR);
} }
@ -1318,55 +1316,50 @@ trx_undo_prev_version_build(
if (ut_dulint_cmp(table_id, index->table->id) != 0) { if (ut_dulint_cmp(table_id, index->table->id) != 0) {
ptr = NULL; ptr = NULL;
fprintf(stderr, fputs("InnoDB: Error: trying to access"
"InnoDB: Error: trying to access update undo rec for table %s\n" " update undo rec for table ", stderr);
"InnoDB: but the table id in the undo record is wrong\n", ut_print_name(stderr, index->table_name);
index->table_name); fputs("\n"
fprintf(stderr, "InnoDB: but the table id in the"
"InnoDB: Send a detailed bug report to mysql@lists.mysql.com\n"); " undo record is wrong\n"
"InnoDB: Send a detailed bug report to "
fprintf(stderr, "mysql@lists.mysql.com\n"
"InnoDB: Run also CHECK TABLE on table %s\n", index->table_name); "InnoDB: Run also CHECK TABLE ", stderr);
ut_print_name(stderr, index->table_name);
putc('\n', stderr);
} }
if (ptr == NULL) { if (ptr == NULL) {
/* The record was corrupted, return an error; these printfs /* The record was corrupted, return an error; these printfs
should catch an elusive bug in row_vers_old_has_index_entry */ should catch an elusive bug in row_vers_old_has_index_entry */
fprintf(stderr, fputs("InnoDB: ", stderr);
"InnoDB: Table name %s, index name %s, n_uniq %lu\n", dict_index_name_print(stderr, index);
index->table_name, index->name, fprintf(stderr, ", n_uniq %lu\n"
dict_index_get_n_unique(index)); "InnoDB: undo rec address %p, type %lu cmpl_info %lu\n"
"InnoDB: undo rec table id %lu %lu, index table id %lu %lu\n"
fprintf(stderr, "InnoDB: dump of 150 bytes in undo rec: ",
"InnoDB: undo rec address %lx, type %lu cmpl_info %lu\n", dict_index_get_n_unique(index),
(ulint)undo_rec, type, cmpl_info); undo_rec, type, cmpl_info,
fprintf(stderr,
"InnoDB: undo rec table id %lu %lu, index table id %lu %lu\n",
ut_dulint_get_high(table_id), ut_dulint_get_high(table_id),
ut_dulint_get_low(table_id), ut_dulint_get_low(table_id),
ut_dulint_get_high(index->table->id), ut_dulint_get_high(index->table->id),
ut_dulint_get_low(index->table->id)); ut_dulint_get_low(index->table->id));
ut_sprintf_buf(err_buf, undo_rec, 150); ut_print_buf(stderr, undo_rec, 150);
fputs("\n"
fprintf(stderr, "InnoDB: dump of 150 bytes in undo rec: %s\n", "InnoDB: index record ", stderr);
err_buf); rec_print(stderr, index_rec);
rec_sprintf(err_buf, 900, index_rec); fputs("\n"
fprintf(stderr, "InnoDB: index record %s\n", err_buf); "InnoDB: record version ", stderr);
rec_print(stderr, rec);
rec_sprintf(err_buf, 900, rec); fprintf(stderr, "\n"
fprintf(stderr, "InnoDB: record version %s\n", err_buf); "InnoDB: Record trx id %lu %lu, update rec trx id %lu %lu\n"
"InnoDB: Roll ptr in rec %lu %lu, in update rec %lu %lu\n",
fprintf(stderr,
"InnoDB: Record trx id %lu %lu, update rec trx id %lu %lu\n",
ut_dulint_get_high(rec_trx_id), ut_dulint_get_high(rec_trx_id),
ut_dulint_get_low(rec_trx_id), ut_dulint_get_low(rec_trx_id),
ut_dulint_get_high(trx_id), ut_dulint_get_high(trx_id),
ut_dulint_get_low(trx_id)); ut_dulint_get_low(trx_id),
fprintf(stderr,
"InnoDB: Roll ptr in rec %lu %lu, in update rec %lu %lu\n",
ut_dulint_get_high(old_roll_ptr), ut_dulint_get_high(old_roll_ptr),
ut_dulint_get_low(old_roll_ptr), ut_dulint_get_low(old_roll_ptr),
ut_dulint_get_high(roll_ptr), ut_dulint_get_high(roll_ptr),

View File

@ -228,9 +228,9 @@ trx_rollback_to_savepoint_for_mysql(
if (trx->conc_state == TRX_NOT_STARTED) { if (trx->conc_state == TRX_NOT_STARTED) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fputs(" InnoDB: Error: transaction has a savepoint ", stderr);
" InnoDB: Error: transaction has a savepoint %s though it is not started\n", ut_print_name(stderr, savep->name);
savep->name); fputs(" though it is not started\n", stderr);
return(DB_ERROR); return(DB_ERROR);
} }
@ -466,8 +466,9 @@ loop:
table = dict_table_get_on_id_low(trx->table_id, trx); table = dict_table_get_on_id_low(trx->table_id, trx);
if (table) { if (table) {
fprintf(stderr, fputs("InnoDB: Table found: dropping table ", stderr);
"InnoDB: Table found: dropping table %s in recovery\n", table->name); ut_print_name(stderr, table->name);
fputs(" in recovery\n", stderr);
err = row_drop_table_for_mysql(table->name, trx, TRUE); err = row_drop_table_for_mysql(table->name, trx, TRUE);
@ -729,7 +730,7 @@ trx_roll_pop_top_rec(
undo->top_page_no, mtr); undo->top_page_no, mtr);
offset = undo->top_offset; offset = undo->top_offset;
/* printf("Thread %lu undoing trx %lu undo record %lu\n", /* fprintf(stderr, "Thread %lu undoing trx %lu undo record %lu\n",
os_thread_get_curr_id(), ut_dulint_get_low(trx->id), os_thread_get_curr_id(), ut_dulint_get_low(trx->id),
ut_dulint_get_low(undo->top_undo_no)); */ ut_dulint_get_low(undo->top_undo_no)); */
@ -1140,7 +1141,7 @@ trx_finish_rollback_off_kernel(
} }
if (lock_print_waits) { if (lock_print_waits) {
printf("Trx %lu rollback finished\n", fprintf(stderr, "Trx %lu rollback finished\n",
ut_dulint_get_low(trx->id)); ut_dulint_get_low(trx->id));
} }

View File

@ -600,7 +600,7 @@ trx_sys_update_mysql_binlog_offset(
} }
/********************************************************************* /*********************************************************************
Prints to stdout the MySQL binlog info in the system header if the Prints to stderr the MySQL binlog info in the system header if the
magic number shows it valid. */ magic number shows it valid. */
void void
@ -617,7 +617,7 @@ trx_sys_print_mysql_binlog_offset_from_page(
+ TRX_SYS_MYSQL_LOG_MAGIC_N_FLD) + TRX_SYS_MYSQL_LOG_MAGIC_N_FLD)
== TRX_SYS_MYSQL_LOG_MAGIC_N) { == TRX_SYS_MYSQL_LOG_MAGIC_N) {
printf( fprintf(stderr,
"ibbackup: Last MySQL binlog file position %lu %lu, file name %s\n", "ibbackup: Last MySQL binlog file position %lu %lu, file name %s\n",
mach_read_from_4(sys_header + TRX_SYS_MYSQL_LOG_INFO mach_read_from_4(sys_header + TRX_SYS_MYSQL_LOG_INFO
+ TRX_SYS_MYSQL_LOG_OFFSET_HIGH), + TRX_SYS_MYSQL_LOG_OFFSET_HIGH),

View File

@ -26,10 +26,10 @@ Created 3/26/1996 Heikki Tuuri
#include "os0proc.h" #include "os0proc.h"
/* Copy of the prototype for innobase_mysql_print_thd: this /* Copy of the prototype for innobase_mysql_print_thd: this
copy MUST be equal to the one in mysql/sql/ha_innobase.cc ! */ copy MUST be equal to the one in mysql/sql/ha_innodb.cc ! */
void innobase_mysql_print_thd( void innobase_mysql_print_thd(
char* buf, FILE* f,
void* thd); void* thd);
/* Dummy session used currently in MySQL interface */ /* Dummy session used currently in MySQL interface */
@ -239,19 +239,17 @@ trx_free(
/*=====*/ /*=====*/
trx_t* trx) /* in, own: trx object */ trx_t* trx) /* in, own: trx object */
{ {
char err_buf[1000];
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&kernel_mutex)); ut_ad(mutex_own(&kernel_mutex));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
if (trx->declared_to_be_inside_innodb) { if (trx->declared_to_be_inside_innodb) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
trx_print(err_buf, trx); fputs(
fprintf(stderr,
" InnoDB: Error: Freeing a trx which is declared to be processing\n" " InnoDB: Error: Freeing a trx which is declared to be processing\n"
"InnoDB: inside InnoDB.\n%s\n", err_buf); "InnoDB: inside InnoDB.\n", stderr);
trx_print(stderr, trx);
putc('\n', stderr);
} }
ut_a(trx->magic_n == TRX_MAGIC_N); ut_a(trx->magic_n == TRX_MAGIC_N);
@ -756,7 +754,8 @@ trx_commit_off_kernel(
trx->read_view = NULL; trx->read_view = NULL;
} }
/* printf("Trx %lu commit finished\n", ut_dulint_get_low(trx->id)); */ /* fprintf(stderr, "Trx %lu commit finished\n",
ut_dulint_get_low(trx->id)); */
if (must_flush_log) { if (must_flush_log) {
@ -1566,93 +1565,99 @@ own the kernel mutex. */
void void
trx_print( trx_print(
/*======*/ /*======*/
char* buf, /* in/out: buffer where to print, must be at least FILE* f, /* in: output stream */
800 bytes */
trx_t* trx) /* in: transaction */ trx_t* trx) /* in: transaction */
{ {
char* start_of_line; ibool newline;
buf += sprintf(buf, "TRANSACTION %lu %lu", fprintf(f, "TRANSACTION %lu %lu",
ut_dulint_get_high(trx->id), ut_dulint_get_high(trx->id),
ut_dulint_get_low(trx->id)); ut_dulint_get_low(trx->id));
switch (trx->conc_state) { switch (trx->conc_state) {
case TRX_NOT_STARTED: buf += sprintf(buf, case TRX_NOT_STARTED:
", not started"); break; fputs(", not started", f);
case TRX_ACTIVE: buf += sprintf(buf,
", ACTIVE %lu sec",
(ulint)difftime(time(NULL), trx->start_time)); break;
case TRX_COMMITTED_IN_MEMORY: buf += sprintf(buf,
", COMMITTED IN MEMORY");
break; break;
default: buf += sprintf(buf, " state %lu", trx->conc_state); case TRX_ACTIVE:
fprintf(f, ", ACTIVE %lu sec",
(ulint)difftime(time(NULL), trx->start_time));
break;
case TRX_COMMITTED_IN_MEMORY:
fputs(", COMMITTED IN MEMORY", f);
break;
default:
fprintf(f, " state %lu", trx->conc_state);
} }
#ifdef UNIV_LINUX #ifdef UNIV_LINUX
buf += sprintf(buf, ", process no %lu", trx->mysql_process_no); fprintf(f, ", process no %lu", trx->mysql_process_no);
#endif #endif
buf += sprintf(buf, ", OS thread id %lu", fprintf(f, ", OS thread id %lu",
os_thread_pf(trx->mysql_thread_id)); os_thread_pf(trx->mysql_thread_id));
if (ut_strlen(trx->op_info) > 0) { if (*trx->op_info) {
buf += sprintf(buf, " %s", trx->op_info); putc(' ', f);
fputs(trx->op_info, f);
} }
if (trx->type != TRX_USER) { if (trx->type != TRX_USER) {
buf += sprintf(buf, " purge trx"); fputs(" purge trx", f);
} }
if (trx->declared_to_be_inside_innodb) { if (trx->declared_to_be_inside_innodb) {
buf += sprintf(buf, ", thread declared inside InnoDB %lu", fprintf(f, ", thread declared inside InnoDB %lu",
trx->n_tickets_to_enter_innodb); trx->n_tickets_to_enter_innodb);
} }
buf += sprintf(buf, "\n"); putc('\n', f);
if (trx->n_mysql_tables_in_use > 0 || trx->mysql_n_tables_locked > 0) { if (trx->n_mysql_tables_in_use > 0 || trx->mysql_n_tables_locked > 0) {
buf += sprintf(buf, "mysql tables in use %lu, locked %lu\n", fprintf(f, "mysql tables in use %lu, locked %lu\n",
trx->n_mysql_tables_in_use, trx->n_mysql_tables_in_use,
trx->mysql_n_tables_locked); trx->mysql_n_tables_locked);
} }
start_of_line = buf; newline = TRUE;
switch (trx->que_state) { switch (trx->que_state) {
case TRX_QUE_RUNNING: break; case TRX_QUE_RUNNING:
case TRX_QUE_LOCK_WAIT: buf += sprintf(buf, newline = FALSE; break;
"LOCK WAIT "); break; case TRX_QUE_LOCK_WAIT:
case TRX_QUE_ROLLING_BACK: buf += sprintf(buf, fputs("LOCK WAIT ", f); break;
"ROLLING BACK "); break; case TRX_QUE_ROLLING_BACK:
case TRX_QUE_COMMITTING: buf += sprintf(buf, fputs("ROLLING BACK ", f); break;
"COMMITTING "); break; case TRX_QUE_COMMITTING:
default: buf += sprintf(buf, "que state %lu", trx->que_state); fputs("COMMITTING ", f); break;
default:
fprintf(f, "que state %lu ", trx->que_state);
} }
if (0 < UT_LIST_GET_LEN(trx->trx_locks) || if (0 < UT_LIST_GET_LEN(trx->trx_locks) ||
mem_heap_get_size(trx->lock_heap) > 400) { mem_heap_get_size(trx->lock_heap) > 400) {
newline = TRUE;
buf += sprintf(buf, fprintf(f, "%lu lock struct(s), heap size %lu",
"%lu lock struct(s), heap size %lu",
UT_LIST_GET_LEN(trx->trx_locks), UT_LIST_GET_LEN(trx->trx_locks),
mem_heap_get_size(trx->lock_heap)); mem_heap_get_size(trx->lock_heap));
} }
if (trx->has_search_latch) { if (trx->has_search_latch) {
buf += sprintf(buf, ", holds adaptive hash latch"); newline = TRUE;
fputs(", holds adaptive hash latch", f);
} }
if (ut_dulint_cmp(trx->undo_no, ut_dulint_zero) != 0) { if (ut_dulint_cmp(trx->undo_no, ut_dulint_zero) != 0) {
buf += sprintf(buf, ", undo log entries %lu", newline = TRUE;
fprintf(f, ", undo log entries %lu",
ut_dulint_get_low(trx->undo_no)); ut_dulint_get_low(trx->undo_no));
} }
if (buf != start_of_line) { if (newline) {
putc('\n', f);
buf += sprintf(buf, "\n");
} }
if (trx->mysql_thd != NULL) { if (trx->mysql_thd != NULL) {
innobase_mysql_print_thd(buf, trx->mysql_thd); innobase_mysql_print_thd(f, trx->mysql_thd);
} }
} }

View File

@ -393,13 +393,10 @@ trx_undo_seg_create(
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&(rseg->mutex))); ut_ad(mutex_own(&(rseg->mutex)));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
/*
if (type == TRX_UNDO_INSERT) { /* fputs(type == TRX_UNDO_INSERT
printf("Creating insert undo log segment\n"); ? "Creating insert undo log segment\n"
} else { : "Creating update undo log segment\n", stderr); */
printf("Creating update undo log segment\n");
}
*/
slot_no = trx_rsegf_undo_find_free(rseg_hdr, mtr); slot_no = trx_rsegf_undo_find_free(rseg_hdr, mtr);
if (slot_no == ULINT_UNDEFINED) { if (slot_no == ULINT_UNDEFINED) {

View File

@ -19,6 +19,16 @@ Created 5/11/1994 Heikki Tuuri
ibool ut_always_false = FALSE; ibool ut_always_false = FALSE;
/*********************************************************************
Get the quote character to be used in SQL identifiers.
This definition must match the one in sql/ha_innodb.cc! */
char
mysql_get_identifier_quote_char(void);
/*=================================*/
/* out: quote character to be
used in SQL identifiers */
/************************************************************ /************************************************************
Uses vsprintf to emulate sprintf so that the function always returns Uses vsprintf to emulate sprintf so that the function always returns
the printed length. Apparently in some old SCO Unixes sprintf did not the printed length. Apparently in some old SCO Unixes sprintf did not
@ -139,7 +149,7 @@ ut_print_timestamp(
} }
/************************************************************** /**************************************************************
Sprintfs a timestamp to a buffer. */ Sprintfs a timestamp to a buffer, 13..14 chars plus terminating NUL. */
void void
ut_sprintf_timestamp( ut_sprintf_timestamp(
@ -232,7 +242,7 @@ ut_delay(
} }
if (ut_always_false) { if (ut_always_false) {
printf("%lu", j); ut_always_false = (ibool) j;
} }
return(j); return(j);
@ -244,78 +254,29 @@ Prints the contents of a memory buffer in hex and ascii. */
void void
ut_print_buf( ut_print_buf(
/*=========*/ /*=========*/
byte* buf, /* in: memory buffer */ FILE* file, /* in: file where to print */
const byte* buf, /* in: memory buffer */
ulint len) /* in: length of the buffer */ ulint len) /* in: length of the buffer */
{ {
byte* data; const byte* data;
ulint i; ulint i;
printf(" len %lu; hex ", len); fprintf(file, " len %lu; hex ", len);
for (data = buf, i = 0; i < len; i++) {
fprintf(file, "%02lx", (ulint)*data++);
}
fputs("; asc ", file);
data = buf; data = buf;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
printf("%02lx", (ulint)*data); int c = (int) *data++;
data++; putc(isprint(c) ? c : ' ', file);
} }
printf("; asc "); putc(';', file);
data = buf;
for (i = 0; i < len; i++) {
if (isprint((int)(*data))) {
printf("%c", (char)*data);
}
data++;
}
printf(";");
}
/*****************************************************************
Prints the contents of a memory buffer in hex and ascii. */
ulint
ut_sprintf_buf(
/*===========*/
/* out: printed length in bytes */
char* str, /* in: buffer to print to */
byte* buf, /* in: memory buffer */
ulint len) /* in: length of the buffer */
{
byte* data;
ulint n;
ulint i;
n = 0;
n += sprintf(str + n, " len %lu; hex ", len);
data = buf;
for (i = 0; i < len; i++) {
n += sprintf(str + n, "%02lx", (ulint)*data);
data++;
}
n += sprintf(str + n, "; asc ");
data = buf;
for (i = 0; i < len; i++) {
if (isprint((int)(*data))) {
n += sprintf(str + n, "%c", (char)*data);
} else {
n += sprintf(str + n, ".");
}
data++;
}
n += sprintf(str + n, ";");
return(n);
} }
/**************************************************************** /****************************************************************
@ -351,3 +312,64 @@ ut_2_power_up(
return(res); return(res);
} }
/**************************************************************************
Outputs a NUL-terminated string, quoted as an SQL identifier. */
void
ut_print_name(
/*==========*/
FILE* f, /* in: output stream */
const char* name) /* in: name to print */
{
ut_print_namel(f, name, strlen(name));
}
/**************************************************************************
Outputs a fixed-length string, quoted as an SQL identifier. */
void
ut_print_namel(
/*==========*/
FILE* f, /* in: output stream */
const char* name, /* in: name to print */
ulint namelen)/* in: length of name */
{
const char* s = name;
const char* e = s + namelen;
char q = mysql_get_identifier_quote_char();
putc(q, f);
while (s < e) {
int c = *s++;
if (c == q) {
putc(c, f);
}
putc(c, f);
}
putc(q, f);
}
/**************************************************************************
Catenate files. */
void
ut_copy_file(
/*=========*/
FILE* dest, /* in: output file */
FILE* src) /* in: input file to be appended to output */
{
long len = ftell(src);
char buf[4096];
rewind(src);
do {
size_t maxs =
len < (long) sizeof buf ? (size_t) len : sizeof buf;
size_t size = fread(buf, 1, maxs, src);
fwrite(buf, 1, size, dest);
len -= size;
if (size < maxs) {
break;
}
} while (len > 0);
}

View File

@ -309,70 +309,49 @@ convert_error_code_to_mysql(
} }
} }
extern "C" {
/***************************************************************** /*****************************************************************
Prints info of a THD object (== user session thread) to the Prints info of a THD object (== user session thread) to the
standard output. NOTE that /mysql/innobase/trx/trx0trx.c must contain standard output. NOTE that /mysql/innobase/trx/trx0trx.c must contain
the prototype for this function! */ the prototype for this function! */
extern "C"
void void
innobase_mysql_print_thd( innobase_mysql_print_thd(
/*=====================*/ /*=====================*/
char* buf, /* in/out: buffer where to print, must be at least FILE* f, /* in: output stream */
400 bytes */
void* input_thd)/* in: pointer to a MySQL THD object */ void* input_thd)/* in: pointer to a MySQL THD object */
{ {
THD* thd; THD* thd;
char* old_buf = buf;
thd = (THD*) input_thd; thd = (THD*) input_thd;
/* We cannot use the return value of normal sprintf() as this is fprintf(f, "MySQL thread id %lu, query id %lu",
not portable to some old non-Posix Unixes, e.g., some old SCO thd->thread_id, thd->query_id);
Unixes */
buf += my_sprintf(buf,
(buf, "MySQL thread id %lu, query id %lu",
thd->thread_id, thd->query_id));
if (thd->host) { if (thd->host) {
*buf = ' '; putc(' ', f);
buf++; fputs(thd->host, f);
buf = strnmov(buf, thd->host, 30);
} }
if (thd->ip) { if (thd->ip) {
*buf = ' '; putc(' ', f);
buf++; fputs(thd->ip, f);
buf=strnmov(buf, thd->ip, 20);
} }
if (thd->user) { if (thd->user) {
*buf = ' '; putc(' ', f);
buf++; fputs(thd->user, f);
buf=strnmov(buf, thd->user, 20);
} }
if (thd->proc_info) { if (thd->proc_info) {
*buf = ' '; putc(' ', f);
buf++; fputs(thd->proc_info, f);
buf=strnmov(buf, thd->proc_info, 50);
} }
if (thd->query) { if (thd->query) {
*buf = '\n'; putc(' ', f);
buf++; fputs(thd->query, f);
buf=strnmov(buf, thd->query, 150);
} }
buf[0] = '\n'; putc('\n', f);
buf[1] = '\0'; /* Note that we must put a null character here to end
the printed string */
/* We test the printed length did not overrun the buffer length of
400 bytes */
ut_a(strlen(old_buf) < 400);
}
} }
/************************************************************************* /*************************************************************************
@ -605,12 +584,11 @@ innobase_query_caching_of_table_permitted(
return((my_bool)FALSE); return((my_bool)FALSE);
} }
extern "C" {
/********************************************************************* /*********************************************************************
Invalidates the MySQL query cache for the table. Invalidates the MySQL query cache for the table.
NOTE that the exact prototype of this function has to be in NOTE that the exact prototype of this function has to be in
/innobase/row/row0ins.c! */ /innobase/row/row0ins.c! */
extern "C"
void void
innobase_invalidate_query_cache( innobase_invalidate_query_cache(
/*============================*/ /*============================*/
@ -630,6 +608,17 @@ innobase_invalidate_query_cache(
TRUE); TRUE);
#endif #endif
} }
/*********************************************************************
Get the quote character to be used in SQL identifiers. */
extern "C"
char
mysql_get_identifier_quote_char(void)
/*=================================*/
/* out: quote character to be
used in SQL identifiers */
{
return '`';
} }
/********************************************************************* /*********************************************************************
@ -1244,19 +1233,6 @@ innobase_close_connection(
return(0); return(0);
} }
/**********************************************************************
Prints an error message. */
static
void
innobase_print_error(
/*=================*/
const char* db_errpfx, /* in: error prefix text */
char* buffer) /* in: error text */
{
sql_print_error("%s: %s", db_errpfx, buffer);
}
/***************************************************************************** /*****************************************************************************
** InnoDB database tables ** InnoDB database tables
*****************************************************************************/ *****************************************************************************/
@ -2017,24 +1993,20 @@ ha_innobase::write_row(
if (prebuilt->trx != if (prebuilt->trx !=
(trx_t*) current_thd->transaction.all.innobase_tid) { (trx_t*) current_thd->transaction.all.innobase_tid) {
char err_buf[2000];
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: the transaction object for the table handle is at\n" "InnoDB: Error: the transaction object for the table handle is at\n"
"InnoDB: %lx, but for the current thread it is at %lx\n", "InnoDB: %p, but for the current thread it is at %p\n",
(ulong)prebuilt->trx, prebuilt->trx,
(ulong)current_thd->transaction.all.innobase_tid); current_thd->transaction.all.innobase_tid);
fputs("InnoDB: Dump of 200 bytes around prebuilt: ", stderr);
ut_sprintf_buf(err_buf, ((byte*)prebuilt) - 100, 200); ut_print_buf(stderr, ((const byte*)prebuilt) - 100, 200);
fprintf(stderr, fputs("\n"
"InnoDB: Dump of 200 bytes around prebuilt: %.1000s\n", err_buf); "InnoDB: Dump of 200 bytes around transaction.all: ",
stderr);
ut_sprintf_buf(err_buf, ut_print_buf(stderr,
((byte*)(&(current_thd->transaction.all))) - 100, 200); ((byte*)(&(current_thd->transaction.all))) - 100, 200);
fprintf(stderr, putc('\n', stderr);
"InnoDB: Dump of 200 bytes around transaction.all: %.1000s\n", err_buf); ut_error;
ut_a(0);
} }
statistic_increment(ha_write_count, &LOCK_status); statistic_increment(ha_write_count, &LOCK_status);
@ -4225,15 +4197,18 @@ ha_innobase::update_table_comment(
info on foreign keys */ info on foreign keys */
const char* comment)/* in: table comment defined by user */ const char* comment)/* in: table comment defined by user */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt;
uint length = strlen(comment); uint length = strlen(comment);
char* str = my_malloc(length + 16500, MYF(0)); char* str;
char* pos; row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt;
/* We do not know if MySQL can call this function before calling /* We do not know if MySQL can call this function before calling
external_lock(). To be safe, update the thd of the current table external_lock(). To be safe, update the thd of the current table
handle. */ handle. */
if(length > 64000 - 3) {
return((char*)comment); /* string too long */
}
update_thd(current_thd); update_thd(current_thd);
prebuilt->trx->op_info = (char*)"returning table comment"; prebuilt->trx->op_info = (char*)"returning table comment";
@ -4242,36 +4217,45 @@ ha_innobase::update_table_comment(
possible adaptive hash latch to avoid deadlocks of threads */ possible adaptive hash latch to avoid deadlocks of threads */
trx_search_latch_release_if_reserved(prebuilt->trx); trx_search_latch_release_if_reserved(prebuilt->trx);
str = NULL;
if (!str) { if (FILE* file = tmpfile()) {
prebuilt->trx->op_info = (char*)""; long flen;
return((char*)comment); /* output the data to a temporary file */
fprintf(file, "InnoDB free: %lu kB",
(ulong) innobase_get_free_space());
dict_print_info_on_foreign_keys(FALSE, file, prebuilt->table);
flen = ftell(file);
if(length + flen + 3 > 64000) {
flen = 64000 - 3 - length;
} }
pos = str; ut_ad(flen > 0);
/* allocate buffer for the full string, and
read the contents of the temporary file */
str = my_malloc(length + flen + 3, MYF(0));
if (str) {
char* pos = str + length;
if(length) { if(length) {
pos=strmov(str, comment); memcpy(str, comment, length);
*pos++ = ';'; *pos++ = ';';
*pos++ = ' '; *pos++ = ' ';
} }
rewind(file);
flen = fread(pos, 1, flen, file);
pos[flen] = 0;
}
pos += my_sprintf(pos, fclose(file);
(pos,"InnoDB free: %lu kB",
(ulong) innobase_get_free_space()));
/* We assume 16000 - length bytes of space to print info; the limit
16000 bytes is arbitrary, and MySQL could handle at least 64000
bytes */
if (length < 16000) {
dict_print_info_on_foreign_keys(FALSE, pos, 16000 - length,
prebuilt->table);
} }
prebuilt->trx->op_info = (char*)""; prebuilt->trx->op_info = (char*)"";
return(str); return(str ? str : (char*) comment);
} }
/*********************************************************************** /***********************************************************************
@ -4285,7 +4269,7 @@ ha_innobase::get_foreign_key_create_info(void)
MUST be freed with ::free_foreign_key_create_info */ MUST be freed with ::free_foreign_key_create_info */
{ {
row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt; row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt;
char* str; char* str = 0;
ut_a(prebuilt != NULL); ut_a(prebuilt != NULL);
@ -4295,21 +4279,46 @@ ha_innobase::get_foreign_key_create_info(void)
update_thd(current_thd); update_thd(current_thd);
if (FILE* file = tmpfile()) {
long flen;
prebuilt->trx->op_info = (char*)"getting info on foreign keys"; prebuilt->trx->op_info = (char*)"getting info on foreign keys";
/* In case MySQL calls this in the middle of a SELECT query, release /* In case MySQL calls this in the middle of a SELECT query,
possible adaptive hash latch to avoid deadlocks of threads */ release possible adaptive hash latch to avoid
deadlocks of threads */
trx_search_latch_release_if_reserved(prebuilt->trx); trx_search_latch_release_if_reserved(prebuilt->trx);
str = (char*)ut_malloc(10000); /* output the data to a temporary file */
dict_print_info_on_foreign_keys(TRUE, file, prebuilt->table);
str[0] = '\0';
dict_print_info_on_foreign_keys(TRUE, str, 9000, prebuilt->table);
prebuilt->trx->op_info = (char*)""; prebuilt->trx->op_info = (char*)"";
flen = ftell(file);
if(flen > 64000 - 1) {
flen = 64000 - 1;
}
ut_ad(flen >= 0);
/* allocate buffer for the string, and
read the contents of the temporary file */
str = my_malloc(flen + 1, MYF(0));
if (str) {
rewind(file);
flen = fread(str, 1, flen, file);
str[flen] = 0;
}
fclose(file);
} else {
/* unable to create temporary file */
str = my_malloc(1, MYF(0));
str[0] = 0;
}
return(str); return(str);
} }
@ -4344,7 +4353,7 @@ ha_innobase::free_foreign_key_create_info(
char* str) /* in, own: create info string to free */ char* str) /* in, own: create info string to free */
{ {
if (str) { if (str) {
ut_free(str); my_free(str, MYF(0));
} }
} }
@ -4615,39 +4624,56 @@ innodb_show_status(
innobase_release_stat_resources(trx); innobase_release_stat_resources(trx);
/* We let the InnoDB Monitor to output at most 60 kB of text, add /* We let the InnoDB Monitor to output at most 64000 bytes of text. */
a safety margin of 100 kB for buffer overruns */
buf = (char*)ut_malloc(160 * 1024); long flen;
char* str;
srv_sprintf_innodb_monitor(buf, 60 * 1024); mutex_enter(&srv_monitor_file_mutex);
rewind(srv_monitor_file);
srv_printf_innodb_monitor(srv_monitor_file);
flen = ftell(srv_monitor_file);
if(flen > 64000 - 1) {
flen = 64000 - 1;
}
ut_ad(flen > 0);
/* allocate buffer for the string, and
read the contents of the temporary file */
str = my_malloc(flen + 1, MYF(0));
if (str) {
rewind(srv_monitor_file);
flen = fread(str, 1, flen, srv_monitor_file);
str[flen] = 0;
}
mutex_exit(&srv_monitor_file_mutex);
List<Item> field_list; List<Item> field_list;
field_list.push_back(new Item_empty_string("Status", strlen(buf))); field_list.push_back(new Item_empty_string("Status", flen));
if (send_fields(thd, field_list, 1)) { if (send_fields(thd, field_list, 1)) {
ut_free(buf); my_free(str, MYF(0));
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
packet->length(0); packet->length(0);
net_store_data(packet, str);
net_store_data(packet, buf); my_free(str, MYF(0));
if (my_net_write(&thd->net, (char*)thd->packet.ptr(), if (my_net_write(&thd->net, (char*)thd->packet.ptr(),
packet->length())) { packet->length())) {
ut_free(buf);
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
ut_free(buf);
send_eof(&thd->net); send_eof(&thd->net);
DBUG_RETURN(0); DBUG_RETURN(0);
} }