diff options
63 files changed, 213 insertions, 153 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c3bb7bef9e2..0bba24898cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -243,8 +243,8 @@ ENDIF() # Set DBUG_OFF and other optional release-only flags for non-debug project types FOREACH(BUILD_TYPE RELEASE RELWITHDEBINFO MINSIZEREL) FOREACH(LANG C CXX) - IF (NOT CMAKE_${LANG}_FLAGS_${BUILD_TYPE} MATCHES "DDBUG_" AND - NOT CMAKE_${LANG}_FLAGS MATCHES "DDBUG_") + IF (NOT CMAKE_${LANG}_FLAGS_${BUILD_TYPE} MATCHES "DDBUG_ON" AND + NOT CMAKE_${LANG}_FLAGS MATCHES "DDBUG_ON") SET(CMAKE_${LANG}_FLAGS_${BUILD_TYPE} "${CMAKE_${LANG}_FLAGS_${BUILD_TYPE}} -DDBUG_OFF") ENDIF() diff --git a/client/mysqltest.cc b/client/mysqltest.cc index b036ff5645c..9ab6028c13e 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -8907,7 +8907,7 @@ static void dump_backtrace(void) #endif } fputs("Attempting backtrace...\n", stderr); - my_print_stacktrace(NULL, (ulong)my_thread_stack_size); + my_print_stacktrace(NULL, (ulong)my_thread_stack_size, 0); } #else diff --git a/dbug/dbug.c b/dbug/dbug.c index 4b96560b907..c9d63f527b4 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -2144,7 +2144,6 @@ void _db_flush_() (void) fflush(cs->stack->out_file->file); } - #ifndef __WIN__ void _db_suicide_() { @@ -2198,3 +2197,23 @@ int i_am_a_dummy_function() { } #endif /* DBUG_OFF */ + +/* + This function is called by default on DBUG_ASSERT() when compiled with + DBUG_ASSERT_AS_PRINTF +*/ + +#ifdef DBUG_ASSERT_AS_PRINTF + +static void default_my_dbug_assert_failed(const char *assert_expr, + const char *file, + unsigned long line) +{ + fprintf(stderr, "Warning: assertion failed: %s at %s line %lu\n", + assert_expr, file, line); +} + +void (*my_dbug_assert_failed)(const char *assert_expr, const char* file, + unsigned long line)= default_my_dbug_assert_failed; + +#endif /* DBUG_ASSERT_AS_PRINTF */ diff --git a/include/my_dbug.h b/include/my_dbug.h index ba9e8a025d7..ac7b13ec294 100644 --- a/include/my_dbug.h +++ b/include/my_dbug.h @@ -103,13 +103,17 @@ extern const char* _db_get_func_(void); #define DBUG_LOCK_FILE _db_lock_file_() #define DBUG_UNLOCK_FILE _db_unlock_file_() #define DBUG_ASSERT(A) assert(A) +#define DBUG_SLOW_ASSERT(A) assert(A) +#define DBUG_ASSERT_EXISTS #define DBUG_EXPLAIN(buf,len) _db_explain_(0, (buf),(len)) #define DBUG_EXPLAIN_INITIAL(buf,len) _db_explain_init_((buf),(len)) #define DEBUGGER_OFF do { _dbug_on_= 0; } while(0) #define DEBUGGER_ON do { _dbug_on_= 1; } while(0) #define IF_DBUG(A,B) A +#define IF_DBUG_ASSERT(A,B) A #define DBUG_SWAP_CODE_STATE(arg) dbug_swap_code_state(arg) #define DBUG_FREE_CODE_STATE(arg) dbug_free_code_state(arg) +#undef DBUG_ASSERT_AS_PRINTF #ifndef __WIN__ #define DBUG_ABORT() (_db_flush_(), abort()) @@ -138,7 +142,7 @@ extern const char* _db_get_func_(void); #else extern void _db_suicide_(void); #define DBUG_SUICIDE() (_db_flush_(), _db_suicide_()) -#endif +#endif /* __WIN__ */ #else /* No debugger */ @@ -159,7 +163,7 @@ extern void _db_suicide_(void); #define DBUG_PROCESS(a1) do { } while(0) #define DBUG_DUMP(keyword,a1,a2) do { } while(0) #define DBUG_END() do { } while(0) -#define DBUG_ASSERT(A) do { } while(0) +#define DBUG_SLOW_ASSERT(A) do { } while(0) #define DBUG_LOCK_FILE do { } while(0) #define DBUG_FILE (stderr) #define DBUG_UNLOCK_FILE do { } while(0) @@ -176,7 +180,16 @@ extern void _db_suicide_(void); #define DBUG_CRASH_VOID_RETURN do { return; } while(0) #define DBUG_SUICIDE() do { } while(0) -#endif +#ifdef DBUG_ASSERT_AS_PRINTF +extern void (*my_dbug_assert_failed)(const char *assert_expr, const char* file, unsigned long line); +#define DBUG_ASSERT(assert_expr) do { if (!(assert_expr)) { my_dbug_assert_failed(#assert_expr, __FILE__, __LINE__); }} while (0) +#define DBUG_ASSERT_EXISTS +#define IF_DBUG_ASSERT(A,B) A +#else +#define DBUG_ASSERT(A) do { } while(0) +#define IF_DBUG_ASSERT(A,B) B +#endif /* DBUG_ASSERT_AS_PRINTF */ +#endif /* !defined(DBUG_OFF) && !defined(_lint) */ #ifdef EXTRA_DEBUG /** diff --git a/include/my_stacktrace.h b/include/my_stacktrace.h index f5eeffbd969..cb817fb43a6 100644 --- a/include/my_stacktrace.h +++ b/include/my_stacktrace.h @@ -42,7 +42,8 @@ C_MODE_START #if defined(HAVE_STACKTRACE) || defined(HAVE_BACKTRACE) void my_init_stacktrace(); -void my_print_stacktrace(uchar* stack_bottom, ulong thread_stack); +void my_print_stacktrace(uchar* stack_bottom, ulong thread_stack, + my_bool silent); int my_safe_print_str(const char* val, int max_len); void my_write_core(int sig); #if BACKTRACE_DEMANGLE diff --git a/include/my_sys.h b/include/my_sys.h index afe50d9a67c..e8658d34af9 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -917,7 +917,7 @@ extern int unpackfrm(uchar **, size_t *, const uchar *); extern ha_checksum my_checksum(ha_checksum crc, const uchar *mem, size_t count); -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS extern void my_debug_put_break_here(void); #else #define my_debug_put_break_here() do {} while(0) diff --git a/libmysqld/emb_qcache.cc b/libmysqld/emb_qcache.cc index 78620f5d940..74a6337912a 100644 --- a/libmysqld/emb_qcache.cc +++ b/libmysqld/emb_qcache.cc @@ -28,14 +28,14 @@ void Querycache_stream::store_uchar(uchar c) if (data_end == cur_data) use_next_block(TRUE); *(cur_data++)= c; -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS stored_size++; #endif } void Querycache_stream::store_short(ushort s) { -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS stored_size+= 2; #endif if (data_end - cur_data > 1) @@ -58,7 +58,7 @@ void Querycache_stream::store_short(ushort s) void Querycache_stream::store_int(uint i) { -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS stored_size+= 4; #endif size_t rest_len= data_end - cur_data; @@ -85,7 +85,7 @@ void Querycache_stream::store_int(uint i) void Querycache_stream::store_ll(ulonglong ll) { -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS stored_size+= 8; #endif size_t rest_len= data_end - cur_data; @@ -110,7 +110,7 @@ void Querycache_stream::store_ll(ulonglong ll) void Querycache_stream::store_str_only(const char *str, uint str_len) { -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS stored_size+= str_len; #endif do diff --git a/libmysqld/emb_qcache.h b/libmysqld/emb_qcache.h index 8fd166df88d..d714450feb8 100644 --- a/libmysqld/emb_qcache.h +++ b/libmysqld/emb_qcache.h @@ -22,7 +22,7 @@ class Querycache_stream Query_cache_block *block; uint headers_len; public: -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS Query_cache_block *first_block; uint stored_size; #endif @@ -31,7 +31,7 @@ public: { cur_data= ((uchar*)block)+headers_len; data_end= cur_data + (block->used-headers_len); -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS first_block= ini_block; stored_size= 0; #endif diff --git a/libmysqld/libmysql.c b/libmysqld/libmysql.c index d1176a4168c..58900b87147 100644 --- a/libmysqld/libmysql.c +++ b/libmysqld/libmysql.c @@ -4375,7 +4375,7 @@ static void stmt_update_metadata(MYSQL_STMT *stmt, MYSQL_ROWS *data) MYSQL_FIELD *field; uchar *null_ptr, bit; uchar *row= (uchar*) data->data; -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS uchar *row_end= row + data->length; #endif diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index 34aeb569faf..c7fc2fbb84f 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -421,11 +421,12 @@ static int keycache_pthread_cond_signal(mysql_cond_t *cond); #undef inline #endif #define inline /* disabled inline for easier debugging */ -static int fail_block(BLOCK_LINK *block); static int fail_hlink(HASH_LINK *hlink); static int cache_empty(SIMPLE_KEY_CACHE_CB *keycache); #endif - +#ifdef DBUG_ASSERT_EXISTS +static int fail_block(BLOCK_LINK *block); +#endif static inline uint next_power(uint value) { @@ -713,7 +714,7 @@ int prepare_resize_simple_key_cache(SIMPLE_KEY_CACHE_CB *keycache, res= 1; goto finish; } - DBUG_ASSERT(cache_empty(keycache)); + DBUG_SLOW_ASSERT(cache_empty(keycache)); /* End the flush phase. */ keycache->resize_in_flush= 0; @@ -1088,7 +1089,7 @@ static void unlink_from_queue(KEYCACHE_WQUEUE *wqueue, thread->prev); } thread->next= NULL; -#if !defined(DBUG_OFF) +#ifdef DBUG_ASSERT_EXISTS /* This makes it easier to see it's not in a chain during debugging. And some DBUG_ASSERT() rely on it. @@ -1211,7 +1212,7 @@ static inline void unlink_changed(BLOCK_LINK *block) block->next_changed->prev_changed= block->prev_changed; *block->prev_changed= block->next_changed; -#if !defined(DBUG_OFF) +#ifdef DBUG_ASSERT_EXISTS /* This makes it easier to see it's not in a chain during debugging. And some DBUG_ASSERT() rely on it. @@ -1497,7 +1498,7 @@ static void unlink_block(SIMPLE_KEY_CACHE_CB *keycache, BLOCK_LINK *block) keycache->used_ins=STRUCT_PTR(BLOCK_LINK, next_used, block->prev_used); } block->next_used= NULL; -#if !defined(DBUG_OFF) +#ifdef DBUG_ASSERT_EXISTS /* This makes it easier to see it's not in a chain during debugging. And some DBUG_ASSERT() rely on it. @@ -4309,10 +4310,8 @@ restart: } /* if (keycache->disk_blocks > 0 */ -#ifndef DBUG_OFF DBUG_EXECUTE("check_keycache", test_key_cache(keycache, "end of flush_key_blocks", 0);); -#endif err: if (cache != cache_buff) my_free(cache); @@ -4790,11 +4789,12 @@ void keycache_debug_log_close(void) #endif /* defined(KEYCACHE_DEBUG) */ -#if !defined(DBUG_OFF) +#ifdef DBUG_ASSERT_EXISTS #define F_B_PRT(_f_, _v_) DBUG_PRINT("assert_fail", (_f_, _v_)) -static int fail_block(BLOCK_LINK *block) +static int fail_block(BLOCK_LINK *block __attribute__((unused))) { +#ifndef DBUG_OFF F_B_PRT("block->next_used: %lx\n", (ulong) block->next_used); F_B_PRT("block->prev_used: %lx\n", (ulong) block->prev_used); F_B_PRT("block->next_changed: %lx\n", (ulong) block->next_changed); @@ -4805,10 +4805,13 @@ static int fail_block(BLOCK_LINK *block) F_B_PRT("block->offset: %u\n", block->offset); F_B_PRT("block->requests: %u\n", block->requests); F_B_PRT("block->temperature: %u\n", block->temperature); +#endif return 0; /* Let the assert fail. */ } +#endif -static int fail_hlink(HASH_LINK *hlink) +#ifndef DBUG_OFF +static int fail_hlink(HASH_LINK *hlink __attribute__((unused))) { F_B_PRT("hlink->next: %lx\n", (ulong) hlink->next); F_B_PRT("hlink->prev: %lx\n", (ulong) hlink->prev); diff --git a/mysys/my_init.c b/mysys/my_init.c index 7f0f7a8cc44..ff9a6913fa2 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -230,7 +230,7 @@ Voluntary context switches %ld, Involuntary context switches %ld\n", my_init_done= my_thr_key_mysys_exists= 0; } /* my_end */ -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS /* Dummy tag function for debugging */ void my_debug_put_break_here(void) diff --git a/mysys/stacktrace.c b/mysys/stacktrace.c index 841a52944df..5d7fa321ce5 100644 --- a/mysys/stacktrace.c +++ b/mysys/stacktrace.c @@ -178,12 +178,13 @@ int my_safe_print_str(const char* val, int max_len) #include <ucontext.h> void my_print_stacktrace(uchar* stack_bottom __attribute__((unused)), - ulong thread_stack __attribute__((unused))) + ulong thread_stack __attribute__((unused)), + my_bool silent) { if (printstack(fileno(stderr)) == -1) my_safe_printf_stderr("%s", "Error when traversing the stack, stack appears corrupt.\n"); - else + else if (!silent) my_safe_printf_stderr("%s", "Please read " "http://dev.mysql.com/doc/refman/5.1/en/resolve-stack-dump.html\n" @@ -260,7 +261,8 @@ static int print_with_addr_resolve(void **addrs, int n) } #endif -void my_print_stacktrace(uchar* stack_bottom, ulong thread_stack) +void my_print_stacktrace(uchar* stack_bottom, ulong thread_stack, + my_bool silent __attribute__((unused))) { void *addrs[128]; char **strings __attribute__((unused)) = NULL; @@ -334,7 +336,8 @@ inline uint32* find_prev_pc(uint32* pc, uchar** fp) } #endif /* defined(__alpha__) && defined(__GNUC__) */ -void my_print_stacktrace(uchar* stack_bottom, ulong thread_stack) +void my_print_stacktrace(uchar* stack_bottom, ulong thread_stack, + my_bool silent) { uchar** UNINIT_VAR(fp); uint frame_count = 0, sigreturn_frame_count; @@ -449,7 +452,8 @@ void my_print_stacktrace(uchar* stack_bottom, ulong thread_stack) "Stack trace seems successful - bottom reached\n"); end: - my_safe_printf_stderr("%s", + if (!silent) + my_safe_printf_stderr("%s", "Please read " "http://dev.mysql.com/doc/refman/5.1/en/resolve-stack-dump.html\n" "and follow instructions on how to resolve the stack trace.\n" @@ -610,7 +614,7 @@ static void get_symbol_path(char *path, size_t size) #define SYMOPT_NO_PROMPTS 0 #endif -void my_print_stacktrace(uchar* unused1, ulong unused2) +void my_print_stacktrace(uchar* unused1, ulong unused2, my_bool silent) { HANDLE hProcess= GetCurrentProcess(); HANDLE hThread= GetCurrentThread(); diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c index 9d917d3dd59..a101c23be58 100644 --- a/mysys/thr_alarm.c +++ b/mysys/thr_alarm.c @@ -261,7 +261,8 @@ void thr_end_alarm(thr_alarm_t *alarmed) alarm_data= (ALARM*) ((uchar*) *alarmed - offsetof(ALARM,alarmed)); mysql_mutex_lock(&LOCK_alarm); DBUG_ASSERT(alarm_data->index_in_queue != 0); - DBUG_ASSERT(queue_element(&alarm_queue, alarm_data->index_in_queue) == + DBUG_ASSERT((ALARM*) queue_element(&alarm_queue, + alarm_data->index_in_queue) == alarm_data); queue_remove(&alarm_queue, alarm_data->index_in_queue); mysql_mutex_unlock(&LOCK_alarm); diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c index 6cb9d6af13d..56ac5298da7 100644 --- a/mysys/thr_lock.c +++ b/mysys/thr_lock.c @@ -1541,7 +1541,7 @@ void thr_downgrade_write_lock(THR_LOCK_DATA *in_data, enum thr_lock_type new_lock_type) { THR_LOCK *lock=in_data->lock; -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS enum thr_lock_type old_lock_type= in_data->type; #endif DBUG_ENTER("thr_downgrade_write_only_lock"); diff --git a/sql/events.cc b/sql/events.cc index 3c66945fbd9..0c3b931e722 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -625,7 +625,7 @@ Events::drop_schema_events(THD *thd, const char *db) DBUG_ENTER("Events::drop_schema_events"); DBUG_PRINT("enter", ("dropping events from %s", db)); - DBUG_ASSERT(ok_for_lower_case_names(db)); + DBUG_SLOW_ASSERT(ok_for_lower_case_names(db)); /* Sic: no check if the scheduler is disabled or system tables diff --git a/sql/item.cc b/sql/item.cc index fe20687bf51..e4fcaa42c6f 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -8813,7 +8813,7 @@ bool Item_default_value::fix_fields(THD *thd, Item **items) goto error; memcpy((void *)def_field, (void *)field_arg->field, field_arg->field->size_of()); - IF_DBUG(def_field->is_stat_field=1,); // a hack to fool ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED + IF_DBUG_ASSERT(def_field->is_stat_field=1,); // a hack to fool ASSERT_COLUMN_MARKED_FOR_WRITE_OR_COMPUTED if (def_field->default_value && def_field->default_value->flags) { uchar *newptr= (uchar*) thd->alloc(1+def_field->pack_length()); diff --git a/sql/item.h b/sql/item.h index 75c14c6338a..8a33b107652 100644 --- a/sql/item.h +++ b/sql/item.h @@ -2220,7 +2220,7 @@ public: LEX_CSTRING m_name; public: -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS /* Routine to which this Item_splocal belongs. Used for checking if correct runtime context is used for variable handling. diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc index a427cba5956..ba24ebe76c5 100644 --- a/sql/item_xmlfunc.cc +++ b/sql/item_xmlfunc.cc @@ -2622,7 +2622,7 @@ my_xpath_parse_VariableReference(MY_XPATH *xpath) { Item_splocal *splocal= new (thd->mem_root) Item_splocal(thd, &name, spv->offset, spv->sql_type(), 0); -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS if (splocal) splocal->m_sp= lex->sphead; #endif diff --git a/sql/lock.cc b/sql/lock.cc index 5c80a2c98cd..a45b93a0260 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -911,7 +911,7 @@ bool lock_object_name(THD *thd, MDL_key::enum_mdl_namespace mdl_type, MDL_request schema_request; MDL_request mdl_request; - DBUG_ASSERT(ok_for_lower_case_names(db)); + DBUG_SLOW_ASSERT(ok_for_lower_case_names(db)); if (thd->locked_tables_mode) { diff --git a/sql/log_event.cc b/sql/log_event.cc index b9d802f7927..abfa0b80ed5 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -6012,7 +6012,7 @@ bool Format_description_log_event::write() FD_queue checksum_alg value. */ compile_time_assert(BINLOG_CHECKSUM_ALG_DESC_LEN == 1); -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS data_written= 0; // to prepare for need_checksum assert #endif uint8 checksum_byte= (uint8) @@ -8687,7 +8687,7 @@ User_var_log_event(const char* buf, uint event_len, we keep the flags set to UNDEF_F. */ uint bytes_read= ((val + val_len) - buf_start); -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS bool old_pre_checksum_fd= description_event->is_version_before_checksum( &description_event->server_version_split); #endif diff --git a/sql/mdl.cc b/sql/mdl.cc index 350d27298de..4efc8b0e361 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -2119,11 +2119,11 @@ MDL_context::acquire_lock(MDL_request *mdl_request, double lock_wait_timeout) the parallel replication scheduler should never schedule a DDL while DML's are still running. */ - DBUG_ASSERT((mdl_request->type != MDL_INTENTION_EXCLUSIVE && - mdl_request->type != MDL_EXCLUSIVE) || - !(get_thd()->rgi_slave && - get_thd()->rgi_slave->is_parallel_exec && - lock->check_if_conflicting_replication_locks(this))); + DBUG_SLOW_ASSERT((mdl_request->type != MDL_INTENTION_EXCLUSIVE && + mdl_request->type != MDL_EXCLUSIVE) || + !(get_thd()->rgi_slave && + get_thd()->rgi_slave->is_parallel_exec && + lock->check_if_conflicting_replication_locks(this))); mysql_prlock_unlock(&lock->m_rwlock); @@ -2644,7 +2644,7 @@ void MDL_context::release_lock(enum_mdl_duration duration, MDL_ticket *ticket) void MDL_context::release_lock(MDL_ticket *ticket) { - DBUG_ASSERT(ticket->m_duration == MDL_EXPLICIT); + DBUG_SLOW_ASSERT(ticket->m_duration == MDL_EXPLICIT); release_lock(MDL_EXPLICIT, ticket); } @@ -2904,8 +2904,8 @@ bool MDL_context::has_lock(const MDL_savepoint &mdl_savepoint, void MDL_context::set_lock_duration(MDL_ticket *mdl_ticket, enum_mdl_duration duration) { - DBUG_ASSERT(mdl_ticket->m_duration == MDL_TRANSACTION && - duration != MDL_TRANSACTION); + DBUG_SLOW_ASSERT(mdl_ticket->m_duration == MDL_TRANSACTION && + duration != MDL_TRANSACTION); m_tickets[MDL_TRANSACTION].remove(mdl_ticket); m_tickets[duration].push_front(mdl_ticket); diff --git a/sql/mdl.h b/sql/mdl.h index 97216b8e7b1..f30c976ac94 100644 --- a/sql/mdl.h +++ b/sql/mdl.h @@ -349,7 +349,7 @@ public: NAME_LEN) - m_ptr + 1); m_hash_value= my_hash_sort(&my_charset_bin, (uchar*) m_ptr + 1, m_length - 1); - DBUG_ASSERT(mdl_namespace_arg == USER_LOCK || ok_for_lower_case_names(db)); + DBUG_SLOW_ASSERT(mdl_namespace_arg == USER_LOCK || ok_for_lower_case_names(db)); } void mdl_key_init(const MDL_key *rhs) { diff --git a/sql/my_decimal.h b/sql/my_decimal.h index 265b370a154..918213568fc 100644 --- a/sql/my_decimal.h +++ b/sql/my_decimal.h @@ -132,8 +132,8 @@ public: void sanity_check() { - DBUG_ASSERT(foo1 == test_value); - DBUG_ASSERT(foo2 == test_value); + DBUG_SLOW_ASSERT(foo1 == test_value); + DBUG_SLOW_ASSERT(foo2 == test_value); } void fix_buffer_pointer() { buf= buffer; } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 630a5d64c8f..2ef2830e80b 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2160,7 +2160,7 @@ static void mysqld_exit(int exit_code) set_malloc_size_cb(NULL); if (!opt_debugging && !my_disable_leak_check) { - DBUG_ASSERT(global_status_var.global_memory_used == 0); + DBUG_SLOW_ASSERT(global_status_var.global_memory_used == 0); } cleanup_tls(); DBUG_LEAVE; @@ -3322,6 +3322,20 @@ static size_t my_setstacksize(pthread_attr_t *attr, size_t stacksize) } #endif +#ifdef DBUG_ASSERT_AS_PRINTF +extern "C" void +mariadb_dbug_assert_failed(const char *assert_expr, const char *file, + unsigned long line) +{ + fprintf(stderr, "Warning: assertion failed: %s at %s line %lu\n", + assert_expr, file, line); + if (opt_stack_trace) + { + fprintf(stderr, "Attempting backtrace to find out the reason for the assert:\n"); + my_print_stacktrace(NULL, (ulong) my_thread_stack_size, 1); + } +} +#endif /* DBUG_ASSERT_AS_PRINT */ #if !defined(__WIN__) #ifndef SA_RESETHAND @@ -4140,7 +4154,10 @@ static int init_common_variables() #ifdef SAFEMALLOC sf_malloc_dbug_id= mariadb_dbug_id; -#endif +#endif /* SAFEMALLOC */ +#ifdef DBUG_ASSERT_AS_PRINTF + my_dbug_assert_failed= mariadb_dbug_assert_failed; +#endif /* DBUG_ASSERT_AS_PRINTF */ if (!(type_handler_data= new Type_handler_data) || type_handler_data->init()) diff --git a/sql/protocol.cc b/sql/protocol.cc index 205b640dcb1..dbaa8ae6a1e 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -1235,7 +1235,7 @@ bool Protocol_text::store(Field *field) char buff[MAX_FIELD_WIDTH]; String str(buff,sizeof(buff), &my_charset_bin); CHARSET_INFO *tocs= this->thd->variables.character_set_results; -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS TABLE *table= field->table; my_bitmap_map *old_map= 0; if (table->file) @@ -1243,7 +1243,7 @@ bool Protocol_text::store(Field *field) #endif field->val_str(&str); -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS if (old_map) dbug_tmp_restore_column_map(table->read_set, old_map); #endif diff --git a/sql/rpl_gtid.cc b/sql/rpl_gtid.cc index 965af7e9b69..f746496993c 100644 --- a/sql/rpl_gtid.cc +++ b/sql/rpl_gtid.cc @@ -317,7 +317,7 @@ rpl_slave_state::update(uint32 domain_id, uint32 server_id, uint64 sub_id, { if (rgi->gtid_ignore_duplicate_state==rpl_group_info::GTID_DUPLICATE_OWNER) { -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS Relay_log_info *rli= rgi->rli; #endif uint32 count= elem->owner_count; @@ -2096,15 +2096,14 @@ void slave_connection_state::remove(const rpl_gtid *in_gtid) { uchar *rec= my_hash_search(&hash, (const uchar *)(&in_gtid->domain_id), 0); -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS bool err; rpl_gtid *slave_gtid= &((entry *)rec)->gtid; DBUG_ASSERT(rec /* We should never try to remove not present domain_id. */); DBUG_ASSERT(slave_gtid->server_id == in_gtid->server_id); DBUG_ASSERT(slave_gtid->seq_no == in_gtid->seq_no); + err= #endif - - IF_DBUG(err=, ) my_hash_delete(&hash, rec); DBUG_ASSERT(!err); } diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc index 1d8cd15dc51..bf0d98e1cf7 100644 --- a/sql/rpl_utility.cc +++ b/sql/rpl_utility.cc @@ -1127,7 +1127,7 @@ bool event_checksum_test(uchar *event_buf, ulong event_len, enum enum_binlog_che if (event_buf[EVENT_TYPE_OFFSET] == FORMAT_DESCRIPTION_EVENT) { -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS int8 fd_alg= event_buf[event_len - BINLOG_CHECKSUM_LEN - BINLOG_CHECKSUM_ALG_DESC_LEN]; #endif diff --git a/sql/signal_handler.cc b/sql/signal_handler.cc index d7f26ea5aa3..5cc8b958b0a 100644 --- a/sql/signal_handler.cc +++ b/sql/signal_handler.cc @@ -163,7 +163,7 @@ extern "C" sig_handler handle_fatal_signal(int sig) "where mysqld died. If you see no messages after this, something went\n" "terribly wrong...\n"); my_print_stacktrace(thd ? (uchar*) thd->thread_stack : NULL, - (ulong)my_thread_stack_size); + (ulong)my_thread_stack_size, 0); } if (thd) { diff --git a/sql/sp.cc b/sql/sp.cc index 85cef2a7d81..bc7da657462 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -1557,7 +1557,7 @@ bool lock_db_routines(THD *thd, const char *db) uchar keybuf[MAX_KEY_LENGTH]; DBUG_ENTER("lock_db_routines"); - DBUG_ASSERT(ok_for_lower_case_names(db)); + DBUG_SLOW_ASSERT(ok_for_lower_case_names(db)); /* mysql.proc will be re-opened during deletion, so we can ignore diff --git a/sql/sp_head.cc b/sql/sp_head.cc index a199a181be2..8865a18749a 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1561,7 +1561,7 @@ sp_head::execute_trigger(THD *thd, goto err_with_cleanup; } -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS nctx->sp= this; #endif @@ -1685,7 +1685,7 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, */ thd->restore_active_arena(&call_arena, &backup_arena); -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS nctx->sp= this; #endif @@ -1891,7 +1891,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) DBUG_RETURN(TRUE); } -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS octx->sp= 0; #endif thd->spcont= octx; @@ -1906,7 +1906,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) thd->spcont= save_spcont; DBUG_RETURN(TRUE); } -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS nctx->sp= this; #endif diff --git a/sql/sp_rcontext.h b/sql/sp_rcontext.h index 98464518787..6ff6e02f737 100644 --- a/sql/sp_rcontext.h +++ b/sql/sp_rcontext.h @@ -176,7 +176,7 @@ public: /// of the client/server protocol. bool end_partial_result_set; -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS /// The stored program for which this runtime context is created. Used for /// checking if correct runtime context is used for variable handling. sp_head *sp; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 15c55ccaef0..81859d2fed6 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -3175,7 +3175,7 @@ static void remove_ptr_from_dynarray(DYNAMIC_ARRAY *array, void *ptr) { DBUG_ASSERT(!found); delete_dynamic_element(array, i); - IF_DBUG(found= true, break); + IF_DBUG_ASSERT(found= true, break); } } DBUG_ASSERT(found); diff --git a/sql/sql_alter.cc b/sql/sql_alter.cc index 867b5218fa3..f2f3f7f25d9 100644 --- a/sql/sql_alter.cc +++ b/sql/sql_alter.cc @@ -90,7 +90,7 @@ Alter_table_ctx::Alter_table_ctx() new_db(NULL), new_name(NULL), new_alias(NULL), fk_error_if_delete_row(false), fk_error_id(NULL), fk_error_table(NULL) -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS , tmp_table(false) #endif { @@ -110,7 +110,7 @@ Alter_table_ctx::Alter_table_ctx(THD *thd, TABLE_LIST *table_list, new_db(new_db_arg), new_name(new_name_arg), fk_error_if_delete_row(false), fk_error_id(NULL), fk_error_table(NULL) -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS , tmp_table(false) #endif { @@ -187,7 +187,7 @@ Alter_table_ctx::Alter_table_ctx(THD *thd, TABLE_LIST *table_list, this case. This fact is enforced with assert. */ build_tmptable_filename(thd, tmp_path, sizeof(tmp_path)); -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS tmp_table= true; #endif } diff --git a/sql/sql_alter.h b/sql/sql_alter.h index c0232dd7358..a37d96934ea 100644 --- a/sql/sql_alter.h +++ b/sql/sql_alter.h @@ -331,7 +331,7 @@ private: char new_path[FN_REFLEN + 1]; char tmp_path[FN_REFLEN + 1]; -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS /** Indicates that we are altering temporary table. Used only in asserts. */ bool tmp_table; #endif diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 2ef20268e14..b53d6332eb6 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -2342,7 +2342,7 @@ void Query_cache::invalidate(THD *thd, const char *db) if (is_disabled()) DBUG_VOID_RETURN; - DBUG_ASSERT(ok_for_lower_case_names(db)); + DBUG_SLOW_ASSERT(ok_for_lower_case_names(db)); bool restart= FALSE; /* diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 129f7abc136..d8c6d0db380 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -833,7 +833,7 @@ THD::THD(my_thread_id id, bool is_wsrep_applier) enable_slow_log= 0; durability_property= HA_REGULAR_DURABILITY; -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS dbug_sentry=THD_SENTRY_MAGIC; #endif mysql_audit_init_thd(this); @@ -1635,7 +1635,7 @@ THD::~THD() mysql_cond_destroy(&COND_wakeup_ready); mysql_mutex_destroy(&LOCK_wakeup_ready); mysql_mutex_destroy(&LOCK_thd_data); -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS dbug_sentry= THD_SENTRY_GONE; #endif #ifndef EMBEDDED_LIBRARY @@ -3692,7 +3692,7 @@ void THD::set_n_backup_active_arena(Query_arena *set, Query_arena *backup) backup->set_query_arena(this); set_query_arena(set); -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS backup->is_backup_arena= TRUE; #endif DBUG_VOID_RETURN; @@ -3711,7 +3711,7 @@ void THD::restore_active_arena(Query_arena *set, Query_arena *backup) DBUG_ASSERT(backup->is_backup_arena); set->set_query_arena(this); set_query_arena(backup); -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS backup->is_backup_arena= FALSE; #endif DBUG_VOID_RETURN; @@ -6409,7 +6409,7 @@ CPP_UNNAMED_NS_START { DBUG_ASSERT(s < sizeof(m_ptr)/sizeof(*m_ptr)); DBUG_ASSERT(m_ptr[s] != 0); - DBUG_ASSERT(m_alloc_checked == TRUE); + DBUG_SLOW_ASSERT(m_alloc_checked == TRUE); return m_ptr[s]; } diff --git a/sql/sql_class.h b/sql/sql_class.h index 1c2b2717591..f5834186a45 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -890,7 +890,7 @@ void free_tmp_table(THD *thd, TABLE *entry); /* The following macro is to make init of Query_arena simpler */ -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS #define INIT_ARENA_DBUG_INFO is_backup_arena= 0; is_reprepared= FALSE; #else #define INIT_ARENA_DBUG_INFO @@ -905,7 +905,7 @@ public: */ Item *free_list; MEM_ROOT *mem_root; // Pointer to current memroot -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS bool is_backup_arena; /* True if this arena is used for backup. */ bool is_reprepared; #endif @@ -2206,7 +2206,7 @@ public: HASH ull_hash; /* Hash of used seqeunces (for PREVIOUS value) */ HASH sequences; -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS uint dbug_sentry; // watch out for memory corruption #endif struct st_my_thread_var *mysys_var; @@ -6036,7 +6036,7 @@ public: (int) m_db.length, (m_db.length ? m_db.str : ""), dot, ".", (int) m_name.length, m_name.str); - DBUG_ASSERT(ok_for_lower_case_names(m_db.str)); + DBUG_SLOW_ASSERT(ok_for_lower_case_names(m_db.str)); return false; } }; diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 223d3c1b86e..c71c1e6f378 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -5473,7 +5473,7 @@ bool LEX::sp_for_loop_condition(THD *thd, const Lex_for_loop_st &loop) Item_splocal(thd, &src->name, src->offset, src->sql_type()); if (args[i] == NULL) return true; -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS args[i]->m_sp= sphead; #endif } @@ -5607,7 +5607,7 @@ bool LEX::sp_for_loop_increment(THD *thd, const Lex_for_loop_st &loop) loop.m_index->sql_type()); if (splocal == NULL) return true; -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS splocal->m_sp= sphead; #endif Item_int *inc= new (thd->mem_root) Item_int(thd, loop.m_direction); @@ -6396,7 +6396,7 @@ Item_splocal *LEX::create_item_spvar_row_field(THD *thd, pos_in_q, length_in_q))) return NULL; } -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS item->m_sp= sphead; #endif safe_to_cache_query=0; @@ -6563,7 +6563,7 @@ Item *LEX::create_item_limit(THD *thd, spv->offset, spv->sql_type(), pos_in_q, length_in_q))) return NULL; -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS item->m_sp= sphead; #endif safe_to_cache_query= 0; @@ -6686,7 +6686,7 @@ Item *LEX::create_item_ident_sp(THD *thd, LEX_CSTRING *name, start_in_q, length_in_q); if (splocal == NULL) return NULL; -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS splocal->m_sp= sphead; #endif safe_to_cache_query= 0; diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 9bae754a8c7..0302c4f13bf 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1669,7 +1669,7 @@ int plugin_init(int *argc, char **argv, int flags) */ global_system_variables.table_plugin = intern_plugin_lock(NULL, plugin_int_to_ref(plugin_ptr)); - DBUG_ASSERT(plugin_ptr->ref_count == 1); + DBUG_SLOW_ASSERT(plugin_ptr->ref_count == 1); } mysql_mutex_unlock(&LOCK_plugin); diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index ef94d06a567..1e117ae93ba 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -2953,7 +2953,7 @@ void reinit_stmt_before_use(THD *thd, LEX *lex) for (order= sl->order_list.first; order; order= order->next) order->item= &order->item_ptr; { -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS bool res= #endif sl->handle_derived(lex, DT_REINIT); @@ -4254,7 +4254,7 @@ Prepared_statement::execute_bulk_loop(String *expanded_query, packet_end= packet_end_arg; iterations= TRUE; start_param= true; -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS Item *free_list_state= thd->free_list; #endif thd->select_number= select_number_after_prepare; @@ -4479,7 +4479,7 @@ Prepared_statement::reprepare() { swap_prepared_statement(©); swap_parameter_array(param_array, copy.param_array, param_count); -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS is_reprepared= TRUE; #endif /* diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index e02e5f9d5f1..70237264770 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -217,7 +217,7 @@ int LEX::case_stmt_action_when(Item *when, bool simple) var= new (thd->mem_root) Item_case_expr(thd, spcont->get_current_case_expr_id()); -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS if (var) { var->m_sp= sphead; @@ -399,7 +399,7 @@ LEX::create_item_for_sp_var(LEX_CSTRING *name, sp_variable *spvar, Item_splocal(thd, name, spvar->offset, spvar->sql_type(), pos_in_q, len_in_q); -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS if (item) item->m_sp= sphead; #endif diff --git a/sql/sys_vars.ic b/sql/sys_vars.ic index ed0d6d59f30..f3837f0246a 100644 --- a/sql/sys_vars.ic +++ b/sql/sys_vars.ic @@ -612,7 +612,7 @@ public: /* parse and feel list with default values */ if (thd) { -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS bool res= #endif sysvartrack_validate_value(thd, diff --git a/sql/table.h b/sql/table.h index f2c615ba414..9ecec6d636c 100644 --- a/sql/table.h +++ b/sql/table.h @@ -2605,7 +2605,7 @@ static inline void tmp_restore_column_map(MY_BITMAP *bitmap, static inline my_bitmap_map *dbug_tmp_use_all_columns(TABLE *table, MY_BITMAP *bitmap) { -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS return tmp_use_all_columns(table, bitmap); #else return 0; @@ -2615,7 +2615,7 @@ static inline my_bitmap_map *dbug_tmp_use_all_columns(TABLE *table, static inline void dbug_tmp_restore_column_map(MY_BITMAP *bitmap, my_bitmap_map *old) { -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS tmp_restore_column_map(bitmap, old); #endif } @@ -2630,7 +2630,7 @@ static inline void dbug_tmp_use_all_columns(TABLE *table, MY_BITMAP *read_set, MY_BITMAP *write_set) { -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS save[0]= read_set->bitmap; save[1]= write_set->bitmap; (void) tmp_use_all_columns(table, read_set); @@ -2643,7 +2643,7 @@ static inline void dbug_tmp_restore_column_maps(MY_BITMAP *read_set, MY_BITMAP *write_set, my_bitmap_map **old) { -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS tmp_restore_column_map(read_set, old[0]); tmp_restore_column_map(write_set, old[1]); #endif diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 2887e66c3ad..de752e93b55 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -3087,7 +3087,7 @@ ha_innobase::update_thd( m_user_thd, thd)); /* The table should have been opened in ha_innobase::open(). */ - DBUG_ASSERT(m_prebuilt->table->n_ref_count > 0); + ut_ad(m_prebuilt->table->n_ref_count > 0); trx_t* trx = check_trx_exists(thd); @@ -14340,7 +14340,7 @@ ha_innobase::info_low( m_prebuilt->trx->op_info = "returning various info to MariaDB"; ib_table = m_prebuilt->table; - DBUG_ASSERT(ib_table->n_ref_count > 0); + ut_ad(ib_table->n_ref_count > 0); if (flag & HA_STATUS_TIME) { if (is_analyze || innobase_stats_on_metadata) { diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index 04c4af36aa9..0155d1d5d20 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -1677,7 +1677,7 @@ struct dict_table_t { It is protected by lock_sys->mutex. */ ulint n_rec_locks; -#ifndef UNIV_DEBUG +#ifndef DBUG_ASSERT_EXISTS private: #endif /** Count of how many handles are opened to this table. Dropping of the diff --git a/storage/innobase/include/sync0types.h b/storage/innobase/include/sync0types.h index c2864fa2f56..e08c978fa40 100644 --- a/storage/innobase/include/sync0types.h +++ b/storage/innobase/include/sync0types.h @@ -493,10 +493,10 @@ struct OSMutex { } private: -#ifdef UNIV_DEBUG +#ifdef DBUG_ASSERT_EXISTS /** true if the mutex has been freed/destroyed. */ bool m_freed; -#endif /* UNIV_DEBUG */ +#endif /* DBUG_ASSERT_EXISTS */ sys_mutex_t m_mutex; }; diff --git a/storage/innobase/include/ut0dbg.h b/storage/innobase/include/ut0dbg.h index a860196e3db..a6be74b816f 100644 --- a/storage/innobase/include/ut0dbg.h +++ b/storage/innobase/include/ut0dbg.h @@ -61,7 +61,7 @@ ut_dbg_assertion_failed( ut_dbg_assertion_failed(0, __FILE__, __LINE__) /** Debug assertion */ -#define ut_ad DBUG_ASSERT +#define ut_ad DBUG_SLOW_ASSERT #if defined(UNIV_DEBUG) || !defined(DBUG_OFF) /** Debug statement. Does nothing unless UNIV_DEBUG is defined. */ #define ut_d(EXPR) EXPR diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 717e65244cd..3166bb810a1 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -1865,7 +1865,7 @@ lock_queue_validate( hash_table_t* hash; hash_cell_t* cell; lock_t* next; - bool wait_lock = false; + bool wait_lock __attribute__((unused))= false; if (in_lock == NULL) { return true; diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index ccff9726732..112ca9c3df2 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -1443,7 +1443,7 @@ row_merge_write_rec_low( } memcpy(b, mrec - rec_offs_extra_size(offsets), rec_offs_size(offsets)); - DBUG_ASSERT(b + rec_offs_size(offsets) == end); + DBUG_SLOW_ASSERT(b + rec_offs_size(offsets) == end); DBUG_VOID_RETURN; } diff --git a/storage/maria/ma_bitmap.c b/storage/maria/ma_bitmap.c index 0abfa34a85f..977dd888365 100644 --- a/storage/maria/ma_bitmap.c +++ b/storage/maria/ma_bitmap.c @@ -2926,7 +2926,7 @@ int _ma_bitmap_create_first(MARIA_SHARE *share) static my_bool flush_log_for_bitmap(PAGECACHE_IO_HOOK_ARGS *args __attribute__ ((unused))) { -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS const MARIA_SHARE *share= (MARIA_SHARE*)args->data; #endif DBUG_ENTER("flush_log_for_bitmap"); diff --git a/storage/maria/ma_blockrec.c b/storage/maria/ma_blockrec.c index 57596558208..a9476f25173 100644 --- a/storage/maria/ma_blockrec.c +++ b/storage/maria/ma_blockrec.c @@ -6893,7 +6893,7 @@ uint _ma_apply_redo_insert_row_blobs(MARIA_HA *info, } else { -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS uchar found_page_type= (buff[PAGE_TYPE_OFFSET] & PAGE_TYPE_MASK); #endif if (lsn_korr(buff) >= lsn) diff --git a/storage/maria/ma_key_recover.c b/storage/maria/ma_key_recover.c index 8b6342b76b5..d400bfcb7f1 100644 --- a/storage/maria/ma_key_recover.c +++ b/storage/maria/ma_key_recover.c @@ -946,7 +946,7 @@ uint _ma_apply_redo_index(MARIA_HA *info, uint page_offset= 0, org_page_length; uint page_length, keypage_header, keynr; uint max_page_size= share->max_index_block_size; -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS uint new_page_length= 0; #endif int result; @@ -1110,7 +1110,7 @@ uint _ma_apply_redo_index(MARIA_HA *info, DBUG_PRINT("redo", ("org_page_length: %u new_page_length: %u", uint2korr(header), uint2korr(header+2))); DBUG_ASSERT(uint2korr(header) == page_length); -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS new_page_length= MY_MIN(uint2korr(header+2), max_page_size); #endif header+= 4; diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c index defa11ad6b4..94a5c9f1e71 100644 --- a/storage/maria/ma_loghandler.c +++ b/storage/maria/ma_loghandler.c @@ -3010,7 +3010,7 @@ restart: if (cmp_translog_addr(addr, in_buffers) >= 0) { uint16 buffer_no= log_descriptor.bc.buffer_no; -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS uint16 buffer_start= buffer_no; #endif struct st_translog_buffer *buffer_unlock= log_descriptor.bc.buffer; @@ -6228,7 +6228,7 @@ my_bool translog_write_record(LSN *lsn, DBUG_ASSERT(translog_status == TRANSLOG_OK || translog_status == TRANSLOG_READONLY); DBUG_ASSERT(type != 0); - DBUG_ASSERT((uint)type <= max_allowed_translog_type); + DBUG_SLOW_ASSERT((uint)type <= max_allowed_translog_type); if (unlikely(translog_status != TRANSLOG_OK)) { DBUG_PRINT("error", ("Transaction log is write protected")); diff --git a/storage/maria/ma_page.c b/storage/maria/ma_page.c index 4021fb8e161..d6acc0520c1 100644 --- a/storage/maria/ma_page.c +++ b/storage/maria/ma_page.c @@ -420,11 +420,11 @@ my_off_t _ma_new(register MARIA_HA *info, int level, Next deleted page's number is in the header of the present page (single linked list): */ -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS my_off_t key_del_current; #endif share->key_del_current= mi_sizekorr(buff+share->keypage_header); -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS key_del_current= share->key_del_current; DBUG_ASSERT((key_del_current != 0) && ((key_del_current == HA_OFFSET_ERROR) || @@ -512,7 +512,7 @@ static my_bool _ma_log_compact_keypage(MARIA_PAGE *ma_page, @param min_read_from Remove all trids from page less than this @retval 0 Ok - ®retval 1 Error; my_errno contains the error + ®retval 1 Error; my_errno contains the error */ my_bool _ma_compact_keypage(MARIA_PAGE *ma_page, TrID min_read_from) diff --git a/storage/maria/ma_pagecache.c b/storage/maria/ma_pagecache.c index a1c407967b7..9449c730a04 100644 --- a/storage/maria/ma_pagecache.c +++ b/storage/maria/ma_pagecache.c @@ -2044,7 +2044,7 @@ restart: DBUG_ASSERT(block->rlocks_queue == 0); DBUG_ASSERT(block->pins == 0); block->status= 0; -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS block->type= PAGECACHE_EMPTY_PAGE; #endif DBUG_ASSERT(reg_req); @@ -2187,7 +2187,7 @@ restart: block->last_hit_time= 0; block->status= error ? PCBLOCK_ERROR : 0; block->error= error ? (int16) my_errno : 0; -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS block->type= PAGECACHE_EMPTY_PAGE; if (error) my_debug_put_break_here(); @@ -4274,7 +4274,7 @@ static my_bool free_block(PAGECACHE *pagecache, PAGECACHE_BLOCK_LINK *block, DBUG_ASSERT(block->requests >= 1); DBUG_ASSERT(block->next_used == NULL); block->status= 0; -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS block->type= PAGECACHE_EMPTY_PAGE; #endif block->rec_lsn= LSN_MAX; @@ -4781,10 +4781,8 @@ restart: wqueue_release_queue(&us_flusher.flush_queue); } -#ifndef DBUG_OFF DBUG_EXECUTE("check_pagecache", test_key_cache(pagecache, "end of flush_pagecache_blocks", 0);); -#endif if (cache != cache_buff) my_free(cache); if (rc != 0) diff --git a/storage/maria/ma_pagecrc.c b/storage/maria/ma_pagecrc.c index 838913cc3ed..8982c7e5c09 100644 --- a/storage/maria/ma_pagecrc.c +++ b/storage/maria/ma_pagecrc.c @@ -287,7 +287,7 @@ my_bool maria_page_crc_check_none(int res, my_bool maria_page_filler_set_normal(PAGECACHE_IO_HOOK_ARGS *args) { uchar *page= args->page; -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS pgcache_page_no_t page_no= args->pageno; #endif MARIA_SHARE *share= (MARIA_SHARE *)args->data; diff --git a/storage/maria/ma_state.c b/storage/maria/ma_state.c index 15cc48ad468..817e1b69ddf 100644 --- a/storage/maria/ma_state.c +++ b/storage/maria/ma_state.c @@ -533,7 +533,7 @@ my_bool _ma_trnman_end_trans_hook(TRN *trn, my_bool commit, } else { -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS /* We need to keep share->in_trans correct in the debug library because of the assert in maria_close() diff --git a/storage/mroonga/lib/mrn_debug_column_access.cpp b/storage/mroonga/lib/mrn_debug_column_access.cpp index ed7cacae90f..db0c303ddd0 100644 --- a/storage/mroonga/lib/mrn_debug_column_access.cpp +++ b/storage/mroonga/lib/mrn_debug_column_access.cpp @@ -23,13 +23,13 @@ namespace mrn { DebugColumnAccess::DebugColumnAccess(TABLE *table, MY_BITMAP *bitmap) : table_(table), bitmap_(bitmap) { -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS map_ = dbug_tmp_use_all_columns(table_, bitmap_); #endif } DebugColumnAccess::~DebugColumnAccess() { -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS dbug_tmp_restore_column_map(bitmap_, map_); #endif } diff --git a/storage/mroonga/lib/mrn_debug_column_access.hpp b/storage/mroonga/lib/mrn_debug_column_access.hpp index 1548b4d8459..4887849349e 100644 --- a/storage/mroonga/lib/mrn_debug_column_access.hpp +++ b/storage/mroonga/lib/mrn_debug_column_access.hpp @@ -26,7 +26,7 @@ namespace mrn { class DebugColumnAccess { TABLE *table_; MY_BITMAP *bitmap_; -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS my_bitmap_map *map_; #endif public: diff --git a/storage/rocksdb/rdb_datadic.h b/storage/rocksdb/rdb_datadic.h index 9c7cd956eb3..91e8fb6f389 100644 --- a/storage/rocksdb/rdb_datadic.h +++ b/storage/rocksdb/rdb_datadic.h @@ -603,6 +603,10 @@ public: const int storage_length = static_cast<int>(max_storage_fmt_length()); return (storage_length - offset) >= needed; } +#else + inline bool is_storage_available(const int &offset, const int &needed) const { + return 1; + } #endif // DBUG_OFF /* Global number of this index (used as prefix in StorageFormat) */ diff --git a/storage/tokudb/tokudb_thread.h b/storage/tokudb/tokudb_thread.h index dcb1fd6ec63..72eb17ea05a 100644 --- a/storage/tokudb/tokudb_thread.h +++ b/storage/tokudb/tokudb_thread.h @@ -235,19 +235,19 @@ inline mutex_t::mutex_t(void) { _owners = 0; _owner = _null_owner; #endif - int r = pthread_mutex_init(&_mutex, MY_MUTEX_INIT_FAST); + int r __attribute__((unused)) = pthread_mutex_init(&_mutex, MY_MUTEX_INIT_FAST); assert_debug(r == 0); } inline mutex_t::~mutex_t(void) { #ifdef TOKUDB_DEBUG assert_debug(_owners == 0); #endif - int r = pthread_mutex_destroy(&_mutex); + int r __attribute__((unused)) = pthread_mutex_destroy(&_mutex); assert_debug(r == 0); } inline void mutex_t::lock(void) { assert_debug(is_owned_by_me() == false); - int r = pthread_mutex_lock(&_mutex); + int r __attribute__((unused)) = pthread_mutex_lock(&_mutex); assert_debug(r == 0); #ifdef TOKUDB_DEBUG _owners++; @@ -274,7 +274,7 @@ inline void mutex_t::unlock(void) { _owners--; _owner = _null_owner; #endif - int r = pthread_mutex_unlock(&_mutex); + int r __attribute__((unused)) = pthread_mutex_unlock(&_mutex); assert_debug(r == 0); } #ifdef TOKUDB_DEBUG @@ -285,11 +285,11 @@ inline bool mutex_t::is_owned_by_me(void) const { inline rwlock_t::rwlock_t(void) { - int r = pthread_rwlock_init(&_rwlock, NULL); + int r __attribute__((unused)) = pthread_rwlock_init(&_rwlock, NULL); assert_debug(r == 0); } inline rwlock_t::~rwlock_t(void) { - int r = pthread_rwlock_destroy(&_rwlock); + int r __attribute__((unused)) = pthread_rwlock_destroy(&_rwlock); assert_debug(r == 0); } inline void rwlock_t::lock_read(void) { @@ -345,7 +345,7 @@ inline int rwlock_t::lock_write(ulonglong microseconds) { return r; } inline void rwlock_t::unlock(void) { - int r = pthread_rwlock_unlock(&_rwlock); + int r __attribute__((unused)) = pthread_rwlock_unlock(&_rwlock); assert_debug(r == 0); } inline rwlock_t::rwlock_t(const rwlock_t&) { @@ -358,7 +358,7 @@ inline rwlock_t& rwlock_t::operator=(const rwlock_t&) { inline event_t::event_t(bool create_signalled, bool manual_reset) : _manual_reset(manual_reset) { - int r = pthread_mutex_init(&_mutex, NULL); + int __attribute__((unused)) r = pthread_mutex_init(&_mutex, NULL); assert_debug(r == 0); r = pthread_cond_init(&_cond, NULL); assert_debug(r == 0); @@ -370,13 +370,13 @@ inline event_t::event_t(bool create_signalled, bool manual_reset) : _pulsed = false; } inline event_t::~event_t(void) { - int r = pthread_mutex_destroy(&_mutex); + int r __attribute__((unused)) = pthread_mutex_destroy(&_mutex); assert_debug(r == 0); r = pthread_cond_destroy(&_cond); assert_debug(r == 0); } inline void event_t::wait(void) { - int r = pthread_mutex_lock(&_mutex); + int r __attribute__((unused)) = pthread_mutex_lock(&_mutex); assert_debug(r == 0); while (_signalled == false && _pulsed == false) { r = pthread_cond_wait(&_cond, &_mutex); @@ -413,7 +413,7 @@ inline int event_t::wait(ulonglong microseconds) { return 0; } inline void event_t::signal(void) { - int r = pthread_mutex_lock(&_mutex); + int r __attribute__((unused)) = pthread_mutex_lock(&_mutex); assert_debug(r == 0); _signalled = true; if (_manual_reset) { @@ -427,7 +427,7 @@ inline void event_t::signal(void) { assert_debug(r == 0); } inline void event_t::pulse(void) { - int r = pthread_mutex_lock(&_mutex); + int r __attribute__((unused)) = pthread_mutex_lock(&_mutex); assert_debug(r == 0); _pulsed = true; r = pthread_cond_signal(&_cond); @@ -437,7 +437,7 @@ inline void event_t::pulse(void) { } inline bool event_t::signalled(void) { bool ret = false; - int r = pthread_mutex_lock(&_mutex); + int r __attribute__((unused)) = pthread_mutex_lock(&_mutex); assert_debug(r == 0); ret = _signalled; r = pthread_mutex_unlock(&_mutex); @@ -445,7 +445,7 @@ inline bool event_t::signalled(void) { return ret; } inline void event_t::reset(void) { - int r = pthread_mutex_lock(&_mutex); + int r __attribute__((unused)) = pthread_mutex_lock(&_mutex); assert_debug(r == 0); _signalled = false; _pulsed = false; @@ -467,21 +467,21 @@ inline semaphore_t::semaphore_t( _initial_count(initial_count), _max_count(max_count) { - int r = pthread_mutex_init(&_mutex, NULL); + int r __attribute__((unused)) = pthread_mutex_init(&_mutex, NULL); assert_debug(r == 0); r = pthread_cond_init(&_cond, NULL); assert_debug(r == 0); _signalled = _initial_count; } inline semaphore_t::~semaphore_t(void) { - int r = pthread_mutex_destroy(&_mutex); + int r __attribute__((unused)) = pthread_mutex_destroy(&_mutex); assert_debug(r == 0); r = pthread_cond_destroy(&_cond); assert_debug(r == 0); } inline semaphore_t::E_WAIT semaphore_t::wait(void) { E_WAIT ret; - int r = pthread_mutex_lock(&_mutex); + int r __attribute__((unused)) = pthread_mutex_lock(&_mutex); assert_debug(r == 0); while (_signalled == 0 && _interrupted == false) { r = pthread_cond_wait(&_cond, &_mutex); @@ -524,7 +524,7 @@ inline semaphore_t::E_WAIT semaphore_t::wait(ulonglong microseconds) { } inline bool semaphore_t::signal(void) { bool ret = false; - int r = pthread_mutex_lock(&_mutex); + int r __attribute__((unused)) = pthread_mutex_lock(&_mutex); assert_debug(r == 0); if (_signalled < _max_count) { _signalled++; @@ -538,7 +538,7 @@ inline bool semaphore_t::signal(void) { } inline int semaphore_t::signalled(void) { int ret = 0; - int r = pthread_mutex_lock(&_mutex); + int r __attribute__((unused)) = pthread_mutex_lock(&_mutex); assert_debug(r == 0); ret = _signalled; r = pthread_mutex_unlock(&_mutex); @@ -546,7 +546,7 @@ inline int semaphore_t::signalled(void) { return ret; } inline void semaphore_t::reset(void) { - int r = pthread_mutex_lock(&_mutex); + int r __attribute__((unused)) = pthread_mutex_lock(&_mutex); assert_debug(r == 0); _signalled = 0; r = pthread_mutex_unlock(&_mutex); @@ -554,7 +554,7 @@ inline void semaphore_t::reset(void) { return; } inline void semaphore_t::set_interrupt(void) { - int r = pthread_mutex_lock(&_mutex); + int r __attribute__((unused)) = pthread_mutex_lock(&_mutex); assert_debug(r == 0); _interrupted = true; r = pthread_cond_broadcast(&_cond); @@ -563,7 +563,7 @@ inline void semaphore_t::set_interrupt(void) { assert_debug(r == 0); } inline void semaphore_t::clear_interrupt(void) { - int r = pthread_mutex_lock(&_mutex); + int r __attribute__((unused)) = pthread_mutex_lock(&_mutex); assert_debug(r == 0); _interrupted = false; r = pthread_mutex_unlock(&_mutex); diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index 071d50d8256..3913ab054db 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -2618,14 +2618,14 @@ void my_fill_utf32(CHARSET_INFO *cs, char *s, size_t slen, int fill) { char buf[10]; -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS uint buflen; #endif char *e= s + slen; DBUG_ASSERT((slen % 4) == 0); -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS buflen= #endif cs->cset->wc_mb(cs, (my_wc_t) fill, (uchar*) buf, diff --git a/strings/strings_def.h b/strings/strings_def.h index f1fcfe2f7cc..afe737ab301 100644 --- a/strings/strings_def.h +++ b/strings/strings_def.h @@ -17,6 +17,7 @@ /* This file is to be include first in all files in the string directory */ +#undef DBUG_ASSERT_AS_PRINTF #include <my_global.h> /* Define standar vars */ #include "m_string.h" /* Exernal defintions of string functions */ |