Re: BUG #19629: pg_restore_relation_stats reports XX000 instead of proper SQLSTATE for input validation errors - Mailing list pgsql-bugs

From Alexander Lakhin
Subject Re: BUG #19629: pg_restore_relation_stats reports XX000 instead of proper SQLSTATE for input validation errors
Date
Msg-id bea2e8a5-4d84-4ecf-9433-470fc356ef9f@gmail.com
Whole thread
List pgsql-bugs
Hello,

21.08.2026 11:41, Fujii Masao wrote:
> On Fri, Aug 21, 2026 at 7:30 AM Michael Paquier <michael@paquier.xyz> wrote:
>> Adding an errcode() is a life improvement thing.  So, while I agree
>> that the proposed patch is an improvement, I don't see a strong need
>> for a backpatch.  Feel free to override this argument as you feel, of
>> course.
> I understand your point, but I'm inclined to backpatch this to v18.
>
> These are input-validation errors that are directly reachable from SQL,
> and the SQLSTATE is exposed to applications. Since applications commonly
> branch on SQLSTATE, reporting XX000 makes these errors look like internal
> errors rather than invalid input. That seems more like a bug than
> a cosmetic improvement to me.
>
>> I'd suggest to keep things isolated in their own fashion, as they
>> address different areas with slightly different user-changes changes
>> (okay, not much).

FWIW, I have my own collection of XX000 errors that can be reached by
users. I see there are distinct bug reports following this one, but I
guess, it won't be convenient to process dozens of such reports (if I
add mine). Maybe it would make sense to create a wiki page to
enumerate all these legally reachable internal errors (probably some of
them would stay as-is)...

What do you think?

Just a couple of examples to be concrete:
do $$ #print_strict_params XXX $$;
ERROR:  XX000: unrecognized print_strict_params option xxx

select pg_catalog.range_in('', 23, 0);
ERROR:  XX000: type 23 is not a range type

Best regards,
Alexander



pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #19638: Planner chooses an index-only scan for an index AM without amcanreturn, and execution fails
Next
From: Andrey Rachitskiy
Date:
Subject: Re: BUG #19638: Planner chooses an index-only scan for an index AM without amcanreturn, and execution fails