Thread: Error Codes

Error Codes

From
David Fetter
Date:
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?

TIA for brickbats, comments, &c. :)

Cheers,
D
-- 
David Fetter david@fetter.org http://fetter.org/
phone: +1 510 893 6100    mobile: +1 415 235 3778

Before you try to play the history card, make sure it's in your hand.


Re: Error Codes

From
Bruce Momjian
Date:
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.

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073
 


Re: Error Codes

From
David Fetter
Date:
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
INTOsqlstates (sqlstate, warning) VALUES ($sqlstate, $warning);";   print $sql;   # Now, do the inserts...but where?
 
}


Cheers,
D
-- 
David Fetter david@fetter.org http://fetter.org/
phone: +1 510 893 6100   mobile: +1 415 235 3778

Remember to vote!