Skip to content

Commit 3b5f4f1

Browse files
committed
Fail BRIN control functions during recovery explicitly
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
1 parent 476ba1e commit 3b5f4f1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/backend/access/brin/brin.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,12 @@ brin_summarize_range(PG_FUNCTION_ARGS)
868868
Relation heapRel;
869869
double numSummarized = 0;
870870

871+
if (RecoveryInProgress())
872+
ereport(ERROR,
873+
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
874+
errmsg("recovery is in progress"),
875+
errhint("BRIN control functions cannot be executed during recovery.")));
876+
871877
if (heapBlk64 > BRIN_ALL_BLOCKRANGES || heapBlk64 < 0)
872878
{
873879
char *blk = psprintf(INT64_FORMAT, heapBlk64);
@@ -939,6 +945,12 @@ brin_desummarize_range(PG_FUNCTION_ARGS)
939945
Relation indexRel;
940946
bool done;
941947

948+
if (RecoveryInProgress())
949+
ereport(ERROR,
950+
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
951+
errmsg("recovery is in progress"),
952+
errhint("BRIN control functions cannot be executed during recovery.")));
953+
942954
if (heapBlk64 > MaxBlockNumber || heapBlk64 < 0)
943955
{
944956
char *blk = psprintf(INT64_FORMAT, heapBlk64);

0 commit comments

Comments
 (0)