assert_mdwritev.patch
text/x-diff
Filename: assert_mdwritev.patch
Type: text/x-diff
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/backend/storage/smgr/md.c | 8 | 2 |
diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
index 6796756358..3849397b25 100644
--- a/src/backend/storage/smgr/md.c
+++ b/src/backend/storage/smgr/md.c
@@ -28,6 +28,7 @@
#include "access/xlogutils.h"
#include "commands/tablespace.h"
#include "common/file_utils.h"
+#include "common/int.h"
#include "miscadmin.h"
#include "pg_trace.h"
#include "pgstat.h"
@@ -929,8 +930,13 @@ mdwritev(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
const void **buffers, BlockNumber nblocks, bool skipFsync)
{
/* This assert is too expensive to have on normally ... */
-#ifdef CHECK_WRITE_VS_EXTEND
- Assert((uint64) blocknum + (uint64) nblocks <= (uint64) mdnblocks(reln, forknum));
+#if defined(USE_ASSERT_CHECKING) && defined(CHECK_WRITE_VS_EXTEND)
+ uint32 tot_blocks;
+
+ if (pg_add_u32_overflow(blocknum, nblocks, &tot_blocks))
+ Assert(false);
+
+ Assert(tot_blocks <= mdnblocks(reln, forknum));
#endif
while (nblocks > 0)