From:             bergy at us dot ibm dot com
Operating system: Red Hat 8.0
PHP version:      4.3.4
PHP Bug Type:     ODBC related
Bug description:  ODBC Not returning all error messages

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 bug report at http://bugs.php.net/?id=27315&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=27315&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=27315&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=27315&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=27315&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=27315&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=27315&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=27315&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=27315&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=27315&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=27315&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=27315&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=27315&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27315&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=27315&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=27315&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=27315&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27315&r=float

Reply via email to