summaryrefslogtreecommitdiff
path: root/libmysqld/lib_sql.cc
diff options
context:
space:
mode:
authorunknown <hf@deer.(none)>2004-05-17 12:05:57 +0500
committerunknown <hf@deer.(none)>2004-05-17 12:05:57 +0500
commitafe09e48e0471e989f01b4fe4125d2fd91db2ab8 (patch)
treef862e98f96e4688390bfe532bbb2f31e1f8ae2da /libmysqld/lib_sql.cc
parent8ef62cc1ef3e2b16795fa5fbbc45bcdf422f344c (diff)
downloadmariadb-git-afe09e48e0471e989f01b4fe4125d2fd91db2ab8.tar.gz
Proposed fix for #3744 (embedded server, wrong error message if database is
missing) libmysqld/embedded_priv.h: embedded_get_error interface added libmysqld/lib_sql.cc: embedded_get_error implementation/using added libmysqld/libmysqld.c: embedded_get_error call added
Diffstat (limited to 'libmysqld/lib_sql.cc')
-rw-r--r--libmysqld/lib_sql.cc31
1 files changed, 19 insertions, 12 deletions
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc
index cfb50d3907a..137af80313a 100644
--- a/libmysqld/lib_sql.cc
+++ b/libmysqld/lib_sql.cc
@@ -42,6 +42,22 @@ C_MODE_START
#include "errmsg.h"
#include <sql_common.h>
+void embedded_get_error(MYSQL *mysql)
+{
+ THD *thd=(THD *) mysql->thd;
+ NET *net= &mysql->net;
+ if ((net->last_errno= thd->net.last_errno))
+ {
+ memcpy(net->last_error, thd->net.last_error, sizeof(net->last_error));
+ memcpy(net->sqlstate, thd->net.sqlstate, sizeof(net->sqlstate));
+ }
+ else
+ {
+ net->last_error[0]= 0;
+ strmov(net->sqlstate, not_error_sqlstate);
+ }
+}
+
static my_bool
emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
const char *header, ulong header_length,
@@ -86,16 +102,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
if (!skip_check)
result= thd->net.last_errno ? -1 : 0;
- if ((net->last_errno= thd->net.last_errno))
- {
- memcpy(net->last_error, thd->net.last_error, sizeof(net->last_error));
- memcpy(net->sqlstate, thd->net.sqlstate, sizeof(net->sqlstate));
- }
- else
- {
- net->last_error[0]= 0;
- strmov(net->sqlstate, not_error_sqlstate);
- }
+ embedded_get_error(mysql);
mysql->server_status= thd->server_status;
mysql->warning_count= ((THD*)mysql->thd)->total_warn_count;
return result;
@@ -237,6 +244,7 @@ static void emb_free_embedded_thd(MYSQL *mysql)
free_rows(thd->data);
thread_count--;
delete thd;
+ mysql->thd=0;
}
static const char * emb_read_statistics(MYSQL *mysql)
@@ -496,8 +504,7 @@ int check_embedded_connection(MYSQL *mysql)
thd->host= (char*)my_localhost;
thd->host_or_ip= thd->host;
thd->user= my_strdup(mysql->user, MYF(0));
- check_user(thd, COM_CONNECT, NULL, 0, thd->db, true);
- return 0;
+ return check_user(thd, COM_CONNECT, NULL, 0, thd->db, true);
}
#else