|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2019-06-21 22:06 UTC] dpuglielli at magnitude dot com
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 ) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 12:00:02 2025 UTC |
This looks like a bug to me. Having the former status as fourth element would be okay, but the driver specific error code and message (second and third) need to match, but apparently don't: 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 ) Unfortunately, the test script is no longer available.