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

From: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: 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-19 16:12:18
Message-ID: CAJTYsWX8WYhEC-A92cfDGSUxOZmk474_knCnwYmUiXELQnPtGA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

On Wed, 19 Aug 2026 at 20:52, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:

> On Wed, Aug 19, 2026 at 6:24 PM PG Bug reporting form
> <noreply(at)postgresql(dot)org> wrote:
> > Suggested fix: add errcode() to each ereport call
> > (ERRCODE_INVALID_PARAMETER_VALUE,
> > ERRCODE_NULL_VALUE_NOT_ALLOWED, ERRCODE_DATATYPE_MISMATCH
> respectively).
>
> Thanks for the report and suggestion!
>
> I agree that these errors should not be reported with SQLSTATE XX000.
> Attached is a patch that assigns specific SQLSTATEs to these cases.
>
> The first three use the error codes you suggested. For the fourth case,
> "maximum number of statistics slots exceeded", I used
> ERRCODE_PROGRAM_LIMIT_EXCEEDED rather than
> ERRCODE_INVALID_PARAMETER_VALUE. This is caused by PostgreSQL's fixed
> limit on pg_statistic slots, so PROGRAM_LIMIT_EXCEEDED seemed more
> appropriate.
>
> I think this should be backpatched to v18, where
> pg_restore_relation_stats() and pg_restore_attribute_stats() were
> introduced.
>
> Thought?
>

Thanks for the patch, Fujii-san!

I had posted a patch for all the three related bugs at [0]

Found some more places where the issue exists and added
there. Maybe you can incorporate those too in your patch?

Regards,
Ayush

[0]
https://www.postgresql.org/message-id/CAJTYsWWpwHsvzKp0JPvGbWttXrOafMCtmGBBQs6bhCKn88fgug%40mail.gmail.com

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Srinath Reddy Sadipiralla 2026-08-19 16:16:55 Re: repack with verbose output: not showing the number of removable row versions when using USING INDEX or CONCURRENTLY option
Previous Message Fujii Masao 2026-08-19 15:22:15 Re: BUG #19629: pg_restore_relation_stats reports XX000 instead of proper SQLSTATE for input validation errors