Re: Todo item: Include the symbolic SQLSTATE name in verbose error reports

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Josh Kupershmidt <schmiddy(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Todo item: Include the symbolic SQLSTATE name in verbose error reports
Date: 2026-05-25 18:58:11
Message-ID: 136109.1779735491@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Josh Kupershmidt <schmiddy(at)gmail(dot)com> writes:
> Attached is a patch implementing an old feature request on the wiki's Todo:
> "Include the symbolic SQLSTATE name in verbose error reports"

I kind of doubt that this is actually useful (which presumably is
the reason the TODO item has languished uncompleted for so long).

The first problem is that the SQL spec's list of error codes isn't
very granular, so that there are many cases where different errors
with different messages have been mapped to the same SQLSTATE.
You are way better off to read the message text than to believe
that the SQLSTATE is a useful summary.

The second problem is that the proposed implementation relies on
libpq to know the server's list of SQLSTATEs, with obvious risks
for cross-version skew.

I also wonder if this wouldn't break some applications that are
expecting specific output from psql, or for that matter from
anything else relying on libpq's error message formatting.
No doubt such apps could be fixed, but the cost/benefit ratio
just doesn't seem all that attractive.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Mats Kindahl 2026-05-25 18:59:47 Re: pg_rewind does not rewind diverging timelines
Previous Message Lukas Fittl 2026-05-25 18:43:43 Re: RFC: Allow EXPLAIN to Output Page Fault Information