MDEV-29613 Improve WITH_DBUG_TRACE=OFF

In commit 28325b08633372cc343dfcbc41fe252020cf6e6e
a compile-time option was introduced to disable the macros
DBUG_ENTER and DBUG_RETURN or DBUG_VOID_RETURN.

The parameter name WITH_DBUG_TRACE would hint that it also
covers DBUG_PRINT statements. Let us do that: WITH_DBUG_TRACE=OFF
shall disable DBUG_PRINT() as well.

A few InnoDB recovery tests used to check that some output from
DBUG_PRINT("ib_log", ...) is present. We can live without those checks.

Reviewed by: Vladislav Vaintroub
This commit is contained in:
Marko Mäkelä 2022-09-23 13:40:42 +03:00
parent db7e04ed3a
commit a69cf6f07e
31 changed files with 89 additions and 99 deletions

View File

@ -248,9 +248,11 @@ ENDIF()
INCLUDE(wsrep) INCLUDE(wsrep)
OPTION(WITH_DBUG_TRACE "Enable DBUG_ENTER()/DBUG_EXIT()" ON) OPTION(WITH_DBUG_TRACE "Enable DBUG_ENTER()/DBUG_RETURN()/DBUG_PRINT()" ON)
IF(WITH_DBUG_TRACE) IF(WITH_DBUG_TRACE)
ADD_DEFINITIONS(-DDBUG_TRACE) FOREACH(LANG C CXX)
SET(CMAKE_${LANG}_FLAGS_DEBUG "${CMAKE_${LANG}_FLAGS_DEBUG} -DDBUG_TRACE")
ENDFOREACH()
ENDIF() ENDIF()
# Always enable debug sync for debug builds. # Always enable debug sync for debug builds.

View File

@ -6158,18 +6158,18 @@ static bool xtrabackup_prepare_func(char** argv)
{ {
for (int i= 0; i < got; i++) for (int i= 0; i < got; i++)
{ {
#ifndef DBUG_OFF #ifdef DBUG_TRACE
int rc= int rc=
#endif // !DBUG_OFF #endif
innobase_rollback_by_xid(NULL, xid_list + i); innobase_rollback_by_xid(NULL, xid_list + i);
#ifndef DBUG_OFF #ifdef DBUG_TRACE
if (rc == 0) if (rc == 0)
{ {
char buf[XIDDATASIZE * 4 + 6]; // see xid_to_str char buf[XIDDATASIZE * 4 + 6]; // see xid_to_str
DBUG_PRINT("info", DBUG_PRINT("info",
("rollback xid %s", xid_to_str(buf, xid_list[i]))); ("rollback xid %s", xid_to_str(buf, xid_list[i])));
} }
#endif // !DBUG_OFF #endif
} }
} }
ut_d(recv_no_log_write= true); ut_d(recv_no_log_write= true);

View File

@ -74,6 +74,9 @@ extern int (*dbug_sanity)(void);
_db_stack_frame_.line= 0; \ _db_stack_frame_.line= 0; \
} while(0) } while(0)
#define DBUG_PRINT(keyword,arglist) \
do if (_db_pargs_(__LINE__,keyword)) _db_doprnt_ arglist; while(0)
#ifdef HAVE_ATTRIBUTE_CLEANUP #ifdef HAVE_ATTRIBUTE_CLEANUP
#define DBUG_ENTER(a) struct _db_stack_frame_ _db_stack_frame_ __attribute__((cleanup(_db_return_))); \ #define DBUG_ENTER(a) struct _db_stack_frame_ _db_stack_frame_ __attribute__((cleanup(_db_return_))); \
_db_enter_ (a,__FILE__,__LINE__,&_db_stack_frame_) _db_enter_ (a,__FILE__,__LINE__,&_db_stack_frame_)
@ -91,6 +94,7 @@ extern int (*dbug_sanity)(void);
#define DBUG_ENTER(a) #define DBUG_ENTER(a)
#define DBUG_RETURN(a1) return(a1) #define DBUG_RETURN(a1) return(a1)
#define DBUG_VOID_RETURN return #define DBUG_VOID_RETURN return
#define DBUG_PRINT(keyword,arglist) do{} while(0)
#endif #endif
#define DBUG_EXECUTE(keyword,a1) \ #define DBUG_EXECUTE(keyword,a1) \
@ -101,8 +105,6 @@ extern int (*dbug_sanity)(void);
(_db_keyword_(0,(keyword), 0) ? (a1) : (a2)) (_db_keyword_(0,(keyword), 0) ? (a1) : (a2))
#define DBUG_EVALUATE_IF(keyword,a1,a2) \ #define DBUG_EVALUATE_IF(keyword,a1,a2) \
(_db_keyword_(0,(keyword), 1) ? (a1) : (a2)) (_db_keyword_(0,(keyword), 1) ? (a1) : (a2))
#define DBUG_PRINT(keyword,arglist) \
do if (_db_pargs_(__LINE__,keyword)) _db_doprnt_ arglist; while(0)
#define DBUG_PUSH(a1) _db_push_ (a1) #define DBUG_PUSH(a1) _db_push_ (a1)
#define DBUG_POP() _db_pop_ () #define DBUG_POP() _db_pop_ ()
#define DBUG_SET(a1) _db_set_ (a1) #define DBUG_SET(a1) _db_set_ (a1)
@ -164,6 +166,7 @@ extern void _db_suicide_(void);
#define DBUG_LEAVE #define DBUG_LEAVE
#define DBUG_RETURN(a1) do { return(a1); } while(0) #define DBUG_RETURN(a1) do { return(a1); } while(0)
#define DBUG_VOID_RETURN do { return; } while(0) #define DBUG_VOID_RETURN do { return; } while(0)
#define DBUG_PRINT(keyword, arglist) do { } while(0)
#define DBUG_EXECUTE(keyword,a1) do { } while(0) #define DBUG_EXECUTE(keyword,a1) do { } while(0)
#define DBUG_EXECUTE_IF(keyword,a1) do { } while(0) #define DBUG_EXECUTE_IF(keyword,a1) do { } while(0)
#define DBUG_EVALUATE(keyword,a1,a2) (a2) #define DBUG_EVALUATE(keyword,a1,a2) (a2)

View File

@ -15,7 +15,6 @@ set global debug_key_management_version=10;
select count(*) from information_schema.innodb_tablespaces_encryption where current_key_version <> 10; select count(*) from information_schema.innodb_tablespaces_encryption where current_key_version <> 10;
count(*) count(*)
0 0
SET GLOBAL debug_dbug = '+d,ib_log';
SET GLOBAL innodb_log_checkpoint_now = 1; SET GLOBAL innodb_log_checkpoint_now = 1;
SET GLOBAL innodb_flush_log_at_trx_commit = 1; SET GLOBAL innodb_flush_log_at_trx_commit = 1;
INSERT INTO t1 VALUES(NULL); INSERT INTO t1 VALUES(NULL);

View File

@ -25,7 +25,6 @@ let $wait_condition= select count(*) = $tables_count from information_schema.inn
select count(*) from information_schema.innodb_tablespaces_encryption where current_key_version <> 10; select count(*) from information_schema.innodb_tablespaces_encryption where current_key_version <> 10;
# Test redo log key rotation and crash recovery. # Test redo log key rotation and crash recovery.
SET GLOBAL debug_dbug = '+d,ib_log';
SET GLOBAL innodb_log_checkpoint_now = 1; SET GLOBAL innodb_log_checkpoint_now = 1;
SET GLOBAL innodb_flush_log_at_trx_commit = 1; SET GLOBAL innodb_flush_log_at_trx_commit = 1;
INSERT INTO t1 VALUES(NULL); INSERT INTO t1 VALUES(NULL);

View File

@ -11,11 +11,8 @@ INSERT INTO t1 VALUES (1,2);
ALTER TABLE t1 ADD PRIMARY KEY(a), LOCK=SHARED, ALGORITHM=INPLACE; ALTER TABLE t1 ADD PRIMARY KEY(a), LOCK=SHARED, ALGORITHM=INPLACE;
ALTER TABLE t1 DROP INDEX b, ADD INDEX (b), LOCK=SHARED; ALTER TABLE t1 DROP INDEX b, ADD INDEX (b), LOCK=SHARED;
# Kill the server # Kill the server
# restart: --debug=d,ib_log # restart
FOUND 2 /scan \d+: multi-log rec MLOG_FILE_CREATE2 len \d+ page \d+:0/ in mysqld.1.err
FOUND 3 /scan \d+: log rec MLOG_INDEX_LOAD/ in mysqld.1.err
CHECK TABLE t1; CHECK TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 check status OK test.t1 check status OK
# restart
DROP TABLE t1; DROP TABLE t1;

View File

@ -9,10 +9,9 @@ CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
SELECT * FROM t1; SELECT * FROM t1;
ERROR 42000: Unknown storage engine 'InnoDB' ERROR 42000: Unknown storage engine 'InnoDB'
FOUND 1 /InnoDB: Tablespace 4294967280 was not found at .*, but there were no modifications either/ in mysqld.1.err FOUND 1 /InnoDB: Tablespace 4294967280 was not found at .*, but there were no modifications either/ in mysqld.1.err
# restart: --debug=d,innodb_log_abort_3,ib_log --innodb-log-files-in-group=1 --innodb-log-file-size=4M # restart: --debug=d,innodb_log_abort_3 --innodb-log-files-in-group=1 --innodb-log-file-size=4M
SELECT * FROM t1; SELECT * FROM t1;
ERROR 42000: Unknown storage engine 'InnoDB' ERROR 42000: Unknown storage engine 'InnoDB'
FOUND 1 /ib_log: MLOG_CHECKPOINT.* written/ in mysqld.1.err
# restart # restart
# restart # restart
DROP TABLE t1; DROP TABLE t1;

View File

@ -26,22 +26,7 @@ ALTER TABLE t1 DROP INDEX b, ADD INDEX (b), LOCK=SHARED;
--let CLEANUP_IF_CHECKPOINT=DROP TABLE t1; --let CLEANUP_IF_CHECKPOINT=DROP TABLE t1;
--source include/no_checkpoint_end.inc --source include/no_checkpoint_end.inc
--let $restart_parameters= --debug=d,ib_log
--source include/start_mysqld.inc --source include/start_mysqld.inc
let SEARCH_FILE = $MYSQLTEST_VARDIR/log/mysqld.1.err;
let SEARCH_ABORT=NOT FOUND;
# ensure that we have exactly 2 records there.
let SEARCH_PATTERN=scan \d+: multi-log rec MLOG_FILE_CREATE2 len \d+ page \d+:0;
--source include/search_pattern_in_file.inc
# ensure that we have exactly 3 records there.
let SEARCH_PATTERN=scan \d+: log rec MLOG_INDEX_LOAD;
--source include/search_pattern_in_file.inc
CHECK TABLE t1; CHECK TABLE t1;
# Remove the --debug=d,ib_log setting.
--let $restart_parameters=
--source include/restart_mysqld.inc
DROP TABLE t1; DROP TABLE t1;

View File

@ -35,12 +35,10 @@ SELECT * FROM t1;
--let SEARCH_PATTERN = InnoDB: Tablespace 4294967280 was not found at .*, but there were no modifications either --let SEARCH_PATTERN = InnoDB: Tablespace 4294967280 was not found at .*, but there were no modifications either
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
--let $restart_parameters= --debug=d,innodb_log_abort_3,ib_log $resize --let $restart_parameters= --debug=d,innodb_log_abort_3 $resize
--source include/restart_mysqld.inc --source include/restart_mysqld.inc
--error ER_UNKNOWN_STORAGE_ENGINE --error ER_UNKNOWN_STORAGE_ENGINE
SELECT * FROM t1; SELECT * FROM t1;
--let SEARCH_PATTERN= ib_log: MLOG_CHECKPOINT.* written
--source include/search_pattern_in_file.inc
--let $restart_parameters= --let $restart_parameters=
--source include/restart_mysqld.inc --source include/restart_mysqld.inc

View File

@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. /* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
Copyright (c) 2017, MariaDB Corporation. Copyright (c) 2017, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -376,7 +376,7 @@ static void keycache_debug_print(const char *fmt,...);
#define KEYCACHE_DBUG_ASSERT(a) DBUG_ASSERT(a) #define KEYCACHE_DBUG_ASSERT(a) DBUG_ASSERT(a)
#endif /* defined(KEYCACHE_DEBUG_LOG) && defined(KEYCACHE_DEBUG) */ #endif /* defined(KEYCACHE_DEBUG_LOG) && defined(KEYCACHE_DEBUG) */
#if defined(KEYCACHE_DEBUG) || !defined(DBUG_OFF) #if defined(KEYCACHE_DEBUG) || defined(DBUG_TRACE)
static long keycache_thread_id; static long keycache_thread_id;
#define KEYCACHE_THREAD_TRACE(l) \ #define KEYCACHE_THREAD_TRACE(l) \
KEYCACHE_DBUG_PRINT(l,("|thread %ld",keycache_thread_id)) KEYCACHE_DBUG_PRINT(l,("|thread %ld",keycache_thread_id))
@ -392,7 +392,7 @@ static long keycache_thread_id;
#define KEYCACHE_THREAD_TRACE_BEGIN(l) #define KEYCACHE_THREAD_TRACE_BEGIN(l)
#define KEYCACHE_THREAD_TRACE_END(l) #define KEYCACHE_THREAD_TRACE_END(l)
#define KEYCACHE_THREAD_TRACE(l) #define KEYCACHE_THREAD_TRACE(l)
#endif /* defined(KEYCACHE_DEBUG) || !defined(DBUG_OFF) */ #endif /* defined(KEYCACHE_DEBUG) || defined(DBUG_TRACE) */
#define BLOCK_NUMBER(b) \ #define BLOCK_NUMBER(b) \
((uint) (((char*)(b)-(char *) keycache->block_root)/sizeof(BLOCK_LINK))) ((uint) (((char*)(b)-(char *) keycache->block_root)/sizeof(BLOCK_LINK)))

View File

@ -1,5 +1,5 @@
/* Copyright (c) 2009, 2013, Oracle and/or its affiliates. /* Copyright (c) 2009, 2013, Oracle and/or its affiliates.
Copyright (c) 2013, 2020, MariaDB Copyright (c) 2013, 2022, MariaDB
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -326,7 +326,7 @@ static char *debug_sync_bmove_len(char *to, char *to_end,
} }
#if !defined(DBUG_OFF) #ifdef DBUG_TRACE
/** /**
Create a string that describes an action. Create a string that describes an action.
@ -416,8 +416,7 @@ static void debug_sync_print_actions(THD *thd)
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
#endif /* defined(DBUG_TRACE) */
#endif /* !defined(DBUG_OFF) */
/** /**
@ -748,6 +747,7 @@ static bool debug_sync_set_action(THD *thd, st_debug_sync_action *action)
else else
{ {
const char *dsp_name= action->sync_point.c_ptr(); const char *dsp_name= action->sync_point.c_ptr();
#ifdef DBUG_TRACE
DBUG_EXECUTE("debug_sync", { DBUG_EXECUTE("debug_sync", {
/* Functions as DBUG_PRINT args can change keyword and line nr. */ /* Functions as DBUG_PRINT args can change keyword and line nr. */
const char *sig_emit= action->signal.c_ptr(); const char *sig_emit= action->signal.c_ptr();
@ -758,6 +758,7 @@ static bool debug_sync_set_action(THD *thd, st_debug_sync_action *action)
dsp_name, action->activation_count, dsp_name, action->activation_count,
action->hit_limit, action->execute, action->timeout, action->hit_limit, action->execute, action->timeout,
sig_emit, sig_wait));}); sig_emit, sig_wait));});
#endif
/* Check this before sorting the array. action may move. */ /* Check this before sorting the array. action may move. */
is_dsp_now= !my_strcasecmp(system_charset_info, dsp_name, "now"); is_dsp_now= !my_strcasecmp(system_charset_info, dsp_name, "now");
@ -770,7 +771,9 @@ static bool debug_sync_set_action(THD *thd, st_debug_sync_action *action)
sizeof(st_debug_sync_action), debug_sync_qsort_cmp); sizeof(st_debug_sync_action), debug_sync_qsort_cmp);
} }
} }
#ifdef DBUG_TRACE
DBUG_EXECUTE("debug_sync_list", debug_sync_print_actions(thd);); DBUG_EXECUTE("debug_sync_list", debug_sync_print_actions(thd););
#endif
/* Execute the special sync point 'now' if activated above. */ /* Execute the special sync point 'now' if activated above. */
if (is_dsp_now) if (is_dsp_now)
@ -1334,7 +1337,7 @@ uchar *debug_sync_value_ptr(THD *thd)
static void debug_sync_execute(THD *thd, st_debug_sync_action *action) static void debug_sync_execute(THD *thd, st_debug_sync_action *action)
{ {
#ifndef DBUG_OFF #ifdef DBUG_TRACE
const char *dsp_name= action->sync_point.c_ptr(); const char *dsp_name= action->sync_point.c_ptr();
const char *sig_emit= action->signal.c_ptr(); const char *sig_emit= action->signal.c_ptr();
const char *sig_wait= action->wait_for.c_ptr(); const char *sig_wait= action->wait_for.c_ptr();
@ -1425,12 +1428,12 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action)
restore_current_mutex = false; restore_current_mutex = false;
set_timespec(abstime, action->timeout); set_timespec(abstime, action->timeout);
DBUG_EXECUTE("debug_sync_exec", { DBUG_EXECUTE("debug_sync_exec",
/* Functions as DBUG_PRINT args can change keyword and line nr. */ /* Functions as DBUG_PRINT args can change keyword and line nr. */
const char *sig_glob= debug_sync_global.ds_signal.c_ptr();
DBUG_PRINT("debug_sync_exec", DBUG_PRINT("debug_sync_exec",
("wait for '%s' at: '%s' curr: '%s'", ("wait for '%s' at: '%s' curr: '%s'",
sig_wait, dsp_name, sig_glob));}); sig_wait, dsp_name,
debug_sync_global.ds_signal.c_ptr())););
/* /*
Wait until global signal string matches the wait_for string. Wait until global signal string matches the wait_for string.
@ -1444,12 +1447,12 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action)
error= mysql_cond_timedwait(&debug_sync_global.ds_cond, error= mysql_cond_timedwait(&debug_sync_global.ds_cond,
&debug_sync_global.ds_mutex, &debug_sync_global.ds_mutex,
&abstime); &abstime);
DBUG_EXECUTE("debug_sync", { DBUG_EXECUTE("debug_sync",
/* Functions as DBUG_PRINT args can change keyword and line nr. */ /* Functions as DBUG_PRINT args can change keyword and line nr. */
const char *sig_glob= debug_sync_global.ds_signal.c_ptr();
DBUG_PRINT("debug_sync", DBUG_PRINT("debug_sync",
("awoke from %s global: %s error: %d", ("awoke from %s global: %s error: %d",
sig_wait, sig_glob, error));}); sig_wait, debug_sync_global.ds_signal.c_ptr(),
error)););
if (unlikely(error == ETIMEDOUT || error == ETIME)) if (unlikely(error == ETIMEDOUT || error == ETIME))
{ {
// We should not make the statement fail, even if in strict mode. // We should not make the statement fail, even if in strict mode.

View File

@ -538,7 +538,7 @@ Event_queue::empty_queue()
void void
Event_queue::dbug_dump_queue(my_time_t when) Event_queue::dbug_dump_queue(my_time_t when)
{ {
#ifndef DBUG_OFF #ifdef DBUG_TRACE
my_time_t now= when; my_time_t now= when;
Event_queue_element *et; Event_queue_element *et;
uint i; uint i;

View File

@ -3269,7 +3269,7 @@ bool Field_new_decimal::store_value(const my_decimal *decimal_value,
DBUG_ASSERT(marked_for_write_or_computed()); DBUG_ASSERT(marked_for_write_or_computed());
int error= 0; int error= 0;
DBUG_ENTER("Field_new_decimal::store_value"); DBUG_ENTER("Field_new_decimal::store_value");
#ifndef DBUG_OFF #ifdef DBUG_TRACE
{ {
char dbug_buff[DECIMAL_MAX_STR_LENGTH+2]; char dbug_buff[DECIMAL_MAX_STR_LENGTH+2];
DBUG_PRINT("enter", ("value: %s", dbug_decimal_as_string(dbug_buff, decimal_value))); DBUG_PRINT("enter", ("value: %s", dbug_decimal_as_string(dbug_buff, decimal_value)));
@ -3284,7 +3284,7 @@ bool Field_new_decimal::store_value(const my_decimal *decimal_value,
error= 1; error= 1;
decimal_value= &decimal_zero; decimal_value= &decimal_zero;
} }
#ifndef DBUG_OFF #ifdef DBUG_TRACE
{ {
char dbug_buff[DECIMAL_MAX_STR_LENGTH+2]; char dbug_buff[DECIMAL_MAX_STR_LENGTH+2];
DBUG_PRINT("info", ("saving with precision %d scale: %d value %s", DBUG_PRINT("info", ("saving with precision %d scale: %d value %s",
@ -3376,7 +3376,7 @@ int Field_new_decimal::store(const char *from, size_t length,
} }
} }
#ifndef DBUG_OFF #ifdef DBUG_TRACE
char dbug_buff[DECIMAL_MAX_STR_LENGTH+2]; char dbug_buff[DECIMAL_MAX_STR_LENGTH+2];
DBUG_PRINT("enter", ("value: %s", DBUG_PRINT("enter", ("value: %s",
dbug_decimal_as_string(dbug_buff, &decimal_value))); dbug_decimal_as_string(dbug_buff, &decimal_value)));

View File

@ -116,16 +116,20 @@ static void GCALC_DBUG_PRINT_PI(const Gcalc_heap::Info *pi)
int n_buf; int n_buf;
if (pi->type == Gcalc_heap::nt_intersection) if (pi->type == Gcalc_heap::nt_intersection)
{ {
#ifdef DBUG_TRACE
const Gcalc_scan_iterator::intersection_info *ic= i_data(pi); const Gcalc_scan_iterator::intersection_info *ic= i_data(pi);
GCALC_DBUG_PRINT(("intersection point %d %d", GCALC_DBUG_PRINT(("intersection point %d %d",
ic->edge_a->thread, ic->edge_b->thread)); ic->edge_a->thread, ic->edge_b->thread));
#endif
return; return;
} }
if (pi->type == Gcalc_heap::nt_eq_node) if (pi->type == Gcalc_heap::nt_eq_node)
{ {
#ifdef DBUG_TRACE
const Gcalc_scan_iterator::point *e= eq_sp(pi); const Gcalc_scan_iterator::point *e= eq_sp(pi);
GCALC_DBUG_PRINT(("eq point %d", e->thread)); GCALC_DBUG_PRINT(("eq point %d", e->thread));
#endif
return; return;
} }
n_buf= gcalc_pi_str(buf, pi, ""); n_buf= gcalc_pi_str(buf, pi, "");

View File

@ -726,7 +726,7 @@ public:
} }
void harvest_bytes_written(Atomic_counter<uint64> *counter) void harvest_bytes_written(Atomic_counter<uint64> *counter)
{ {
#ifndef DBUG_OFF #ifdef DBUG_TRACE
char buf1[22],buf2[22]; char buf1[22],buf2[22];
#endif #endif
DBUG_ENTER("harvest_bytes_written"); DBUG_ENTER("harvest_bytes_written");

View File

@ -1,6 +1,6 @@
/* /*
Copyright (c) 2000, 2019, Oracle and/or its affiliates. Copyright (c) 2000, 2019, Oracle and/or its affiliates.
Copyright (c) 2009, 2021, MariaDB Copyright (c) 2009, 2022, MariaDB
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -4557,7 +4557,7 @@ static void copy_str_and_move(const char **src,
} }
#ifndef DBUG_OFF #ifdef DBUG_TRACE
static char const * static char const *
code_name(int code) code_name(int code)
{ {

View File

@ -2278,7 +2278,7 @@ MDL_context::acquire_lock(MDL_request *mdl_request, double lock_wait_timeout)
MDL_ticket *ticket; MDL_ticket *ticket;
MDL_wait::enum_wait_status wait_status; MDL_wait::enum_wait_status wait_status;
DBUG_ENTER("MDL_context::acquire_lock"); DBUG_ENTER("MDL_context::acquire_lock");
#ifndef DBUG_OFF #ifdef DBUG_TRACE
const char *mdl_lock_name= get_mdl_lock_name( const char *mdl_lock_name= get_mdl_lock_name(
mdl_request->key.mdl_namespace(), mdl_request->type)->str; mdl_request->key.mdl_namespace(), mdl_request->type)->str;
#endif #endif
@ -2304,7 +2304,7 @@ MDL_context::acquire_lock(MDL_request *mdl_request, double lock_wait_timeout)
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
} }
#ifndef DBUG_OFF #ifdef DBUG_TRACE
const char *ticket_msg= dbug_print_mdl(ticket); const char *ticket_msg= dbug_print_mdl(ticket);
#endif #endif

View File

@ -263,14 +263,14 @@ public:
*/ */
int check_state(enum_state const target_state) int check_state(enum_state const target_state)
{ {
#ifndef DBUG_OFF #ifdef DBUG_TRACE
static char const *state_name[] = { static char const *state_name[] = {
"START_STATE", "TABLE_STATE", "ROW_STATE", "STATE_COUNT" "START_STATE", "TABLE_STATE", "ROW_STATE", "STATE_COUNT"
}; };
DBUG_ASSERT(target_state <= STATE_COUNT);
DBUG_PRINT("info", ("In state %s", state_name[m_state])); DBUG_PRINT("info", ("In state %s", state_name[m_state]));
#endif #endif
DBUG_ASSERT(target_state <= STATE_COUNT);
if (m_state <= target_state && target_state <= m_state + 1 && if (m_state <= target_state && target_state <= m_state + 1 &&
m_state < STATE_COUNT) m_state < STATE_COUNT)

View File

@ -1,5 +1,5 @@
/* Copyright (c) 2007, 2013, Oracle and/or its affiliates. /* Copyright (c) 2007, 2013, Oracle and/or its affiliates.
Copyright (c) 2008, 2019, MariaDB Corporation. Copyright (c) 2008, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -319,7 +319,9 @@ unpack_row(rpl_group_info *rgi,
normal unpack operation. normal unpack operation.
*/ */
uint16 const metadata= tabledef->field_metadata(i); uint16 const metadata= tabledef->field_metadata(i);
IF_DBUG(uchar const *const old_pack_ptr= pack_ptr;,) #ifdef DBUG_TRACE
uchar const *const old_pack_ptr= pack_ptr;
#endif
pack_ptr= f->unpack(f->ptr, pack_ptr, row_end, metadata); pack_ptr= f->unpack(f->ptr, pack_ptr, row_end, metadata);
DBUG_PRINT("debug", ("field: %s; metadata: 0x%x;" DBUG_PRINT("debug", ("field: %s; metadata: 0x%x;"

View File

@ -3831,7 +3831,7 @@ apply_event_and_update_pos_apply(Log_event* ev, THD* thd, rpl_group_info *rgi,
} }
#endif #endif
#ifndef DBUG_OFF #ifdef DBUG_TRACE
/* /*
This only prints information to the debug trace. This only prints information to the debug trace.
@ -3857,7 +3857,7 @@ apply_event_and_update_pos_apply(Log_event* ev, THD* thd, rpl_group_info *rgi,
if (exec_res == 0) if (exec_res == 0)
{ {
int error= ev->update_pos(rgi); int error= ev->update_pos(rgi);
#ifndef DBUG_OFF #ifdef DBUG_TRACE
DBUG_PRINT("info", ("update_pos error = %d", error)); DBUG_PRINT("info", ("update_pos error = %d", error));
if (!rli->belongs_to_client()) if (!rli->belongs_to_client())
{ {

View File

@ -41,14 +41,13 @@ static int check_event_type(int type, Relay_log_info *rli)
*/ */
if (fd_event && fd_event->event_type_permutation) if (fd_event && fd_event->event_type_permutation)
{ {
IF_DBUG({ #ifdef DBUG_TRACE
int new_type= fd_event->event_type_permutation[type]; int new_type= fd_event->event_type_permutation[type];
DBUG_PRINT("info", DBUG_PRINT("info",
("converting event type %d to %d (%s)", ("converting event type %d to %d (%s)",
type, new_type, type, new_type,
Log_event::get_type_str((Log_event_type)new_type))); Log_event::get_type_str((Log_event_type)new_type)));
}, #endif
(void)0);
type= fd_event->event_type_permutation[type]; type= fd_event->event_type_permutation[type];
} }

View File

@ -4762,7 +4762,7 @@ void Query_cache::cache_dump()
void Query_cache::queries_dump() void Query_cache::queries_dump()
{ {
#ifdef DBUG_TRACE
if (!initialized) if (!initialized)
{ {
DBUG_PRINT("qcache", ("Query Cache not initialized")); DBUG_PRINT("qcache", ("Query Cache not initialized"));
@ -4823,11 +4823,13 @@ void Query_cache::queries_dump()
DBUG_PRINT("qcache", ("no queries in list")); DBUG_PRINT("qcache", ("no queries in list"));
} }
DBUG_PRINT("qcache", ("------------------")); DBUG_PRINT("qcache", ("------------------"));
#endif
} }
void Query_cache::tables_dump() void Query_cache::tables_dump()
{ {
#ifdef DBUG_TRACE
if (!initialized || query_cache_size == 0) if (!initialized || query_cache_size == 0)
{ {
DBUG_PRINT("qcache", ("Query Cache not initialized")); DBUG_PRINT("qcache", ("Query Cache not initialized"));
@ -4850,6 +4852,7 @@ void Query_cache::tables_dump()
else else
DBUG_PRINT("qcache", ("no tables in list")); DBUG_PRINT("qcache", ("no tables in list"));
DBUG_PRINT("qcache", ("--------------------")); DBUG_PRINT("qcache", ("--------------------"));
#endif
} }

View File

@ -7054,7 +7054,7 @@ int THD::binlog_flush_pending_rows_event(bool stmt_end, bool is_transactional)
} }
#if !defined(DBUG_OFF) && !defined(_lint) #if defined(DBUG_TRACE) && !defined(_lint)
static const char * static const char *
show_query_type(THD::enum_binlog_query_type qtype) show_query_type(THD::enum_binlog_query_type qtype)
{ {

View File

@ -8583,7 +8583,7 @@ int TABLE::update_virtual_fields(handler *h, enum_vcol_update_mode update_mode)
{ {
/* Compute the actual value of the virtual fields */ /* Compute the actual value of the virtual fields */
DBUG_FIX_WRITE_SET(vf); DBUG_FIX_WRITE_SET(vf);
# ifndef DBUG_OFF # ifdef DBUG_TRACE
int field_error= int field_error=
# endif # endif
vcol_info->expr->save_in_field(vf, 0); vcol_info->expr->save_in_field(vf, 0);

View File

@ -892,7 +892,7 @@ que_node_get_containing_loop_node(
return(node); return(node);
} }
#ifndef DBUG_OFF #ifdef DBUG_TRACE
/** Gets information of an SQL query graph node. /** Gets information of an SQL query graph node.
@return type description */ @return type description */
static MY_ATTRIBUTE((warn_unused_result, nonnull)) static MY_ATTRIBUTE((warn_unused_result, nonnull))
@ -949,7 +949,7 @@ que_node_type_string(
return("UNKNOWN NODE TYPE"); return("UNKNOWN NODE TYPE");
} }
} }
#endif /* !DBUG_OFF */ #endif /* DBUG_TRACE */
/**********************************************************************//** /**********************************************************************//**
Performs an execution step on a query thread. Performs an execution step on a query thread.

View File

@ -1040,7 +1040,7 @@ static int chk_index(HA_CHECK *param, MARIA_HA *info, MARIA_KEYDEF *keyinfo,
share->state.state.data_file_length) || share->state.state.data_file_length) ||
(share->data_file_type == NO_RECORD && record != 0)) (share->data_file_type == NO_RECORD && record != 0))
{ {
#ifndef DBUG_OFF #ifdef DBUG_TRACE
char llbuff2[22], llbuff3[22]; char llbuff2[22], llbuff3[22];
#endif #endif
_ma_check_print_error(param, _ma_check_print_error(param,

View File

@ -2661,7 +2661,7 @@ static my_bool translog_buffer_flush(struct st_translog_buffer *buffer)
i < buffer->size; i < buffer->size;
i+= TRANSLOG_PAGE_SIZE, pg++) i+= TRANSLOG_PAGE_SIZE, pg++)
{ {
#ifndef DBUG_OFF #ifdef DBUG_TRACE
TRANSLOG_ADDRESS addr= (buffer->offset + i); TRANSLOG_ADDRESS addr= (buffer->offset + i);
#endif #endif
DBUG_PRINT("info", ("send log form %lu till %lu address: " LSN_FMT " " DBUG_PRINT("info", ("send log form %lu till %lu address: " LSN_FMT " "
@ -2908,7 +2908,7 @@ static my_bool translog_page_validator(int res, PAGECACHE_IO_HOOK_ARGS *args)
uint flags; uint flags;
uchar *page_pos; uchar *page_pos;
TRANSLOG_FILE *data= (TRANSLOG_FILE *) args->data; TRANSLOG_FILE *data= (TRANSLOG_FILE *) args->data;
#ifndef DBUG_OFF #ifdef DBUG_TRACE
pgcache_page_no_t offset= page_no * TRANSLOG_PAGE_SIZE; pgcache_page_no_t offset= page_no * TRANSLOG_PAGE_SIZE;
#endif #endif
DBUG_ENTER("translog_page_validator"); DBUG_ENTER("translog_page_validator");
@ -3268,7 +3268,7 @@ static my_bool translog_get_last_page_addr(TRANSLOG_ADDRESS *addr,
my_off_t file_size; my_off_t file_size;
uint32 file_no= LSN_FILE_NO(*addr); uint32 file_no= LSN_FILE_NO(*addr);
TRANSLOG_FILE *file; TRANSLOG_FILE *file;
#ifndef DBUG_OFF #ifdef DBUG_TRACE
char buff[21]; char buff[21];
#endif #endif
DBUG_ENTER("translog_get_last_page_addr"); DBUG_ENTER("translog_get_last_page_addr");

View File

@ -184,7 +184,7 @@ struct st_pagecache_hash_link
enum PCBLOCK_TEMPERATURE { PCBLOCK_COLD /*free*/ , PCBLOCK_WARM , PCBLOCK_HOT }; enum PCBLOCK_TEMPERATURE { PCBLOCK_COLD /*free*/ , PCBLOCK_WARM , PCBLOCK_HOT };
/* debug info */ /* debug info */
#ifndef DBUG_OFF #ifdef DBUG_TRACE
static const char *page_cache_page_type_str[]= static const char *page_cache_page_type_str[]=
{ {
/* used only for control page type changing during debugging */ /* used only for control page type changing during debugging */
@ -219,8 +219,9 @@ static const char *page_cache_page_pin_str[]=
"unpinned -> pinned", "unpinned -> pinned",
"pinned -> unpinned" "pinned -> unpinned"
}; };
#endif /* DBUG_TRACE */
#ifndef DBUG_OFF
typedef struct st_pagecache_pin_info typedef struct st_pagecache_pin_info
{ {
struct st_pagecache_pin_info *next, **prev; struct st_pagecache_pin_info *next, **prev;
@ -549,7 +550,7 @@ static void pagecache_debug_print _VARARGS((const char *fmt, ...));
#define KEYCACHE_DBUG_ASSERT(a) DBUG_ASSERT(a) #define KEYCACHE_DBUG_ASSERT(a) DBUG_ASSERT(a)
#endif /* defined(PAGECACHE_DEBUG_LOG) && defined(PAGECACHE_DEBUG) */ #endif /* defined(PAGECACHE_DEBUG_LOG) && defined(PAGECACHE_DEBUG) */
#if defined(PAGECACHE_DEBUG) || !defined(DBUG_OFF) #if defined(PAGECACHE_DEBUG) || defined(DBUG_TRACE)
static long pagecache_thread_id; static long pagecache_thread_id;
#define KEYCACHE_THREAD_TRACE(l) \ #define KEYCACHE_THREAD_TRACE(l) \
KEYCACHE_DBUG_PRINT(l,("|thread %ld",pagecache_thread_id)) KEYCACHE_DBUG_PRINT(l,("|thread %ld",pagecache_thread_id))
@ -566,7 +567,7 @@ static long pagecache_thread_id;
#define KEYCACHE_THREAD_TRACE_BEGIN(l) #define KEYCACHE_THREAD_TRACE_BEGIN(l)
#define KEYCACHE_THREAD_TRACE_END(l) #define KEYCACHE_THREAD_TRACE_END(l)
#define KEYCACHE_THREAD_TRACE(l) #define KEYCACHE_THREAD_TRACE(l)
#endif /* defined(PAGECACHE_DEBUG) || !defined(DBUG_OFF) */ #endif /* defined(PAGECACHE_DEBUG) || defined(DBUG_TRACE) */
#define PCBLOCK_NUMBER(p, b) \ #define PCBLOCK_NUMBER(p, b) \
((uint) (((char*)(b)-(char *) p->block_root)/sizeof(PAGECACHE_BLOCK_LINK))) ((uint) (((char*)(b)-(char *) p->block_root)/sizeof(PAGECACHE_BLOCK_LINK)))
@ -3345,8 +3346,9 @@ uchar *pagecache_read(PAGECACHE *pagecache,
unlock_pin= lock_to_pin[buff==0][lock].unlock_pin; unlock_pin= lock_to_pin[buff==0][lock].unlock_pin;
PAGECACHE_BLOCK_LINK *fake_link; PAGECACHE_BLOCK_LINK *fake_link;
my_bool reg_request; my_bool reg_request;
#ifndef DBUG_OFF #ifdef DBUG_TRACE
char llbuf[22]; char llbuf[22];
#endif
DBUG_ENTER("pagecache_read"); DBUG_ENTER("pagecache_read");
DBUG_PRINT("enter", ("fd: %u page: %s buffer: %p level: %u " DBUG_PRINT("enter", ("fd: %u page: %s buffer: %p level: %u "
"t:%s (%d)%s->%s %s->%s", "t:%s (%d)%s->%s %s->%s",
@ -3361,7 +3363,6 @@ uchar *pagecache_read(PAGECACHE *pagecache,
DBUG_ASSERT(buff != 0 || (buff == 0 && (unlock_pin == PAGECACHE_PIN || DBUG_ASSERT(buff != 0 || (buff == 0 && (unlock_pin == PAGECACHE_PIN ||
unlock_pin == PAGECACHE_PIN_LEFT_PINNED))); unlock_pin == PAGECACHE_PIN_LEFT_PINNED)));
DBUG_ASSERT(pageno < ((1ULL) << 40)); DBUG_ASSERT(pageno < ((1ULL) << 40));
#endif
if (!page_link) if (!page_link)
page_link= &fake_link; page_link= &fake_link;
@ -3976,8 +3977,9 @@ my_bool pagecache_write_part(PAGECACHE *pagecache,
my_bool error= 0; my_bool error= 0;
int need_lock_change= write_lock_change_table[lock].need_lock_change; int need_lock_change= write_lock_change_table[lock].need_lock_change;
my_bool reg_request; my_bool reg_request;
#ifndef DBUG_OFF #ifdef DBUG_TRACE
char llbuf[22]; char llbuf[22];
#endif
DBUG_ENTER("pagecache_write_part"); DBUG_ENTER("pagecache_write_part");
DBUG_PRINT("enter", ("fd: %u page: %s level: %u type: %s lock: %s " DBUG_PRINT("enter", ("fd: %u page: %s level: %u type: %s lock: %s "
"pin: %s mode: %s offset: %u size %u", "pin: %s mode: %s offset: %u size %u",
@ -3992,7 +3994,6 @@ my_bool pagecache_write_part(PAGECACHE *pagecache,
DBUG_ASSERT(lock != PAGECACHE_LOCK_READ_UNLOCK); DBUG_ASSERT(lock != PAGECACHE_LOCK_READ_UNLOCK);
DBUG_ASSERT(offset + size <= pagecache->block_size); DBUG_ASSERT(offset + size <= pagecache->block_size);
DBUG_ASSERT(pageno < ((1ULL) << 40)); DBUG_ASSERT(pageno < ((1ULL) << 40));
#endif
if (!page_link) if (!page_link)
page_link= &fake_link; page_link= &fake_link;

View File

@ -661,14 +661,10 @@ err:
static void *test_thread(void *arg) static void *test_thread(void *arg)
{ {
#ifndef DBUG_OFF
int param= *((int*) arg);
#endif
my_thread_init(); my_thread_init();
{ {
DBUG_ENTER("test_thread"); DBUG_ENTER("test_thread");
DBUG_PRINT("enter", ("param: %d", param)); DBUG_PRINT("enter", ("param: %d", *(int*) arg));
if (!simple_read_write_test() || if (!simple_read_write_test() ||
!simple_read_change_write_read_test() || !simple_read_change_write_read_test() ||

View File

@ -858,7 +858,7 @@ static int chk_index(HA_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo,
} }
if (record >= info->state->data_file_length) if (record >= info->state->data_file_length)
{ {
#ifndef DBUG_OFF #ifdef DBUG_TRACE
char llbuff2[22], llbuff3[22]; char llbuff2[22], llbuff3[22];
#endif #endif
mi_check_print_error(param,"Found key at page %s that points to record outside datafile",llstr(page,llbuff)); mi_check_print_error(param,"Found key at page %s that points to record outside datafile",llstr(page,llbuff));

View File

@ -702,7 +702,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
if (mi_state_info_write(file, &share.state, 2) || if (mi_state_info_write(file, &share.state, 2) ||
mi_base_info_write(file, &share.base)) mi_base_info_write(file, &share.base))
goto err; goto err;
#ifndef DBUG_OFF #ifdef DBUG_TRACE
if ((uint) mysql_file_tell(file, MYF(0)) != base_pos + MI_BASE_INFO_SIZE) if ((uint) mysql_file_tell(file, MYF(0)) != base_pos + MI_BASE_INFO_SIZE)
{ {
uint pos=(uint) mysql_file_tell(file, MYF(0)); uint pos=(uint) mysql_file_tell(file, MYF(0));
@ -802,12 +802,12 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
if (mi_recinfo_write(file, &recinfo[i])) if (mi_recinfo_write(file, &recinfo[i]))
goto err; goto err;
#ifndef DBUG_OFF #ifdef DBUG_TRACE
if ((uint) mysql_file_tell(file, MYF(0)) != info_length)
{ {
uint pos= (uint) mysql_file_tell(file, MYF(0)); uint pos= (uint) mysql_file_tell(file, MYF(0));
DBUG_PRINT("warning",("info_length: %d != used_length: %d", if (pos != info_length)
info_length, pos)); DBUG_PRINT("warning",("info_length: %d != used_length: %d",
info_length, pos));
} }
#endif #endif