From: Vadim B. Mikheev Date: Fri, 20 Oct 2000 11:28:39 +0000 (+0000) Subject: WAL need in overwrite mode - restored in new way X-Git-Tag: REL7_1_BETA~416 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=27bc34be5566e3a917684df2aa62392a966b0b7a;p=postgresql WAL need in overwrite mode - restored in new way (without PageManagetSetMode -:)) Safe shuffle mode behaviour retained. --- diff --git a/src/backend/storage/page/bufpage.c b/src/backend/storage/page/bufpage.c index 1a970a1375..dd1b44d334 100644 --- a/src/backend/storage/page/bufpage.c +++ b/src/backend/storage/page/bufpage.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.31 2000/07/21 06:42:33 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.32 2000/10/20 11:28:39 vadim Exp $ * *------------------------------------------------------------------------- */ @@ -80,6 +80,9 @@ PageAddItem(Page page, ItemId itemId; OffsetNumber limit; bool needshuffle = false; + bool overwritemode = flags & OverwritePageMode; + + flags &= ~OverwritePageMode; /* * Find first unallocated offsetNumber @@ -89,8 +92,28 @@ PageAddItem(Page page, /* was offsetNumber passed in? */ if (OffsetNumberIsValid(offsetNumber)) { - needshuffle = true; /* need to increase "lower" */ - /* don't actually do the shuffle till we've checked free space! */ + if (overwritemode) + { + if (offsetNumber > limit) + { + elog(NOTICE, "PageAddItem: tried overwrite after maxoff"); + return InvalidOffsetNumber; + } + itemId = &((PageHeader) page)->pd_linp[offsetNumber - 1]; + if (((*itemId).lp_flags & LP_USED) || + ((*itemId).lp_len != 0)) + { + elog(NOTICE, "PageAddItem: tried overwrite of used ItemId"); + return InvalidOffsetNumber; + } + } + else + { + /* + * Don't actually do the shuffle till we've checked free space! + */ + needshuffle = true; /* need to increase "lower" */ + } } else {