Re: autogenerating error code lists (was Re: [COMMITTERS] pgsql: Add foreign data wrapper error code values for SQL/MED.) - Mailing list pgsql-hackers

From Jan Urbański
Subject Re: autogenerating error code lists (was Re: [COMMITTERS] pgsql: Add foreign data wrapper error code values for SQL/MED.)
Date
Msg-id 4D2DF996.9000100@wulczer.org
Whole thread Raw
In response to Re: autogenerating error code lists (was Re: [COMMITTERS] pgsql: Add foreign data wrapper error code values for SQL/MED.)  (Jan Urbański <wulczer@wulczer.org>)
Responses Re: autogenerating error code lists (was Re: [COMMITTERS] pgsql: Add foreign data wrapper error code values for SQL/MED.)  (Jan Urbański <wulczer@wulczer.org>)
List pgsql-hackers
On 11/01/11 21:21, Jan Urbański wrote:
> On 11/01/11 18:59, Tom Lane wrote:
>> =?UTF-8?B?SmFuIFVyYmHFhHNraQ==?= <wulczer@wulczer.org> writes:
>>> On 11/01/11 17:11, Tom Lane wrote:
>> Peter would probably be a better person than me to answer that, but I
>> imagine that what you want is similar to what src/backend/Makefile does
>> for parser/gram.h, only applied at the src/ level or maybe even the
>> root.

> And actually, if I change my rule to read:
>
> $(SUBDIRS:%=all-%-recurse): $(top_builddir)/src/include/utils/errcodes.h
>
> it works. Now whether that's acceptable or not is another thing entirely...

And so I came up with three patches to make errcodes.h, plerrcodes.h and
errcodes.sgml (respectively) generated files.

The autogenerated files are almost identical with the originals (except
for formatting, sometimes, and comments) except:

 * in errcodes.sgml the Meaning field for INVALID ARGUMENT FOR NTH_VALUE
FUNCTION changed to INVALID ARGUMENT FOR NTH VALUE FUNCTION. Not ideal,
but I wouldn't shed any tears. The Constant field stays the same, and
that's what's important for a PL/pgSQL programmer

 * in errcodes.h there are a few changes like that:

 #define ERRCODE_DATETIME_FIELD_OVERFLOW        MAKE_SQLSTATE('2','2',
'0','0','8')
-#define ERRCODE_DATETIME_VALUE_OUT_OF_RANGE ERRCODE_DATETIME_FIELD_OVERFLOW
+#define ERRCODE_DATETIME_VALUE_OUT_OF_RANGE
MAKE_SQLSTATE('2','2','0','0','8')
 #define ERRCODE_DIVISION_BY_ZERO           MAKE_SQLSTATE('2','2',
'0','1','2')

unless your MAKE_SQLSTATE macro has side-effects, it should not be a problem

 * in plerrcodes.h a few entries disappeard, and that's because they had
duplicated SQLSTATE values. As they were not documented in
errcodes.sgml, no one should even know they existed, and as they catch
the same SQLSTATE, again it shouldn't be an issue.

As a bonus, a documented but forgotten exception got added. Try this in
HEAD:

do $$ begin begin exception when nonstandard_use_of_escape_character
then null; end; end$$;

It will fail.

Cheers,
Jan

Attachment

pgsql-hackers by date:

Previous
From: "David E. Wheeler"
Date:
Subject: Re: WIP: Range Types
Next
From: Robert Haas
Date:
Subject: Re: libpq documentation cleanups (repost 3)