summaryrefslogtreecommitdiff
path: root/extra/perror.c
diff options
context:
space:
mode:
Diffstat (limited to 'extra/perror.c')
-rw-r--r--extra/perror.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/extra/perror.c b/extra/perror.c
index 382805c5dfd..3c00b9b11d7 100644
--- a/extra/perror.c
+++ b/extra/perror.c
@@ -32,7 +32,7 @@ static my_bool verbose, print_all_codes;
#include "../include/my_base.h"
#include "../mysys/my_handler_errors.h"
-#include "../include/my_handler.h"
+// #include "../include/my_compare.h"
#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
static my_bool ndb_code;
@@ -240,7 +240,39 @@ static my_bool print_win_error_msg(DWORD error, my_bool verbose)
}
#endif
+/*
+ Register handler error messages for usage with my_error()
+ NOTES
+ This is safe to call multiple times as my_error_register()
+ will ignore calls to register already registered error numbers.
+*/
+
+static const char **get_handler_error_messages()
+{
+ return handler_error_messages;
+}
+
+void my_handler_error_register(void)
+{
+ /*
+ If you got compilation error here about compile_time_assert array, check
+ that every HA_ERR_xxx constant has a corresponding error message in
+ handler_error_messages[] list (check mysys/ma_handler_errors.h and
+ include/my_base.h).
+ */
+ compile_time_assert(HA_ERR_FIRST + array_elements(handler_error_messages) ==
+ HA_ERR_LAST + 1);
+ my_error_register(get_handler_error_messages, HA_ERR_FIRST,
+ HA_ERR_FIRST+ array_elements(handler_error_messages)-1);
+}
+
+
+void my_handler_error_unregister(void)
+{
+ my_error_unregister(HA_ERR_FIRST,
+ HA_ERR_FIRST+ array_elements(handler_error_messages)-1);
+}
int main(int argc,char *argv[])
{