summaryrefslogtreecommitdiff
path: root/ext/pdo_mysql/mysql_driver.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-12-10 11:46:29 +0100
committerNikita Popov <nikita.ppv@gmail.com>2020-12-10 11:46:29 +0100
commit288581fadef58363dac4fc72ded0fae830bf603c (patch)
tree22652c599af378afafcac907d4b140a9faa92cbf /ext/pdo_mysql/mysql_driver.c
parentd63aedd173fbb8b3399cff4b991f8a343dd0f331 (diff)
downloadphp-git-288581fadef58363dac4fc72ded0fae830bf603c.tar.gz
Fixed bug #79872 by improving error message
The actual behavior here is correct, but the previous error message was misleading, as neither fetchAll() nor buffered queries would help in this situation. Instead it is necessary to consume all rowsets, which can be done by either unsetting the statement or calling closeCursor().
Diffstat (limited to 'ext/pdo_mysql/mysql_driver.c')
-rw-r--r--ext/pdo_mysql/mysql_driver.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/ext/pdo_mysql/mysql_driver.c b/ext/pdo_mysql/mysql_driver.c
index 764c453438..90bc7792d5 100644
--- a/ext/pdo_mysql/mysql_driver.c
+++ b/ext/pdo_mysql/mysql_driver.c
@@ -73,12 +73,20 @@ int _pdo_mysql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *file, int lin
if (einfo->errcode) {
if (einfo->errcode == 2014) {
- einfo->errmsg = pestrdup(
- "Cannot execute queries while other unbuffered queries are active. "
- "Consider using PDOStatement::fetchAll(). Alternatively, if your code "
- "is only ever going to run against mysql, you may enable query "
- "buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.",
- dbh->is_persistent);
+ if (mysql_more_results(H->server)) {
+ einfo->errmsg = pestrdup(
+ "Cannot execute queries while there are pending result sets. "
+ "Consider unsetting the previous PDOStatement or calling "
+ "PDOStatement::closeCursor()",
+ dbh->is_persistent);
+ } else {
+ einfo->errmsg = pestrdup(
+ "Cannot execute queries while other unbuffered queries are active. "
+ "Consider using PDOStatement::fetchAll(). Alternatively, if your code "
+ "is only ever going to run against mysql, you may enable query "
+ "buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.",
+ dbh->is_persistent);
+ }
} else if (einfo->errcode == 2057) {
einfo->errmsg = pestrdup(
"A stored procedure returning result sets of different size was called. "