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

Commit f04d1c1

Browse files
committed
Improve assertion in mdwritev()
The assertion used at the beginning of mdwritev(), that is not enabled except by defining -DCHECK_WRITE_VS_EXTEND as mdnblocks() is costly, forgot about the total number of blocks to write at location specified by the caller. The calculation is fixed to count for that, and uses casts to uint64 to ensure a proper check should the number of blocks overflow. Using a cast is a suggestion from Tom Lane. Oversight in 4908c58. Author: Xing Guo Discussion: https://postgr.es/m/CACpMh+BM-VgKeO7suPG-VHTtpzJ+zsbDPwVHu42PLp-iTk0z+A@mail.gmail.com
1 parent 4ebe51a commit f04d1c1

File tree

1 file changed

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

1 file changed

+1
-1
lines changed

src/backend/storage/smgr/md.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ mdwritev(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
930930
{
931931
/* This assert is too expensive to have on normally ... */
932932
#ifdef CHECK_WRITE_VS_EXTEND
933-
Assert(blocknum < mdnblocks(reln, forknum));
933+
Assert((uint64) blocknum + (uint64) nblocks <= (uint64) mdnblocks(reln, forknum));
934934
#endif
935935

936936
while (nblocks > 0)

0 commit comments

Comments
 (0)