php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49429 odbc_autocommit doesn't work
Submitted: 2009-09-01 10:50 UTC Modified: 2010-03-20 19:19 UTC
Votes:7
Avg. Score:5.0 ± 0.0
Reproduced:7 of 7 (100.0%)
Same Version:7 (100.0%)
Same OS:4 (57.1%)
From: jvanderleij at desyderetail dot nl Assigned: felipe (profile)
Status: Closed Package: ODBC related
PHP Version: 5.3.0 OS: Windows XP professional
Private report: No CVE-ID: None
 [2009-09-01 10:50 UTC] jvanderleij at desyderetail dot nl
Description:
------------
In PHP-version 5.3.0 the odbc_autocommit function with second parameter filled in always returns false. We tested this with sql server and progress database. In PHP-version 5.2.10 we don't have this problem.

The actual result is the progress output from PHP 5.3.0.
The expected result is the progress output from PHP 5.2.10.

Reproduce code:
---------------
<?php

	function reporterror($con, $extramsg)
	{
		echo $extramsg.'<br>';
		$errnum = odbc_error($con);
		$errstr = odbc_errormsg ($con);
		echo 'error '.$errnum.' errmsg '.$errstr.'<br>';
	}

	function setisolationlevel($con, $level)
	{
		$statement = 'SET TRANSACTION ISOLATION LEVEL ' . $level;
		$res = odbc_exec ($con, $statement);
		if ($res === FALSE)
			reporterror($con, 'exec failed '.$statement);
	}

	function starttransaction($con)
	{
		$res = odbc_autocommit ($con, false);
		if ($res !==  TRUE)
			reporterror($con, 'odbc_autocommit false failed ');
	}

	function committransaction($con)
	{
		$res = odbc_commit($con);
		if ($res !== TRUE)
			reporterror($con, 'committransaction failed ');
				$res = odbc_autocommit ($con, true);
		$res = odbc_autocommit ($con, true);
		if ($res !==  TRUE)
			reporterror($con, 'odbc_autocommit true failed ');
	}


	function test1($con)
	{

		echo 'test 1<br>';

		setisolationlevel($con, 'READ UNCOMMITTED');
		starttransaction($con);
		$rs = odbc_exec ($con, "SELECT * from tbloctsequence where seqname = 'testdanny'");
		if ($rs === FALSE)
		{
			reporterror($con, 'exec failed');
			echo 'exec failed<br>';
		} else
		{
			echo 'exec succeeded<br>';
			for (;;)
			{
				$ar = odbc_fetch_array($rs);
				if ($ar === FALSE)
					break;
				else
				{
					print_r($ar);
					echo '<br>';
				}
			}

			odbc_free_result ($rs);
		}
		committransaction($con);
	}


	function test2($con)
	{

		echo 'test 2<br>';

		setisolationlevel($con, 'READ COMMITTED');
		starttransaction($con);
		$rs = odbc_exec ($con, "INSERT INTO tblLabelnamen (Naam) VALUES ('testdanny')" );
		if ($rs === FALSE)
		{
			reporterror($con, 'exec failed');
			echo 'exec failed<br>';
		} else
			echo 'exec succeeded<br>';
		committransaction($con);
	}



	$con = odbc_connect ( 'progresstest', 'test' , 'test');
//	$con = odbc_connect ( 'mssqltest', 'test' , 'test');

	if ($con == 0)
	{
		echo 'connect failed<br>';
	} else
	{
		echo 'connect succeeded<br>';
		test1($con);
		test2($con);

		odbc_close ($con );
	}



?>

Expected result:
----------------
connect succeeded
test 1
exec succeeded
test 2
exec succeeded


Actual result:
--------------
connect succeeded
test 1
odbc_autocommit false failed 
error ?-? errmsg 
exec succeeded
test 2
exec failed SET TRANSACTION ISOLATION LEVEL READ COMMITTED
error S1000 errmsg [DataDirect][ODBC Progress OpenEdge Wire Protocol driver][OPENEDGE]Cannot change the transaction isolation level while in a transaction. (13742)
odbc_autocommit false failed 
error S1000 errmsg [DataDirect][ODBC Progress OpenEdge Wire Protocol driver][OPENEDGE]Cannot change the transaction isolation level while in a transaction. (13742)
exec failed
error S1000 errmsg [DataDirect][ODBC Progress OpenEdge Wire Protocol driver][OPENEDGE]Statement not allowed in readonly isolation level (7671)
exec failed


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-11-24 12:45 UTC] kristoff dot picard at ingres dot com
Same problem with 5.3.1
Tested on Linux with unixODBC and Ingres

Simple testcase:
------
$dsn='mydsn';
$conn=odbc_connect($dsn,'','');

$rc=odbc_autocommit($conn,FALSE);
echo "return set odbc_autocommit false: ".$rc. "\n";

$rc=odbc_autocommit($conn);
echo "return get odbc_autocommit: ".$rc. "\n";
-----

Output is as follows:
return set odbc_autocommit false: 1
return get odbc_autocommit: 1

While with 5.2.11 it is:
return set odbc_autocommit false: 1
return get odbc_autocommit: 0


ODBC trace shows that in 5.3.x SQLSetConnectOption() isn't called when passing FALSE as second parameter, but SQLGetConnectOption. 

When passing TRUE SQLSetConnectOption() is called as expetced.
 [2010-03-20 19:19 UTC] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=296467
Log: - Fixed bug #49429, #51331 (odbc_autocommit doesn't work)
 [2010-03-20 19:19 UTC] felipe@php.net
-Summary: Problem with odbc_autocommit +Summary: odbc_autocommit doesn't work -Status: Open +Status: Closed -Assigned To: +Assigned To: felipe
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 13:01:29 2024 UTC