Fix stmt_free_result implementation and usage

Two bugs both affecting the bug_pecl_7976.phpt test ("works with
mysqlnd" haha):

 * We should not change the connection state in stmt_free_result.
   This makes mysql_stmt_free_result usable under mysqlnd and
   not just libmysqlclient.
 * If we call mysql_stmt_free_result, we still need to consume
   any outstanding result sets.
This commit is contained in:
Nikita Popov 2020-12-09 11:13:48 +01:00
parent 9c0712d2cd
commit 18517e7a63
3 changed files with 1 additions and 9 deletions

View file

@ -1931,10 +1931,6 @@ MYSQLND_METHOD(mysqlnd_stmt, free_result)(MYSQLND_STMT * const s)
stmt->state = MYSQLND_STMT_PREPARED;
}
if (GET_CONNECTION_STATE(&conn->state) != CONN_QUIT_SENT) {
SET_CONNECTION_STATE(&conn->state, CONN_READY);
}
DBG_RETURN(PASS);
}
/* }}} */

View file

@ -893,9 +893,7 @@ static int pdo_mysql_stmt_cursor_closer(pdo_stmt_t *stmt) /* {{{ */
S->result = NULL;
}
if (S->stmt) {
int retval;
retval = mysql_stmt_free_result(S->stmt);
PDO_DBG_RETURN(retval ? 0 : 1);
mysql_stmt_free_result(S->stmt);
}
while (mysql_more_results(S->H->server)) {

View file

@ -56,8 +56,6 @@ require __DIR__ . '/mysql_pdo_test.inc';
$db = MySQLPDOTest::factory();
$db->exec('DROP PROCEDURE IF EXISTS p');
?>
--XFAIL--
Works with mysqlnd. It is not supported by libmysql. For libmysql is good enough to see no crash.
--EXPECT--
Emulated...
array(1) {