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

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: 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-25 05:14:25
Message-ID: CAHGQGwEVQiNN_niHrDsmaxricO6gqVCFP4gfhYTc_etXz6yB5Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Aug 21, 2026 at 5:41 PM Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
> 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.
>
> Also, these functions were introduced in v18, so the risk of breaking
> existing applications that depend on the current XX000 behavior should
> be low. For these reasons, I think backpatching to v18 is preferable here.
> Thoughts?
>
> But, on the other hand, if we want to avoid breaking existing
> applications that depend on the current XX000 behavior, backpatching
> to v19 might be a reasonable alternative.

I found a similar precedent in commit 89e80b032975. It also changed
user-visible SQLSTATEs from XX000 to more appropriate error codes,
but was backpatched only to v9.5, which had not been released yet
at the time. The commit message says:

Back-patch to 9.5, but no further; changing ERRCODE assignments in
stable branches doesn't seem like a good idea.

Following that, I am now inclined to backpatch this only to v19, and
not to v18.

Regards,

--
Fujii Masao

In response to

Browse pgsql-bugs by date

  From Date Subject
Previous Message Rahila Syed 2026-08-25 04:30:16 Re: SIGSEGV in dynahash