summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2021-05-14 15:27:24 +0300
committerSergei Golubchik <serg@mariadb.org>2021-05-19 22:54:13 +0200
commit496a14e18714ac3f0b686ec5f57bf88e96512d2f (patch)
treecbeb02f7072e2ae3ded695e4360d581e19166286
parentad02d53a715b9aeb7637f6a2c3685b094b15fa6b (diff)
downloadmariadb-git-496a14e18714ac3f0b686ec5f57bf88e96512d2f.tar.gz
Move debug_crash_here to it's own source files
-rw-r--r--libmysqld/CMakeLists.txt3
-rw-r--r--sql/CMakeLists.txt2
-rw-r--r--sql/debug.cc88
-rw-r--r--sql/debug.h39
-rw-r--r--sql/debug_sync.cc71
-rw-r--r--sql/debug_sync.h9
-rw-r--r--sql/parse_file.cc2
-rw-r--r--sql/sql_db.cc2
-rw-r--r--sql/sql_insert.cc4
-rw-r--r--sql/sql_rename.cc2
-rw-r--r--sql/sql_table.cc4
-rw-r--r--sql/sql_trigger.cc5
-rw-r--r--sql/sql_view.cc20
-rw-r--r--storage/maria/ha_maria.cc2
14 files changed, 151 insertions, 102 deletions
diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt
index 447817999c9..e74a6fbc6c2 100644
--- a/libmysqld/CMakeLists.txt
+++ b/libmysqld/CMakeLists.txt
@@ -78,7 +78,8 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
../sql/sql_binlog.cc ../sql/sql_manager.cc
../sql/sql_parse.cc ../sql/sql_bootstrap.cc
../sql/sql_partition.cc ../sql/sql_plugin.cc
- ../sql/debug_sync.cc ../sql/opt_table_elimination.cc
+ ../sql/debug_sync.cc ../sql/debug.cc
+ ../sql/opt_table_elimination.cc
../sql/sql_prepare.cc ../sql/sql_rename.cc ../sql/sql_repl.cc
../sql/sql_select.cc ../sql/sql_servers.cc
../sql/group_by_handler.cc ../sql/derived_handler.cc
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
index 118971cd02b..5e6153202f7 100644
--- a/sql/CMakeLists.txt
+++ b/sql/CMakeLists.txt
@@ -117,7 +117,7 @@ SET (SQL_SOURCE
sql_list.cc sql_load.cc sql_manager.cc
sql_parse.cc sql_bootstrap.cc
sql_partition.cc sql_plugin.cc sql_prepare.cc sql_rename.cc
- debug_sync.cc
+ debug_sync.cc debug.cc
sql_repl.cc sql_select.cc sql_show.cc sql_state.c
group_by_handler.cc derived_handler.cc select_handler.cc
sql_statistics.cc sql_string.cc lex_string.h
diff --git a/sql/debug.cc b/sql/debug.cc
new file mode 100644
index 00000000000..a0e2340e254
--- /dev/null
+++ b/sql/debug.cc
@@ -0,0 +1,88 @@
+/* Copyright (c) 2021, MariaDB Corporation.
+
+ 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 Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
+
+#include "mariadb.h"
+#include "sql_class.h"
+#include "debug.h"
+
+/**
+ 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 */
diff --git a/sql/debug.h b/sql/debug.h
new file mode 100644
index 00000000000..48bae774625
--- /dev/null
+++ b/sql/debug.h
@@ -0,0 +1,39 @@
+#ifndef DEBUG_INCLUDED
+#define DEBUG_INCLUDED
+
+/* Copyright (c) 2021, MariaDB Corporation
+
+ 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 Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
+
+/**
+ @file
+
+ Declarations for debug_crash_here and other future mariadb server debug
+ functionality.
+*/
+
+/* debug_crash_here() functionallity.
+ See mysql_test/suite/atomic/create_table.test for an example of how it
+ can be used
+*/
+
+#ifndef DBUG_OFF
+void debug_crash_here(const char *keyword);
+bool debug_simulate_error(const char *keyword, uint error);
+#else
+#define debug_crash_here(A) do { } while(0)
+#define debug_simulate_error(A, B) 0
+#endif
+
+#endif /* DEBUG_INCLUDED */
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 */
diff --git a/sql/debug_sync.h b/sql/debug_sync.h
index 4e3e10fcc51..831b86b688e 100644
--- a/sql/debug_sync.h
+++ b/sql/debug_sync.h
@@ -52,13 +52,4 @@ static inline void debug_sync_reset_thread(THD *thd) {}
static inline bool debug_sync_set_action(THD *, const char *, size_t)
{ return false; }
#endif /* defined(ENABLED_DEBUG_SYNC) */
-
-#ifndef DBUG_OFF
-void debug_crash_here(const char *keyword);
-bool debug_simulate_error(const char *keyword, uint error);
-#else
-#define debug_crash_here(A) do { } while(0)
-#define debug_simulate_error(A, B) 0
-#endif
-
#endif /* DEBUG_SYNC_INCLUDED */
diff --git a/sql/parse_file.cc b/sql/parse_file.cc
index 8ea00e96f33..8911c683901 100644
--- a/sql/parse_file.cc
+++ b/sql/parse_file.cc
@@ -25,7 +25,7 @@
#include "parse_file.h"
#include "unireg.h" // CREATE_MODE
#include "sql_table.h" // build_table_filename
-#include "debug_sync.h"
+#include "debug.h"
#include <mysys_err.h> // EE_WRITE
#include <m_ctype.h>
#include <my_dir.h>
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index 6a493ed725f..4fd90a0e0b1 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -47,7 +47,7 @@
#ifdef __WIN__
#include <direct.h>
#endif
-#include "debug_sync.h"
+#include "debug.h" // debug_crash_here
#define MAX_DROP_TABLE_Q_LEN 1024
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 8dde0ec8989..54fb94e8e4f 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -77,10 +77,10 @@
#include "sql_audit.h"
#include "sql_derived.h" // mysql_handle_derived
#include "sql_prepare.h"
+#include "debug_sync.h" // DEBUG_SYNC
+#include "debug.h" // debug_crash_here
#include <my_bit.h>
-#include "debug_sync.h"
-
#ifdef WITH_WSREP
#include "wsrep_trans_observer.h" /* wsrep_start_transction() */
#endif /* WITH_WSREP */
diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc
index ec782792f30..205c3ce91b7 100644
--- a/sql/sql_rename.cc
+++ b/sql/sql_rename.cc
@@ -31,7 +31,7 @@
#include "sql_handler.h" // mysql_ha_rm_tables
#include "sql_statistics.h"
#include "ddl_log.h"
-#include "debug_sync.h"
+#include "debug.h"
/* used to hold table entries for as part of list of renamed temporary tables */
struct TABLE_PAIR
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 95337d641a5..f1390f232f1 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -54,9 +54,9 @@
#include "sql_audit.h"
#include "sql_sequence.h"
#include "tztime.h"
-#include "sql_insert.h" // binlog_drop_table
+#include "sql_insert.h" // binlog_drop_table
#include "ddl_log.h"
-#include "debug_sync.h" // debug_crash_here()
+#include "debug.h" // debug_crash_here()
#include <algorithm>
#ifdef __WIN__
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index 181cca39f7e..c5e112bf8ae 100644
--- a/sql/sql_trigger.cc
+++ b/sql/sql_trigger.cc
@@ -33,8 +33,9 @@
#include "sql_handler.h" // mysql_ha_rm_tables
#include "sp_cache.h" // sp_invalidate_cache
#include <mysys_err.h>
-#include <ddl_log.h> // ddl_log_state
-#include "debug_sync.h"
+#include "ddl_log.h" // ddl_log_state
+#include "debug_sync.h" // DEBUG_SYNC
+#include "debug.h" // debug_crash_here
#include "mysql/psi/mysql_sp.h"
/*************************************************************************/
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index c72d31d7472..61a2c43a43f 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -16,29 +16,29 @@
*/
#define MYSQL_LEX 1
-#include "mariadb.h" /* NO_EMBEDDED_ACCESS_CHECKS */
+#include "mariadb.h" /* NO_EMBEDDED_ACCESS_CHECKS */
#include "sql_priv.h"
#include "unireg.h"
#include "sql_view.h"
-#include "sql_base.h" // find_table_in_global_list, lock_table_names
-#include "sql_parse.h" // sql_parse
-#include "sql_cache.h" // query_cache_*
-#include "lock.h" // MYSQL_OPEN_SKIP_TEMPORARY
-#include "sql_show.h" // append_identifier
-#include "sql_table.h" // build_table_filename
+#include "sql_base.h" // find_table_in_global_list, lock_table_names
+#include "sql_parse.h" // sql_parse
+#include "sql_cache.h" // query_cache_*
+#include "lock.h" // MYSQL_OPEN_SKIP_TEMPORARY
+#include "sql_show.h" // append_identifier
+#include "sql_table.h" // build_table_filename
#include "sql_db.h" // mysql_opt_change_db, mysql_change_db
#include "sql_select.h"
#include "parse_file.h"
#include "sp_head.h"
#include "sp.h"
#include "sp_cache.h"
-#include "datadict.h" // dd_frm_is_view()
+#include "datadict.h" // dd_frm_is_view()
#include "sql_derived.h"
-#include "sql_cte.h" // check_dependencies_in_with_clauses()
+#include "sql_cte.h" // check_dependencies_in_with_clauses()
#include "opt_trace.h"
#include "ddl_log.h"
+#include "debug.h" // debug_crash_here
#include "wsrep_mysqld.h"
-#include "debug_sync.h" // debug_crash_here
#define MD5_BUFF_LENGTH 33
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc
index d3600e9fc45..381a84cebf0 100644
--- a/storage/maria/ha_maria.cc
+++ b/storage/maria/ha_maria.cc
@@ -45,7 +45,7 @@ C_MODE_END
#include "key.h"
#include "log.h"
#include "sql_parse.h"
-#include "debug_sync.h"
+#include "debug.h"
/*
Note that in future versions, only *transactional* Maria tables can