pgsql: Improve error message for database object stats manipulation fun

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Improve error message for database object stats manipulation fun
Date: 2024-11-19 17:02:16
Message-ID: E1tDRcG-002aOj-7m@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Improve error message for database object stats manipulation functions.

Previously, database object statistics manipulation functions like
pg_set_relation_stats() reported unclear error and hint messages
when executed during recovery. These messages were "internal",
making it difficult for users to understand the issue:

ERROR: cannot acquire lock mode ShareUpdateExclusiveLock on database objects while recovery is in progress
HINT: Only RowExclusiveLock or less can be acquired on database objects during recovery.

This commit updates the error handling so that, if these functions
are called during recovery, they produce clearer messages:

ERROR: recovery is in progress
HINT: Statistics cannot be modified during recovery.

The related documentation has also been updated to explicitly
clarify that these functions are not available during recovery.

Author: Fujii Masao
Reviewed-by: Heikki Linnakangas, Maxim Orlov
Discussion: https://postgr.es/m/6d313829-5f56-4a28-ae4b-bd01bf1ae791@oss.nttdata.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/c166454496876818216e222890ab1ae788551c42

Modified Files
--------------
doc/src/sgml/func.sgml | 1 +
src/backend/statistics/attribute_stats.c | 12 ++++++++++++
src/backend/statistics/relation_stats.c | 6 ++++++
3 files changed, 19 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message noreply 2024-11-19 22:10:47 pgsql: Tag refs/tags/REL_16_6 was created
Previous Message Michael Paquier 2024-11-19 04:28:38 pgsql: libpq: Improve error message when parsing URI parameters and key