mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Remove PageSetTLI and rename pd_tli to pd_checksum
Remove use of PageSetTLI() from all page manipulation functions and adjust README to indicate change in the way we make changes to pages. Repurpose those bytes into the pd_checksum field and explain how that works in comments about page header. Refactoring ahead of actual feature patch which would make use of the checksum field, arriving later. Jeff Davis, with comments and doc changes by Simon Riggs Direction suggested by Robert Haas; many others providing review comments.
This commit is contained in:
@@ -858,11 +858,9 @@ _bt_insertonpg(Relation rel,
|
||||
if (BufferIsValid(metabuf))
|
||||
{
|
||||
PageSetLSN(metapg, recptr);
|
||||
PageSetTLI(metapg, ThisTimeLineID);
|
||||
}
|
||||
|
||||
PageSetLSN(page, recptr);
|
||||
PageSetTLI(page, ThisTimeLineID);
|
||||
}
|
||||
|
||||
END_CRIT_SECTION();
|
||||
@@ -946,7 +944,6 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright,
|
||||
* examine these fields and possibly dump them in a page image.
|
||||
*/
|
||||
PageSetLSN(leftpage, PageGetLSN(origpage));
|
||||
PageSetTLI(leftpage, PageGetTLI(origpage));
|
||||
|
||||
/* init btree private data */
|
||||
oopaque = (BTPageOpaque) PageGetSpecialPointer(origpage);
|
||||
@@ -1319,13 +1316,10 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright,
|
||||
recptr = XLogInsert(RM_BTREE_ID, xlinfo, rdata);
|
||||
|
||||
PageSetLSN(origpage, recptr);
|
||||
PageSetTLI(origpage, ThisTimeLineID);
|
||||
PageSetLSN(rightpage, recptr);
|
||||
PageSetTLI(rightpage, ThisTimeLineID);
|
||||
if (!P_RIGHTMOST(ropaque))
|
||||
{
|
||||
PageSetLSN(spage, recptr);
|
||||
PageSetTLI(spage, ThisTimeLineID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1961,9 +1955,7 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
|
||||
recptr = XLogInsert(RM_BTREE_ID, XLOG_BTREE_NEWROOT, rdata);
|
||||
|
||||
PageSetLSN(rootpage, recptr);
|
||||
PageSetTLI(rootpage, ThisTimeLineID);
|
||||
PageSetLSN(metapg, recptr);
|
||||
PageSetTLI(metapg, ThisTimeLineID);
|
||||
}
|
||||
|
||||
END_CRIT_SECTION();
|
||||
|
@@ -241,9 +241,7 @@ _bt_getroot(Relation rel, int access)
|
||||
recptr = XLogInsert(RM_BTREE_ID, XLOG_BTREE_NEWROOT, &rdata);
|
||||
|
||||
PageSetLSN(rootpage, recptr);
|
||||
PageSetTLI(rootpage, ThisTimeLineID);
|
||||
PageSetLSN(metapg, recptr);
|
||||
PageSetTLI(metapg, ThisTimeLineID);
|
||||
}
|
||||
|
||||
END_CRIT_SECTION();
|
||||
@@ -534,8 +532,8 @@ _bt_log_reuse_page(Relation rel, BlockNumber blkno, TransactionId latestRemovedX
|
||||
START_CRIT_SECTION();
|
||||
|
||||
/*
|
||||
* We don't do MarkBufferDirty here because we're about initialise the
|
||||
* page, and nobody else can see it yet.
|
||||
* We don't do MarkBufferDirty here because we're about to initialise
|
||||
* the page, and nobody else can see it yet.
|
||||
*/
|
||||
|
||||
/* XLOG stuff */
|
||||
@@ -554,8 +552,8 @@ _bt_log_reuse_page(Relation rel, BlockNumber blkno, TransactionId latestRemovedX
|
||||
XLogInsert(RM_BTREE_ID, XLOG_BTREE_REUSE_PAGE, rdata);
|
||||
|
||||
/*
|
||||
* We don't do PageSetLSN or PageSetTLI here because we're about
|
||||
* initialise the page, so no need.
|
||||
* We don't do PageSetLSN here because we're about to initialise
|
||||
* the page, so no need.
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -863,7 +861,6 @@ _bt_delitems_vacuum(Relation rel, Buffer buf,
|
||||
recptr = XLogInsert(RM_BTREE_ID, XLOG_BTREE_VACUUM, rdata);
|
||||
|
||||
PageSetLSN(page, recptr);
|
||||
PageSetTLI(page, ThisTimeLineID);
|
||||
}
|
||||
|
||||
END_CRIT_SECTION();
|
||||
@@ -951,7 +948,6 @@ _bt_delitems_delete(Relation rel, Buffer buf,
|
||||
recptr = XLogInsert(RM_BTREE_ID, XLOG_BTREE_DELETE, rdata);
|
||||
|
||||
PageSetLSN(page, recptr);
|
||||
PageSetTLI(page, ThisTimeLineID);
|
||||
}
|
||||
|
||||
END_CRIT_SECTION();
|
||||
@@ -1533,22 +1529,17 @@ _bt_pagedel(Relation rel, Buffer buf, BTStack stack)
|
||||
if (BufferIsValid(metabuf))
|
||||
{
|
||||
PageSetLSN(metapg, recptr);
|
||||
PageSetTLI(metapg, ThisTimeLineID);
|
||||
}
|
||||
page = BufferGetPage(pbuf);
|
||||
PageSetLSN(page, recptr);
|
||||
PageSetTLI(page, ThisTimeLineID);
|
||||
page = BufferGetPage(rbuf);
|
||||
PageSetLSN(page, recptr);
|
||||
PageSetTLI(page, ThisTimeLineID);
|
||||
page = BufferGetPage(buf);
|
||||
PageSetLSN(page, recptr);
|
||||
PageSetTLI(page, ThisTimeLineID);
|
||||
if (BufferIsValid(lbuf))
|
||||
{
|
||||
page = BufferGetPage(lbuf);
|
||||
PageSetLSN(page, recptr);
|
||||
PageSetTLI(page, ThisTimeLineID);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -276,11 +276,6 @@ _bt_blwritepage(BTWriteState *wstate, Page page, BlockNumber blkno)
|
||||
/* We use the heap NEWPAGE record type for this */
|
||||
log_newpage(&wstate->index->rd_node, MAIN_FORKNUM, blkno, page);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Leave the page LSN zero if not WAL-logged, but set TLI anyway */
|
||||
PageSetTLI(page, ThisTimeLineID);
|
||||
}
|
||||
|
||||
/*
|
||||
* If we have to write pages nonsequentially, fill in the space with
|
||||
|
@@ -186,7 +186,6 @@ _bt_restore_meta(RelFileNode rnode, XLogRecPtr lsn,
|
||||
((char *) md + sizeof(BTMetaPageData)) - (char *) metapg;
|
||||
|
||||
PageSetLSN(metapg, lsn);
|
||||
PageSetTLI(metapg, ThisTimeLineID);
|
||||
MarkBufferDirty(metabuf);
|
||||
UnlockReleaseBuffer(metabuf);
|
||||
}
|
||||
@@ -241,7 +240,6 @@ btree_xlog_insert(bool isleaf, bool ismeta,
|
||||
elog(PANIC, "btree_insert_redo: failed to add item");
|
||||
|
||||
PageSetLSN(page, lsn);
|
||||
PageSetTLI(page, ThisTimeLineID);
|
||||
MarkBufferDirty(buffer);
|
||||
UnlockReleaseBuffer(buffer);
|
||||
}
|
||||
@@ -358,7 +356,6 @@ btree_xlog_split(bool onleft, bool isroot,
|
||||
}
|
||||
|
||||
PageSetLSN(rpage, lsn);
|
||||
PageSetTLI(rpage, ThisTimeLineID);
|
||||
MarkBufferDirty(rbuf);
|
||||
|
||||
/* don't release the buffer yet; we touch right page's first item below */
|
||||
@@ -430,7 +427,6 @@ btree_xlog_split(bool onleft, bool isroot,
|
||||
lopaque->btpo_cycleid = 0;
|
||||
|
||||
PageSetLSN(lpage, lsn);
|
||||
PageSetTLI(lpage, ThisTimeLineID);
|
||||
MarkBufferDirty(lbuf);
|
||||
}
|
||||
|
||||
@@ -466,7 +462,6 @@ btree_xlog_split(bool onleft, bool isroot,
|
||||
pageop->btpo_prev = xlrec->rightsib;
|
||||
|
||||
PageSetLSN(page, lsn);
|
||||
PageSetTLI(page, ThisTimeLineID);
|
||||
MarkBufferDirty(buffer);
|
||||
}
|
||||
UnlockReleaseBuffer(buffer);
|
||||
@@ -563,7 +558,6 @@ btree_xlog_vacuum(XLogRecPtr lsn, XLogRecord *record)
|
||||
opaque->btpo_flags &= ~BTP_HAS_GARBAGE;
|
||||
|
||||
PageSetLSN(page, lsn);
|
||||
PageSetTLI(page, ThisTimeLineID);
|
||||
MarkBufferDirty(buffer);
|
||||
UnlockReleaseBuffer(buffer);
|
||||
}
|
||||
@@ -780,7 +774,6 @@ btree_xlog_delete(XLogRecPtr lsn, XLogRecord *record)
|
||||
opaque->btpo_flags &= ~BTP_HAS_GARBAGE;
|
||||
|
||||
PageSetLSN(page, lsn);
|
||||
PageSetTLI(page, ThisTimeLineID);
|
||||
MarkBufferDirty(buffer);
|
||||
UnlockReleaseBuffer(buffer);
|
||||
}
|
||||
@@ -851,7 +844,6 @@ btree_xlog_delete_page(uint8 info, XLogRecPtr lsn, XLogRecord *record)
|
||||
}
|
||||
|
||||
PageSetLSN(page, lsn);
|
||||
PageSetTLI(page, ThisTimeLineID);
|
||||
MarkBufferDirty(buffer);
|
||||
UnlockReleaseBuffer(buffer);
|
||||
}
|
||||
@@ -877,7 +869,6 @@ btree_xlog_delete_page(uint8 info, XLogRecPtr lsn, XLogRecord *record)
|
||||
pageop->btpo_prev = leftsib;
|
||||
|
||||
PageSetLSN(page, lsn);
|
||||
PageSetTLI(page, ThisTimeLineID);
|
||||
MarkBufferDirty(buffer);
|
||||
UnlockReleaseBuffer(buffer);
|
||||
}
|
||||
@@ -905,7 +896,6 @@ btree_xlog_delete_page(uint8 info, XLogRecPtr lsn, XLogRecord *record)
|
||||
pageop->btpo_next = rightsib;
|
||||
|
||||
PageSetLSN(page, lsn);
|
||||
PageSetTLI(page, ThisTimeLineID);
|
||||
MarkBufferDirty(buffer);
|
||||
UnlockReleaseBuffer(buffer);
|
||||
}
|
||||
@@ -928,7 +918,6 @@ btree_xlog_delete_page(uint8 info, XLogRecPtr lsn, XLogRecord *record)
|
||||
pageop->btpo_cycleid = 0;
|
||||
|
||||
PageSetLSN(page, lsn);
|
||||
PageSetTLI(page, ThisTimeLineID);
|
||||
MarkBufferDirty(buffer);
|
||||
UnlockReleaseBuffer(buffer);
|
||||
|
||||
@@ -992,7 +981,6 @@ btree_xlog_newroot(XLogRecPtr lsn, XLogRecord *record)
|
||||
}
|
||||
|
||||
PageSetLSN(page, lsn);
|
||||
PageSetTLI(page, ThisTimeLineID);
|
||||
MarkBufferDirty(buffer);
|
||||
UnlockReleaseBuffer(buffer);
|
||||
|
||||
|
Reference in New Issue
Block a user