Skip to content

Commit

Permalink
Fix stmt_free_result implementation and usage
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nikic committed Dec 9, 2020
1 parent 9c0712d commit 18517e7
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 9 deletions.
4 changes: 0 additions & 4 deletions ext/mysqlnd/mysqlnd_ps.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
/* }}} */
Expand Down
4 changes: 1 addition & 3 deletions ext/pdo_mysql/mysql_statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 0 additions & 2 deletions ext/pdo_mysql/tests/bug_pecl_7976.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 18517e7

Please sign in to comment.