php.net |  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
Votes:1
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
 [2006-12-28 17:46 UTC] solar dot c at gmx dot net
Description:
------------
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:
---------------
<?php 

$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
var_dump(pg_fetch_all($res1));

?>

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

Patches

Pull Requests

History

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

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?

Greetz
Clemens
 [2007-01-03 23:18 UTC] iliaa@php.net
comment was removed because the bug was not solved.
 [2007-01-07 04:36 UTC] iliaa@php.net
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
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC