diff options
| author | Monty <monty@mariadb.org> | 2021-05-14 15:27:24 +0300 |
|---|---|---|
| committer | Sergei Golubchik <serg@mariadb.org> | 2021-05-19 22:54:13 +0200 |
| commit | 496a14e18714ac3f0b686ec5f57bf88e96512d2f (patch) | |
| tree | cbeb02f7072e2ae3ded695e4360d581e19166286 /sql/debug_sync.cc | |
| parent | ad02d53a715b9aeb7637f6a2c3685b094b15fa6b (diff) | |
| download | mariadb-git-496a14e18714ac3f0b686ec5f57bf88e96512d2f.tar.gz | |
Move debug_crash_here to it's own source files
Diffstat (limited to 'sql/debug_sync.cc')
| -rw-r--r-- | sql/debug_sync.cc | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/sql/debug_sync.cc b/sql/debug_sync.cc index f523e22f6ce..1fbb15592a4 100644 --- a/sql/debug_sync.cc +++ b/sql/debug_sync.cc @@ -1628,74 +1628,3 @@ bool debug_sync_set_action(THD *thd, const char *action_str, size_t len) /* prevent linker/lib warning about file without public symbols */ int debug_sync_dummy; #endif /* defined(ENABLED_DEBUG_SYNC) */ - - -/** - Debug utility to do crash after a set number of executions - - The user variable, either @debug_crash_counter or @debug_error_counter, - is decremented each time debug_crash() or debug_simulate_error is called - if the keyword is set with @@debug_push, like - @@debug_push="d+frm_data_type_info_emulate" - - If the variable is not set or is not an integer it will be ignored. -*/ - -#ifndef DBUG_OFF - -static const LEX_CSTRING debug_crash_counter= -{ STRING_WITH_LEN("debug_crash_counter") }; -static const LEX_CSTRING debug_error_counter= -{ STRING_WITH_LEN("debug_error_counter") }; - -static bool debug_decrement_counter(const LEX_CSTRING *name) -{ - THD *thd= current_thd; - user_var_entry *entry= (user_var_entry*) - my_hash_search(&thd->user_vars, (uchar*) name->str, name->length); - if (!entry || entry->type != INT_RESULT || ! entry->value) - return 0; - (*(ulonglong*) entry->value)= (*(ulonglong*) entry->value)-1; - return !*(ulonglong*) entry->value; -} - -void debug_crash_here(const char *keyword) -{ - DBUG_ENTER("debug_crash_here"); - DBUG_PRINT("enter", ("keyword: %s", keyword)); - - DBUG_EXECUTE_IF(keyword, - if (debug_decrement_counter(&debug_crash_counter)) - { - my_printf_error(ER_INTERNAL_ERROR, - "Crashing at %s", - MYF(ME_ERROR_LOG | ME_NOTE), keyword); - DBUG_SUICIDE(); - }); - DBUG_VOID_RETURN; -} - -/* - This can be used as debug_counter to simulate an error at a specific - position. - - Typical usage would be - if (debug_simualte_error("keyword")) - error= 1; -*/ - -bool debug_simulate_error(const char *keyword, uint error) -{ - DBUG_ENTER("debug_crash_here"); - DBUG_PRINT("enter", ("keyword: %s", keyword)); - DBUG_EXECUTE_IF(keyword, - if (debug_decrement_counter(&debug_error_counter)) - { - my_printf_error(error, - "Simulating error for '%s'", - MYF(ME_ERROR_LOG), keyword); - DBUG_RETURN(1); - }); - DBUG_RETURN(0); -} -#endif /* DBUG_OFF */ |
