From:             solar dot c at gmx dot net
Operating system: SLES 10
PHP version:      5.2.0
PHP Bug Type:     PostgreSQL related
Bug description:  PGSQL_CONNECT_FORCE_NEW will causes next connect to establish 
a new connection

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

-- 
Edit bug report at http://bugs.php.net/?id=39979&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=39979&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=39979&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=39979&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=39979&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=39979&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=39979&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=39979&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=39979&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=39979&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=39979&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=39979&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=39979&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=39979&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=39979&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=39979&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=39979&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=39979&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=39979&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=39979&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=39979&r=mysqlcfg

Reply via email to