Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf37ff03

Browse files
committed
Refactor confusing code in _mdfd_openseg().
As reported independently by a couple of people, _mdfd_openseg() is coded in away that seems to imply that the segments could be opened in an order thatisn't strictly sequential. Even if that were true, it's also using the wrongcomparison. It's not an active bug, since the condition is always true anyway,but it's confusing, so replace it with an assertion.Author: Thomas MunroReviewed-by: Andres Freund, Kyotaro Horiguchi, Noah MischDiscussion:https://postgr.es/m/CA%2BhUKG%2BNBw%2BuSzxF1os-SO6gUuw%3DcqO5DAybk6KnHKzgGvxhxA%40mail.gmail.comDiscussion:https://postgr.es/m/20191222091930.GA1280238%40rfd.leadboat.com
1 parent215824f commitf37ff03

File tree

1 file changed

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

1 file changed

+7
-2
lines changed

‎src/backend/storage/smgr/md.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,8 +1100,13 @@ _mdfd_openseg(SMgrRelation reln, ForkNumber forknum, BlockNumber segno,
11001100
if (fd<0)
11011101
returnNULL;
11021102

1103-
if (segno <=reln->md_num_open_segs[forknum])
1104-
_fdvec_resize(reln,forknum,segno+1);
1103+
/*
1104+
* Segments are always opened in order from lowest to highest, so we must
1105+
* be adding a new one at the end.
1106+
*/
1107+
Assert(segno==reln->md_num_open_segs[forknum]);
1108+
1109+
_fdvec_resize(reln,forknum,segno+1);
11051110

11061111
/* fill the entry */
11071112
v=&reln->md_seg_fds[forknum][segno];

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp