Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.12.2

Bug #5982 No connection with PostgreSQL via sockets and non default port
Submitted: 2005-11-16 11:42 UTC
From: r dot m dot guerrero at usit dot uio dot no Assigned: lsmith
Status: Closed Package: DB
PHP Version: 4.3.11 OS: Linux RHEL WS 3
Roadmaps: (Not assigned)    

 [2005-11-16 11:42 UTC] r dot m dot guerrero at usit dot uio dot no
Description: ------------ System: - PostgreSQL 8.0.4 (socket in f.ex:/tmp/sockets/, port= 5433) - PHP 4.3.11 - Apache 1.3.33 - pear DB 1.7.6 Using postgreSQL with a non standard port (f.ex.: 5433) would create the Unix domain socket /tmp/sockets/.s.PGSQL.5433. With the actual format of DSN, we can not define a non standard socket location with a non standad port. We can define this: pgsql://postgres@unix(/tmp/sockets/)/test but this will try to connect to tmp/sockets/.s.PGSQL.5432 (default port) and it does not work if we are using another port. "...(/tmp/sockets/:5433)" does not work, this tries to use /tmp/pg_sockets/bbking01:5433/.s.PGSQL.5432 I have patched DB.php (see patch) so it will be possible to define a socket directory and a port in DSN with the format: phptype://user:passwd@unix(/path/to/socket:port)/database Test script: --------------- --- DB.php 2005-11-16 12:25:59.000000000 +0100 +++ DB_patched.php 2005-11-16 12:25:07.000000000 +0100 @@ -816,8 +816,13 @@ class DB $parsed['hostspec'] = $proto_opts; } } elseif ($parsed['protocol'] == 'unix') { - $parsed['socket'] = $proto_opts; - } + if (strpos($proto_opts, ':') !== false) { + list($parsed['socket'], + $parsed['port']) = explode(':', $proto_opts); + } else { + $parsed['socket'] = $proto_opts; + } + } // Get dabase if any // $dsn => database


 [2006-03-01 23:31 UTC] lsmith
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on by the end of next Sunday (CET). If this was a problem with the website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. I implemented the patch slightly more efficient.