Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlvaro Herrera2015-03-10 15:26:34 +0000
committerAlvaro Herrera2015-03-10 15:27:15 +0000
commite491bd2ee34860b14ff18abc5602f9aa5b197a2d (patch)
treeb6b2bde52149169db4b0c666bce203c7d8da1820 /src/backend
parent865f14a2d31af23a05bbf2df04c274629c5d5c4d (diff)
Move BRIN page type to page's last two bytes
... which is the usual convention among AMs, so that pg_filedump and similar utilities can tell apart pages of different AMs. It was also the intent of the original code, but I failed to realize that alignment considerations would move the whole thing to the previous-to-last word in the page. The new definition of the associated macro makes surrounding code a bit leaner, too. Per note from Heikki at http://www.postgresql.org/message-id/546A16EF.9070005@vmware.com
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/access/brin/brin_pageops.c23
-rw-r--r--src/backend/access/brin/brin_revmap.c2
2 files changed, 6 insertions, 19 deletions
diff --git a/src/backend/access/brin/brin_pageops.c b/src/backend/access/brin/brin_pageops.c
index 4e9392bd824..acb64bde4fc 100644
--- a/src/backend/access/brin/brin_pageops.c
+++ b/src/backend/access/brin/brin_pageops.c
@@ -53,7 +53,6 @@ brin_doupdate(Relation idxrel, BlockNumber pagesPerRange,
BrinTuple *oldtup;
Size oldsz;
Buffer newbuf;
- BrinSpecialSpace *special;
bool extended = false;
newsz = MAXALIGN(newsz);
@@ -113,8 +112,6 @@ brin_doupdate(Relation idxrel, BlockNumber pagesPerRange,
return false;
}
- special = (BrinSpecialSpace *) PageGetSpecialPointer(oldpage);
-
/*
* Great, the old tuple is intact. We can proceed with the update.
*
@@ -124,7 +121,7 @@ brin_doupdate(Relation idxrel, BlockNumber pagesPerRange,
* caller told us there isn't, if a concurrent update moved another tuple
* elsewhere or replaced a tuple with a smaller one.
*/
- if (((special->flags & BRIN_EVACUATE_PAGE) == 0) &&
+ if (((BrinPageFlags(oldpage) & BRIN_EVACUATE_PAGE) == 0) &&
brin_can_do_samepage_update(oldbuf, origsz, newsz))
{
if (BufferIsValid(newbuf))
@@ -374,12 +371,9 @@ brin_doinsert(Relation idxrel, BlockNumber pagesPerRange,
void
brin_page_init(Page page, uint16 type)
{
- BrinSpecialSpace *special;
-
PageInit(page, BLCKSZ, sizeof(BrinSpecialSpace));
- special = (BrinSpecialSpace *) PageGetSpecialPointer(page);
- special->type = type;
+ BrinPageType(page) = type;
}
/*
@@ -420,7 +414,6 @@ brin_start_evacuating_page(Relation idxRel, Buffer buf)
{
OffsetNumber off;
OffsetNumber maxoff;
- BrinSpecialSpace *special;
Page page;
page = BufferGetPage(buf);
@@ -428,8 +421,6 @@ brin_start_evacuating_page(Relation idxRel, Buffer buf)
if (PageIsNew(page))
return false;
- special = (BrinSpecialSpace *) PageGetSpecialPointer(page);
-
maxoff = PageGetMaxOffsetNumber(page);
for (off = FirstOffsetNumber; off <= maxoff; off++)
{
@@ -439,7 +430,7 @@ brin_start_evacuating_page(Relation idxRel, Buffer buf)
if (ItemIdIsUsed(lp))
{
/* prevent other backends from adding more stuff to this page */
- special->flags |= BRIN_EVACUATE_PAGE;
+ BrinPageFlags(page) |= BRIN_EVACUATE_PAGE;
MarkBufferDirtyHint(buf, true);
return true;
@@ -463,8 +454,7 @@ brin_evacuate_page(Relation idxRel, BlockNumber pagesPerRange,
page = BufferGetPage(buf);
- Assert(((BrinSpecialSpace *)
- PageGetSpecialPointer(page))->flags & BRIN_EVACUATE_PAGE);
+ Assert(BrinPageFlags(page) & BRIN_EVACUATE_PAGE);
maxoff = PageGetMaxOffsetNumber(page);
for (off = FirstOffsetNumber; off <= maxoff; off++)
@@ -677,11 +667,8 @@ brin_getinsertbuffer(Relation irel, Buffer oldbuf, Size itemsz,
static Size
br_page_get_freespace(Page page)
{
- BrinSpecialSpace *special;
-
- special = (BrinSpecialSpace *) PageGetSpecialPointer(page);
if (!BRIN_IS_REGULAR_PAGE(page) ||
- (special->flags & BRIN_EVACUATE_PAGE) != 0)
+ (BrinPageFlags(page) & BRIN_EVACUATE_PAGE) != 0)
return 0;
else
return PageGetFreeSpace(page);
diff --git a/src/backend/access/brin/brin_revmap.c b/src/backend/access/brin/brin_revmap.c
index 5e4499d15ae..80795eca650 100644
--- a/src/backend/access/brin/brin_revmap.c
+++ b/src/backend/access/brin/brin_revmap.c
@@ -446,7 +446,7 @@ revmap_physical_extend(BrinRevmap *revmap)
ereport(ERROR,
(errcode(ERRCODE_INDEX_CORRUPTED),
errmsg("unexpected page type 0x%04X in BRIN index \"%s\" block %u",
- BRIN_PAGE_TYPE(page),
+ BrinPageType(page),
RelationGetRelationName(irel),
BufferGetBlockNumber(buf))));