php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57117 Core dump when using db2_bind_param and stored procedures
Submitted: 2006-06-29 09:40 UTC Modified: 2006-09-22 11:28 UTC
From: ian dot bjorhovde at gmail dot com Assigned:
Status: Closed Package: ibm_db2 (PECL)
PHP Version: 4.3.9 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
17 + 28 = ?
Subscribe to this entry?

 
 [2006-06-29 09:40 UTC] ian dot bjorhovde at gmail dot com
Description:
------------
When using stored procedures and db2_bind_param to bind variables to parameter markers, PHP will core dump.  This is reproducible with:

PHP 4.3.9 (included with RHEL4) as well as current PHP (5.1.2)
and both
ibm_db2 1.2.1 and ibm_db2 1.2.3.


Note, using db2_execute() and passing IN parameters as an array works fine.

Reproduce code:
---------------
Example Stored Procedure:

create procedure test(IN i_tabschema varchar(128), OUT o_cnt smallint)
reads sql data
language sql
no external action
begin
   select count(*)
   into o_cnt
   from syscat.tables
   where tabschema = i_tabschema;

end@



PHP Code to call procedure:


<?php

$dbh = db2_connect('SAMPLE','','');
$sql = "call test(?, ?)";
$sth = db2_prepare($dbh, $sql);

$schema = "SYSCAT";
$count  = 0;

db2_bind_param($sth, 1, "schema");
db2_bind_param($sth, 2, "count");

db2_execute($sth);

print "There are $count tables for schema $schema\n";

db2_close($dbh);


?>


Expected result:
----------------
Should output:  

"There are 100 tables for schema SYSCAT"

Actual result:
--------------
[db2p01@kwaiken ~]$ php x.php
Content-type: text/html
X-Powered-By: PHP/4.3.9

There are 0 tables for schema SYSCAT
Segmentation fault (core dumped).



---
The backtrace isn't too useful, because PHP on my system was not compiled in debug mode, but this bug is easily reproducible.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-07-05 14:41 UTC] kfbombar at us dot ibm dot com
Please try the following changes and let us know if this fixes your issues:

<?php

$dbh = db2_connect('SAMPLE','','');
$sql = "call test(?, ?)";
$sth = db2_prepare($dbh, $sql);

$schema = "SYSCAT";
$count  = 0;

db2_bind_param($sth, 1, "schema", DB2_PARAM_IN);
db2_bind_param($sth, 2, "count", DB2_PARAM_OUT);

db2_execute($sth);

print "There are $count tables for schema $schema\n";

db2_close($dbh);

?>
 [2006-07-05 23:25 UTC] ian dot bjorhovde at gmail dot com
I have tried this, and adding the parameter type (DB2_PARAM_IN or DB2_PARAM_OUT) does not resolve the problem.
 [2006-07-13 14:10 UTC] kfbombar at us dot ibm dot com
We have not been able to reproduce this issue with your sample script.  We have set up the same stored procedure that you have given us and we used the following PHP script:
<?
    $conn = db2_connect('sample', 'db2user', 'db2pass');

    if ($conn) {
        $sql = "call test(?, ?)";
        $sth = db2_prepare($conn, $sql);
        $schema = "SYSCAT";
        $count  = 0;
        db2_bind_param($sth, 1, "schema", DB2_PARAM_IN);
        db2_bind_param($sth, 2, "count", DB2_PARAM_OUT);
        db2_execute($sth);
        print "There are $count tables for schema $schema\n";
        db2_close( $conn );
    } else {
        print "\nnot connected\n";
    }
?>
This script provides us with the following result with no core dumps:
There are 110 tables for schema SYSCAT

Please provide more information or anything else to allow us to view your problem.  Thank you.
 [2006-08-03 10:48 UTC] kfbombar at us dot ibm dot com
We are waiting for your feedback on this issue.  As stated previously, we have not been able to reproduce this issue.  Please inform us if your issue has been found or solved.  If the problem is still occuring, please give us any information possible to try and resolve this issue.  Thank you.
 [2006-09-22 11:28 UTC] kfbombar at us dot ibm dot com
50 days since last feedback.  Closing until further feedback is given.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 21:01:30 2024 UTC