Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 490cb5d

Browse files
committed
Merge rejected patch
1 parent 317f76c commit 490cb5d

File tree

1 file changed

+8
-2
lines changed
  • src/backend/storage/smgr

1 file changed

+8
-2
lines changed

src/backend/storage/smgr/md.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,12 +814,18 @@ mdwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
814814
BlockNumber
815815
mdnblocks(SMgrRelation reln, ForkNumber forknum)
816816
{
817-
MdfdVec *v = mdopenfork(reln, forknum, EXTENSION_FAIL);
817+
/*
818+
* If we access session relation, there may be no files yet of this relation for this backend.
819+
* Pass EXTENSION_RETURN_NULL to make mdopen return NULL in this case instead of reporting error.
820+
*/
821+
MdfdVec *v = mdopenfork(reln, forknum, RelFileNodeBackendIsGlobalTemp(reln->smgr_rnode)
822+
? EXTENSION_RETURN_NULL : EXTENSION_FAIL);
818823
BlockNumber nblocks;
819824
BlockNumber segno = 0;
820825

821826
/* mdopen has opened the first segment */
822-
Assert(reln->md_num_open_segs[forknum] > 0);
827+
if (reln->md_num_open_segs[forknum] == 0)
828+
return 0;
823829

824830
/*
825831
* Start from the last open segments, to avoid redundant seeks. We have

0 commit comments

Comments
 (0)