Req #27315 [Opn->Csd]: ODBC Not returning all error messages
| From: | ilutov@php.net | Date: | Thu, 07 Apr 2022 19:19:33 +0000 |
| Subject: | Req #27315 [Opn->Csd]: ODBC Not returning all error messages | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-240771@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=27315&edit=1
ID: 27315
Updated by: ilutov@php.net
Reported by: bergy at us dot ibm dot com
Summary: ODBC Not returning all error messages
-Status: Open
+Status: Closed
Type: Feature/Change Request
Package: ODBC related
Operating System: Red Hat 8.0
PHP Version: 4.3.4
-Assigned To:
+Assigned To: ilutov
Block user comment: N
Private report: N
New Comment:
Lots of time has passed since this issue was created. If this is still relevant, please create an
issue on GitHub.
Previous Comments:
------------------------------------------------------------------------
[2020-04-18 03:51:57] sample at email dot tst
The following patch has been added/updated:
Patch Name: xqxmjbea
Revision: 1587181917
URL: https://bugs.php.net/patch-display.php?bug=27315&patch=xqxmjbea&revision=1587181917
------------------------------------------------------------------------
[2004-02-18 16:08:33] bergy at us dot ibm dot com
Description:
------------
When accessing a DB2 database (either DB2 version 7 or 8) via ODBC (i.e., PHP compiled without the
--with-db2 flag), every odbc_exec call that generates an error, returns the error message:
function.odbc-exec.html</a>]: SQL error: [unixODBC][IBM][CLI Driver] CLI0005W Option value
changed. SQLSTATE=01S02, SQL state 01S02 in SQLExecDirect in ...
Notice that the message (returned by odbc_errormsg), and the corresponding error number (returned by
odbc_error) point to the warning, even though an error occured. We have confirmed that an error has
occured, but it is not due to the option value changing.
This appears to be a duplicate of bug number 15141, which is from 21 Jan 2002 and was closed
"No Feedback".
I have examined the ODBC source code, and see that function odbc_sql_error has comments in it that
indicated that it was orgionally designed to retrieve all the errors assoicated with an ODBC call.
The loop is commented out, and the comments indicate that some ODBC device drivers would cause an
endless loop. These comments appear in the latest snapshot.
Since I can't control the options that are generating the "option value changed"
warning, I'd really like a solution where I can see the real errors. I'm not familiar
enough with the PHP and ODBC soure to be competent in suggesting a solution, but it would appear to
me that returning multiple error messages while guarding against an endless loop would be
appropriate. Perhaps a simple counter to return no more than 5 messages (which I would think would
be enough, given that no one else seems to notice that it won't return more than 1) would work.
Reproduce code:
---------------
<?php
if ( $cid = odbc_connect("coredev", "xxxxx", "xxxxx") ) {
if ( $rid = @odbc_exec($cid, "select count(*) from c_sensor") ) {
if ( odbc_fetch_into($rid, $result) ) {
echo "No Error Occured, result: ", var_dump($result), "\n";
} else {
echo "Error on odbc_fetch_into:\n";
echo " ", odbc_errormsg($cid), "\n";
}
} else {
echo "Error on odbc_exec:\n";
echo " ", odbc_errormsg($cid), "\n";
}
} else {
echo "Error trying to connect to database\n";
}
?>
Expected result:
----------------
In the sample code above, the sql statement is in error, because the table referenced doesn't
exist. The output should be:
Error on odbc_exec:
[unixODBC][IBM][CLI Driver] SQL0204N "BERGY.C_SENSOR" is an undefined name.
SQLSTATE=42704
Actual result:
--------------
Error on odbc_exec:
[unixODBC][IBM][CLI Driver] CLI0005W Option value changed. SQLSTATE=01S02
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=27315&edit=1