From 18517e7a635e68969ed926f159bb66fb89d5cd3b Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 9 Dec 2020 11:13:48 +0100 Subject: [PATCH] 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. --- ext/mysqlnd/mysqlnd_ps.c | 4 ---- ext/pdo_mysql/mysql_statement.c | 4 +--- ext/pdo_mysql/tests/bug_pecl_7976.phpt | 2 -- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/ext/mysqlnd/mysqlnd_ps.c b/ext/mysqlnd/mysqlnd_ps.c index b97bccbe60..d2ec46e8da 100644 --- a/ext/mysqlnd/mysqlnd_ps.c +++ b/ext/mysqlnd/mysqlnd_ps.c @@ -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); } /* }}} */ diff --git a/ext/pdo_mysql/mysql_statement.c b/ext/pdo_mysql/mysql_statement.c index 9d544b23c2..e82cc6ddcc 100644 --- a/ext/pdo_mysql/mysql_statement.c +++ b/ext/pdo_mysql/mysql_statement.c @@ -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)) { diff --git a/ext/pdo_mysql/tests/bug_pecl_7976.phpt b/ext/pdo_mysql/tests/bug_pecl_7976.phpt index 13d4d1b519..af34f02331 100644 --- a/ext/pdo_mysql/tests/bug_pecl_7976.phpt +++ b/ext/pdo_mysql/tests/bug_pecl_7976.phpt @@ -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) { -- 2.40.0