php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31222 ocicommit not working
Submitted: 2004-12-21 08:31 UTC Modified: 2005-06-08 12:37 UTC
From: amonw at hotmail dot com Assigned: tony2001 (profile)
Status: Not a bug Package: OCI8 related
PHP Version: 4CVS-2005-04-04 OS: *
Private report: No CVE-ID: None
 [2004-12-21 08:31 UTC] amonw at hotmail dot com
Description:
------------
ocicommit not working in the following code when connected to oracle 8.1.7 .
The oddest thing is I can avoid this by doing any one of the following:
1. don't use the user defined function "query", and used it's content to replace the function calls
or 
2. use different veriable name for the two connections
or
3. use different veriable name for the two query results
or
4. add $statement=anything or unset($statement) before the second "$statement=query($c,$sql)"

configure command(from phpinfo()):
'./configure' '--with-apxs' '--with-gd' '--with-oci8=shared' '--with-zlib' '--with-jpeg-dir' '--enable-gd-native-ttf' '--with-freetype-dir' '--with-ttf' '--enable-ftp' 

Reproduce code:
---------------
<?php
function query($conn,$sqlstr)
{
	$statement=ociparse($conn,$sqlstr);
	ociexecute($statement,OCI_DEFAULT);
 	return $statement;
} 
dl('oci8.so');
$c=ocilogon('user','pwd');	
$sql="select sysdate from dual";
$statement=query($c,$sql);
$c=ocilogon('user','pwd');
$sql="delete from info_user where device_number='1234567890'";
$statement=query($c,$sql);
if(!ocicommit($c))
{
       $error = OCIError($c); 
       echo 'Commit failed. Oracle reports: ' . $error['message']; 
}
print("$sql :".ocirowcount($statement).' records updated.');
?>

Expected result:
----------------
Prints out "delete from info_user where device_number='1234567890' :x records deleted" and
all records with device_number='1234567890' should be deleted.

Actual result:
--------------
Prints out "delete from info_user where device_number='1234567890' :x records deleted" but no records was deleted.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-21 10:48 UTC] tony2001@php.net
I can't reproduce it with any of PHP versions and Oracle 9.2. 
Did you try to run this code using PHP-CLI? 
Does it work for you?
 [2004-12-21 14:56 UTC] amonw at hotmail dot com
Thanks for your trying and reply.
I tried php-cli and it print the same result plus a new line with some blanks and no records was deleted either.
And I tried php 4.2.2 on the other machine connected to oracle 8.1.7,php 4.3.10 connected to oracle 9.2.0.1.0,php 4.2.2 connected to oracle 9.2.0.1.0. They all produced the same result. Except that when I used php-cli 4.2.2, it also printed "Segmentation fault" at the end.
Are you sure you used exactly the same code as I quoted? 
As I mentioned, even some minor changes which seem not relevant may affect the result.
Thank you again for your quick response.
 [2004-12-21 15:05 UTC] tony2001@php.net
Yes, I tried to run exactly your code, with one modification: I changed login & password.
4.2.2 is too old to talk about, try PHP 5.0.3 instead, if you can.
Also, it would be nice if you try to compile OCI8 module statically and to run the same code with it.
 [2004-12-22 09:19 UTC] amonw at hotmail dot com
I tried compiling oci8 statically and it produced the same result.
I'm building a test system. After I finish it, I'll send you a telnet account to test, if you're willing to.
 [2004-12-22 10:01 UTC] tony2001@php.net
Thanks, it would be very nice.
 [2004-12-23 13:26 UTC] amonw at hotmail dot com
Just in case, did you receive my email with a test account? I sent it about 8 hours ago.
 [2004-12-23 18:16 UTC] tony2001@php.net
You need to use ocinlogon() in this case, because you have 2 similar connections (which are indeed ONE connection) messing around. One of these connections still needs commit and gets  rollback'ed at the end of the script execution and one of them doesn't. So, this is quite expected.

There is another problem: this issue doesn't exist in PHP5 ocilogon()/oci_connect() because behaves similar to ocinlogon()/oci_new_connect() and returns exclusive connection descriptor. 
This is not the intended behaviour and I'll investigate who and why changed it.
 [2004-12-24 03:08 UTC] amonw at hotmail dot com
Thank you for your help.
But can you explain why the 4 methods I listed in the first comment can change the result? 
And why can't I add "ocilogoff($c)" before the second ocilogon to change the result?
 [2005-04-04 09:27 UTC] amonw at hotmail dot com
I tried the http://snaps.php.net/php4-STABLE-latest.tar.gz,which extracted to be php4-STABLE-200504040230,but the code produced the same result.
 [2005-04-05 17:55 UTC] tony2001@php.net
Works just perfectly for all of oci8 users except you.
Try to simplify the code and to look for the problem there.
 [2005-04-26 04:20 UTC] amonw at hotmail dot com
I don't know why, but I upgrate my php again this morning to php4-stable-200504260035, and the problem remains unchanged. I have make the code as simple as possible, and as I mentioned in the first comment, even some minor changes which seem not relevant may affect the result, and I don't know why. I deeply appreciate your patiense and please read my first post again. I can live with it if you are tired of this because it takes so long.
Thank you.
 [2005-04-28 12:56 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.0-win32-latest.zip


 [2005-04-29 05:15 UTC] amonw at hotmail dot com
Thank you for your suggestion. But I'm not ready to upgrade my system to php5 because I don't have much time to modify the old codes to fit in php5 yet.
 [2005-05-12 12:37 UTC] tony2001@php.net
I'm not suggesting you to upgrade, I just want you to try newer version.
 [2005-05-17 07:09 UTC] amonw at hotmail dot com
I've tried the newest version of php4 but it can't solve my problem. Please refer to my last 2 comments.
 [2005-05-18 00:14 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip

We really need to know if this is fixed in HEAD, so please try the snapshot. Nobody is telling you should put it on PRODUCTION machine. You do have some test/dev machines?!

 [2005-05-23 04:42 UTC] amonw at hotmail dot com
I tried php5 yesterday and the problem doesn't exists. So can you fix it in php4? Thanks.
 [2005-05-23 10:13 UTC] tony2001@php.net
I can't fix something that I can't reproduce.
ocicommit() works just PERFECTLY for me and for others, and the version of PHP doesn't really matter here.
 [2005-05-25 06:36 UTC] amonw at hotmail dot com
I've built a test system and sent the information about it to tony2001@php.net. You can ssh2 to it and reproduce the problem.
Thank you.
 [2005-06-02 15:17 UTC] tony2001@php.net
Tested and replied to you.
ocicommit() works fine as I've already told you before.
Even if there is an issue, it has nothing to do with ocicommit() and oci8.
 [2005-06-08 12:28 UTC] amonw at hotmail dot com
I've read your reply and thank you for trying. 
But I already mentioned this in the bug description:
"The oddest thing is I can avoid this by doing any one of the following:
1. don't use the user defined function "query", and used it's content to
replace the function calls 
..."
(please refer to the first comment I wrote)
I know ocicommit does work fine if I code it in other ways,including the 4 methods I mentioned in the bug description.
I just don't understand why it doesn't work in my case. Can you explain it? 
Thank you again.
 [2005-06-08 12:37 UTC] tony2001@php.net
amonw at hotmail dot com:
If there is an issue with reference counting, ocicommit() still has NO PROBLEM.
As you can see yourself, ocicommit() IS working and IF there  is a different issue, it has nothing to do with Oracle, OCI8 and ocicommit().
Please stop reopening this particular report.
Thank you.

Also there was big patch committed to the 4.4 branch recently, that fixes a lot of reference related problems.
So please try latest 4.4 snapshot and tell us the results.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 23:01:28 2024 UTC