Skip to content

Commit d6b4b82

Browse files
committed
PDO MySQL: Use stmt_next_result with libmysqlclient as well
libmysqlclient added this function in version 5.5, which happens to be the minimum we support. If we have a prepared statement, we should use it on both mysqlnd and libmysqlclient, even if the handling afterwards is different. This fixes error handling with native prepared statements.
1 parent 4e51059 commit d6b4b82

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

ext/pdo_mysql/mysql_statement.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -341,30 +341,29 @@ static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt) /* {{{ */
341341
PDO_DBG_INF_FMT("stmt=%p", S->stmt);
342342

343343
/* ensure that we free any previous unfetched results */
344-
if (S->stmt) {
345-
mysql_stmt_free_result(S->stmt);
346-
}
347344
pdo_mysql_free_result(S);
348345

349-
#ifdef PDO_USE_MYSQLND
350346
if (S->stmt) {
351-
if (mysqlnd_stmt_next_result(S->stmt)) {
347+
mysql_stmt_free_result(S->stmt);
348+
if (mysql_stmt_next_result(S->stmt)) {
349+
pdo_mysql_error_stmt(stmt);
350+
S->done = 1;
351+
PDO_DBG_RETURN(0);
352+
}
353+
} else {
354+
if (mysql_next_result(H->server)) {
352355
pdo_mysql_error_stmt(stmt);
353356
S->done = 1;
354357
PDO_DBG_RETURN(0);
355358
}
359+
}
356360

361+
#ifdef PDO_USE_MYSQLND
362+
if (S->stmt) {
357363
PDO_DBG_RETURN(pdo_mysql_stmt_after_execute_prepared(stmt));
358364
}
359365
#endif
360-
361-
if (mysql_next_result(H->server)) {
362-
pdo_mysql_error_stmt(stmt);
363-
S->done = 1;
364-
PDO_DBG_RETURN(0);
365-
} else {
366-
PDO_DBG_RETURN(pdo_mysql_fill_stmt_from_result(stmt));
367-
}
366+
PDO_DBG_RETURN(pdo_mysql_fill_stmt_from_result(stmt));
368367
}
369368
/* }}} */
370369

0 commit comments

Comments
 (0)