Edit report at http://bugs.php.net/bug.php?id=49429&edit=1

 ID:               49429
 Updated by:       fel...@php.net
 Reported by:      jvanderleij at desyderetail dot nl
-Summary:          Problem with odbc_autocommit
+Summary:          odbc_autocommit doesn't work
-Status:           Open
+Status:           Closed
 Type:             Bug
 Package:          ODBC related
 Operating System: Windows XP professional
 PHP Version:      5.3.0
-Assigned To:      
+Assigned To:      felipe



Previous Comments:
------------------------------------------------------------------------
[2010-03-20 19:19:19] fel...@php.net

Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=296467
Log: - Fixed bug #49429, #51331 (odbc_autocommit doesn't work)

------------------------------------------------------------------------
[2009-11-24 12:45:51] 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.

------------------------------------------------------------------------
[2009-09-01 10:50:55] 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




------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=49429&edit=1

Reply via email to