Tom Lane wrote:
> You could imagine including errcodes.h by itself after supplying a
> suitable definition for MAKE_SQLSTATE(); but I think you'd want it to
> reconstitute the five characters into a string literal, and I'm not
> sure that there's any easy way to do that in C. If we wanted to
> go in this direction, it might be easier to create another Perl
> script that puts out an errcodes-fe.h with the errcode symbols
> #defined as string literals.
>
> The larger reason we've not done this is that, once a given errcode
> is wired into some client-side code, it effectively becomes part of
> the protocol and can't be reassigned. See the comments around the
> places in libpq where specific errcodes are referenced. So it's
> not very clear that we want to encourage frontend code to use this
> technique a lot.
Maybe we could mark individual errcodes in errcodes.txt as "exported for
clients" with some new token, and the new errcodes-fe.h list would only
include those. That way, we only fix a limited number of codes instead
of all of them.
We could add such marks to all codes defined by the standard, since we
can't change those anyway.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services