pgsql: Improve SQLSTATE reporting for several error conditions

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Improve SQLSTATE reporting for several error conditions
Date: 2026-11-24 11:44:51
Message-ID: E1xVox8-000000008Uw-2YAu@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Improve SQLSTATE reporting for several error conditions

currtid2() could report internal_error for unsupported views, such as
those grouping by ctid. These are valid views that the function cannot
handle, so use the more appropriate feature_not_supported, matching
the other unsupported-view checks.

Assign appropriate SQLSTATEs to several other errors involving
non-UTF8 server encodings, control file CRC mismatches, invalid GiST
tuples, and attempts to refresh the default collation's version.
Also replace syntax_error with feature_not_supported for the encoding
checks in Unicode normalization and case folding, since these reject
an unsupported database encoding rather than invalid SQL syntax.

Do not backpatch, to avoid changing SQLSTATEs in released branches.

Bug: #19631
Reported-by: Zheng Wang <hackerzheng666(at)gmail(dot)com>
Reported-by: Yanjie Zhao
Reported-by: Yiyang Liu
Author: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
Reviewed-by: Pierre Forstmann <pierre(dot)forstmann(at)gmail(dot)com>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Discussion: https://postgr.es/m/19631-b443dd6cd8d4e40b@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/9ebc9a458c38465cd9609814cfc9ca3a2f46fef5

Modified Files
--------------
src/backend/access/gist/gist.c | 3 ++-
src/backend/backup/basebackup.c | 3 ++-
src/backend/commands/collationcmds.c | 3 ++-
src/backend/utils/adt/formatting.c | 2 +-
src/backend/utils/adt/tid.c | 4 +++-
src/backend/utils/adt/varlena.c | 5 +++--
src/backend/utils/misc/pg_controldata.c | 12 ++++++++----
7 files changed, 21 insertions(+), 11 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Previous Message Amit Kapila 2026-11-24 11:41:51 pgsql: Record logical replication conflicts in the conflict log table.