From: | David Fetter <david(at)fetter(dot)org> |
---|---|
To: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
Cc: | PG Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Error Codes |
Date: | 2004-07-06 19:19:13 |
Message-ID: | 20040706191912.GA30090@fetter.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Jul 06, 2004 at 01:22:35PM -0400, Bruce Momjian wrote:
> David Fetter wrote:
> > Kind people,
> >
> > So far, I have found two places where one can find the SQLSTATE
> > error codes: a header file, and the errcodes-appendix doc. Those
> > are excellent places.
> >
> > Did I miss how to get a list of them in SQL? If I missed it
> > because it isn't there, what would be a good way to have a current
> > list available?
>
> You know, it would be cool to have the codes and descriptions in a
> global SQL table.
I think so, too :)
So, I'm looking at src/include/utils/errcodes.h in CVS tip, and I see
what looks to me like two columns in a table:
sqlstate (e.g. 0100C)
warning (e.g. ERRCODE_WARNING_DYNAMIC_RESULT_SETS_RETURNED)
this would make an excellent table to have handy. How to make sure
that it is, in fact, available, and that its contents match
errcodes.h? Here is a perl hack for parsing errcodes.h:
#!/usr/bin/perl -wl
use strict;
open F, "<errcodes.h" or die "Can't open errcodes.h: $!";
while(<F>) {
chomp;
next unless (/^#define\s+ERRCODE_(\S+)\s+MAKE_SQLSTATE\('(.*)'\).*$/);
# print;
my ($warning, $sqlstate) = ($1, $2);
$warning =~ s/^ERRCODE_//;
$sqlstate =~ s/\W//g; # clean up
my $sql = "INSERT INTO sqlstates (sqlstate, warning) VALUES ($sqlstate, $warning);";
print $sql;
# Now, do the inserts...but where?
}
Cheers,
D
--
David Fetter david(at)fetter(dot)org http://fetter.org/
phone: +1 510 893 6100 mobile: +1 415 235 3778
Remember to vote!
From | Date | Subject | |
---|---|---|---|
Next Message | Simon Riggs | 2004-07-06 19:58:48 | Re: Point in Time Recovery |
Previous Message | Richard Huxton | 2004-07-06 19:00:51 | Re: Point in Time Recovery |