1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-03 20:02:46 +03:00

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 21d9c3ee4e, in 17.

Discussion: https://postgr.es/m/3vae7l5ozvqtxmd7rr7zaeq3qkuipz365u3rtim5t5wdkr6f4g@vkgf2fogjirl
Backpatch-through: 17
This commit is contained in:
Andres Freund
2025-03-18 13:43:10 -04:00
parent 62d712ecfd
commit 499faf9063

View File

@ -234,12 +234,12 @@ smgropen(RelFileLocator rlocator, ProcNumber backend)
reln->smgr_cached_nblocks[i] = InvalidBlockNumber; reln->smgr_cached_nblocks[i] = InvalidBlockNumber;
reln->smgr_which = 0; /* we only have md.c at present */ reln->smgr_which = 0; /* we only have md.c at present */
/* implementation-specific initialization */
smgrsw[reln->smgr_which].smgr_open(reln);
/* it is not pinned yet */ /* it is not pinned yet */
reln->pincount = 0; reln->pincount = 0;
dlist_push_tail(&unpinned_relns, &reln->node); dlist_push_tail(&unpinned_relns, &reln->node);
/* implementation-specific initialization */
smgrsw[reln->smgr_which].smgr_open(reln);
} }
return reln; return reln;