PGSQL_CONNECT_FORCE_NEW will causes next connect to establish a new connection
| 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 |
|
||||||||||
| 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 commits
[2007-01-03 19:41 UTC] solar dot c at gmx dot net
[2007-01-03 23:18 UTC] iliaa@php.net
[2007-01-07 04:36 UTC] iliaa@php.net