Commit 7a528801 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-12072 Do not unnecessarily construct rec_printer objects

I introduced the rec_printer object in MySQL to pretty-print raw InnoDB
records and index tuples in diagnostic messages. These objects are being
constructed unconditionally, even though the DBUG_PRINT is not enabled.

The unnecessary work is avoided by simply passing rec_printer(…).str()
to the DBUG_LOG macro that was introduced in MDEV-11713.
parent 37925c6c
...@@ -3012,18 +3012,10 @@ btr_cur_optimistic_insert( ...@@ -3012,18 +3012,10 @@ btr_cur_optimistic_insert(
page_cursor = btr_cur_get_page_cur(cursor); page_cursor = btr_cur_get_page_cur(cursor);
#ifdef UNIV_DEBUG DBUG_LOG("ib_cur",
{ "insert " << index->name << " (" << index->id << ") by "
rec_printer p(entry); << ib::hex(thr ? trx_get_id_for_print(thr_get_trx(thr)) : 0)
DBUG_PRINT("ib_cur", ("insert %s (" IB_ID_FMT ") by " IB_ID_FMT " %s", << ' ' << rec_printer(entry).str());
index->name(), index->id,
thr != NULL
? trx_get_id_for_print(thr_get_trx(thr))
: 0,
p.str().c_str()));
}
#endif
DBUG_EXECUTE_IF("do_page_reorganize", DBUG_EXECUTE_IF("do_page_reorganize",
btr_page_reorganize(page_cursor, index, mtr);); btr_page_reorganize(page_cursor, index, mtr););
...@@ -3635,14 +3627,10 @@ btr_cur_update_in_place( ...@@ -3635,14 +3627,10 @@ btr_cur_update_in_place(
ut_ad(fil_page_index_page_check(btr_cur_get_page(cursor))); ut_ad(fil_page_index_page_check(btr_cur_get_page(cursor)));
ut_ad(btr_page_get_index_id(btr_cur_get_page(cursor)) == index->id); ut_ad(btr_page_get_index_id(btr_cur_get_page(cursor)) == index->id);
#ifdef UNIV_DEBUG DBUG_LOG("ib_cur",
{ "update-in-place " << index->name << " (" << index->id
rec_printer p(rec, offsets); << ") by " << ib::hex(trx_id) << ": "
DBUG_PRINT("ib_cur", ("update-in-place %s (" IB_ID_FMT ") by " IB_ID_FMT ": %s", << rec_printer(rec, offsets).str());
index->name(), index->id, trx_id,
p.str().c_str()));
}
#endif
block = btr_cur_get_block(cursor); block = btr_cur_get_block(cursor);
page_zip = buf_block_get_page_zip(block); page_zip = buf_block_get_page_zip(block);
...@@ -3842,14 +3830,10 @@ btr_cur_optimistic_update( ...@@ -3842,14 +3830,10 @@ btr_cur_optimistic_update(
} }
} }
#ifdef UNIV_DEBUG DBUG_LOG("ib_cur",
{ "update " << index->name << " (" << index->id << ") by "
rec_printer p(rec, *offsets); << ib::hex(trx_id) << ": "
DBUG_PRINT("ib_cur", ("update %s (" IB_ID_FMT ") by " IB_ID_FMT ": %s", << rec_printer(rec, *offsets).str());
index->name(), index->id, trx_id,
p.str().c_str()));
}
#endif
page_cursor = btr_cur_get_page_cur(cursor); page_cursor = btr_cur_get_page_cur(cursor);
...@@ -4669,15 +4653,11 @@ btr_cur_del_mark_set_clust_rec( ...@@ -4669,15 +4653,11 @@ btr_cur_del_mark_set_clust_rec(
ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE)); ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE));
ut_ad(!trx->in_rollback); ut_ad(!trx->in_rollback);
#ifdef UNIV_DEBUG DBUG_LOG("ib_cur",
{ "delete-mark clust " << index->table->name
rec_printer p(rec, offsets); << " (" << index->id << ") by "
DBUG_PRINT("ib_cur", ("delete-mark clust %s (" IB_ID_FMT ") by " IB_ID_FMT ": %s", << ib::hex(trx_get_id_for_print(trx)) << ": "
index->table_name, index->id, << rec_printer(rec, offsets).str());
trx_get_id_for_print(trx),
p.str().c_str()));
}
#endif
if (dict_index_is_online_ddl(index)) { if (dict_index_is_online_ddl(index)) {
row_log_table_delete(rec, entry, index, offsets, NULL); row_log_table_delete(rec, entry, index, offsets, NULL);
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
...@@ -1641,15 +1642,9 @@ row_log_table_apply_insert_low( ...@@ -1641,15 +1642,9 @@ row_log_table_apply_insert_low(
ut_ad(dtuple_validate(row)); ut_ad(dtuple_validate(row));
ut_ad(trx_id); ut_ad(trx_id);
#ifdef UNIV_DEBUG DBUG_LOG("ib_alter_table",
{ "insert table " << index->table->id << " (index "
rec_printer p(row); << index->id << "): " << rec_printer(row).str());
DBUG_PRINT("ib_alter_table",
("insert table " IB_ID_FMT " (index " IB_ID_FMT "): %s",
index->table->id, index->id,
p.str().c_str()));
}
#endif
static const ulint flags static const ulint flags
= (BTR_CREATE_FLAG = (BTR_CREATE_FLAG
...@@ -1777,15 +1772,10 @@ row_log_table_apply_delete_low( ...@@ -1777,15 +1772,10 @@ row_log_table_apply_delete_low(
ut_ad(dict_index_is_clust(index)); ut_ad(dict_index_is_clust(index));
#ifdef UNIV_DEBUG DBUG_LOG("ib_alter_table",
{ "delete table " << index->table->id << " (index "
rec_printer p(btr_pcur_get_rec(pcur), offsets); << index->id << "): "
DBUG_PRINT("ib_alter_table", << rec_printer(btr_pcur_get_rec(pcur), offsets).str());
("delete table " IB_ID_FMT " (index " IB_ID_FMT "): %s",
index->table->id, index->id,
p.str().c_str()));
}
#endif
if (dict_table_get_next_index(index)) { if (dict_table_get_next_index(index)) {
/* Build a row template for purging secondary index entries. */ /* Build a row template for purging secondary index entries. */
...@@ -2266,17 +2256,11 @@ row_log_table_apply_update( ...@@ -2266,17 +2256,11 @@ row_log_table_apply_update(
cur_offsets, NULL, NULL, NULL, &old_ext, heap); cur_offsets, NULL, NULL, NULL, &old_ext, heap);
ut_ad(old_row); ut_ad(old_row);
#ifdef UNIV_DEBUG DBUG_LOG("ib_alter_table",
{ "update table " << index->table->id
rec_printer old(old_row); << " (index " << index->id
rec_printer new_row(row); << ": " << rec_printer(old_row).str()
DBUG_PRINT("ib_alter_table", << " to " << rec_printer(row).str());
("update table " IB_ID_FMT " (index " IB_ID_FMT "): %s to %s",
index->table->id, index->id,
old.str().c_str(),
new_row.str().c_str()));
}
#endif
} else { } else {
old_row = NULL; old_row = NULL;
old_ext = NULL; old_ext = NULL;
...@@ -3298,17 +3282,11 @@ row_log_apply_op_low( ...@@ -3298,17 +3282,11 @@ row_log_apply_op_low(
ut_ad(!dict_index_is_corrupted(index)); ut_ad(!dict_index_is_corrupted(index));
ut_ad(trx_id != 0 || op == ROW_OP_DELETE); ut_ad(trx_id != 0 || op == ROW_OP_DELETE);
#ifdef UNIV_DEBUG DBUG_LOG("ib_create_index",
{ (op == ROW_OP_INSERT ? "insert " : "delete ")
rec_printer p(entry); << (has_index_lock ? "locked index " : "unlocked index ")
DBUG_PRINT("ib_create_index", << index->id << ',' << ib::hex(trx_id) << ": "
("%s %s index " IB_ID_FMT "," IB_ID_FMT ": %s", << rec_printer(entry).str());
op == ROW_OP_INSERT ? "insert" : "delete",
has_index_lock ? "locked" : "unlocked",
index->id, trx_id,
p.str().c_str()));
}
#endif
mtr_start(&mtr); mtr_start(&mtr);
mtr.set_named_space(index->space); mtr.set_named_space(index->space);
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
...@@ -1100,16 +1101,11 @@ row_merge_buf_write( ...@@ -1100,16 +1101,11 @@ row_merge_buf_write(
row_merge_buf_encode(&b, index, entry, n_fields); row_merge_buf_encode(&b, index, entry, n_fields);
ut_ad(b < &block[srv_sort_buf_size]); ut_ad(b < &block[srv_sort_buf_size]);
#ifdef UNIV_DEBUG DBUG_LOG("ib_merge_sort",
{ reinterpret_cast<const void*>(b) << ','
rec_printer p(entry->fields, n_fields); << of->fd << ',' << of->offset << ' ' <<
DBUG_PRINT("ib_merge_sort", i << ": " <<
("%p,fd=%d,%lu %lu: %s", rec_printer(entry->fields, n_fields).str());
reinterpret_cast<const void*>(b), of->fd,
(ulint)of->offset, (ulint)i,
p.str().c_str()));
}
#endif
} }
/* Write an "end-of-chunk" marker. */ /* Write an "end-of-chunk" marker. */
...@@ -1121,10 +1117,9 @@ row_merge_buf_write( ...@@ -1121,10 +1117,9 @@ row_merge_buf_write(
to avoid bogus warnings. */ to avoid bogus warnings. */
memset(b, 0xff, &block[srv_sort_buf_size] - b); memset(b, 0xff, &block[srv_sort_buf_size] - b);
#endif /* UNIV_DEBUG_VALGRIND */ #endif /* UNIV_DEBUG_VALGRIND */
DBUG_PRINT("ib_merge_sort", DBUG_LOG("ib_merge_sort",
("write %p,%d,%lu EOF", "write " << reinterpret_cast<const void*>(b) << ','
reinterpret_cast<const void*>(b), of->fd, << of->fd << ',' << of->offset << " EOF");
(ulint)of->offset));
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -1177,7 +1172,7 @@ row_merge_read( ...@@ -1177,7 +1172,7 @@ row_merge_read(
os_offset_t ofs = ((os_offset_t) offset) * srv_sort_buf_size; os_offset_t ofs = ((os_offset_t) offset) * srv_sort_buf_size;
DBUG_ENTER("row_merge_read"); DBUG_ENTER("row_merge_read");
DBUG_PRINT("ib_merge_sort", ("fd=%d ofs=" UINT64PF, fd, ofs)); DBUG_LOG("ib_merge_sort", "fd=" << fd << " ofs=" << ofs);
DBUG_EXECUTE_IF("row_merge_read_failure", DBUG_RETURN(FALSE);); DBUG_EXECUTE_IF("row_merge_read_failure", DBUG_RETURN(FALSE););
IORequest request; IORequest request;
...@@ -1224,7 +1219,7 @@ row_merge_write( ...@@ -1224,7 +1219,7 @@ row_merge_write(
void* out_buf = (void *)buf; void* out_buf = (void *)buf;
DBUG_ENTER("row_merge_write"); DBUG_ENTER("row_merge_write");
DBUG_PRINT("ib_merge_sort", ("fd=%d ofs=" UINT64PF, fd, ofs)); DBUG_LOG("ib_merge_sort", "fd=" << fd << " ofs=" << ofs);
DBUG_EXECUTE_IF("row_merge_write_failure", DBUG_RETURN(FALSE);); DBUG_EXECUTE_IF("row_merge_write_failure", DBUG_RETURN(FALSE););
IORequest request(IORequest::WRITE); IORequest request(IORequest::WRITE);
...@@ -1296,11 +1291,10 @@ row_merge_read_rec( ...@@ -1296,11 +1291,10 @@ row_merge_read_rec(
if (UNIV_UNLIKELY(!extra_size)) { if (UNIV_UNLIKELY(!extra_size)) {
/* End of list */ /* End of list */
*mrec = NULL; *mrec = NULL;
DBUG_PRINT("ib_merge_sort", DBUG_LOG("ib_merge_sort",
("read %p,%p,%d,%lu EOF\n", "read " << reinterpret_cast<const void*>(b) << ',' <<
reinterpret_cast<const void*>(b), reinterpret_cast<const void*>(block) << ',' <<
reinterpret_cast<const void*>(block), fd << ',' << *foffs << " EOF");
fd, ulint(*foffs)));
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
} }
...@@ -1413,18 +1407,11 @@ row_merge_read_rec( ...@@ -1413,18 +1407,11 @@ row_merge_read_rec(
b += extra_size + data_size - avail_size; b += extra_size + data_size - avail_size;
func_exit: func_exit:
DBUG_LOG("ib_merge_sort",
#ifdef UNIV_DEBUG reinterpret_cast<const void*>(b) << ',' <<
{ reinterpret_cast<const void*>(block)
rec_printer p(*mrec, 0, offsets); << ",fd=" << fd << ',' << *foffs << ": "
DBUG_PRINT("ib_merge_sort", << rec_printer(*mrec, 0, offsets).str());
("%p,%p,fd=%d,%lu: %s",
reinterpret_cast<const void*>(b),
reinterpret_cast<const void*>(block),
fd, ulint(*foffs),
p.str().c_str()));
}
#endif
DBUG_RETURN(b); DBUG_RETURN(b);
} }
...@@ -1455,15 +1442,9 @@ row_merge_write_rec_low( ...@@ -1455,15 +1442,9 @@ row_merge_write_rec_low(
#endif /* DBUG_OFF */ #endif /* DBUG_OFF */
DBUG_ASSERT(e == rec_offs_extra_size(offsets) + 1); DBUG_ASSERT(e == rec_offs_extra_size(offsets) + 1);
#ifdef UNIV_DEBUG DBUG_LOG("ib_merge_sort",
{ reinterpret_cast<const void*>(b) << ",fd=" << fd << ','
rec_printer p(mrec, 0, offsets); << foffs << ": " << rec_printer(mrec, 0, offsets).str());
DBUG_PRINT("ib_merge_sort",
("%p,fd=%d,%lu: %s",
reinterpret_cast<const void*>(b), fd, ulint(foffs),
p.str().c_str()));
}
#endif
if (e < 0x80) { if (e < 0x80) {
*b++ = (byte) e; *b++ = (byte) e;
...@@ -1573,11 +1554,10 @@ row_merge_write_eof( ...@@ -1573,11 +1554,10 @@ row_merge_write_eof(
ut_ad(foffs); ut_ad(foffs);
DBUG_ENTER("row_merge_write_eof"); DBUG_ENTER("row_merge_write_eof");
DBUG_PRINT("ib_merge_sort", DBUG_LOG("ib_merge_sort",
("%p,%p,fd=%d,%lu", reinterpret_cast<const void*>(b) << ',' <<
reinterpret_cast<const void*>(b), reinterpret_cast<const void*>(block) <<
reinterpret_cast<const void*>(block), ",fd=" << fd << ',' << *foffs);
fd, ulint(*foffs)));
if (b == &block[0]) { if (b == &block[0]) {
b+= ROW_MERGE_RESERVE_SIZE; b+= ROW_MERGE_RESERVE_SIZE;
...@@ -2937,10 +2917,9 @@ row_merge_blocks( ...@@ -2937,10 +2917,9 @@ row_merge_blocks(
ulint* offsets1;/* offsets of mrec1 */ ulint* offsets1;/* offsets of mrec1 */
DBUG_ENTER("row_merge_blocks"); DBUG_ENTER("row_merge_blocks");
DBUG_PRINT("ib_merge_sort", DBUG_LOG("ib_merge_sort",
("fd=%d,%lu+%lu to fd=%d,%lu", "fd=" << file->fd << ',' << *foffs0 << '+' << *foffs1
file->fd, ulint(*foffs0), ulint(*foffs1), << " to fd=" << of->fd << ',' << of->offset);
of->fd, ulint(of->offset)));
heap = row_merge_heap_create(dup->index, &buf, &offsets0, &offsets1); heap = row_merge_heap_create(dup->index, &buf, &offsets0, &offsets1);
...@@ -3050,10 +3029,9 @@ row_merge_blocks_copy( ...@@ -3050,10 +3029,9 @@ row_merge_blocks_copy(
ulint* offsets1;/* dummy offsets */ ulint* offsets1;/* dummy offsets */
DBUG_ENTER("row_merge_blocks_copy"); DBUG_ENTER("row_merge_blocks_copy");
DBUG_PRINT("ib_merge_sort", DBUG_LOG("ib_merge_sort",
("fd=%d,%lu to fd=%d,%lu", "fd=" << file->fd << ',' << foffs0
file->fd, ulint(foffs0), << " to fd=" << of->fd << ',' << of->offset);
of->fd, ulint(of->offset)));
heap = row_merge_heap_create(index, &buf, &offsets0, &offsets1); heap = row_merge_heap_create(index, &buf, &offsets0, &offsets1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment