mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
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.
This commit is contained in:
parent
8588ae7215
commit
a83cc03c13
3 changed files with 200 additions and 11 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue