Commit bf848358 authored by holyfoot/hf@hfmain.(none)'s avatar holyfoot/hf@hfmain.(none)

Merge bk@192.168.21.1:mysql-5.0-opt

into  mysql.com:/home/hf/work/25097/my50-25097
parents e3de6b7d 140ca595
...@@ -420,6 +420,7 @@ int main(int argc,char *argv[]) ...@@ -420,6 +420,7 @@ int main(int argc,char *argv[])
} }
if (mysql_server_init(emb_argc, emb_argv, (char**) server_default_groups)) if (mysql_server_init(emb_argc, emb_argv, (char**) server_default_groups))
{ {
put_error(NULL);
free_defaults(defaults_argv); free_defaults(defaults_argv);
my_end(0); my_end(0);
exit(1); exit(1);
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
extern const char *unknown_sqlstate; extern const char *unknown_sqlstate;
extern const char *cant_connect_sqlstate;
extern const char *not_error_sqlstate; extern const char *not_error_sqlstate;
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -1486,7 +1486,7 @@ my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql) ...@@ -1486,7 +1486,7 @@ my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql)
const char *STDCALL mysql_sqlstate(MYSQL *mysql) const char *STDCALL mysql_sqlstate(MYSQL *mysql)
{ {
return mysql->net.sqlstate; return mysql ? mysql->net.sqlstate : cant_connect_sqlstate;
} }
uint STDCALL mysql_warning_count(MYSQL *mysql) uint STDCALL mysql_warning_count(MYSQL *mysql)
......
...@@ -47,6 +47,8 @@ C_MODE_START ...@@ -47,6 +47,8 @@ C_MODE_START
#include <sql_common.h> #include <sql_common.h>
#include "embedded_priv.h" #include "embedded_priv.h"
extern unsigned int mysql_server_last_errno;
extern char mysql_server_last_error[MYSQL_ERRMSG_SIZE];
static my_bool emb_read_query_result(MYSQL *mysql); static my_bool emb_read_query_result(MYSQL *mysql);
...@@ -1084,3 +1086,11 @@ bool Protocol::net_store_data(const char *from, uint length) ...@@ -1084,3 +1086,11 @@ bool Protocol::net_store_data(const char *from, uint length)
return false; return false;
} }
void vprint_msg_to_log(enum loglevel level __attribute__((unused)),
const char *format, va_list argsi)
{
vsnprintf(mysql_server_last_error, sizeof(mysql_server_last_error),
format, argsi);
mysql_server_last_errno= CR_UNKNOWN_ERROR;
}
...@@ -117,6 +117,7 @@ uint mysql_port=0; ...@@ -117,6 +117,7 @@ uint mysql_port=0;
char *mysql_unix_port= 0; char *mysql_unix_port= 0;
const char *unknown_sqlstate= "HY000"; const char *unknown_sqlstate= "HY000";
const char *not_error_sqlstate= "00000"; const char *not_error_sqlstate= "00000";
const char *cant_connect_sqlstate= "08001";
#ifdef HAVE_SMEM #ifdef HAVE_SMEM
char *shared_memory_base_name= 0; char *shared_memory_base_name= 0;
const char *def_shared_memory_base_name= default_shared_memory_base_name; const char *def_shared_memory_base_name= default_shared_memory_base_name;
...@@ -131,6 +132,9 @@ static int wait_for_data(my_socket fd, uint timeout); ...@@ -131,6 +132,9 @@ static int wait_for_data(my_socket fd, uint timeout);
CHARSET_INFO *default_client_charset_info = &my_charset_latin1; CHARSET_INFO *default_client_charset_info = &my_charset_latin1;
/* Server error code and message */
unsigned int mysql_server_last_errno;
char mysql_server_last_error[MYSQL_ERRMSG_SIZE];
/**************************************************************************** /****************************************************************************
A modified version of connect(). my_connect() allows you to specify A modified version of connect(). my_connect() allows you to specify
...@@ -752,10 +756,18 @@ void set_mysql_error(MYSQL *mysql, int errcode, const char *sqlstate) ...@@ -752,10 +756,18 @@ void set_mysql_error(MYSQL *mysql, int errcode, const char *sqlstate)
DBUG_PRINT("enter", ("error :%d '%s'", errcode, ER(errcode))); DBUG_PRINT("enter", ("error :%d '%s'", errcode, ER(errcode)));
DBUG_ASSERT(mysql != 0); DBUG_ASSERT(mysql != 0);
net= &mysql->net; if (mysql)
net->last_errno= errcode; {
strmov(net->last_error, ER(errcode)); net= &mysql->net;
strmov(net->sqlstate, sqlstate); net->last_errno= errcode;
strmov(net->last_error, ER(errcode));
strmov(net->sqlstate, sqlstate);
}
else
{
mysql_server_last_errno= errcode;
strmov(mysql_server_last_error, ER(errcode));
}
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -1477,7 +1489,10 @@ mysql_init(MYSQL *mysql) ...@@ -1477,7 +1489,10 @@ mysql_init(MYSQL *mysql)
if (!mysql) if (!mysql)
{ {
if (!(mysql=(MYSQL*) my_malloc(sizeof(*mysql),MYF(MY_WME | MY_ZEROFILL)))) if (!(mysql=(MYSQL*) my_malloc(sizeof(*mysql),MYF(MY_WME | MY_ZEROFILL))))
{
set_mysql_error(NULL, CR_OUT_OF_MEMORY, unknown_sqlstate);
return 0; return 0;
}
mysql->free_me=1; mysql->free_me=1;
} }
else else
...@@ -3064,13 +3079,13 @@ unsigned int STDCALL mysql_num_fields(MYSQL_RES *res) ...@@ -3064,13 +3079,13 @@ unsigned int STDCALL mysql_num_fields(MYSQL_RES *res)
uint STDCALL mysql_errno(MYSQL *mysql) uint STDCALL mysql_errno(MYSQL *mysql)
{ {
return mysql->net.last_errno; return mysql ? mysql->net.last_errno : mysql_server_last_errno;
} }
const char * STDCALL mysql_error(MYSQL *mysql) const char * STDCALL mysql_error(MYSQL *mysql)
{ {
return mysql->net.last_error; return mysql ? mysql->net.last_error : mysql_server_last_error;
} }
......
...@@ -2496,12 +2496,7 @@ static void print_buffer_to_nt_eventlog(enum loglevel level, char *buff, ...@@ -2496,12 +2496,7 @@ static void print_buffer_to_nt_eventlog(enum loglevel level, char *buff,
void void
*/ */
#ifdef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
void vprint_msg_to_log(enum loglevel level __attribute__((unused)),
const char *format __attribute__((unused)),
va_list argsi __attribute__((unused)))
{}
#else /*!EMBEDDED_LIBRARY*/
static void print_buffer_to_file(enum loglevel level, const char *buffer) static void print_buffer_to_file(enum loglevel level, const char *buffer)
{ {
time_t skr; time_t skr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment