[DCPM] DBI connect error message oddity - Postgres

Simon Waters simon at technocool.net
Tue Apr 18 03:16:32 PDT 2006


We have some tried and trusted perl scripts.

But I noticed when the database server is down the error message is 
"mangled".

Reproducing snippit.
---------------
#!/usr/bin/perl
use strict;
use warnings;
use DBI;

  my $dbh=DBI->connect("dbi:Pg:dbname=dbname;host='mercury';port=5432",
       "dbuser","dbpass");
----------------

Assuming "mercury" is a host refusing connections.

./fail.pl
DBI connect('dbname=dbname;host='mercury';port=5432','dbuser',...) 
failed: could not connect to server:lT      @ðz@
         Is the server running on host "mercury" and accepting
         TCP/IP connections on port 5432?
  at ./fail.pl line 6

Whats the "lT      @ðz@" bit?

I tried setting some locale settings, but before I dig away at this, 
anyone going to leap up and say it is; "UTF8", "Unicode", bad DSN 
syntax, or other stupidity on my part.

Debian Sarge, and DBI packages from Sarge as well. I don't recall this 
error when it was Redhat, but you know you kind of don't pay much 
attention to "database connect errors" when you are busy fixing the 
database server. But I just know if I ignore this any longer, some day 
it will report something vital in a mangled form much like this one.


More information about the Devoncornwall-pm mailing list