Bug #18451: php4-pgsql should have a way to create a new database connection
| From: | shane at cm dot nu | Date: | Sun, 21 Jul 2002 02:00:41 +0000 |
| Subject: | Bug #18451: php4-pgsql should have a way to create a new database connection | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-14712@lists.php.net to get a copy of this message | ||
From: shane@cm.nu
Operating system: Linux
PHP version: 4.2.1
PHP Bug Type: Feature/Change Request
Bug description: php4-pgsql should have a way to create a new database connection
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 bug report at http://bugs.php.net/?id=18451&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=18451&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=18451&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=18451&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=18451&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=18451&r=support
Expected behavior: http://bugs.php.net/fix.php?id=18451&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=18451&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=18451&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=18451&r=globals