On Wed, Nov 12, 2003 at 04:19:47PM +0100, Jos I. Boumans wrote:
> 
> On 12-nov-03, at 14:27, Tim Bunce wrote:
> 
> >>if i tell DBI to connect to a postgres db, but i don't have DBD::Pg
> >>installed, it will not give me a warning of any kind, including when
> >>DBI->trace(5) is set, that
> >>i do not have the necessary driver installed. It simply silently 
> >>fails.
> >
> >Works for me:
> >
> >$ perl -MDBI -e 'DBI->connect("dbi:Pg:foo",1,1)'
> [..]
> >It would be a *big* help if you could post a test case, like I have 
> >used above, that demonstrates the problem.
> 
> sorry about that, i also thought i attached the log, but apparently i 
> didn't.   Here's the test case:
> 
> $ perl -MDBI -le 
> 'DBI->trace(5);eval{$d=DBI->connect("dbi:Pg:foo",1,1)};print $DBI::errstr if !$d;'
> 
>     DBI 1.38-ithread dispatch trace level set to 5
>     Note: perl is running without the recommended perl -w option
>     -> DBI->connect(dbi:Pg:foo, 1, ****)
>     -> DBI->install_driver(Pg) for linux perl=5.008002 pid=12789 ruid=1001 euid=1001
>     -> $DBI::errstr (&) FETCH from lasth=none
> Can't read $DBI::errstr, last handle unknown or destroyed at -e line 1.
>     <- $DBI::errstr= undef
>     -- DBI::END
> 
> Apparently, the error is only in $@, and not $DBI::errstr, which in 
> itself may not be a bug, just slightly surprising on my end.

$DBI::errstr can't be read because the driver didn't get loaded.
install_driver is defined to die if loading a driver failed.
Because you used an eval and didn't print $@ we can't see the error.

> The complaining about $DBI::errstr only seems to occur if i use trace 
> and set the tracelevel to 2 or higher.

That's a feature.

What does this output:

        perl -MDBI -e 'DBI->connect("dbi:Pg:foo",1,1)'

Tim.

Reply via email to