summaryrefslogtreecommitdiff
path: root/extra/perror.c
diff options
context:
space:
mode:
Diffstat (limited to 'extra/perror.c')
-rw-r--r--extra/perror.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/extra/perror.c b/extra/perror.c
index 212b313ade4..b029d87040f 100644
--- a/extra/perror.c
+++ b/extra/perror.c
@@ -23,21 +23,33 @@
#include <m_string.h>
#include <errno.h>
#include <my_getopt.h>
+#ifdef HAVE_NDBCLUSTER_DB
+#include "../ndb/src/ndbapi/ndberror.c"
+#endif
static my_bool verbose, print_all_codes;
+#ifdef HAVE_NDBCLUSTER_DB
+static my_bool ndb_code;
+static char ndb_string[1024];
+#endif
+
static struct my_option my_long_options[] =
{
{"help", '?', "Displays this help and exits.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
- {"info", 'I', "Synonym for --help", 0, 0, 0, GET_NO_ARG,
+ {"info", 'I', "Synonym for --help.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
+#ifdef HAVE_NDBCLUSTER_DB
+ {"ndb", 0, "Ndbcluster storage engine specific error codes.", (gptr*) &ndb_code,
+ (gptr*) &ndb_code, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+#endif
#ifdef HAVE_SYS_ERRLIST
{"all", 'a', "Print all the error messages and the number.",
(gptr*) &print_all_codes, (gptr*) &print_all_codes, 0, GET_BOOL, NO_ARG,
0, 0, 0, 0, 0, 0},
#endif
- {"silent", 's', "Only print the error message", 0, 0, 0, GET_NO_ARG, NO_ARG,
+ {"silent", 's', "Only print the error message.", 0, 0, 0, GET_NO_ARG, NO_ARG,
0, 0, 0, 0, 0, 0},
{"verbose", 'v', "Print error code and message (default).", (gptr*) &verbose,
(gptr*) &verbose, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
@@ -185,7 +197,7 @@ int main(int argc,char *argv[])
for (code=1 ; code < sys_nerr ; code++)
{
if (sys_errlist[code][0])
- { /* Skipp if no error-text */
+ { /* Skip if no error-text */
printf("%3d = %s\n",code,sys_errlist[code]);
}
}
@@ -204,9 +216,20 @@ int main(int argc,char *argv[])
for ( ; argc-- > 0 ; argv++)
{
+
found=0;
code=atoi(*argv);
- msg= strerror(code);
+#ifdef HAVE_NDBCLUSTER_DB
+ if (ndb_code)
+ {
+ if (ndb_error_string(code, ndb_string, sizeof(ndb_string)) < 0)
+ msg= 0;
+ else
+ msg= ndb_string;
+ }
+ else
+#endif
+ msg = strerror(code);
/*
Don't print message for not existing error messages or for
@@ -218,7 +241,7 @@ int main(int argc,char *argv[])
{
found=1;
if (verbose)
- printf("System error: %3d = %s\n",code,msg);
+ printf("Error code %3d: %s\n",code,msg);
else
puts(msg);
}