Edit report at http://bugs.php.net/bug.php?id=18451&edit=1
ID: 18451 Updated by: [email protected] Reported by: shane at cm dot nu Summary: php4-pgsql should have a way to create a new database connection -Status: Open +Status: Bogus Type: Feature/Change Request -Package: Feature/Change Request +Package: PostgreSQL related Operating System: Linux PHP Version: 4.2.1 Block user comment: N Private report: N New Comment: Fixed by passing PGSQL_CONNECT_FORCE_NEW as 2nd param to pg_connect(). (no idea in what version this was added) Previous Comments: ------------------------------------------------------------------------ [2002-07-20 22:00:39] shane at cm dot nu Hi, When calling pg_connect, the function reuses existing database connections if they are available. For example. $dbh1 = pg_connect(); $dbh2 = pg_connect(); $dbh1 == $dbh2 at this point. However, as there is no way to tell PHP to create a new connection, the reuse can potentially corrupt a transaction. For example: $dbh1 = pg_conect(); pg_query("begin", $dbh1); pg_query("insert into mytable values(...)"), $dbh1); $dbh2 = pg_connect(); ($dbh2 == $dbh1) not good. pg_query("something stupid that causes an error", $dbh2); pg_query("commit", $dbh1); fails The same problem applies to persistant connections though it looks like php does a rollback when a connection terminates which is good. I think the only real fix for this is pg_connect and pg_pconnect should always return a different handle on a call even when not in a transaction. The only time pg_pconnect should return a previously used handle is when pg_pclose has been called. You garantee transaction safety that way and if the programmer wants to reuse database handles, let him declare a global handle. Best regards, Shane ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=18451&edit=1
