in reply to DBD message diagnostic?

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".

Replies are listed 'Best First'.
Re^2: DBD message diagnostic?
by BrowserUk (Patriarch) on Apr 15, 2009 at 07:42 UTC

    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!

        Yeah, The POD is out of step with the code (and the default behaviour is different from DBD::Pg).

        parameter | hard coded default ----------+------------------- dbname | current userid host | localhost port | 5432 path | /tmp debug | undef

        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.

      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).

        Are you sure?

        Yes. Quite sure. This script (just userid & password obscured):

        #! perl -sw use 5.010; use strict; use threads; use DBI; my $dbh = DBI->connect("dbi:Pg:dbname=junk", '******', '********'); say $dbh; my $sth = $dbh->prepare( 'Select * from fred' ); $sth->execute; while( my @row = $sth->fetchrow_array ) { say "@row"; }

        Produces this output:

        c:\test>DB.pl DBI::db=HASH(0x40ae870) 1 fred 2 bill 3 jack 4 joe

        So, maybe PgPP followed Pg's POD and not it's behaviour?


        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.