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

From: Jan Urbański <wulczer(at)wulczer(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org, Shigeru HANADA <hanada(at)metrosystems(dot)co(dot)jp>
Subject: Re: autogenerating error code lists (was Re: [COMMITTERS] pgsql: Add foreign data wrapper error code values for SQL/MED.)
Date: 2011-01-12 18:57:26
Message-ID: 4D2DF996.9000100@wulczer.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers 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(at)wulczer(dot)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 Content-Type Size
0003-Generate-the-error-codes-appendix-file.patch text/x-patch 0 bytes

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Jan Urbański 2011-01-12 22:10:18 Re: autogenerating error code lists (was Re: [COMMITTERS] pgsql: Add foreign data wrapper error code values for SQL/MED.)
Previous Message Robert Haas 2011-01-12 17:00:27 pgsql: Revert patch adding support for logging the current role.

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2011-01-12 18:59:17 Re: libpq documentation cleanups (repost 3)
Previous Message David E. Wheeler 2011-01-12 18:54:11 Re: WIP: Range Types