Home » Database » DB » Bug #1919
Incorrect handling of postgres port for unix domain sockets
Details
| Submitted | 2004-07-20 06:01 UTC |
|---|---|
| From | petrov at alumni dot rice dot edu |
| Assigned | danielc |
| Status | Closed |
| Package | DB |
| PHP Version | Irrelevant |
| OS | Redhat 7.3 |
| Roadmaps | (Not assigned) |
Comments
[2004-07-20 06:01 UTC] petrov at alumni dot rice dot edu
Description:
------------
While I am using v4.1.2 of PHP (from RH 7.3), your stupid bugtracking software won't let me post a bug for that version. While I originally found the bug in that version, the solution is not to upgrade as the bug is still present in the version of the code posted at:
http://cvs.php.net/pear/DB/DB/pgsql.php
which I assume is the latest version (v1.77) of that file.
I am running a PostgreSQL database on a non-standard port number over UNIX domain sockets, by having tcpip_socket = false in my postgresql.conf file and having port=5433. I can correctly connect to this database with the command line utility psql(1) by passing the -p 5433 command line flag. I can correctly connect to this database with pg_connect in PHP by using either of the two following connection string:
$db = pg_connect("port=5433 dbname=$dbname user=$user password=$pw"); // omitting the host parameter defaults to UNIX domain sockets
$db = pg_connect("host=/tmp port=5433 dbname=$dbname user=$user password=$pw");
but when I try to connect by using Pear::DB, this connection string fails to connect:
$db = DB::connect("pgsql://$user:$pw@unix+/tmp:5433/$db");
Similarly, if I provide a $dsn array with 'port' set to '5433' and 'protocol' set to 'unix', the connection attempt fails.
To fix this bug, you are going to need to change the DB_pgsql::connect() function to include the port information for UNIX domain sockets.
Reproduce code:
---------------
See above.
Expected result:
----------------
The connection should succeed.
Actual result:
--------------
The connection fails with an error message, or (in my case where I have a separate Postgres database running on port 5432), the connection succeeds to the wrong database.