|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40313 oci_close() has no effect when in a transaction
Submitted: 2007-02-02 02:29 UTC Modified: 2008-01-09 20:31 UTC
From: christopher dot jones at oracle dot com Assigned: tony2001 (profile)
Status: Wont fix Package: OCI8 related
PHP Version: 5.2.1RC4 OS: n/a
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 — but make sure to vote on the bug!
Your email address:
Solve the problem:
19 + 7 = ?
Subscribe to this entry?

 [2007-02-02 02:29 UTC] christopher dot jones at oracle dot com
The session management differs in some cases when there is an uncommited transaction.

Run the test case with and without the parse/execute lines commented.  When the lines are commented out an explicit oci_close() or the end of f1() causes the connection to be closed.  With the lines active the sessions remain open and the transactions are not rolled back.

A third error case is if the sample script is changed to use oci_new_connect(). Confusingly the explict close has no effect but the end-of-scope will rollback and close the connection.

This may be a in implementation quirk of reference counting but it is a user level bug.  Oci_close() should always close when oci8.oci_old_close_semantics has its default value.  The cleanup at end-of-scope should be consistent regardless of the user transaction state.

Reproduce code:

// Create this table first: create table cj1 (a number);

$v = ini_get('oci8.old_oci_close_semantics');
echo "oci8.old_oci_close_semantics is $v\n";


echo "Test 1\n";

$c1 = oci_new_connect("hr", "hr", "localhost/XE");

echo "Do statement\n";
$s1 = oci_parse($c1, "insert into cj1 values(1)");
var_dump(oci_execute($s1, OCI_DEFAULT));

echo "Before close: transaction should rollback and connection should be closed\n";


echo "After close\n";

echo "Test 2\n";

function f1()
    echo "In f1()\n";
    $c2 = oci_new_connect("hr", "hr", "localhost/XE");

    if (!$c2) {
        $m = ocierror();
        echo $m['message'];
    else {
        echo "Connection succeeded\n";

    echo "Do statement\n";
    $s2 = oci_parse($c2, "insert into cj1 values(1)"); 
    var_dump(oci_execute($s2, OCI_DEFAULT));

    echo "Before end of scope\n";

echo "after f1() call - end of scope\n";

echo "End of script\n";



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-12 17:45 UTC]
I think the current behavior is correct and I personally do not see any reasons to change it at the moment.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Fri Dec 09 19:05:54 2022 UTC