diff options
author | unknown <kaa@kaamos.(none)> | 2008-03-12 11:19:46 +0300 |
---|---|---|
committer | unknown <kaa@kaamos.(none)> | 2008-03-12 11:19:46 +0300 |
commit | d6df18dd3304ef13eaa5f3545cd12575ebbfc33a (patch) | |
tree | f84e4ada799bf37a3d9ef074064f8a17f408aa89 /sql-common | |
parent | 6c2420ed3c0e074fc3b7f47ce00e7ce220906e2c (diff) | |
parent | a5e775b4d657b9521f60b06cf8f19a9a1741c668 (diff) | |
download | mariadb-git-d6df18dd3304ef13eaa5f3545cd12575ebbfc33a.tar.gz |
Merge kaamos.(none):/data/src/mysql-5.1
into kaamos.(none):/data/src/opt/mysql-5.1-opt
client/mysql.cc:
Auto merged
client/mysqldump.c:
Auto merged
configure.in:
Auto merged
include/my_global.h:
Auto merged
libmysql/libmysql.c:
Auto merged
libmysqld/lib_sql.cc:
Auto merged
mysql-test/include/mix1.inc:
Auto merged
mysql-test/r/create.result:
Auto merged
mysql-test/r/func_str.result:
Auto merged
mysql-test/r/innodb.result:
Auto merged
mysql-test/r/innodb_mysql.result:
Auto merged
mysql-test/r/select.result:
Auto merged
mysql-test/r/subselect.result:
Auto merged
mysql-test/t/create.test:
Auto merged
mysql-test/t/disabled.def:
Auto merged
sql/filesort.cc:
Auto merged
sql/handler.cc:
Auto merged
sql/item.cc:
Auto merged
sql/item.h:
Auto merged
sql/item_cmpfunc.cc:
Auto merged
sql/item_func.cc:
Auto merged
sql/item_func.h:
Auto merged
sql/item_sum.cc:
Auto merged
sql/log.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/mysqld.cc:
Auto merged
sql/set_var.cc:
Auto merged
sql/sp.cc:
Auto merged
sql/sql_acl.cc:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_plugin.cc:
Auto merged
sql/sql_select.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
storage/ndb/src/kernel/blocks/backup/Backup.hpp:
Auto merged
tests/mysql_client_test.c:
Auto merged
mysql-test/r/func_time.result:
Manual merge.
mysql-test/r/view.result:
Manual merge.
mysql-test/t/view.test:
Manual merge.
scripts/mysql_config.sh:
Manual merge.
sql-common/client.c:
Manual merge.
sql/sql_parse.cc:
Manual merge.
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 b1728f0f74f..596c9f6c448 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->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; } @@ -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 @@ -3087,13 +3101,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; } |