summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dbug/dbug.c10
-rw-r--r--include/my_dbug.h10
-rw-r--r--include/my_sys.h2
3 files changed, 16 insertions, 6 deletions
diff --git a/dbug/dbug.c b/dbug/dbug.c
index 40620b5e9c6..2d629ac0741 100644
--- a/dbug/dbug.c
+++ b/dbug/dbug.c
@@ -2258,6 +2258,16 @@ static int default_my_dbug_sanity(void)
return 0;
}
+extern my_bool my_assert;
+ATTRIBUTE_COLD
+my_bool _db_my_assert(const char *file, int line, const char *msg)
+{
+ _db_flush_();
+ my_bool a = my_assert;
+ if (!a)
+ fprintf(stderr, "%s:%d: assert: %s\n", file, line, msg);
+ return a;
+}
#else
/*
diff --git a/include/my_dbug.h b/include/my_dbug.h
index bce33285788..2bbe8ff6a30 100644
--- a/include/my_dbug.h
+++ b/include/my_dbug.h
@@ -35,7 +35,6 @@ struct _db_stack_frame_ {
};
struct _db_code_state_;
-extern MYSQL_PLUGIN_IMPORT my_bool my_assert;
extern my_bool _dbug_on_;
extern my_bool _db_keyword_(struct _db_code_state_ *, const char *, int);
extern int _db_explain_(struct _db_code_state_ *cs, char *buf, size_t len);
@@ -59,6 +58,8 @@ extern void _db_dump_(uint _line_,const char *keyword,
extern void _db_end_(void);
extern void _db_lock_file_(void);
extern void _db_unlock_file_(void);
+ATTRIBUTE_COLD
+extern my_bool _db_my_assert(const char *file, int line, const char *msg);
extern FILE *_db_fp_(void);
extern void _db_flush_(void);
extern void dbug_swap_code_state(void **code_state_store);
@@ -104,10 +105,9 @@ extern int (*dbug_sanity)(void);
#define DBUG_END() _db_end_ ()
#define DBUG_LOCK_FILE _db_lock_file_()
#define DBUG_UNLOCK_FILE _db_unlock_file_()
-#define DBUG_ASSERT(A) do { if (!(A)) { _db_flush_(); \
- if (my_assert) assert(A); \
- else fprintf(stderr, "%s:%d: assert: %s\n", __FILE__, __LINE__, #A); \
-}} while (0)
+#define DBUG_ASSERT(A) do { \
+ if (unlikely(!(A)) && _db_my_assert(__FILE__, __LINE__, #A)) assert(A); \
+} while (0)
#define DBUG_SLOW_ASSERT(A) DBUG_ASSERT(A)
#define DBUG_ASSERT_EXISTS
#define DBUG_EXPLAIN(buf,len) _db_explain_(0, (buf),(len))
diff --git a/include/my_sys.h b/include/my_sys.h
index a746dd9de1b..90f37f8ca81 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -267,7 +267,7 @@ extern ulong my_sync_count;
extern uint mysys_usage_id;
extern int32 my_file_opened;
extern my_bool my_init_done, my_thr_key_mysys_exists;
-extern MYSQL_PLUGIN_IMPORT my_bool my_assert;
+extern my_bool my_assert;
extern my_bool my_assert_on_error;
extern myf my_global_flags; /* Set to MY_WME for more error messages */
/* Point to current my_message() */