0002-Set-pd_lower-correctly-in-the-BRIN-index-metapage_v2.patch

text/plain

Filename: 0002-Set-pd_lower-correctly-in-the-BRIN-index-metapage_v2.patch
Type: text/plain
Part: 1
Message: Re: Setting pd_lower in GIN metapage

Patch

Format: format-patch
Series: patch v2-0002
Subject: Set pd_lower correctly in the BRIN index metapage
File+
src/backend/access/brin/brin_pageops.c 7 0
src/backend/access/brin/brin_xlog.c 1 1
From 3f197e13dcef968e8f0a5ff17cf0c328458cde34 Mon Sep 17 00:00:00 2001
From: amit <amitlangote09@gmail.com>
Date: Mon, 26 Jun 2017 15:13:32 +0900
Subject: [PATCH 2/3] Set pd_lower correctly in the BRIN index metapage

---
 src/backend/access/brin/brin_pageops.c | 7 +++++++
 src/backend/access/brin/brin_xlog.c    | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/backend/access/brin/brin_pageops.c b/src/backend/access/brin/brin_pageops.c
index 80f803e438..8762356433 100644
--- a/src/backend/access/brin/brin_pageops.c
+++ b/src/backend/access/brin/brin_pageops.c
@@ -491,6 +491,13 @@ brin_metapage_init(Page page, BlockNumber pagesPerRange, uint16 version)
 	 * revmap page to be created when the index is.
 	 */
 	metadata->lastRevmapPage = 0;
+
+	/*
+	 * Set pd_lower just past the end of the metadata.  This is to log full
+	 * page image of metapage in xloginsert.c.
+	 */
+	((PageHeader) page)->pd_lower =
+		((char *) metadata + sizeof(BrinMetaPageData)) - (char *) page;
 }
 
 /*
diff --git a/src/backend/access/brin/brin_xlog.c b/src/backend/access/brin/brin_xlog.c
index dff7198a39..36e6e1411a 100644
--- a/src/backend/access/brin/brin_xlog.c
+++ b/src/backend/access/brin/brin_xlog.c
@@ -336,7 +336,7 @@ brin_mask(char *pagedata, BlockNumber blkno)
 
 	mask_page_hint_bits(page);
 
-	if (BRIN_IS_REGULAR_PAGE(page))
+	if (BRIN_IS_REGULAR_PAGE(page) || BRIN_IS_META_PAGE(page))
 	{
 		/* Regular brin pages contain unused space which needs to be masked. */
 		mask_unused_space(page);
-- 
2.11.0