Bug #78196 [NEW]: PDOStatement::errorInfo() gives incorrect output
| From: | dpuglielli at magnitude dot com | Date: | Fri, 21 Jun 2019 22:06:53 +0000 |
| Subject: | Bug #78196 [NEW]: PDOStatement::errorInfo() gives incorrect output | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-221447@lists.php.net to get a copy of this message | ||
From: dpuglielli at magnitude dot com
Operating system: Windows 10
PHP version: 7.3.6
Package: PDO ODBC
Bug Type: Bug
Bug description:PDOStatement::errorInfo() gives incorrect output
Description:
------------
Calling PDOStatement::errorInfo with the results of a batched query and
a non-forward cursor yields a four element array, with the fourth
element as another SQLSTATE. This is not consistent with the
documentation, which states that there are three fields in this array
(according to https://www.php.net/manual/en/pdostatement.errorinfo.php).
Moreover, the first element is an incorrect SQLSTATE.
The problem appears to lie in line 49 of ext/pdo_odbc/odbc_driver.c in
pdo_odbc_fetch_error_func(), where the three elements of the error array
are populated. This occurs after an error code has already been added in
line 1678 of ext/pdo/pdo_stmt.c, producing four elements instead of
three.
Test script:
---------------
https://github.com/david-puglielli/msphpsql/blob/pdo-errorinfo-bug/test/functional/pdo_sqlsrv/pdo_errorinfo_bug.phpt
Expected result:
----------------
The output of errorInfo() should have three elements. The first element
should correctly correspond to the diagnostic message in the third
element, like so:
Array
(
[0] => 01S02
[1] => 0
[2] => [Microsoft][ODBC Driver 17 for SQL Server]Cursor type changed
(SQLExecute[0] at ext\pdo_odbc\odbc_stmt.c:254)
)
Actual result:
--------------
The output of the provided test script is as follows:
Database error info:
Array
(
[0] => 00000
[1] =>
[2] =>
)
Statement error info:
Array
(
[0] => 01S02
[1] => 0
[2] => [Microsoft][ODBC Driver 17 for SQL Server]Cursor type changed
(SQLExecute[0] at ext\pdo_odbc\odbc_stmt.c:254)
[3] => 01S02
)
Array
(
[0] => 00000
[1] => 0
[2] => [Microsoft][ODBC Driver 17 for SQL Server]Cursor type changed
(SQLExecute[0] at ext\pdo_odbc\odbc_stmt.c:254)
[3] => 01S02
)
Array
(
[0] => 00000
[1] => 0
[2] => [Microsoft][ODBC Driver 17 for SQL Server]Cursor type changed
(SQLExecute[0] at ext\pdo_odbc\odbc_stmt.c:254)
[3] => 01S02
)
--
Edit bug report at https://bugs.php.net/bug.php?id=78196&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=78196&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=78196&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=78196&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=78196&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78196&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78196&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78196&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78196&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78196&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78196&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78196&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78196&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78196&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=78196&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=78196&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78196&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78196&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78196&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78196&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78196&r=mysqlcfg