diff --git a/libmariadb/mariadb_lib.c b/libmariadb/mariadb_lib.c index 116f7da0..39140260 100644 --- a/libmariadb/mariadb_lib.c +++ b/libmariadb/mariadb_lib.c @@ -4240,13 +4240,22 @@ int STDCALL mysql_reset_connection(MYSQL *mysql) /* skip result sets */ if (mysql->status == MYSQL_STATUS_USE_RESULT || - mysql->status == MYSQL_STATUS_GET_RESULT || - mysql->status & SERVER_MORE_RESULTS_EXIST) + mysql->status == MYSQL_STATUS_GET_RESULT) { mthd_my_skip_result(mysql); - mysql->status= MYSQL_STATUS_READY; } + if (mysql->server_status & SERVER_MORE_RESULTS_EXIST) + { + while (mysql_next_result(mysql)) + { + MYSQL_RES *res= mysql_use_result(mysql); + mysql_free_result(res); + } + } + + mysql->status= MYSQL_STATUS_READY; + rc= ma_simple_command(mysql, COM_RESET_CONNECTION, 0, 0, 0, 0); if (rc && mysql->options.reconnect) { diff --git a/unittest/libmariadb/connection.c b/unittest/libmariadb/connection.c index 624c5945..6b00dd61 100644 --- a/unittest/libmariadb/connection.c +++ b/unittest/libmariadb/connection.c @@ -1922,7 +1922,43 @@ static int test_conc490(MYSQL *my __attribute__((unused))) return OK; } +static int test_conc632(MYSQL *my __attribute__((unused))) +{ + MYSQL *mysql= mysql_init(NULL); + int rc; + + if (!my_test_connect(mysql, hostname, username, password, schema, port, socketname, CLIENT_REMEMBER_OPTIONS)) + { + diag("Connection failed. Error: %s", mysql_error(mysql)); + mysql_close(mysql); + return FAIL; + } + + rc= mysql_query(mysql, "CREATE OR REPLACE PROCEDURE conc632() " + "BEGIN " + " SELECT 1;" + " SELECT 2;" + "END"); + check_mysql_rc(rc, mysql); + + rc= mysql_query(mysql, "CALL conc632()"); + check_mysql_rc(rc, mysql); + + rc= mysql_reset_connection(mysql); + check_mysql_rc(rc, mysql); + + rc= mysql_ping(mysql); + check_mysql_rc(rc, mysql); + + rc= mysql_query(mysql, "DROP PROCEDURE conc632"); + check_mysql_rc(rc, mysql); + + mysql_close(mysql); + return OK; +} + struct my_tests_st my_tests[] = { + {"test_conc632", test_conc632, TEST_CONNECTION_NONE, 0, NULL, NULL}, {"test_conc490", test_conc490, TEST_CONNECTION_NONE, 0, NULL, NULL}, {"test_gtid", test_gtid, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, {"test_conc496", test_conc496, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},