summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <hf@deer.(none)>2003-09-08 13:11:18 +0500
committerunknown <hf@deer.(none)>2003-09-08 13:11:18 +0500
commitd0f9e73a43382b8f53b1d23bd3ffdde8e39f3a5e (patch)
tree9bb4fb9d26d9619c909331d361eb2b1a642f4117
parent08e274758715ead9d55f6b838a36dd1e732facf6 (diff)
downloadmariadb-git-d0f9e73a43382b8f53b1d23bd3ffdde8e39f3a5e.tar.gz
fix for #1210
include/errmsg.h: Error code added libmysql/errmsg.c: Error message added libmysqld/lib_sql.cc: static inited variable changed to global server_inited libmysqld/libmysqld.c: check for mysql_server_init execution added
-rw-r--r--include/errmsg.h1
-rw-r--r--libmysql/errmsg.c9
-rw-r--r--libmysqld/lib_sql.cc7
-rw-r--r--libmysqld/libmysqld.c16
4 files changed, 27 insertions, 6 deletions
diff --git a/include/errmsg.h b/include/errmsg.h
index 1f4e6e12f00..a354c125e36 100644
--- a/include/errmsg.h
+++ b/include/errmsg.h
@@ -86,3 +86,4 @@ extern const char *client_errors[]; /* Error messages */
#define CR_SHARED_MEMORY_CONNECT_SET_ERROR 2045
#define CR_CONN_UNKNOW_PROTOCOL 2046
#define CR_INVALID_CONN_HANDLE 2047
+#define CR_MYSQL_SERVER_INIT_MISSED 2048
diff --git a/libmysql/errmsg.c b/libmysql/errmsg.c
index bbb85885886..d27e981aaab 100644
--- a/libmysql/errmsg.c
+++ b/libmysql/errmsg.c
@@ -71,7 +71,8 @@ const char *client_errors[]=
"Can't open shared memory. Server abandoded and don't sent the answer event (%lu)",
"Can't open shared memory. Can't send the request event to server (%lu)",
"Wrong or unknown protocol",
- "Invalid connection handle"
+ "Invalid connection handle",
+ "mysql_server_init wasn't called"
};
/* Start of code added by Roberto M. Serqueira - martinsc@uol.com.br - 05.24.2001 */
@@ -126,7 +127,8 @@ const char *client_errors[]=
"Can't open shared memory. Server abandoded and don't sent the answer event (%lu)",
"Can't open shared memory. Can't send the request event to server (%lu)",
"Wrong or unknown protocol",
- "Invalid connection handle"
+ "Invalid connection handle",
+ "mysql_server_init wasn't called"
};
#else /* ENGLISH */
@@ -179,7 +181,8 @@ const char *client_errors[]=
"Can't open shared memory. Server abandoded and don't sent the answer event (%lu)",
"Can't open shared memory. Can't send the request event to server (%lu)",
"Wrong or unknown protocol",
- "Invalid connection handle"
+ "Invalid connection handle",
+ "mysql_server_init wasn't called"
};
#endif
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc
index 00ec550273c..31deb1afb01 100644
--- a/libmysqld/lib_sql.cc
+++ b/libmysqld/lib_sql.cc
@@ -26,7 +26,8 @@
static int fake_argc= 1;
static char *fake_argv[]= {(char *)"", 0};
static const char *fake_groups[] = { "server", "embedded", 0 };
-static char inited, org_my_init_done;
+static char org_my_init_done;
+char server_inited;
#if defined (__WIN__)
#include "../sql/mysqld.cpp"
@@ -181,9 +182,9 @@ int STDCALL mysql_server_init(int argc, char **argv, char **groups)
/* Only call MY_INIT() if it hasn't been called before */
- if (!inited)
+ if (!server_inited)
{
- inited=1;
+ server_inited=1;
org_my_init_done=my_init_done;
}
if (!org_my_init_done)
diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c
index 48b3397ee7c..0c772587c4b 100644
--- a/libmysqld/libmysqld.c
+++ b/libmysqld/libmysqld.c
@@ -79,6 +79,8 @@ struct passwd *getpwuid(uid_t);
char* getlogin(void);
#endif
+extern char server_inited;
+
#ifdef __WIN__
static my_bool is_NT(void)
{
@@ -210,6 +212,20 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
db ? db : "(Null)",
user ? user : "(Null)"));
+#ifdef EMBEDDED_LIBRARY
+ /*
+ Here we check that mysql_server_init was called before.
+ Actually we can perform the test for client (not embedded) library as well.
+ But i'm afraid some old applications will be broken then.
+ */
+ if (!server_inited)
+ {
+ mysql->net.last_errno=CR_MYSQL_SERVER_INIT_MISSED;
+ strmov(mysql->net.last_error,ER(mysql->net.last_errno));
+ goto error;
+ }
+#endif /*EMBEDDED_LIBRARY*/
+
if (mysql->options.methods_to_use == MYSQL_OPT_USE_REMOTE_CONNECTION)
cli_mysql_real_connect(mysql, host, user,
passwd, db, port, unix_socket, client_flag);