aboutsummaryrefslogtreecommitdiff
path: root/src/backend/storage/page/bufpage.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/storage/page/bufpage.c')
-rw-r--r--src/backend/storage/page/bufpage.c53
1 files changed, 42 insertions, 11 deletions
diff --git a/src/backend/storage/page/bufpage.c b/src/backend/storage/page/bufpage.c
index abfc569399e..3faae011b37 100644
--- a/src/backend/storage/page/bufpage.c
+++ b/src/backend/storage/page/bufpage.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/storage/page/bufpage.c,v 1.80 2008/07/13 21:50:04 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/storage/page/bufpage.c,v 1.81 2008/11/03 20:47:48 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -254,28 +254,59 @@ PageAddItem(Page page,
/*
* PageGetTempPage
- * Get a temporary page in local memory for special processing
+ * Get a temporary page in local memory for special processing.
+ * The returned page is not initialized at all; caller must do that.
*/
Page
-PageGetTempPage(Page page, Size specialSize)
+PageGetTempPage(Page page)
+{
+ Size pageSize;
+ Page temp;
+
+ pageSize = PageGetPageSize(page);
+ temp = (Page) palloc(pageSize);
+
+ return temp;
+}
+
+/*
+ * PageGetTempPageCopy
+ * Get a temporary page in local memory for special processing.
+ * The page is initialized by copying the contents of the given page.
+ */
+Page
+PageGetTempPageCopy(Page page)
{
Size pageSize;
Page temp;
- PageHeader thdr;
pageSize = PageGetPageSize(page);
temp = (Page) palloc(pageSize);
- thdr = (PageHeader) temp;
- /* copy old page in */
memcpy(temp, page, pageSize);
- /* set high, low water marks */
- thdr->pd_lower = SizeOfPageHeaderData;
- thdr->pd_upper = pageSize - MAXALIGN(specialSize);
+ return temp;
+}
+
+/*
+ * PageGetTempPageCopySpecial
+ * Get a temporary page in local memory for special processing.
+ * The page is PageInit'd with the same special-space size as the
+ * given page, and the special space is copied from the given page.
+ */
+Page
+PageGetTempPageCopySpecial(Page page)
+{
+ Size pageSize;
+ Page temp;
+
+ pageSize = PageGetPageSize(page);
+ temp = (Page) palloc(pageSize);
- /* clear out the middle */
- MemSet((char *) temp + thdr->pd_lower, 0, thdr->pd_upper - thdr->pd_lower);
+ PageInit(temp, pageSize, PageGetSpecialSize(page));
+ memcpy(PageGetSpecialPointer(temp),
+ PageGetSpecialPointer(page),
+ PageGetSpecialSize(page));
return temp;
}