php.net |  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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: christopher dot jones at oracle dot com
New email:
PHP Version: OS:

 

 [2007-02-02 02:29 UTC] christopher dot jones at oracle dot com
Description:
------------
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:
---------------
<?php

// 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";

ociinternaldebug(1);

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";

ocilogoff($c1);

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'];
        exit;
    }
    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";
}

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

echo "End of script\n";

?>



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-12 17:45 UTC] tony2001@php.net
I think the current behavior is correct and I personally do not see any reasons to change it at the moment.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 10 19:01:27 2024 UTC