diff options
| author | Alvaro Herrera | 2015-03-10 15:26:34 +0000 |
|---|---|---|
| committer | Alvaro Herrera | 2015-03-10 15:27:15 +0000 |
| commit | e491bd2ee34860b14ff18abc5602f9aa5b197a2d (patch) | |
| tree | b6b2bde52149169db4b0c666bce203c7d8da1820 /contrib/pageinspect | |
| parent | 865f14a2d31af23a05bbf2df04c274629c5d5c4d (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 'contrib/pageinspect')
| -rw-r--r-- | contrib/pageinspect/brinfuncs.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/contrib/pageinspect/brinfuncs.c b/contrib/pageinspect/brinfuncs.c index 630dda455e7..1b15a7bdfe3 100644 --- a/contrib/pageinspect/brinfuncs.c +++ b/contrib/pageinspect/brinfuncs.c @@ -58,12 +58,9 @@ brin_page_type(PG_FUNCTION_ARGS) { bytea *raw_page = PG_GETARG_BYTEA_P(0); Page page = VARDATA(raw_page); - BrinSpecialSpace *special; char *type; - special = (BrinSpecialSpace *) PageGetSpecialPointer(page); - - switch (special->type) + switch (BrinPageType(page)) { case BRIN_PAGETYPE_META: type = "meta"; @@ -75,7 +72,7 @@ brin_page_type(PG_FUNCTION_ARGS) type = "regular"; break; default: - type = psprintf("unknown (%02x)", special->type); + type = psprintf("unknown (%02x)", BrinPageType(page)); break; } @@ -91,7 +88,6 @@ verify_brin_page(bytea *raw_page, uint16 type, const char *strtype) { Page page; int raw_page_size; - BrinSpecialSpace *special; raw_page_size = VARSIZE(raw_page) - VARHDRSZ; @@ -104,13 +100,12 @@ verify_brin_page(bytea *raw_page, uint16 type, const char *strtype) page = VARDATA(raw_page); /* verify the special space says this page is what we want */ - special = (BrinSpecialSpace *) PageGetSpecialPointer(page); - if (special->type != type) + if (BrinPageType(page) != type) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("page is not a BRIN page of type \"%s\"", strtype), errdetail("Expected special type %08x, got %08x.", - type, special->type))); + type, BrinPageType(page)))); return page; } |
