summaryrefslogtreecommitdiff
path: root/libmysqld/libmysqld.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmysqld/libmysqld.c')
-rw-r--r--libmysqld/libmysqld.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c
index a2bd4242c3d..5df61783451 100644
--- a/libmysqld/libmysqld.c
+++ b/libmysqld/libmysqld.c
@@ -14,6 +14,11 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+#include <my_global.h>
+#include <mysql.h>
+#include <mysql_embed.h>
+#include <mysqld_error.h>
+#include <my_pthread.h>
#include "embedded_priv.h"
#include <my_sys.h>
#include <mysys_err.h>
@@ -151,12 +156,26 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
if (!user)
user= "";
- mysql->user=my_strdup(user,MYF(0));
+ /*
+ We need to alloc some space for mysql->info but don't want to
+ put extra 'my_free's in mysql_close.
+ So we alloc it with the 'user' string to be freed at once
+ */
+ mysql->user= my_strdup(user, MYF(0));
port=0;
unix_socket=0;
db_name = db ? my_strdup(db,MYF(MY_WME)) : NULL;
+ /* Send client information for access check */
+ client_flag|=CLIENT_CAPABILITIES;
+ if (client_flag & CLIENT_MULTI_STATEMENTS)
+ client_flag|= CLIENT_MULTI_RESULTS;
+ client_flag&= ~CLIENT_COMPRESS;
+ if (db)
+ client_flag|=CLIENT_CONNECT_WITH_DB;
+
+ mysql->info_buffer= my_malloc(MYSQL_ERRMSG_SIZE, MYF(0));
mysql->thd= create_embedded_thd(client_flag, db_name);
init_embedded_mysql(mysql, client_flag, db_name);
@@ -167,11 +186,6 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
if (check_embedded_connection(mysql))
goto error;
- /* Send client information for access check */
- client_flag|=CLIENT_CAPABILITIES;
- client_flag&= ~CLIENT_COMPRESS;
- if (db)
- client_flag|=CLIENT_CONNECT_WITH_DB;
mysql->server_status= SERVER_STATUS_AUTOCOMMIT;
if (mysql->options.init_commands)
@@ -198,7 +212,6 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
DBUG_RETURN(mysql);
error:
- embedded_get_error(mysql);
DBUG_PRINT("error",("message: %u (%s)", mysql->net.last_errno,
mysql->net.last_error));
{