ID: 43492 User updated by: michael dot virnstein at brodos dot de -Summary: cursor not closed when selecting more than one cursor Reported By: michael dot virnstein at brodos dot de Status: Open Bug Type: OCI8 related Operating System: Linux PHP Version: 5.2.5 New Comment:
edit summary Previous Comments: ------------------------------------------------------------------------ [2007-12-04 07:47:24] michael dot virnstein at brodos dot de Description: ------------ As requested in Bug #42496 (http://bugs.php.net/bug.php?id=42496), here's a separate bug report for the cursor issue: If you use a query with more than one cursor as result column, the statement won't get closed correctly. You have to call oci_free_statement() for as many times as there are result-cursors to get the statement closed correctly. I tried the fix for LOBs as reported in Bug #42496 for SQLT_RSET, but that didn't work really well. There are two problems: 1. If you use the reproduce code below with the fix (removing "zend_list_addref(outcol->statement->id);" from SQLT_RSET in php_oci_define_callback function() [oci8_statement.c]), you'll get an "ORA-01001: invalid cursor" when you try to fetch from the returned cursor. It seems that the statement ($stmt) is closed when leaving the function. 2. If you use the reproduce code below without the fix above, you'll get an "ORA-01000: maximum open cursors exceeded" when you hit you're "open_cursors" db-setting. The statement ($stmt) never gets closed and leaves a dangling cursor. I don't know if that can be implemented easily, but the best thing would be, that a statement gets closed if it is already out of scope and therefore not accessible from the php-code anymore and all nested cursors got closed already. Reproduce code: --------------- <?php $conn = ocilogon('user', 'pass', 'db'); function fetch($conn, $id) { $result = null; $stmt = ociparse($conn, 'select cursor(select * from dual) c from dual'); ociexecute($stmt, OCI_DEFAULT); ocifetchinto($stmt, $result, OCI_ASSOC); ociexecute($result['C'], OCI_DEFAULT); return $result['C']; } for ($id = 1; $id <= 300; $id++) { $cur = fetch($conn, $id); ocifetchinto($cur, $row, OCI_ASSOC); ocifreestatement($cur); } ?> Expected result: ---------------- Neither an "ORA-01001: invalid cursor" nor an "ORA-01000: maximum open cursors exceeded" Actual result: -------------- Depends on the fix. Either "ORA-01001: invalid cursor" or "ORA-01000: maximum open cursors exceeded" ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43492&edit=1