summaryrefslogtreecommitdiff
path: root/innobase/trx
diff options
context:
space:
mode:
Diffstat (limited to 'innobase/trx')
-rw-r--r--innobase/trx/trx0purge.c10
-rw-r--r--innobase/trx/trx0rec.c115
-rw-r--r--innobase/trx/trx0roll.c15
-rw-r--r--innobase/trx/trx0sys.c4
-rw-r--r--innobase/trx/trx0trx.c97
-rw-r--r--innobase/trx/trx0undo.c11
6 files changed, 124 insertions, 128 deletions
diff --git a/innobase/trx/trx0purge.c b/innobase/trx/trx0purge.c
index 6a509b163b3..a8b6b9fcc21 100644
--- a/innobase/trx/trx0purge.c
+++ b/innobase/trx/trx0purge.c
@@ -337,7 +337,7 @@ trx_purge_free_segment(
ibool marked = FALSE;
mtr_t mtr;
-/* printf("Freeing an update undo log segment\n"); */
+/* fputs("Freeing an update undo log segment\n", stderr); */
#ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&(purge_sys->mutex)));
@@ -918,7 +918,7 @@ trx_purge_fetch_next_rec(
trx_purge_truncate_if_arr_empty();
if (srv_print_thread_releases) {
- printf(
+ fprintf(stderr,
"Purge: No logs left in the history list; pages handled %lu\n",
purge_sys->n_pages_handled);
}
@@ -951,7 +951,7 @@ trx_purge_fetch_next_rec(
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(),
ut_dulint_get_low(purge_sys->purge_trx_no),
ut_dulint_get_low(purge_sys->purge_undo_no)); */
@@ -1064,14 +1064,14 @@ trx_purge(void)
if (srv_print_thread_releases) {
- printf("Starting purge\n");
+ fputs("Starting purge\n", stderr);
}
que_run_threads(thr);
if (srv_print_thread_releases) {
- printf(
+ fprintf(stderr,
"Purge ends; pages handled %lu\n", purge_sys->n_pages_handled);
}
diff --git a/innobase/trx/trx0rec.c b/innobase/trx/trx0rec.c
index 9d944e16a1e..4926c776ae9 100644
--- a/innobase/trx/trx0rec.c
+++ b/innobase/trx/trx0rec.c
@@ -823,17 +823,18 @@ trx_undo_update_rec_get_update(
if (field_no >= dict_index_get_n_fields(index)) {
fprintf(stderr,
- "InnoDB: Error: trying to access update undo rec field %lu in table %s\n"
- "InnoDB: index %s, but index has only %lu fields\n",
- field_no, index->table_name, index->name,
- dict_index_get_n_fields(index));
- fprintf(stderr,
- "InnoDB: Send a detailed bug report to mysql@lists.mysql.com");
-
- fprintf(stderr,
- "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);
+ "InnoDB: Error: trying to access"
+ " update undo rec field %lu in ", field_no);
+ 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));
+ ut_print_name(stderr, index->table_name);
+ fprintf(stderr, "\n"
+ "InnoDB: n_fields = %lu, i = %lu, ptr %p\n",
+ n_fields, i, ptr);
return(NULL);
}
@@ -1258,8 +1259,6 @@ trx_undo_prev_version_build(
byte* buf;
ulint err;
ulint i;
- char err_buf[1000];
-
#ifdef UNIV_SYNC_DEBUG
ut_ad(rw_lock_own(&(purge_sys->latch), RW_LOCK_SHARED));
#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_PAGE_X_FIX));
if (!(index->type & DICT_CLUSTERED)) {
- fprintf(stderr,
- "InnoDB: Error: trying to access update undo rec for table %s\n"
- "InnoDB: index %s which is not a clustered index\n",
- index->table_name, index->name);
- fprintf(stderr,
- "InnoDB: Send a detailed bug report to mysql@lists.mysql.com");
-
- rec_sprintf(err_buf, 900, index_rec);
- fprintf(stderr, "InnoDB: index record %s\n", err_buf);
-
- rec_sprintf(err_buf, 900, rec);
- fprintf(stderr, "InnoDB: record version %s\n", err_buf);
-
+ fputs("InnoDB: Error: trying to access"
+ " update undo rec for non-clustered ", stderr);
+ dict_index_name_print(stderr, index);
+ fputs("\n"
+ "InnoDB: Send a detailed bug report to"
+ " mysql@lists.mysql.com\n"
+ "InnoDB: index record ", stderr);
+ rec_print(stderr, index_rec);
+ fputs("\n"
+ "InnoDB: record version ", stderr);
+ rec_print(stderr, rec);
+ putc('\n', stderr);
return(DB_ERROR);
}
@@ -1318,55 +1316,50 @@ trx_undo_prev_version_build(
if (ut_dulint_cmp(table_id, index->table->id) != 0) {
ptr = NULL;
- fprintf(stderr,
- "InnoDB: Error: trying to access update undo rec for table %s\n"
- "InnoDB: but the table id in the undo record is wrong\n",
- index->table_name);
- fprintf(stderr,
- "InnoDB: Send a detailed bug report to mysql@lists.mysql.com\n");
-
- fprintf(stderr,
- "InnoDB: Run also CHECK TABLE on table %s\n", index->table_name);
+ fputs("InnoDB: Error: trying to access"
+ " update undo rec for table ", stderr);
+ ut_print_name(stderr, index->table_name);
+ fputs("\n"
+ "InnoDB: but the table id in the"
+ " undo record is wrong\n"
+ "InnoDB: Send a detailed bug report to "
+ "mysql@lists.mysql.com\n"
+ "InnoDB: Run also CHECK TABLE ", stderr);
+ ut_print_name(stderr, index->table_name);
+ putc('\n', stderr);
}
if (ptr == NULL) {
/* The record was corrupted, return an error; these printfs
should catch an elusive bug in row_vers_old_has_index_entry */
- fprintf(stderr,
- "InnoDB: Table name %s, index name %s, n_uniq %lu\n",
- index->table_name, index->name,
- dict_index_get_n_unique(index));
-
- fprintf(stderr,
- "InnoDB: undo rec address %lx, type %lu cmpl_info %lu\n",
- (ulint)undo_rec, type, cmpl_info);
- fprintf(stderr,
- "InnoDB: undo rec table id %lu %lu, index table id %lu %lu\n",
+ fputs("InnoDB: ", stderr);
+ dict_index_name_print(stderr, index);
+ fprintf(stderr, ", n_uniq %lu\n"
+ "InnoDB: undo rec address %p, type %lu cmpl_info %lu\n"
+ "InnoDB: undo rec table id %lu %lu, index table id %lu %lu\n"
+ "InnoDB: dump of 150 bytes in undo rec: ",
+ dict_index_get_n_unique(index),
+ undo_rec, type, cmpl_info,
ut_dulint_get_high(table_id),
ut_dulint_get_low(table_id),
ut_dulint_get_high(index->table->id),
ut_dulint_get_low(index->table->id));
- ut_sprintf_buf(err_buf, undo_rec, 150);
-
- fprintf(stderr, "InnoDB: dump of 150 bytes in undo rec: %s\n",
- err_buf);
- rec_sprintf(err_buf, 900, index_rec);
- fprintf(stderr, "InnoDB: index record %s\n", err_buf);
-
- rec_sprintf(err_buf, 900, rec);
- fprintf(stderr, "InnoDB: record version %s\n", err_buf);
-
- fprintf(stderr,
- "InnoDB: Record trx id %lu %lu, update rec trx id %lu %lu\n",
+ ut_print_buf(stderr, undo_rec, 150);
+ fputs("\n"
+ "InnoDB: index record ", stderr);
+ rec_print(stderr, index_rec);
+ fputs("\n"
+ "InnoDB: record version ", stderr);
+ rec_print(stderr, rec);
+ fprintf(stderr, "\n"
+ "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",
ut_dulint_get_high(rec_trx_id),
ut_dulint_get_low(rec_trx_id),
ut_dulint_get_high(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_low(trx_id),
ut_dulint_get_high(old_roll_ptr),
ut_dulint_get_low(old_roll_ptr),
ut_dulint_get_high(roll_ptr),
diff --git a/innobase/trx/trx0roll.c b/innobase/trx/trx0roll.c
index 2adebbc6b4b..eed5e79a20f 100644
--- a/innobase/trx/trx0roll.c
+++ b/innobase/trx/trx0roll.c
@@ -228,9 +228,9 @@ trx_rollback_to_savepoint_for_mysql(
if (trx->conc_state == TRX_NOT_STARTED) {
ut_print_timestamp(stderr);
- fprintf(stderr,
-" InnoDB: Error: transaction has a savepoint %s though it is not started\n",
- savep->name);
+ fputs(" InnoDB: Error: transaction has a savepoint ", stderr);
+ ut_print_name(stderr, savep->name);
+ fputs(" though it is not started\n", stderr);
return(DB_ERROR);
}
@@ -466,8 +466,9 @@ loop:
table = dict_table_get_on_id_low(trx->table_id, trx);
if (table) {
- fprintf(stderr,
-"InnoDB: Table found: dropping table %s in recovery\n", table->name);
+ fputs("InnoDB: Table found: dropping table ", stderr);
+ ut_print_name(stderr, table->name);
+ fputs(" in recovery\n", stderr);
err = row_drop_table_for_mysql(table->name, trx, TRUE);
@@ -729,7 +730,7 @@ trx_roll_pop_top_rec(
undo->top_page_no, mtr);
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),
ut_dulint_get_low(undo->top_undo_no)); */
@@ -1140,7 +1141,7 @@ trx_finish_rollback_off_kernel(
}
if (lock_print_waits) {
- printf("Trx %lu rollback finished\n",
+ fprintf(stderr, "Trx %lu rollback finished\n",
ut_dulint_get_low(trx->id));
}
diff --git a/innobase/trx/trx0sys.c b/innobase/trx/trx0sys.c
index 493a5e94e79..e0c30df17af 100644
--- a/innobase/trx/trx0sys.c
+++ b/innobase/trx/trx0sys.c
@@ -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. */
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) {
- printf(
+ fprintf(stderr,
"ibbackup: Last MySQL binlog file position %lu %lu, file name %s\n",
mach_read_from_4(sys_header + TRX_SYS_MYSQL_LOG_INFO
+ TRX_SYS_MYSQL_LOG_OFFSET_HIGH),
diff --git a/innobase/trx/trx0trx.c b/innobase/trx/trx0trx.c
index 9b6e6904537..7a028c92060 100644
--- a/innobase/trx/trx0trx.c
+++ b/innobase/trx/trx0trx.c
@@ -26,10 +26,10 @@ Created 3/26/1996 Heikki Tuuri
#include "os0proc.h"
/* 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(
- char* buf,
+ FILE* f,
void* thd);
/* Dummy session used currently in MySQL interface */
@@ -239,19 +239,17 @@ trx_free(
/*=====*/
trx_t* trx) /* in, own: trx object */
{
- char err_buf[1000];
-
#ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&kernel_mutex));
#endif /* UNIV_SYNC_DEBUG */
if (trx->declared_to_be_inside_innodb) {
ut_print_timestamp(stderr);
- trx_print(err_buf, trx);
-
- fprintf(stderr,
+ fputs(
" 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);
@@ -756,7 +754,8 @@ trx_commit_off_kernel(
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) {
@@ -1566,93 +1565,99 @@ own the kernel mutex. */
void
trx_print(
/*======*/
- char* buf, /* in/out: buffer where to print, must be at least
- 800 bytes */
+ FILE* f, /* in: output stream */
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_low(trx->id));
switch (trx->conc_state) {
- case TRX_NOT_STARTED: buf += sprintf(buf,
- ", not started"); break;
- 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");
+ case TRX_NOT_STARTED:
+ fputs(", not started", f);
+ break;
+ case TRX_ACTIVE:
+ fprintf(f, ", ACTIVE %lu sec",
+ (ulint)difftime(time(NULL), trx->start_time));
break;
- default: buf += sprintf(buf, " state %lu", trx->conc_state);
+ case TRX_COMMITTED_IN_MEMORY:
+ fputs(", COMMITTED IN MEMORY", f);
+ break;
+ default:
+ fprintf(f, " state %lu", trx->conc_state);
}
#ifdef UNIV_LINUX
- buf += sprintf(buf, ", process no %lu", trx->mysql_process_no);
+ fprintf(f, ", process no %lu", trx->mysql_process_no);
#endif
- buf += sprintf(buf, ", OS thread id %lu",
+ fprintf(f, ", OS thread id %lu",
os_thread_pf(trx->mysql_thread_id));
- if (ut_strlen(trx->op_info) > 0) {
- buf += sprintf(buf, " %s", trx->op_info);
+ if (*trx->op_info) {
+ putc(' ', f);
+ fputs(trx->op_info, f);
}
if (trx->type != TRX_USER) {
- buf += sprintf(buf, " purge trx");
+ fputs(" purge trx", f);
}
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);
}
- buf += sprintf(buf, "\n");
+ putc('\n', f);
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->mysql_n_tables_locked);
}
- start_of_line = buf;
+ newline = TRUE;
switch (trx->que_state) {
- case TRX_QUE_RUNNING: break;
- case TRX_QUE_LOCK_WAIT: buf += sprintf(buf,
- "LOCK WAIT "); break;
- case TRX_QUE_ROLLING_BACK: buf += sprintf(buf,
- "ROLLING BACK "); break;
- case TRX_QUE_COMMITTING: buf += sprintf(buf,
- "COMMITTING "); break;
- default: buf += sprintf(buf, "que state %lu", trx->que_state);
+ case TRX_QUE_RUNNING:
+ newline = FALSE; break;
+ case TRX_QUE_LOCK_WAIT:
+ fputs("LOCK WAIT ", f); break;
+ case TRX_QUE_ROLLING_BACK:
+ fputs("ROLLING BACK ", f); break;
+ case TRX_QUE_COMMITTING:
+ fputs("COMMITTING ", f); break;
+ default:
+ fprintf(f, "que state %lu ", trx->que_state);
}
if (0 < UT_LIST_GET_LEN(trx->trx_locks) ||
mem_heap_get_size(trx->lock_heap) > 400) {
+ newline = TRUE;
- buf += sprintf(buf,
-"%lu lock struct(s), heap size %lu",
+ fprintf(f, "%lu lock struct(s), heap size %lu",
UT_LIST_GET_LEN(trx->trx_locks),
mem_heap_get_size(trx->lock_heap));
}
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) {
- buf += sprintf(buf, ", undo log entries %lu",
+ newline = TRUE;
+ fprintf(f, ", undo log entries %lu",
ut_dulint_get_low(trx->undo_no));
}
- if (buf != start_of_line) {
-
- buf += sprintf(buf, "\n");
+ if (newline) {
+ putc('\n', f);
}
if (trx->mysql_thd != NULL) {
- innobase_mysql_print_thd(buf, trx->mysql_thd);
+ innobase_mysql_print_thd(f, trx->mysql_thd);
}
}
diff --git a/innobase/trx/trx0undo.c b/innobase/trx/trx0undo.c
index de3da382e83..cf8a69c8cca 100644
--- a/innobase/trx/trx0undo.c
+++ b/innobase/trx/trx0undo.c
@@ -393,13 +393,10 @@ trx_undo_seg_create(
#ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&(rseg->mutex)));
#endif /* UNIV_SYNC_DEBUG */
-/*
- if (type == TRX_UNDO_INSERT) {
- printf("Creating insert undo log segment\n");
- } else {
- printf("Creating update undo log segment\n");
- }
-*/
+
+/* fputs(type == TRX_UNDO_INSERT
+ ? "Creating insert undo log segment\n"
+ : "Creating update undo log segment\n", stderr); */
slot_no = trx_rsegf_undo_find_free(rseg_hdr, mtr);
if (slot_no == ULINT_UNDEFINED) {