diff options
author | unknown <holyfoot/hf@hfmain.(none)> | 2008-02-27 13:00:59 +0400 |
---|---|---|
committer | unknown <holyfoot/hf@hfmain.(none)> | 2008-02-27 13:00:59 +0400 |
commit | 33c4301922112658131e094b3b6b5912c236e90d (patch) | |
tree | a3eef8d4ff9d07ed0b848f3d59a308366a952f5c /sql-common | |
parent | 78e19d4283572f1706738980b8242a5e65619caf (diff) | |
parent | a4b0a2cf67356c0f8f80b5291b3c1f4f8327cb97 (diff) | |
download | mariadb-git-33c4301922112658131e094b3b6b5912c236e90d.tar.gz |
Merge mysql.com:/home/hf/work/25097/my50-25097
into mysql.com:/home/hf/work/25097/my51-25097
client/mysql.cc:
Auto merged
include/sql_common.h:
Auto merged
libmysql/libmysql.c:
Auto merged
libmysqld/lib_sql.cc:
Auto merged
sql-common/client.c:
merging
sql/log.cc:
merging
Diffstat (limited to 'sql-common')
-rw-r--r-- | sql-common/client.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/sql-common/client.c b/sql-common/client.c index 1a0f9c64d7d..e5667fa6735 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -112,6 +112,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; @@ -126,6 +127,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 @@ -288,11 +292,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->client_last_errno= errcode; - strmov(net->client_last_error, ER(errcode)); - strmov(net->sqlstate, sqlstate); - + if (mysql) + { + net= &mysql->net; + net->client_last_errno= errcode; + strmov(net->client_last_error, ER(errcode)); + strmov(net->sqlstate, sqlstate); + } + else + { + mysql_server_last_errno= errcode; + strmov(mysql_server_last_error, ER(errcode)); + } DBUG_VOID_RETURN; } @@ -1489,7 +1500,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 @@ -3079,13 +3093,13 @@ unsigned int STDCALL mysql_num_fields(MYSQL_RES *res) uint STDCALL mysql_errno(MYSQL *mysql) { - return mysql->net.client_last_errno; + return mysql ? mysql->net.client_last_errno : mysql_server_last_errno; } const char * STDCALL mysql_error(MYSQL *mysql) { - return mysql->net.client_last_error; + return mysql ? mysql->net.client_last_error : mysql_server_last_error; } |