Lists: | pgsql-general |
---|
From: | Toomas Vendelin <pg(at)vendelin(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Pgsql errors, DBI and CGI::Carp |
Date: | 2009-04-29 05:06:46 |
Message-ID: | 9AC4C112-183A-433C-8ADE-4676CA301747@vendelin.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
I'm writing CGI scripts in Perl using Postgresql via DBI interface.
RAISE_ERROR is on.
For some reason (unlike with MySQL), when a Perl script dies from
Postgresql error, the line number of Perl script where the error
occurred is not reported, just the SQL statement line number is given.
In a longer script looking it may become a tedious task to guess the
line in script that caused the problem. Is that an expected behavior
or am I missing something?
Toomas
From: | "Daniel Verite" <daniel(at)manitou-mail(dot)org> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Pgsql errors, DBI and CGI::Carp |
Date: | 2009-05-01 13:07:32 |
Message-ID: | f11a4afa-23ad-4703-a85c-c6ed53d4e7d9@mm |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Toomas Vendelin wrote:
> I'm writing CGI scripts in Perl using Postgresql via DBI interface.
> RAISE_ERROR is on.
>
> For some reason (unlike with MySQL), when a Perl script dies from
> Postgresql error, the line number of Perl script where the error
> occurred is not reported, just the SQL statement line number is
given.
> In a longer script looking it may become a tedious task to guess the
> line in script that caused the problem. Is that an expected behavior
> or am I missing something?
It works for me:
$ cat dberr.pl
use CGI::Carp;
use DBI;
my $dbh=DBI->connect("dbi:Pg:dbname=test") or die;
$dbh->do("bogus SQL");
$ perl dberr.pl
[Fri May 1 15:05:08 2009] dberr.pl: DBD::Pg::db do failed: ERROR:
syntax error at or near "bogus"
[Fri May 1 15:05:08 2009] dberr.pl: LINE 1: bogus SQL
[Fri May 1 15:05:08 2009] dberr.pl: ^ at dberr.pl line 4.
If you run that trivial program in your environment, what output do you
get?
Best regards,
--
Daniel
PostgreSQL-powered mail user agent and storage:
http://www.manitou-mail.org
From: | Toomas Vendelin <pg(at)vendelin(dot)com> |
---|---|
To: | Daniel Verite <daniel(at)manitou-mail(dot)org> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Pgsql errors, DBI and CGI::Carp |
Date: | 2009-05-12 05:48:38 |
Message-ID: | 1AABBAC0-D68F-4CB0-9CAE-E9D5408FC255@vendelin.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
My mistake was using DBD::PgPP (as suggested in "Beginning Databases
with PostgreSQL" by Neil Matthew and Richard stones, Apress) instead
of DBD::Pg.
Thanks for help!
On May 1, 2009, at 4:07 PM, Daniel Verite wrote:
> Toomas Vendelin wrote:
>
>> I'm writing CGI scripts in Perl using Postgresql via DBI
>> interface. RAISE_ERROR is on.
>> For some reason (unlike with MySQL), when a Perl script dies from
>> Postgresql error, the line number of Perl script where the error
>> occurred is not reported, just the SQL statement line number is
> given.
>> In a longer script looking it may become a tedious task to guess the
>
>> line in script that caused the problem. Is that an expected behavior
>
>> or am I missing something?
>
> It works for me:
>
> $ cat dberr.pl
> use CGI::Carp;
> use DBI;
> my $dbh=DBI->connect("dbi:Pg:dbname=test") or die;
> $dbh->do("bogus SQL");
>
> $ perl dberr.pl
> [Fri May 1 15:05:08 2009] dberr.pl: DBD::Pg::db do failed: ERROR:
> syntax error at or near "bogus"
> [Fri May 1 15:05:08 2009] dberr.pl: LINE 1: bogus SQL
> [Fri May 1 15:05:08 2009] dberr.pl: ^ at dberr.pl line 4.
>
> If you run that trivial program in your environment, what output do
> you get?
>
> Best regards,
> --
> Daniel
> PostgreSQL-powered mail user agent and storage:
> http://www.manitou-mail.org
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general