Skip to content

Commit 499faf9

Browse files
committed
smgr: Make SMgrRelation initialization safer against errors
In case the smgr_open callback failed, the ->pincount field would not be initialized and the relation would not be put onto the unpinned_relns list. This buglet was introduced in 21d9c3e, in 17. Discussion: https://postgr.es/m/3vae7l5ozvqtxmd7rr7zaeq3qkuipz365u3rtim5t5wdkr6f4g@vkgf2fogjirl Backpatch-through: 17
1 parent 62d712e commit 499faf9

File tree

1 file changed

+3
-3
lines changed
  • src/backend/storage/smgr

1 file changed

+3
-3
lines changed

src/backend/storage/smgr/smgr.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,12 @@ smgropen(RelFileLocator rlocator, ProcNumber backend)
234234
reln->smgr_cached_nblocks[i] = InvalidBlockNumber;
235235
reln->smgr_which = 0; /* we only have md.c at present */
236236

237-
/* implementation-specific initialization */
238-
smgrsw[reln->smgr_which].smgr_open(reln);
239-
240237
/* it is not pinned yet */
241238
reln->pincount = 0;
242239
dlist_push_tail(&unpinned_relns, &reln->node);
240+
241+
/* implementation-specific initialization */
242+
smgrsw[reln->smgr_which].smgr_open(reln);
243243
}
244244

245245
return reln;

0 commit comments

Comments
 (0)