]> granicus.if.org Git - php/commitdiff
Handle errors during PDO row fetch
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 29 Oct 2020 13:07:08 +0000 (14:07 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 29 Oct 2020 13:17:29 +0000 (14:17 +0100)
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.

ext/pdo_mysql/mysql_statement.c

index f3811abfe60ad5f37361a5238c750762e955cc57..dbac374171078697f7341a59f13170a57666a73d 100644 (file)
@@ -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);