Improve error message for database object stats manipulation functions.
commitc166454496876818216e222890ab1ae788551c42
authorFujii Masao <fujii@postgresql.org>
Tue, 19 Nov 2024 17:00:50 +0000 (20 02:00 +0900)
committerFujii Masao <fujii@postgresql.org>
Tue, 19 Nov 2024 17:00:50 +0000 (20 02:00 +0900)
tree9f4dad53c3d90270de39edd797bf34c246d20625
parenta3699daea2026de324ed7cc7115c36d3499010d3
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
doc/src/sgml/func.sgml
src/backend/statistics/attribute_stats.c
src/backend/statistics/relation_stats.c