From bea068326fa72be791bac5c2f1658e27e7080cb9 Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Sun, 9 May 2010 20:02:05 -0700 Subject: Using an initial command with mysql_options(..., MYSQL_INIT_COMMAND, ...) that generated multiple result sets (such as a stored procedure or a multi-statement command) would leave the connection unusable. (Bug #42373) A side-effect of this bug fix is to make MYSQL_INIT_COMMAND settings ignored when connecting from within the server, but none of the existing mechanisms for connecting from within the server use or need to set the initial command. --- sql-common/client.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'sql-common/client.c') diff --git a/sql-common/client.c b/sql-common/client.c index 51bbda3bade..1b7723ce0a5 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -2455,6 +2455,11 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, goto error; } + /* + Using init_commands is not supported when connecting from within the + server. + */ +#ifndef MYSQL_SERVER if (mysql->options.init_commands) { DYNAMIC_ARRAY *init_commands= mysql->options.init_commands; @@ -2466,18 +2471,26 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, for (; ptr < end_command; ptr++) { - MYSQL_RES *res; + int status; + if (mysql_real_query(mysql,*ptr, (ulong) strlen(*ptr))) goto error; - if (mysql->fields) - { - if (!(res= cli_use_result(mysql))) - goto error; - mysql_free_result(res); - } + + do { + if (mysql->fields) + { + MYSQL_RES *res; + if (!(res= cli_use_result(mysql))) + goto error; + mysql_free_result(res); + } + if ((status= mysql_next_result(mysql)) > 0) + goto error; + } while (status == 0); } mysql->reconnect=reconnect; } +#endif #ifndef TO_BE_DELETED if (mysql->options.rpl_probe && mysql_rpl_probe(mysql)) -- cgit v1.2.1