|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39979 PGSQL_CONNECT_FORCE_NEW will causes next connect to establish a new connection
Submitted: 2006-12-28 17:46 UTC Modified: 2007-01-07 04:36 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: solar dot c at gmx dot net Assigned: iliaa (profile)
Status: Closed Package: PostgreSQL related
PHP Version: 5.2.0 OS: SLES 10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
28 - 15 = ?
Subscribe to this entry?

 [2006-12-28 17:46 UTC] solar dot c at gmx dot net
I want to force a NEW connection to a psql server with PGSQL_CONNECT_FORCE_NEW.

After this i make a second pg_connect, which should have the same connection/ressource as the 1st one. 

But with the force-option the second pg_connect is also forced to establish a new connection (the 3rd pg_connect will use the ressource of the 2nd).

I tested this on 5.2 and 5.1.1. 
Only 5.2 showed up this behavior.
Apache2, PostgreSQL 8.2 and 8.0.3

Reproduce code:

$host       = "dbhost.local";
$port       = "1234";    
$dbname     = "dbname";
$user       = "dbuser";
$password   = "dbpass";

$connstring = "host={$host} port={$port} dbname={$dbname} user={$user} password={$password}";

$conn1 = pg_connect($connstring, PGSQL_CONNECT_FORCE_NEW);
$conn2 = pg_connect($connstring);
$conn3 = pg_connect($connstring);

print "conn1:".intval($conn1); 
print "\nconn2:".intval($conn2); // different result than 1
print "\nconn3:".intval($conn3); // different result than 1 (same as 2)

// get current activity
$qry  = "select * from pg_stat_activity;";
$res2 = pg_query($conn2, $qry); $res3 = pg_query($conn3, $qry); $res1 = pg_query($conn1, $qry);

// we will know see 2 openend connections (if the pg_server issn't busy elsewhere ;)) - except of 1


Expected result:
Expected to only establish 1 connection, and reuse the established ones.

the ressource id outputted should be everytime same.

the stat_activity should show only one recordset (if the server issn't busy elsewhere).

Actual result:
2 connection will be established, 
2 different ressource ids
2 recordsets will be returned @ var_dump


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-01-03 19:41 UTC] solar dot c at gmx dot net

I've seen that the bug should be solved in the latest CVS - at least iliaa has written a comment with this information (why did you removed your comment?).

So I fetched the latest CVS and tryed it - didn't solve the Problem.

How can I help you to solve it?

 [2007-01-03 23:18 UTC]
comment was removed because the bug was not solved.
 [2007-01-07 04:36 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jul 25 13:01:28 2024 UTC