Re: Appendix A. PostgreSQL Error Codes

From: Jürgen Purtz <juergen(at)purtz(dot)de>
To: pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: Appendix A. PostgreSQL Error Codes
Date: 2018-04-28 09:42:18
Message-ID: 33572adf-59d0-f0d5-5515-0fbde8871afd@purtz.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

The SQL standard sorts the SQLSTATE table in a first step according to
the *textual representation* of class (first two byte) and in a second
step to the textual representation of subclass (next 3 byte) - keeping
the text '(no subclass)' for subclass '000' on top. Obviously for some
people this 'textual' sort order is relevant.

For my personal use I strongly prefer a pure 'numeric' sort order of
SQLSTATE. Therefore I created a Perl program, which generates the SGML
file out of errcode.txt and published it in
https://www.postgresql.org/message-id/d69ce4f1-dd4e-61c1-070e-25f662e9c622%40purtz.de
. This was a follow-up action after a discussion about illegal SQLSTATE
values in PG, see:
https://www.postgresql.org/message-id/11558.1513819695%40sss.pgh.pa.us.

PG documentation uses a numeric sort order for class and a semantic sort
order for subclass.

Which one of the three is best? Here is my judgement: For technical
oriented people the first approach is horrible because it sorts not only
the subclass-text but also the class-text. This scrambles important and
less important values to arbitrary positions. For me, sorting of the
numeric value of class in a first step is essential. The third approach
may be good for persons which work on the improvement of the PG source
code. But they can refer to errcodes.txt. The primary readers of our
documentation are users which work in roles as DBA or application
developer. I doubt that they are interested in the semantic order of
subclass. But I do not know whether they prefer numeric to text or text
to numeric translation.

Jürgen Purtz

On 27.04.2018 17:16, Tom Lane wrote:

> Bruce Momjian <bruce(at)momjian(dot)us> writes:
>> On Fri, Apr 27, 2018 at 10:08:12AM +0000, PG Doc comments form wrote:
>>> Would it be possible to present the codes in ascending sequence?
>> Uh, I am guessing this is the order listed in the SQL standard. How
>> would you order them differently? Have the letters only at the end?
> There was some discussion of this a couple months ago, which I'm too lazy
> to search the archives for right now, but it trailed off without any
> agreement on what to do.
>
> There are at least three different ordering principles that might be
> applied here: numeric by code (well, perhaps more like "ASCII sort
> order"); alphabetical by exception name (but probably still keeping the
> 000 category codes at the top); or semantic grouping (ie try to keep
> related errors together). It looks to me like all three of these have
> been applied in different places ;-).
>
> One idea that might help is to present two tables with different sort
> orders, say strict numeric and strict alphabetical. (If we did that,
> I'd be inclined to leave errcodes.txt alone and put the sorting
> responsibility on the script that converts it to SGML.)
>
> One question that has to be asked is what we think the use-case for this
> table is at all. Different use-cases result in different ideas about the
> best ordering.
>
> regards, tom lane
>
>

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message Alvaro Herrera 2018-04-28 20:49:56 Re: Documentation for CommandComplete is incorrect for CREATE TABLE with server version 10.2
Previous Message Andy Dossett 2018-04-28 08:08:26 RE: Appendix A. PostgreSQL Error Codes