Skip to content

Commit c9a7345

Browse files
committed
>the extra level of struct naming for pd_opaque has no obvious
>usefulness. > >> [...] should I post a patch that puts pagesize directly into >> PageHeaderData? > >If you're so inclined. Given that pd_opaque is hidden in those macros, >there wouldn't be much of any gain in readability either, so I haven't >worried about changing the declaration. Thanks for the clarification. Here is the patch. Not much gain, but at least it saves the next junior hacker from scratching his head ... Manfred Koizar
1 parent 22347d6 commit c9a7345

File tree

2 files changed

+18
-26
lines changed

2 files changed

+18
-26
lines changed

src/backend/access/hash/hashutil.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashutil.c,v 1.30 2002/06/20 20:29:24 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashutil.c,v 1.31 2002/07/02 06:18:57 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -131,13 +131,13 @@ _hash_checkpage(Page page, int flags)
131131
HashPageOpaque opaque;
132132

133133
Assert(page);
134-
Assert(((PageHeader) (page))->pd_lower >= (sizeof(PageHeaderData) - sizeof(ItemIdData)));
134+
Assert(((PageHeader) (page))->pd_lower >= SizeOfPageHeaderData);
135135
#if 1
136136
Assert(((PageHeader) (page))->pd_upper <=
137137
(BLCKSZ - MAXALIGN(sizeof(HashPageOpaqueData))));
138138
Assert(((PageHeader) (page))->pd_special ==
139139
(BLCKSZ - MAXALIGN(sizeof(HashPageOpaqueData))));
140-
Assert(((PageHeader) (page))->pd_opaque.od_pagesize == BLCKSZ);
140+
Assert(PageGetPageSize(page) == BLCKSZ);
141141
#endif
142142
if (flags)
143143
{

src/include/storage/bufpage.h

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: bufpage.h,v 1.49 2002/07/02 05:48:44 momjian Exp $
10+
* $Id: bufpage.h,v 1.50 2002/07/02 06:18:57 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -65,8 +65,7 @@
6565
* byte-offset position, tuples can be physically shuffled on a page
6666
* whenever the need arises.
6767
*
68-
* AM-generic per-page information is kept in the pd_opaque field of
69-
* the PageHeaderData. (Currently, only the page size is kept here.)
68+
* AM-generic per-page information is kept in PageHeaderData.
7069
*
7170
* AM-specific per-page data (if any) is kept in the area marked "special
7271
* space"; each AM has an "opaque" structure defined somewhere that is
@@ -92,25 +91,18 @@ typedef uint16 LocationIndex;
9291

9392

9493
/*
94+
* disk page organization
9595
* space management information generic to any page
9696
*
97-
* od_pagesize - size in bytes.
98-
* Minimum possible page size is perhaps 64B to fit
99-
* page header, opaque space and a minimal tuple;
100-
* of course, in reality you want it much bigger.
101-
* On the high end, we can only support pages up
102-
* to 32KB because lp_off/lp_len are 15 bits.
103-
*/
104-
typedef struct OpaqueData
105-
{
106-
uint16 od_pagesize;
107-
} OpaqueData;
108-
109-
typedef OpaqueData *Opaque;
110-
111-
112-
/*
113-
* disk page organization
97+
* pd_lower - offset to start of free space.
98+
* pd_upper - offset to end of free space.
99+
* pd_special - offset to start of special space.
100+
* pd_pagesize - size in bytes.
101+
* Minimum possible page size is perhaps 64B to fit
102+
* page header, opaque space and a minimal tuple;
103+
* of course, in reality you want it much bigger.
104+
* On the high end, we can only support pages up
105+
* to 32KB because lp_off/lp_len are 15 bits.
114106
*/
115107
typedef struct PageHeaderData
116108
{
@@ -124,7 +116,7 @@ typedef struct PageHeaderData
124116
LocationIndex pd_lower; /* offset to start of free space */
125117
LocationIndex pd_upper; /* offset to end of free space */
126118
LocationIndex pd_special; /* offset to start of special space */
127-
OpaqueData pd_opaque; /* AM-generic information */
119+
uint16 pd_pagesize;
128120
ItemIdData pd_linp[1]; /* beginning of line pointer array */
129121
} PageHeaderData;
130122

@@ -216,14 +208,14 @@ typedef enum
216208
* however, it can be called on a page for which there is no buffer.
217209
*/
218210
#define PageGetPageSize(page) \
219-
((Size) ((PageHeader) (page))->pd_opaque.od_pagesize)
211+
((Size) ((PageHeader) (page))->pd_pagesize)
220212

221213
/*
222214
* PageSetPageSize
223215
* Sets the page size of a page.
224216
*/
225217
#define PageSetPageSize(page, size) \
226-
(((PageHeader) (page))->pd_opaque.od_pagesize = (size))
218+
(((PageHeader) (page))->pd_pagesize = (size))
227219

228220
/* ----------------
229221
* page special data macros

0 commit comments

Comments
 (0)