index-only-scan.patch
application/octet-stream
Filename: index-only-scan.patch
Type: application/octet-stream
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/access/heap/visibilitymap.c | 0 | 0 |
diff --git a/src/backend/access/heap/visibilitymap.c b/src/backend/access/heap/visibilitymap.c
new file mode 100644
index 76b3a46..472b780
*** a/src/backend/access/heap/visibilitymap.c
--- b/src/backend/access/heap/visibilitymap.c
***************
*** 88,93 ****
--- 88,94 ----
#include "storage/bufmgr.h"
#include "storage/lmgr.h"
#include "storage/smgr.h"
+ #include "utils/inval.h"
/*#define TRACE_VISIBILITYMAP */
*************** vm_readbuf(Relation rel, BlockNumber blk
*** 486,497 ****
/*
* If we haven't cached the size of the visibility map fork yet, check it
! * first. Also recheck if the requested block seems to be past end, since
! * our cached value might be stale. (We send smgr inval messages on
! * truncation, but not on extension.)
*/
! if (rel->rd_smgr->smgr_vm_nblocks == InvalidBlockNumber ||
! blkno >= rel->rd_smgr->smgr_vm_nblocks)
{
if (smgrexists(rel->rd_smgr, VISIBILITYMAP_FORKNUM))
rel->rd_smgr->smgr_vm_nblocks = smgrnblocks(rel->rd_smgr,
--- 487,497 ----
/*
* If we haven't cached the size of the visibility map fork yet, check it
! * first. This will also catch any changes to the visibility map's size
! * made by other backends, since we send smgr inval messages on create,
! * extend and truncate.
*/
! if (rel->rd_smgr->smgr_vm_nblocks == InvalidBlockNumber)
{
if (smgrexists(rel->rd_smgr, VISIBILITYMAP_FORKNUM))
rel->rd_smgr->smgr_vm_nblocks = smgrnblocks(rel->rd_smgr,
*************** vm_extend(Relation rel, BlockNumber vm_n
*** 560,565 ****
--- 560,575 ----
vm_nblocks_now = smgrnblocks(rel->rd_smgr, VISIBILITYMAP_FORKNUM);
+ /*
+ * Send a shared-inval message to force other backends to close any smgr
+ * references they may have for this rel, which we are about to change.
+ * This is a useful optimization because it means that backends don't have
+ * to keep checking for creation or extension of the file, which happens
+ * infrequently.
+ */
+ CacheInvalidateSmgr(rel->rd_smgr->smgr_rnode);
+
+ /* Now extend the file */
while (vm_nblocks_now < vm_nblocks)
{
smgrextend(rel->rd_smgr, VISIBILITYMAP_FORKNUM, vm_nblocks_now,