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: 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 15:22:15
Message-ID: CAHGQGwHZLiLa9iM7NAiugp1B7CumN94=YBeho9t=qKJMnTGwMQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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?

Regards,

--
Fujii Masao

Attachment Content-Type Size
v1-v18-0001-Report-specific-SQLSTATEs-for-stats-restore-error.txt text/plain 3.1 KB
v1-0001-Report-specific-SQLSTATEs-for-stats-restore-error.patch application/octet-stream 2.8 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Ayush Tiwari 2026-08-19 16:12:18 Re: BUG #19629: pg_restore_relation_stats reports XX000 instead of proper SQLSTATE for input validation errors
Previous Message Alexander Korotkov 2026-08-19 11:58:10 Re: MERGE/SPLIT PARTITIONS issues/questions