php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56792 NULL values kill column function calls
Submitted: 2006-01-23 12:24 UTC Modified: 2006-01-23 13:57 UTC
From: larry dot menard at rogers dot com Assigned:
Status: Closed Package: ibm_db2 (PECL)
PHP Version: 5.1.1 OS: Windows XP, SP2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: larry dot menard at rogers dot com
New email:
PHP Version: OS:

 

 [2006-01-23 12:24 UTC] larry dot menard at rogers dot com
Description:
------------
Note: DB2 is version 8 FP10.

Calling a column function like COUNT() using 'ibm_db2' fails if there are NULLs in the column.  See the repro code below.

It works fine with ODBC.

This is a simplified repro scenario from a large application I'm porting.  In that application, db2_stmt_error() and db2_stmt_errormsg() return more info, but for some reason they don't seem to be working in my simple script.

Reproduce code:
---------------
DDL:

create table mytable (col1 int);
insert into mytable values (1);
insert into mytable values (2);
insert into mytable values (NULL);
insert into mytable values (4);

PHP app:

$statement = "SELECT count(col1) FROM mytable";
$result = db2_exec($dbconn, $statement);
if (db2_stmt_error())
{
  printf("%s\n", db2_stmt_errormsg());
}
while ($row = db2_fetch_array($result))
{
  printf ("\"%s\"\n", $row[0]);
}


Expected result:
----------------
"3"

Actual result:
--------------
PHP Warning:  db2_fetch_array(): Fetch Failure in C:\MyServer\testDb2Api.php on line 85

Warning: db2_fetch_array(): Fetch Failure in C:\MyServer\testDb2Api.php on line 85

In my large app, db2_stmt_errormsg() returns:

[IBM][CLI Driver][DB2/NT] SQLSTATE 01003: Null values were eliminated from the argument of a column function.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-23 13:57 UTC] denials at gmail dot com
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.

CVS HEAD contains a fix that considers SQL_SUCCESS_WITH_INFO as a success in _php_db2_bind_fetch_helper after fetching the row -- this bug came up because SQLFetch() returns SQLSTATE 01003, warning that the column function contains a NULL value. 

Thanks for reporting this bug, Larry, and helping to make PHP and the ibm_db2 extension better.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 17:01:31 2025 UTC