Bug #80472 [NEW]: fetchAll after execute now failing on DELETE's

From: Date: Wed, 02 Dec 2020 15:51:09 +0000
Subject: Bug #80472 [NEW]: fetchAll after execute now failing on DELETE's
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-230798@lists.php.net to get a copy of this message
From: dougnelson at silktide dot com Operating system: Linux (Ubuntu + Alpine tested) PHP version: 7.4.13 Package: PDO MySQL Bug Type: Bug Bug description:fetchAll after execute now failing on DELETE's Description: ------------ A caveat that the code being here isn't ideal, but this has caused a BC and some unexpected prod problems. If you run a delete query using PDO-MySQL in the format: $statement->prepare($query) $statement->execute() $statement->fetchAll() You previously would not encounter any issues, this exists in some generalised "run this sql" code. As of PHP 7.4.13, this will now throw an error "General error: 2014 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" This also fails on PHP 8, but as that lies over a BC boundary, that seems reasonable. Test script: --------------- script.php <?php $pdo = new \PDO("mysql:host=my-hostname;dbname=testcase", "username", "password, [ PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, ]); $pdo->exec("DROP TABLE IF EXISTS users"); $pdo->exec("CREATE TABLE IF NOT EXISTS users(id INTEGER PRIMARY KEY,name TEXT)"); $sql = "DELETE FROM users"; $statement = $pdo->prepare($sql); print_r($statement->execute()); print_r($statement->fetchAll()); run.sh: #!/usr/bin/env sh docker-php-source extract docker-php-ext-install pdo_mysql php script.php command to isolate it as 12 vs 13: docker run -it -v "$PWD":/usr/src/myapp -w /usr/src/myapp php:7.4.12-cli-alpine ./run.sh docker run -it -v "$PWD":/usr/src/myapp -w /usr/src/myapp php:7.4.13-cli-alpine ./run.sh Expected result: ---------------- I'd expect it to not throw an error. Actual result: -------------- It throws an error -- Edit bug report at https://bugs.php.net/bug.php?id=80472&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=80472&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=80472&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=80472&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=80472&r=needscript Try newer version: https://bugs.php.net/fix.php?id=80472&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=80472&r=support Expected behavior: https://bugs.php.net/fix.php?id=80472&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=80472&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=80472&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=80472&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=80472&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=80472&r=dst IIS Stability: https://bugs.php.net/fix.php?id=80472&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=80472&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=80472&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=80472&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=80472&r=mysqlcfg

« previous php.bugs (#230798) next »