Skip to content

Commit

Permalink
Handle errors during PDO row fetch
Browse files Browse the repository at this point in the history
The EOF flag also gets set on error, so we always end up ignoring
errors here.

However, we should only check errors for unbuffered results. For
buffered results, this function is guaranteed not to error, and
querying the errno may return an unrelated error.
  • Loading branch information
nikic committed Oct 29, 2020
1 parent dd97cb1 commit 0044a81
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions ext/pdo_mysql/mysql_statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,11 +668,7 @@ static int pdo_mysql_stmt_fetch(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori
#endif /* PDO_USE_MYSQLND */

if ((S->current_data = mysql_fetch_row(S->result)) == NULL) {
#if PDO_USE_MYSQLND
if (S->result->unbuf && !S->result->unbuf->eof_reached && mysql_errno(S->H->server)) {
#else
if (!S->result->eof && mysql_errno(S->H->server)) {
#endif
if (!S->H->buffered && mysql_errno(S->H->server)) {
pdo_mysql_error_stmt(stmt);
}
PDO_DBG_RETURN(0);
Expand Down

0 comments on commit 0044a81

Please sign in to comment.