mirror of
https://github.com/MariaDB/server.git
synced 2026-04-20 15:25:33 +02:00
Bug #25097 mysql_server_init fails silently if no errmsg.sys is present.
There was no way to return an error from the client library if no MYSQL connections was established. So here i added variables to store that king of errors and made functions like mysql_error(NULL) to return these. client/mysql.cc: Bug #25097 mysql_server_init fails silently if no errmsg.sys is present. Show the error message on std_error include/sql_common.h: Bug #25097 mysql_server_init fails silently if no errmsg.sys is present. cant_connect_sqlstate constant declared libmysql/libmysql.c: Bug #25097 mysql_server_init fails silently if no errmsg.sys is present. mysql_sqlstate(NULL) returns 'unknown_sqlstate' libmysqld/lib_sql.cc: Bug #25097 mysql_server_init fails silently if no errmsg.sys is present. EMBEDDED_SERVER version of the vprint_msg_to_log() implemented sql-common/client.c: Bug #25097 mysql_server_init fails silently if no errmsg.sys is present. mysql_server_last_errno and mysql_server_last_error introduced to store errors not related to particular connections. mysql_error(NULL) and mysql_errno(NULL) now returns these mysql_server_last_error and errno respectively sql/log.cc: Bug #25097 mysql_server_init fails silently if no errmsg.sys is present. EMBEDDED_LIBRARY implementation of the vprint_msg_to_log() moved to lib_sql.cc
This commit is contained in:
parent
4d794c2334
commit
a4b0a2cf67
6 changed files with 35 additions and 13 deletions
|
|
@ -117,6 +117,7 @@ uint mysql_port=0;
|
|||
char *mysql_unix_port= 0;
|
||||
const char *unknown_sqlstate= "HY000";
|
||||
const char *not_error_sqlstate= "00000";
|
||||
const char *cant_connect_sqlstate= "08001";
|
||||
#ifdef HAVE_SMEM
|
||||
char *shared_memory_base_name= 0;
|
||||
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);
|
|||
|
||||
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
|
||||
|
|
@ -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_ASSERT(mysql != 0);
|
||||
|
||||
net= &mysql->net;
|
||||
net->last_errno= errcode;
|
||||
strmov(net->last_error, ER(errcode));
|
||||
strmov(net->sqlstate, sqlstate);
|
||||
if (mysql)
|
||||
{
|
||||
net= &mysql->net;
|
||||
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;
|
||||
}
|
||||
|
|
@ -1477,7 +1489,10 @@ mysql_init(MYSQL *mysql)
|
|||
if (!mysql)
|
||||
{
|
||||
if (!(mysql=(MYSQL*) my_malloc(sizeof(*mysql),MYF(MY_WME | MY_ZEROFILL))))
|
||||
{
|
||||
set_mysql_error(NULL, CR_OUT_OF_MEMORY, unknown_sqlstate);
|
||||
return 0;
|
||||
}
|
||||
mysql->free_me=1;
|
||||
}
|
||||
else
|
||||
|
|
@ -3064,13 +3079,13 @@ unsigned int STDCALL mysql_num_fields(MYSQL_RES *res)
|
|||
|
||||
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)
|
||||
{
|
||||
return mysql->net.last_error;
|
||||
return mysql ? mysql->net.last_error : mysql_server_last_error;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue