From: the_dude61 at hotmail dot com
Operating system: openSUSE 10.2
PHP version: 5.2.5
PHP Bug Type: DBX related
Bug description: ibm_db2 / db2_execute failure
Description:
------------
Problem relates to ibm_db2-1.6.5 and DB2 v9.5.0.0 LINUXAMD6495.
I called a stored procedure with a blob parameter as follows:
$stmt = db2_prepare($conn, $sqlcmd);
$par_inid = 0;
$par_indata = "00000000001111111111";
$par_outrc = 0;
db2_bind_param($stmt, 1, "par_inid", DB2_PARAM_IN);
db2_bind_param($stmt, 2, "par_indata", DB2_PARAM_IN,DB2_BINARY);
db2_bind_param($stmt, 3, "par_outrc", DB2_PARAM_OUT);
if (db2_execute($stmt) )
<ok>
else
<error>
The DB2 stored procedure raises an error with [IBM][CLI
Driver][DB2/LINUXX8664] SQL0438N Application raised error with diagnostic
text: "Id not found". SQLSTATE=77100.
But the db2_execute() function returns TRUE as if it was successfull.
I added some missing error handling code in ibm_db2.c - db2_execute() to
get the correct behaviour (see code below). The while loop did not handle a
SQL_ERROR of SQLParamData() as it occurs in my case. My case was that the
SQLExecute() requested one more data packet (SQL_NEED_MORE). The next call
to SQLParamData() within the while-loop returned a sql error raised by the
application because of an invalid id. This error was not covered and
db2_execute() returned with TRUE (=successful).
Modified code (starts at line# 3277):
if ( rc == SQL_NEED_DATA ) {
while ( (rc = SQLParamData((SQLHSTMT)stmt_res->hstmt, (SQLPOINTER
*)&valuePtr)) == SQL_NEED_DATA ) {
/* passing data value for a parameter */
rc = SQLPutData((SQLHSTMT)stmt_res->hstmt,
(SQLPOINTER)(((zvalue_value*)valuePtr)->str.val),
((zvalue_value*)valuePtr)->str.len);
if ( rc == SQL_ERROR ) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Sending
data failed");
_php_db2_check_sql_errors(stmt_res->hstmt,
SQL_HANDLE_STMT, rc, 1,
NULL, -1, 1 TSRMLS_CC);
RETVAL_FALSE;
}
}
if ( rc == SQL_ERROR ) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Statement Execute
Failed");
_php_db2_check_sql_errors(stmt_res->hstmt, SQL_HANDLE_STMT, rc,
1, NULL,
-1, 1 TSRMLS_CC);
RETVAL_FALSE;
}
}
Hope that this is not a "huge text" ;-)
--
Edit bug report at http://bugs.php.net/?id=44203&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=44203&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=44203&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=44203&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=44203&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=44203&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=44203&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=44203&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=44203&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=44203&r=support
Expected behavior: http://bugs.php.net/fix.php?id=44203&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=44203&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=44203&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=44203&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44203&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=44203&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=44203&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=44203&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=44203&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=44203&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=44203&r=mysqlcfg