Re: BUG #19629: pg_restore_relation_stats reports XX000 instead of proper SQLSTATE for input validation errors

From: Alexander Lakhin <exclusion(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>, hackerzheng666(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19629: pg_restore_relation_stats reports XX000 instead of proper SQLSTATE for input validation errors
Date: 2026-08-24 12:00:01
Message-ID: bea2e8a5-4d84-4ecf-9433-470fc356ef9f@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello,

21.08.2026 11:41, Fujii Masao wrote:
> On Fri, Aug 21, 2026 at 7:30 AM Michael Paquier <michael(at)paquier(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Daniel Gustafsson 2026-08-24 12:31:07 Re: autovacuum: automatically propagate updated parameters
Previous Message Ewan Young 2026-08-24 11:20:42 Re: BUG #19595: Three memory-safety defects in src/backend/tsearch/spell.c (dictionary loader), PG 18.3