#27824 [Fbk->Csd]: pg_pconnect failing to create multiple connections per script
| From: | gwood at ewebengine dot com | Date: | Thu, 01 Apr 2004 14:52:38 +0000 |
| Subject: | #27824 [Fbk->Csd]: pg_pconnect failing to create multiple connections per script | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-57322@lists.php.net to get a copy of this message | ||
ID: 27824
User updated by: gwood at ewebengine dot com
Reported By: gwood at ewebengine dot com
-Status: Feedback
+Status: Closed
Bug Type: PostgreSQL related
Operating System: FreeBSD 5.1-RELEASE-p10
PHP Version: 4.3.4
New Comment:
You are exactly correct, I apologize: I was incorrect about my
expectations of pg_connect(). I reread the documentation with regards
to this and sure enough that is the expected behavior.
In my testing I had mixed pg_pconnect() and pg_connect() which resulted
in different results, hence my confusion.
I guess I'll have to fool PHP into thinking that they're two separate
connections by creating a junk user or an alias for the host name. Ugh.
Previous Comments:
------------------------------------------------------------------------
[2004-04-01 09:23:56] derick@php.net
Non-persistent connections behave exactly the same as persistent ones
for this too. If not, *that*'s a bug. Can you please verify that?
------------------------------------------------------------------------
[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