|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74401 PDO trigger warning already set throw exception
Submitted: 2017-04-10 09:39 UTC Modified: 2020-10-28 14:40 UTC
Avg. Score:4.0 ± 1.0
Reproduced:8 of 8 (100.0%)
Same Version:4 (50.0%)
Same OS:1 (12.5%)
From: lusc at jiedaibao dot com Assigned: nikic (profile)
Status: Closed Package: PDO MySQL
PHP Version: 7.0.17 OS: Centos6.x
Private report: No CVE-ID: None
 [2017-04-10 09:39 UTC] lusc at jiedaibao dot com
PDOStatement::execute trigger an error when lost connection. I have already set 
$this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

bug an Warning error is trigger , like:
Warning: PDOStatement::execute: MySQL server has gone away in ...

Expected result:
just throw exception

Actual result:
warning and exception all trigger


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-04-10 09:52 UTC]
Please can you provide a simple test script that shows this.
 [2017-04-10 09:56 UTC]
-Status: Open +Status: Feedback
 [2017-04-10 09:56 UTC]
Forgot to update the status to feedback. Also, the reason I'm asking for an example is that the code for generating warning or exceptions looks really quite unlikely to do both.
 [2017-04-11 15:04 UTC] lusc at jiedaibao dot com
-Status: Feedback +Status: Open
 [2017-04-11 15:04 UTC] lusc at jiedaibao dot com
ini_set('display_errors', 'on');
try {
    $pdo = new PDO('mysql:dbname=qiye;host=;charset=utf8', 'myroot', 'Hsql1234');

    $stmt1 = $pdo->prepare('SELECT * FROM auth limit 1');

    sleep('30'); // stop the mysql server at this time

    $stmt1 = $pdo->prepare('SELECT * FROM jdb_company_info limit 1');
} catch (Throwable $e) {


array(0) {
Warning: PDOStatement::execute(): MySQL server has gone away in /mnt/g/workspace/workspace/qiye/tests/web/test.php on line 21

Warning: PDOStatement::execute(): Error reading result set's header in /mnt/g/workspace/workspace/qiye/tests/web/test.php on line 21
string(240) "PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away in /mnt/g/workspace/workspace/qiye/tests/web/test.php:21
Stack trace:
#0 /mnt/g/workspace/workspace/qiye/tests/web/test.php(21): PDOStatement->execute()
#1 {main}"
 [2017-04-12 06:45 UTC] lusc at jiedaibao dot com , same problem.
 [2017-04-13 02:50 UTC] lusc at jiedaibao dot com
mysqlnd_result.c line 429
php_error_docref(NULL, E_WARNING, "Error reading result set's header");

line 298 and line 310
php_error_docref(NULL, E_WARNING, "%s", mysqlnd_server_gone);
 [2019-01-15 17:43 UTC] dws dot vad at gmail dot com
7.3.1 this issue actual
 [2020-10-28 14:40 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2020-10-28 14:40 UTC]
This should be fixed since PHP 7.4, by
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Oct 17 21:03:32 2021 UTC