1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-12 05:01:15 +03:00

Clean up the messy semantics (not to mention inefficiency) of PageGetTempPage

by splitting it into three functions with better-defined behaviors.

Zdenek Kotala
This commit is contained in:
Tom Lane
2008-11-03 20:47:49 +00:00
parent f0dae70431
commit b4eae023bb
10 changed files with 60 additions and 55 deletions

View File

@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/gin/gindatapage.c,v 1.11 2008/06/19 00:46:03 alvherre Exp $
* $PostgreSQL: pgsql/src/backend/access/gin/gindatapage.c,v 1.12 2008/11/03 20:47:48 tgl Exp $
*-------------------------------------------------------------------------
*/
@@ -445,7 +445,7 @@ dataSplitPage(GinBtree btree, Buffer lbuf, Buffer rbuf, OffsetNumber off, XLogRe
char *ptr;
OffsetNumber separator;
ItemPointer bound;
Page lpage = GinPageGetCopyPage(BufferGetPage(lbuf));
Page lpage = PageGetTempPageCopy(BufferGetPage(lbuf));
ItemPointerData oldbound = *GinDataPageGetRightBound(lpage);
int sizeofitem = GinSizeOfItem(lpage);
OffsetNumber maxoff = GinPageGetOpaque(lpage)->maxoff;

View File

@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/gin/ginentrypage.c,v 1.17 2008/07/11 21:06:29 tgl Exp $
* $PostgreSQL: pgsql/src/backend/access/gin/ginentrypage.c,v 1.18 2008/11/03 20:47:48 tgl Exp $
*-------------------------------------------------------------------------
*/
@@ -458,7 +458,7 @@ entrySplitPage(GinBtree btree, Buffer lbuf, Buffer rbuf, OffsetNumber off, XLogR
leftrightmost = NULL;
static ginxlogSplit data;
Page page;
Page lpage = GinPageGetCopyPage(BufferGetPage(lbuf));
Page lpage = PageGetTempPageCopy(BufferGetPage(lbuf));
Page rpage = BufferGetPage(rbuf);
Size pageSize = PageGetPageSize(lpage);

View File

@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/gin/ginutil.c,v 1.17 2008/09/30 10:52:10 heikki Exp $
* $PostgreSQL: pgsql/src/backend/access/gin/ginutil.c,v 1.18 2008/11/03 20:47:48 tgl Exp $
*-------------------------------------------------------------------------
*/
@@ -310,21 +310,6 @@ extractEntriesSU(GinState *ginstate, OffsetNumber attnum, Datum value, int32 *ne
return entries;
}
/*
* It's analog of PageGetTempPage(), but copies whole page
*/
Page
GinPageGetCopyPage(Page page)
{
Size pageSize = PageGetPageSize(page);
Page tmppage;
tmppage = (Page) palloc(pageSize);
memcpy(tmppage, page, pageSize);
return tmppage;
}
Datum
ginoptions(PG_FUNCTION_ARGS)
{

View File

@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/gin/ginvacuum.c,v 1.24 2008/10/31 15:04:59 heikki Exp $
* $PostgreSQL: pgsql/src/backend/access/gin/ginvacuum.c,v 1.25 2008/11/03 20:47:48 tgl Exp $
*-------------------------------------------------------------------------
*/
@@ -546,7 +546,7 @@ ginVacuumEntryPage(GinVacuumState *gvs, Buffer buffer, BlockNumber *roots, uint3
* On first difference we create temporary page in memory
* and copies content in to it.
*/
tmppage = GinPageGetCopyPage(origpage);
tmppage = PageGetTempPageCopy(origpage);
if (newN > 0)
{