summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
authorDaniel Fischer <df@sun.com>2010-04-21 14:58:09 +0200
committerDaniel Fischer <df@sun.com>2010-04-21 14:58:09 +0200
commitb83e1c868622125ff59d405710cb6438c131a7f4 (patch)
tree4fad82e285f056995b626f0a62b5fa0488294c19 /extra
parent718ee3e595d3c73517c1bc1df8d3bdfc2e22510b (diff)
parent210d37e5c0aaa821783023b3f275c5e7992c515c (diff)
downloadmariadb-git-b83e1c868622125ff59d405710cb6438c131a7f4.tar.gz
Merge
Diffstat (limited to 'extra')
-rwxr-xr-xextra/CMakeLists.txt2
-rw-r--r--extra/comp_err.c32
-rw-r--r--extra/perror.c48
-rw-r--r--extra/yassl/include/yassl_error.hpp2
-rw-r--r--extra/yassl/src/ssl.cpp2
-rw-r--r--extra/yassl/src/yassl_error.cpp2
6 files changed, 81 insertions, 7 deletions
diff --git a/extra/CMakeLists.txt b/extra/CMakeLists.txt
index ee575685655..27fc31cbdde 100755
--- a/extra/CMakeLists.txt
+++ b/extra/CMakeLists.txt
@@ -68,7 +68,7 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
ENDIF()
-ADD_EXECUTABLE(replace replace.c)
+MYSQL_ADD_EXECUTABLE(replace replace.c)
TARGET_LINK_LIBRARIES(replace mysys)
IF(UNIX)
MYSQL_ADD_EXECUTABLE(innochecksum innochecksum.c)
diff --git a/extra/comp_err.c b/extra/comp_err.c
index 0b894dae477..e4a07caa2ef 100644
--- a/extra/comp_err.c
+++ b/extra/comp_err.c
@@ -199,11 +199,34 @@ int main(int argc, char *argv[])
}
+static void print_escaped_string(FILE *f, const char *str)
+{
+ const char *tmp = str;
+
+ while (tmp[0] != 0)
+ {
+ switch (tmp[0])
+ {
+ case '\\': fprintf(f, "\\\\"); break;
+ case '\'': fprintf(f, "\\\'"); break;
+ case '\"': fprintf(f, "\\\""); break;
+ case '\n': fprintf(f, "\\n"); break;
+ case '\r': fprintf(f, "\\r"); break;
+ default: fprintf(f, "%c", tmp[0]);
+ }
+ tmp++;
+ }
+}
+
+
static int create_header_files(struct errors *error_head)
{
uint er_last;
FILE *er_definef, *sql_statef, *er_namef;
struct errors *tmp_error;
+ struct message *er_msg;
+ const char *er_text;
+
DBUG_ENTER("create_header_files");
LINT_INIT(er_last);
@@ -245,9 +268,12 @@ static int create_header_files(struct errors *error_head)
"{ %-40s,\"%s\", \"%s\" },\n", tmp_error->er_name,
tmp_error->sql_code1, tmp_error->sql_code2);
/*generating er_name file */
- fprintf(er_namef, "{ \"%s\", %d },\n", tmp_error->er_name,
- tmp_error->d_code);
-
+ er_msg= find_message(tmp_error, default_language, 0);
+ er_text = (er_msg ? er_msg->text : "");
+ fprintf(er_namef, "{ \"%s\", %d, \"", tmp_error->er_name,
+ tmp_error->d_code);
+ print_escaped_string(er_namef, er_text);
+ fprintf(er_namef, "\" },\n");
}
/* finishing off with mysqld_error.h */
fprintf(er_definef, "#define ER_ERROR_LAST %d\n", er_last);
diff --git a/extra/perror.c b/extra/perror.c
index a98a4fc3d1b..d9c636ceb8c 100644
--- a/extra/perror.c
+++ b/extra/perror.c
@@ -184,6 +184,45 @@ static const char *get_ha_error_msg(int code)
return NullS;
}
+typedef struct
+{
+ const char *name;
+ uint code;
+ const char *text;
+} st_error;
+
+static st_error global_error_names[] =
+{
+#include <mysqld_ername.h>
+ { 0, 0, 0 }
+};
+
+/**
+ Lookup an error by code in the global_error_names array.
+ @param code the code to lookup
+ @param [out] name_ptr the error name, when found
+ @param [out] msg_ptr the error text, when found
+ @return 1 when found, otherwise 0
+*/
+int get_ER_error_msg(uint code, const char **name_ptr, const char **msg_ptr)
+{
+ st_error *tmp_error;
+
+ tmp_error= & global_error_names[0];
+
+ while (tmp_error->name != NULL)
+ {
+ if (tmp_error->code == code)
+ {
+ *name_ptr= tmp_error->name;
+ *msg_ptr= tmp_error->text;
+ return 1;
+ }
+ tmp_error++;
+ }
+
+ return 0;
+}
#if defined(__WIN__)
static my_bool print_win_error_msg(DWORD error, my_bool verbose)
@@ -211,6 +250,7 @@ int main(int argc,char *argv[])
{
int error,code,found;
const char *msg;
+ const char *name;
char *unknown_error = 0;
#if defined(__WIN__)
my_bool skip_win_message= 0;
@@ -316,6 +356,14 @@ int main(int argc,char *argv[])
else
puts(msg);
}
+ if (get_ER_error_msg(code, & name, & msg))
+ {
+ found= 1;
+ if (verbose)
+ printf("MySQL error code %3d (%s): %s\n", code, name, msg);
+ else
+ puts(msg);
+ }
if (!found)
{
#if defined(__WIN__)
diff --git a/extra/yassl/include/yassl_error.hpp b/extra/yassl/include/yassl_error.hpp
index 63fa9a761ba..d2473fb3e2b 100644
--- a/extra/yassl/include/yassl_error.hpp
+++ b/extra/yassl/include/yassl_error.hpp
@@ -64,7 +64,7 @@ enum YasslError {
enum Library { yaSSL_Lib = 0, CryptoLib, SocketLib };
enum { MAX_ERROR_SZ = 80 };
-void SetErrorString(YasslError, char*);
+void SetErrorString(unsigned long, char*);
/* remove for now, if go back to exceptions use this wrapper
// Base class for all yaSSL exceptions
diff --git a/extra/yassl/src/ssl.cpp b/extra/yassl/src/ssl.cpp
index 29aa034f885..4d8b6ac69b8 100644
--- a/extra/yassl/src/ssl.cpp
+++ b/extra/yassl/src/ssl.cpp
@@ -991,7 +991,7 @@ char* ERR_error_string(unsigned long errNumber, char* buffer)
static char* msg = (char*)"Please supply a buffer for error string";
if (buffer) {
- SetErrorString(YasslError(errNumber), buffer);
+ SetErrorString(errNumber, buffer);
return buffer;
}
diff --git a/extra/yassl/src/yassl_error.cpp b/extra/yassl/src/yassl_error.cpp
index a1ef8578da6..dd30348cd93 100644
--- a/extra/yassl/src/yassl_error.cpp
+++ b/extra/yassl/src/yassl_error.cpp
@@ -55,7 +55,7 @@ Library Error::get_lib() const
*/
-void SetErrorString(YasslError error, char* buffer)
+void SetErrorString(unsigned long error, char* buffer)
{
using namespace TaoCrypt;
const int max = MAX_ERROR_SZ; // shorthand