Bug #78152 [NEW]: PDO::exec() - Bad error handling with multiple commands
From: szijarto dot tamas dot developer at gmail dot com
Operating system: Linux
PHP version: 7.3Git-2019-06-12 (Git)
Package: PDO MySQL
Bug Type: Bug
Bug description:PDO::exec() - Bad error handling with multiple commands
Description:
------------
The PDO::exec() does not handle the error if the first command is
successfully completed.
Environment:
=====================================================================
PHP : ~/php-install/bin/php
PHP_SAPI : cli
PHP_VERSION : 7.3.8-dev
ZEND_VERSION: 3.3.8-dev
PHP_OS : Linux - Linux ... 4.18.0-21-generic #22~18.04.1-Ubuntu SMP
Thu May 16 15:07:19 UTC 2019 x86_64
INI actual : ~/php-install/lib/php.ini
More .INIs :
Test script:
---------------
/** @var PDO $db */
$res = $db->exec("INSERT INTO test(id, label) VALUES (41, 'x');
INSERT INTO test_bad(id, label) VALUES (42, 'y')");
if( $res === false ){
print 'OK';
}
else{
var_dump($res);
print 'Failed, because the command ran!';
}
The full script is available here:
https://github.com/szicsu/php-src/blob/PHP-7.3/ext/pdo_mysql/tests/pdo_mysql_exec_multi_command.phpt
The error message comes back from mysql but is not handled:
sendto(3, "_\0\0\0\3INSERT INTO test(id, label) VALUES (41, 'x'); INSERT
INTO test_bad(id, label) VALUES (42, 'y')", 99, MSG_DONTWAIT, NULL, 0) =
99
poll([{fd=3, events=POLLIN|POLLERR|POLLHUP}], 1, 86400000) = 1 ([{fd=3,
revents=POLLIN}])
recvfrom(3, "\7\0\0\1\0\1\0\n\0\0\0", 32768, MSG_DONTWAIT, NULL, NULL) =
11
poll([{fd=3, events=POLLIN|POLLERR|POLLHUP}], 1, 86400000) = 1 ([{fd=3,
revents=POLLIN}])
recvfrom(3, "/\0\0\2\377z\4#42S02Table 'php_src.test_bad' doesn't
exist", 32768, MSG_DONTWAIT, NULL, NULL) = 51
--
Edit bug report at https://bugs.php.net/bug.php?id=78152&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=78152&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=78152&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=78152&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=78152&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78152&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78152&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78152&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78152&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78152&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78152&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78152&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78152&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78152&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=78152&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=78152&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78152&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78152&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78152&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78152&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78152&r=mysqlcfg
Thread (3 messages)
- szijarto dot tamas dot developer at gmail dot com