diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-07-13 21:50:04 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-07-13 21:50:04 +0000 |
commit | 6816577a786cd9be257f6600e3cde2d86f5adb46 (patch) | |
tree | 4b008d2476c45707b5f0df4a55927b9e039b9a7c /src/backend/storage/page/bufpage.c | |
parent | 9d035f425452279041c52e01cf83b2a27e121b5c (diff) | |
download | postgresql-6816577a786cd9be257f6600e3cde2d86f5adb46.tar.gz postgresql-6816577a786cd9be257f6600e3cde2d86f5adb46.zip |
Change the PageGetContents() macro to guarantee its result is maxalign'd,
thereby forestalling any problems with alignment of the data structure placed
there. Since SizeOfPageHeaderData is maxalign'd anyway in 8.3 and HEAD, this
does not actually change anything right now, but it is foreseeable that the
header size will change again someday. I had to fix a couple of places that
were assuming that the content offset is just SizeOfPageHeaderData rather than
MAXALIGN(SizeOfPageHeaderData). Per discussion of Zdenek's page-macros patch.
Diffstat (limited to 'src/backend/storage/page/bufpage.c')
-rw-r--r-- | src/backend/storage/page/bufpage.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/backend/storage/page/bufpage.c b/src/backend/storage/page/bufpage.c index c4af3b193fc..abfc569399e 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.79 2008/05/13 15:44:08 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/storage/page/bufpage.c,v 1.80 2008/07/13 21:50:04 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -260,7 +260,6 @@ Page PageGetTempPage(Page page, Size specialSize) { Size pageSize; - Size size; Page temp; PageHeader thdr; @@ -271,15 +270,13 @@ PageGetTempPage(Page page, Size specialSize) /* copy old page in */ memcpy(temp, page, pageSize); - /* clear out the middle */ - size = pageSize - SizeOfPageHeaderData; - size -= MAXALIGN(specialSize); - MemSet(PageGetContents(thdr), 0, size); - /* set high, low water marks */ thdr->pd_lower = SizeOfPageHeaderData; thdr->pd_upper = pageSize - MAXALIGN(specialSize); + /* clear out the middle */ + MemSet((char *) temp + thdr->pd_lower, 0, thdr->pd_upper - thdr->pd_lower); + return temp; } |