Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc166454

Browse files
committed
Improve error message for database object stats manipulation functions.
Previously, database object statistics manipulation functions likepg_set_relation_stats() reported unclear error and hint messageswhen 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 functionsare 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 explicitlyclarify that these functions are not available during recovery.Author: Fujii MasaoReviewed-by: Heikki Linnakangas, Maxim OrlovDiscussion:https://postgr.es/m/6d313829-5f56-4a28-ae4b-bd01bf1ae791@oss.nttdata.com
1 parenta3699da commitc166454

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

‎doc/src/sgml/func.sgml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30029,6 +30029,7 @@ postgres=# SELECT '0/0'::pg_lsn + pd.segment_number * ps.setting::int + :offset
3002930029
<para>
3003030030
<xref linkend="functions-admin-statsmod"/> lists functions used to
3003130031
manipulate statistics.
30032+
These functions cannot be executed during recovery.
3003230033
<warning>
3003330034
<para>
3003430035
Changes made by these statistics manipulation functions are likely to be

‎src/backend/statistics/attribute_stats.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ attribute_statistics_update(FunctionCallInfo fcinfo, int elevel)
155155
stats_check_required_arg(fcinfo,attarginfo,ATTRELATION_ARG);
156156
reloid=PG_GETARG_OID(ATTRELATION_ARG);
157157

158+
if (RecoveryInProgress())
159+
ereport(ERROR,
160+
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
161+
errmsg("recovery is in progress"),
162+
errhint("Statistics cannot be modified during recovery.")));
163+
158164
/* lock before looking up attribute */
159165
stats_lock_check_privileges(reloid);
160166

@@ -865,6 +871,12 @@ pg_clear_attribute_stats(PG_FUNCTION_ARGS)
865871
stats_check_required_arg(fcinfo,attarginfo,ATTRELATION_ARG);
866872
reloid=PG_GETARG_OID(ATTRELATION_ARG);
867873

874+
if (RecoveryInProgress())
875+
ereport(ERROR,
876+
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
877+
errmsg("recovery is in progress"),
878+
errhint("Statistics cannot be modified during recovery.")));
879+
868880
stats_lock_check_privileges(reloid);
869881

870882
stats_check_required_arg(fcinfo,attarginfo,ATTNAME_ARG);

‎src/backend/statistics/relation_stats.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ relation_statistics_update(FunctionCallInfo fcinfo, int elevel)
7272
stats_check_required_arg(fcinfo,relarginfo,RELATION_ARG);
7373
reloid=PG_GETARG_OID(RELATION_ARG);
7474

75+
if (RecoveryInProgress())
76+
ereport(ERROR,
77+
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
78+
errmsg("recovery is in progress"),
79+
errhint("Statistics cannot be modified during recovery.")));
80+
7581
stats_lock_check_privileges(reloid);
7682

7783
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp