BrowserUk has asked for the wisdom of the Perl Monks concerning the following question:

What does the following error mean?

DBI connect('dbname=junk','...',...) failed: Couldn't connect to /tmp/.s.PGSQL.5432: at C:/Perl64/site/lib/DBD/PgPP.pm

I can see from the DBD::PgPP POD that there is a 'path' parameter that defaults to '/tmp', but why is it trying to use it--and what for?

The connection succeeds if I specify host=localhost;port=5432, but these are also the defaults, so why do I need to specify them?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re: DBD message diagnostic?
by ikegami (Patriarch) on Apr 15, 2009 at 06:15 UTC
    There are two methods to connect: via a unix socket (path + port) or via a tcp socket (host + port). DBD::PgPP defaults to the former. Specifying the host name differentiates forces the use of tcp.

    Update: This would be more accurate

    parameter hard coded default ------------------------------------------------------ hostname* local domain socket port 5432 dbname** current userid user current userid password '' debug undef args '' tty '' timeout 60 * - "hostname" may be abbreviated to "host" ** - "dbname" may be abbreviated to "db".

      OK. That explains why scripts that worked on my XP system no longer work on my Vista system. The former had DBD::Pg and the latter DBD::PgPP

      The problem is implementation differences between DBD::Pg and DBD::PgPP. The former defaults to making a tcp connection unless you set the host parameter to path, in which case it will try for a unix-domain socket. On Win, it could try for a named-pipe connection. I guess it would just take for someone to write the patch.

      (I wonder why the PgPP author deviated and introduced the path parameter. It makes the host default useless.)


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        Looking at the source, it looks as though there technically is no default hostname. Check out the _connect sub, and you'll see that it checks whether hostname is defined to decide whether to try a TCP socket. But looking a few lines up at new, there isn't any default for hostname, it has to be passed as an argument to new():
        sub new { my ($class, %args) = @_; my $self = bless { hostname => $args{hostname}, path => $args{path} || DEFAULT_UNIX_SOCKE +T, port => $args{port} || DEFAULT_PORT_NUMBE +R, #...snip!

        The former defaults to making a tcp connection unless you set the host parameter to path,

        Are you sure? The documentation for DBD::Pg says it defaults to using a local domain socket when the host isn't specified (which is what DBD::PgPP does).