From e951f66deadbe78da83b2d1919d39883d098fdff Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Thu, 14 Jun 2018 12:51:32 -0400 Subject: [PATCH] Fail BRIN control functions during recovery explicitly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit They already fail anyway, but prior to this patch they raise an ugly error message about a lock that cannot be acquired. This just improves the message. Author: Masahiko Sawada Reported-by: Masahiko Sawada Discussion: https://postgr.es/m/CAD21AoBZau4g4_NUf3BKNd=CdYK+xaPdtJCzvOC1TxGdTiJx_Q@mail.gmail.com Reviewed-by: Kuntal Ghosh, Alexander Korotkov, Simon Riggs, Michaël Paquier, Álvaro Herrera --- src/backend/access/brin/brin.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/backend/access/brin/brin.c b/src/backend/access/brin/brin.c index 706b3ee824..ee1c4cc4f1 100644 --- a/src/backend/access/brin/brin.c +++ b/src/backend/access/brin/brin.c @@ -788,6 +788,12 @@ brin_summarize_new_values(PG_FUNCTION_ARGS) Relation heapRel; double numSummarized = 0; + if (RecoveryInProgress()) + ereport(ERROR, + (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("recovery is in progress"), + errhint("BRIN control functions cannot be executed during recovery."))); + /* * We must lock table before index to avoid deadlocks. However, if the * passed indexoid isn't an index then IndexGetRelation() will fail.