pgsql: Report specific SQLSTATEs for stats restore errors

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Report specific SQLSTATEs for stats restore errors
Date: 2026-08-27 14:43:09
Message-ID: E1wzbJs-00000002LsX-0TNm@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Report specific SQLSTATEs for stats restore errors

The pg_restore_*_stats() functions could report SQLSTATE XX000 for
invalid variadic arguments, such as an unmatched name/value pair, a NULL
argument name, or a non-text argument name. Attribute and extended
statistics restores could also report XX000 when the supplied statistics
exceed the number of slots PostgreSQL can store.

These are not internal errors. They result from invalid caller input or
a PostgreSQL implementation limit, but the lack of specific SQLSTATEs
made clients treat them as internal errors.

Assign appropriate SQLSTATEs to these errors so that applications and
tests can classify them correctly.

Backpatch to v19, but no further; changing ERRCODE assignments in
released stable branches doesn't seem like a good idea.

Bug: #19629
Reported-by: Zheng Wang <hackerzheng666(at)gmail(dot)com>
Reported-by: Yanjie Zhao
Reported-by: Yiyang Liu
Author: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Discussion: https://postgr.es/m/19629-76babc04b683594d@postgresql.org
Backpatch-through: 19

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/398a6bdd933e2fe8ce8589ac728f649d1b70b3e4

Modified Files
--------------
src/backend/statistics/stat_utils.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2026-08-27 14:43:23 pgsql: Report specific SQLSTATEs for stats restore errors
Previous Message Heikki Linnakangas 2026-08-27 12:06:35 pgsql: Don't create a shell type for function returning an array