#27824 [Opn->Fbk]: pg_pconnect failing to create multiple connections per script
ID: 27824
Updated by: derick@php.net
Reported By: gwood at ewebengine dot com
-Status: Open
+Status: Feedback
-Bug Type: Documentation problem
+Bug Type: PostgreSQL related
Operating System: FreeBSD 5.1-RELEASE-p10
PHP Version: 4.3.4
New Comment:
Non-persistent connections behave exactly the same as persistent ones
for this too. If not, *that*'s a bug. Can you please verify that?
Previous Comments:
------------------------------------------------------------------------
[2004-04-01 09:06:59] gwood at ewebengine dot com
If this isn't considered a bug, then the documentation is incorrect.
The documentation states that persistant connections can be swapped out
for non-persistant connections with no problem. This IS NOT TRUE for
the example I presented.
If this is expected behaviour this caveat needs to be added to the
warnings on the persistant connection page.
------------------------------------------------------------------------
[2004-04-01 08:53:00] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
When creating a persistent connection PHP uses the provided
authentication information to determine is such connection
is already avaliable. This is why when using pg_pconnect
with the same data in one script would result in a single
connection.
------------------------------------------------------------------------
[2004-04-01 08:51:32] gwood at ewebengine dot com
Description:
------------
According to the documentation:
"An important summary. Persistent connections were designed to have
one-to-one mapping to regular connections. That means that you should
always be able to replace persistent connections with non-persistent
connections, and it won't change the way your script behaves. It may
(and probably will) change the efficiency of the script, but not its
behavior!"
This does not appear to be the case with pg_pconnect. Specifically,
creating two database connections using pg_pconnect with the same
connection parameters, results in only a single database connection.
This means that instead of being able to execute queries in parallel,
all queries are executed sequentially.
This happens with both the CLI interface and mod_php.
Reproduce code:
---------------
$conn1 = pg_pconnect($connect_string);
$conn2 = pg_pconnect($connect_string);
pg_query($conn1, 'BEGIN');
pg_query($conn2, 'BEGIN');
pg_query($conn1, 'INSERT INTO test (int1) VALUES (1)');
pg_query($conn2, 'INSERT INTO test (int1) VALUES (2)');
pg_query($conn1, 'ROLLBACK');
pg_query($conn2, 'COMMIT');
Expected result:
----------------
This should result in the second insert to the database being
committed, while the first insert is rolled back. This is what happens
when pg_connect() is substituted for pg_pconnect.
Actual result:
--------------
Both inserts are rolled back.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=27824&edit=1
Thread (5 messages)