|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
[2020-04-22 07:04 UTC] sjon@php.net
-Status: Open
+Status: Verified
-PHP Version: 7.2.12
+PHP Version: 7.4.5
[2020-04-22 07:04 UTC] sjon@php.net
[2020-09-01 11:19 UTC] cmb@php.net
[2020-10-28 15:09 UTC] nikic@php.net
-Status: Verified
+Status: Closed
-Assigned To:
+Assigned To: nikic
[2020-10-28 15:09 UTC] nikic@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 18:00:02 2025 UTC |
Description: ------------ When using PDO MySQL to select rows for update with PDO::ATTR_EMULATE_PREPARES set to false and PDO::ATTR_ERRMODE set to PDO::ERRMODE_EXCEPTION no exception is thrown when the rows are already locked and a timeout occurs. Note: The exception is thrown when PDO::ATTR_EMULATE_PREPARES is not set/set to true or when a parameter is used in the select query. Instructions on reproducing this: Open mysql on cli, and perform queries: CREATE DATABASE testdb; USE testdb; CREATE TABLE test (`id` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, `value` VARCHAR(30) NOT NULL); INSERT INTO `test` (`value`) VALUES ('test'); # Before starting the test script open a transaction and lock the table: BEGIN; SELECT * FROM `test` FOR UPDATE; # Now run the script Test script: --------------- <?php $pdo = new PDO('mysql:dbname=testdb;host=localhost', 'username', 'password'); $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $pdo->beginTransaction(); $statement = $pdo->prepare('SELECT * FROM `test` FOR UPDATE'); $statement->execute(); var_dump( $statement->fetchAll(), $statement->errorCode() ); $pdo->commit(); Expected result: ---------------- Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction in test-pdo.php:14 Stack trace: #0 test-pdo.php(14): PDOStatement->execute() #1 {main} thrown in test-pdo.php on line 14 Actual result: -------------- array(0) { } string(5) "00000"