summaryrefslogtreecommitdiff
path: root/ext/pdo_mysql/mysql_statement.c
diff options
context:
space:
mode:
authorDharman <tekiela246@gmail.com>2020-12-02 21:24:20 +0000
committerNikita Popov <nikita.ppv@gmail.com>2020-12-04 16:59:47 +0100
commita83cc03c138b8cf27a840bd7cd913eb7050e55ba (patch)
tree981e1ab2afa561c1ced7454ae551f80b865e51f5 /ext/pdo_mysql/mysql_statement.c
parent8588ae72156eeead928a8fe93bb8a5ab293f1e89 (diff)
downloadphp-git-a83cc03c138b8cf27a840bd7cd913eb7050e55ba.tar.gz
Fixed bug #80458
If there is no result set (e.g. for upsert queries), still allow fetching to occur without error, i.e. treat it the same way as an empty result set. This normalizes behavior between native and emulated prepared statements and addresses a regression in PHP 7.4.13.
Diffstat (limited to 'ext/pdo_mysql/mysql_statement.c')
-rw-r--r--ext/pdo_mysql/mysql_statement.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/ext/pdo_mysql/mysql_statement.c b/ext/pdo_mysql/mysql_statement.c
index dbac374171..58711459ae 100644
--- a/ext/pdo_mysql/mysql_statement.c
+++ b/ext/pdo_mysql/mysql_statement.c
@@ -621,7 +621,12 @@ static int pdo_mysql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_da
static int pdo_mysql_stmt_fetch(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori, zend_long offset) /* {{{ */
{
pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data;
-#if PDO_USE_MYSQLND
+
+ if (!S->result) {
+ PDO_DBG_RETURN(0);
+ }
+
+#ifdef PDO_USE_MYSQLND
zend_bool fetched_anything;
PDO_DBG_ENTER("pdo_mysql_stmt_fetch");
@@ -634,6 +639,10 @@ static int pdo_mysql_stmt_fetch(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori
PDO_DBG_RETURN(1);
}
+
+ if (!S->stmt && S->current_data) {
+ mnd_free(S->current_data);
+ }
#else
int ret;
@@ -657,16 +666,6 @@ static int pdo_mysql_stmt_fetch(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori
}
#endif /* PDO_USE_MYSQLND */
- if (!S->result) {
- strcpy(stmt->error_code, "HY000");
- PDO_DBG_RETURN(0);
- }
-#if PDO_USE_MYSQLND
- if (!S->stmt && S->current_data) {
- mnd_free(S->current_data);
- }
-#endif /* PDO_USE_MYSQLND */
-
if ((S->current_data = mysql_fetch_row(S->result)) == NULL) {
if (!S->H->buffered && mysql_errno(S->H->server)) {
pdo_mysql_error_stmt(stmt);