From:             christopher dot jones at oracle dot com
Operating system: n/a
PHP version:      5.2.5
PHP Bug Type:     OCI8 related
Bug description:  Cursor leak with REF CURSORS

Description:
------------
When more than one REF CURSOR is returned in a query, ORA-1000 occurs
after some iterations.
Haneef investigated and says:
  "The refcount of the parent statement is incremented by the ref
  cursors in php_oci_define_callback and is not decremented. The
  incrementing is necessary as the parent statement needs to be around
  while fetching the data from the ref cursor. The fix is to decrement
  the refcount of the parent statement before ref cursor is freed."
The fix is being tested.

Reproduce code:
---------------
<?php
$c = oci_connect('hr', 'hrpwd', '//localhost/XE');
for ($x = 0; $x < 400; $x++) {
// more than one CURSOR column causes the problem.
    $sql = "select cursor(select $x from dual) a,
                   cursor(select $x from dual) b
                   from dual";
    
    $sth = oci_parse($c, $sql);
    $r = oci_execute($sth);
    if (!$r) {
        echo "Exiting $x\n"; exit;
    }
    while ($row = oci_fetch_array($sth, OCI_ASSOC)) {
        if ($row) {
            foreach ($row as $k => $v) {
                if (is_resource($v) &&
                    get_resource_type($v) == "oci8 statement") {
                    oci_execute($v);
                    oci_fetch_all($v, $row[$k], 0, -1, OCI_ASSOC);
                    oci_free_statement($v);
                }
            }
        }
        echo $x, "\n";
    }
    oci_free_statement($sth);
}
print "Completed $x\n";
oci_close($c);
?>


Expected result:
----------------
...
398
399
Completed 400

Actual result:
--------------
...
295
296
PHP Warning:  oci_execute(): ORA-00604: error occurred at recursive SQL
level 1
ORA-01000: maximum open cursors exceeded in test.php on line 10
Exiting 297

-- 
Edit bug report at http://bugs.php.net/?id=44206&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=44206&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=44206&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=44206&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=44206&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=44206&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=44206&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=44206&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=44206&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=44206&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=44206&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=44206&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=44206&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=44206&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=44206&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=44206&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=44206&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=44206&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=44206&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=44206&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=44206&r=mysqlcfg

Reply via email to