Thread: Error Codes?

Error Codes?

From
Fran Fabrizio
Date:
I'm a bit confused about the current state of error codes in Pg.  The
docs and
the mailing list archives seem to indicate that this is a TODO item,
however,
at least when using Perl with DBD::Pg, when I call $db->err() or examine

$DBI::err I get a number back.  For instance, 7 if I try to insert too
many
columns into a row, and a 1 if the connection fails.  What's the scoop,
and if
error codes really do exist, is there a list of such codes?

Thanks,
Fran


Re: Error Codes?

From
"Rob Arnold"
Date:
Look at $db->errstr  That has the text version of the error code.

--rob

----- Original Message -----
From: "Fran Fabrizio" <ffabrizio@mmrd.com>
To: <pgsql-general@postgresql.org>
Sent: Wednesday, October 10, 2001 2:48 PM
Subject: [GENERAL] Error Codes?


> I'm a bit confused about the current state of error codes in Pg.  The
> docs and
> the mailing list archives seem to indicate that this is a TODO item,
> however,
> at least when using Perl with DBD::Pg, when I call $db->err() or examine
>
> $DBI::err I get a number back.  For instance, 7 if I try to insert too
> many
> columns into a row, and a 1 if the connection fails.  What's the scoop,
> and if
> error codes really do exist, is there a list of such codes?
>
> Thanks,
> Fran
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>


Re: Error Codes?

From
Fran Fabrizio
Date:
> Rob Arnold wrote:
>
> > Look at $db->errstr  That has the text version of the error code.
> >
> > --rob

Yes, but I want to know about the codes, not the text.  If the codes exist,
they are easier to work with than the text.

-Fran


Re: Error Codes?

From
Martijn van Oosterhout
Date:
On Wed, Oct 10, 2001 at 05:41:37PM -0400, Fran Fabrizio wrote:
> > Rob Arnold wrote:
> >
> > > Look at $db->errstr  That has the text version of the error code.
> > >
> > > --rob
>
> Yes, but I want to know about the codes, not the text.  If the codes exist,
> they are easier to work with than the text.

I find this code useful. You can build a hash from which you can extract more
useful error messages.

perl -MPg <<'EOF'
print map { "$_ => ".$Pg::{$_}->()."\n" }
      sort grep { /^PGRES_/ }
      keys %Pg::
EOF

=== output ===
PGRES_BAD_RESPONSE => 5
PGRES_COMMAND_OK => 1
PGRES_CONNECTION_BAD => 1
PGRES_CONNECTION_OK => 0
PGRES_COPY_IN => 4
PGRES_COPY_OUT => 3
PGRES_EMPTY_QUERY => 0
PGRES_FATAL_ERROR => 7
PGRES_INV_ARCHIVE => 65536
PGRES_INV_READ => 262144
PGRES_INV_SMGRMASK => 65535
PGRES_INV_WRITE => 131072
PGRES_InvalidOid => 0
PGRES_NONFATAL_ERROR => 6
PGRES_TUPLES_OK => 2
================

>
> -Fran
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly

--
Martijn van Oosterhout <kleptog@svana.org>
http://svana.org/kleptog/
> Magnetism, electricity and motion are like a three-for-two special offer:
> if you have two of them, the third one comes free.