diff options
author | Andres Freund <andres@anarazel.de> | 2025-03-18 13:43:10 -0400 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2025-03-18 14:04:44 -0400 |
commit | 499faf9063a4c5a9985d7ac657b86e8e34e02199 (patch) | |
tree | b128ef16b08f98e111eb875406e48aa33bf067a9 /src | |
parent | 62d712ecfd940f60e68bde5b6972b6859937c412 (diff) | |
download | postgresql-499faf9063a4c5a9985d7ac657b86e8e34e02199.tar.gz postgresql-499faf9063a4c5a9985d7ac657b86e8e34e02199.zip |
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 21d9c3ee4ef7, in 17.
Discussion: https://postgr.es/m/3vae7l5ozvqtxmd7rr7zaeq3qkuipz365u3rtim5t5wdkr6f4g@vkgf2fogjirl
Backpatch-through: 17
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/storage/smgr/smgr.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/backend/storage/smgr/smgr.c b/src/backend/storage/smgr/smgr.c index ebe35c04de5..e6cbb9b4ca2 100644 --- a/src/backend/storage/smgr/smgr.c +++ b/src/backend/storage/smgr/smgr.c @@ -234,12 +234,12 @@ smgropen(RelFileLocator rlocator, ProcNumber backend) reln->smgr_cached_nblocks[i] = InvalidBlockNumber; 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 */ reln->pincount = 0; dlist_push_tail(&unpinned_relns, &reln->node); + + /* implementation-specific initialization */ + smgrsw[reln->smgr_which].smgr_open(reln); } return reln; |