mirror of
https://github.com/postgres/postgres.git
synced 2025-06-27 23:21:58 +03:00
Make GiST indexes on-disk compatible with 9.2 again.
The patch that turned XLogRecPtr into a uint64 inadvertently changed the on-disk format of GiST indexes, because the NSN field in the GiST page opaque is an XLogRecPtr. That breaks pg_upgrade. Revert the format of that field back to the two-field struct that XLogRecPtr was before. This is the same we did to LSNs in the page header to avoid changing on-disk format. Bump catversion, as this invalidates any existing GiST indexes built on 9.3devel.
This commit is contained in:
@ -240,7 +240,7 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
|
||||
{
|
||||
/* save old rightlink and NSN */
|
||||
oldrlink = GistPageGetOpaque(page)->rightlink;
|
||||
oldnsn = GistPageGetOpaque(page)->nsn;
|
||||
oldnsn = GistPageGetNSN(page);
|
||||
|
||||
dist->buffer = buffer;
|
||||
dist->block.blkno = BufferGetBlockNumber(buffer);
|
||||
@ -364,7 +364,7 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
|
||||
* F_FOLLOW_RIGHT flags ensure that scans will follow the
|
||||
* rightlinks until the downlinks are inserted.
|
||||
*/
|
||||
GistPageGetOpaque(ptr->page)->nsn = oldnsn;
|
||||
GistPageSetNSN(ptr->page, oldnsn);
|
||||
}
|
||||
|
||||
START_CRIT_SECTION();
|
||||
@ -473,7 +473,7 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
|
||||
{
|
||||
Page leftpg = BufferGetPage(leftchildbuf);
|
||||
|
||||
GistPageGetOpaque(leftpg)->nsn = recptr;
|
||||
GistPageSetNSN(leftpg, recptr);
|
||||
GistClearFollowRight(leftpg);
|
||||
|
||||
PageSetLSN(leftpg, recptr);
|
||||
@ -561,7 +561,7 @@ gistdoinsert(Relation r, IndexTuple itup, Size freespace, GISTSTATE *giststate)
|
||||
}
|
||||
|
||||
if (stack->blkno != GIST_ROOT_BLKNO &&
|
||||
stack->parent->lsn < GistPageGetOpaque(stack->page)->nsn)
|
||||
stack->parent->lsn < GistPageGetNSN(stack->page))
|
||||
{
|
||||
/*
|
||||
* Concurrent split detected. There's no guarantee that the
|
||||
@ -707,8 +707,7 @@ gistdoinsert(Relation r, IndexTuple itup, Size freespace, GISTSTATE *giststate)
|
||||
*/
|
||||
}
|
||||
else if (GistFollowRight(stack->page) ||
|
||||
stack->parent->lsn <
|
||||
GistPageGetOpaque(stack->page)->nsn)
|
||||
stack->parent->lsn < GistPageGetNSN(stack->page))
|
||||
{
|
||||
/*
|
||||
* The page was split while we momentarily unlocked the
|
||||
@ -793,7 +792,7 @@ gistFindPath(Relation r, BlockNumber child, OffsetNumber *downlinkoffnum)
|
||||
if (GistFollowRight(page))
|
||||
elog(ERROR, "concurrent GiST page split was incomplete");
|
||||
|
||||
if (top->parent && top->parent->lsn < GistPageGetOpaque(page)->nsn &&
|
||||
if (top->parent && top->parent->lsn < GistPageGetNSN(page) &&
|
||||
GistPageGetOpaque(page)->rightlink != InvalidBlockNumber /* sanity check */ )
|
||||
{
|
||||
/*
|
||||
|
@ -263,7 +263,7 @@ gistScanPage(IndexScanDesc scan, GISTSearchItem *pageItem, double *myDistances,
|
||||
*/
|
||||
if (!XLogRecPtrIsInvalid(pageItem->data.parentlsn) &&
|
||||
(GistFollowRight(page) ||
|
||||
pageItem->data.parentlsn < opaque->nsn) &&
|
||||
pageItem->data.parentlsn < GistPageGetNSN(page)) &&
|
||||
opaque->rightlink != InvalidBlockNumber /* sanity check */ )
|
||||
{
|
||||
/* There was a page split, follow right link to add pages */
|
||||
|
@ -114,7 +114,7 @@ pushStackIfSplited(Page page, GistBDItem *stack)
|
||||
GISTPageOpaque opaque = GistPageGetOpaque(page);
|
||||
|
||||
if (stack->blkno != GIST_ROOT_BLKNO && !XLogRecPtrIsInvalid(stack->parentlsn) &&
|
||||
(GistFollowRight(page) || stack->parentlsn < opaque->nsn) &&
|
||||
(GistFollowRight(page) || stack->parentlsn < GistPageGetNSN(page)) &&
|
||||
opaque->rightlink != InvalidBlockNumber /* sanity check */ )
|
||||
{
|
||||
/* split page detected, install right link to the stack */
|
||||
|
@ -66,7 +66,7 @@ gistRedoClearFollowRight(XLogRecPtr lsn, XLogRecord *record, int block_index,
|
||||
*/
|
||||
if (lsn >= PageGetLSN(page))
|
||||
{
|
||||
GistPageGetOpaque(page)->nsn = lsn;
|
||||
GistPageSetNSN(page, lsn);
|
||||
GistClearFollowRight(page);
|
||||
|
||||
PageSetLSN(page, lsn);
|
||||
@ -271,7 +271,7 @@ gistRedoPageSplitRecord(XLogRecPtr lsn, XLogRecord *record)
|
||||
if (newpage->header->blkno == GIST_ROOT_BLKNO)
|
||||
{
|
||||
GistPageGetOpaque(page)->rightlink = InvalidBlockNumber;
|
||||
GistPageGetOpaque(page)->nsn = xldata->orignsn;
|
||||
GistPageSetNSN(page, xldata->orignsn);
|
||||
GistClearFollowRight(page);
|
||||
}
|
||||
else
|
||||
@ -280,7 +280,7 @@ gistRedoPageSplitRecord(XLogRecPtr lsn, XLogRecord *record)
|
||||
GistPageGetOpaque(page)->rightlink = xlrec.page[i + 1].header->blkno;
|
||||
else
|
||||
GistPageGetOpaque(page)->rightlink = xldata->origrlink;
|
||||
GistPageGetOpaque(page)->nsn = xldata->orignsn;
|
||||
GistPageSetNSN(page, xldata->orignsn);
|
||||
if (i < xlrec.data->npage - 1 && !isrootsplit &&
|
||||
xldata->markfollowright)
|
||||
GistMarkFollowRight(page);
|
||||
|
Reference in New Issue
Block a user