Skip to content

Commit 0ab0f12

Browse files
committed
Fix connection reuse
1 parent ce1bd55 commit 0ab0f12

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

ext/pgsql/pgsql.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
731731
* and add a pointer to it with hashed_details as the key.
732732
*/
733733
if (!(connect_type & PGSQL_CONNECT_FORCE_NEW)
734-
&& (index_ptr = zend_hash_find_ptr(&PGG(connections), str.s)) != NULL) {
734+
&& (index_ptr = zend_hash_find(&PGG(connections), str.s)) != NULL) {
735735
php_pgsql_set_default_link(Z_OBJ_P(index_ptr));
736736
ZVAL_COPY(return_value, index_ptr);
737737

ext/pgsql/tests/connection_reuse.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Reusing connection with same connection string
3+
--SKIPIF--
4+
<?php include("skipif.inc"); ?>
5+
--FILE--
6+
<?php
7+
include('config.inc');
8+
9+
$db1 = pg_connect($conn_str);
10+
$db2 = pg_connect($conn_str);
11+
var_dump($db1, $db2);
12+
?>
13+
--EXPECT--
14+
object(PgSql\Connection)#1 (0) {
15+
}
16+
object(PgSql\Connection)#1 (0) {
17+
}

0 commit comments

Comments
 (0)