7
7
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
8
8
* Portions Copyright (c) 1994, Regents of the University of California
9
9
*
10
- * $PostgreSQL: pgsql/src/include/storage/bufpage.h,v 1.71 2007/02/21 20:02:17 momjian Exp $
10
+ * $PostgreSQL: pgsql/src/include/storage/bufpage.h,v 1.72 2007/03/02 00:48:44 tgl Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -90,6 +90,7 @@ typedef uint16 LocationIndex;
90
90
*
91
91
* pd_lsn - identifies xlog record for last change to this page.
92
92
* pd_tli - ditto.
93
+ * pd_flags - flag bits.
93
94
* pd_lower - offset to start of free space.
94
95
* pd_upper - offset to end of free space.
95
96
* pd_special - offset to start of special space.
@@ -98,8 +99,9 @@ typedef uint16 LocationIndex;
98
99
* The LSN is used by the buffer manager to enforce the basic rule of WAL:
99
100
* "thou shalt write xlog before data". A dirty buffer cannot be dumped
100
101
* to disk until xlog has been flushed at least as far as the page's LSN.
101
- * We also store the TLI for identification purposes (it is not clear that
102
- * this is actually necessary, but it seems like a good idea).
102
+ * We also store the 16 least significant bits of the TLI for identification
103
+ * purposes (it is not clear that this is actually necessary, but it seems
104
+ * like a good idea).
103
105
*
104
106
* The page version number and page size are packed together into a single
105
107
* uint16 field. This is for historical reasons: before PostgreSQL 7.3,
@@ -119,7 +121,9 @@ typedef struct PageHeaderData
119
121
/* XXX LSN is member of *any* block, not only page-organized ones */
120
122
XLogRecPtr pd_lsn ; /* LSN: next byte after last byte of xlog
121
123
* record for last change to this page */
122
- TimeLineID pd_tli ; /* TLI of last change */
124
+ uint16 pd_tli ; /* least significant bits of the TimeLineID
125
+ * containing the LSN */
126
+ uint16 pd_flags ; /* flag bits, see below */
123
127
LocationIndex pd_lower ; /* offset to start of free space */
124
128
LocationIndex pd_upper ; /* offset to end of free space */
125
129
LocationIndex pd_special ; /* offset to start of special space */
@@ -129,12 +133,25 @@ typedef struct PageHeaderData
129
133
130
134
typedef PageHeaderData * PageHeader ;
131
135
136
+ /*
137
+ * pd_flags contains the following flag bits. Undefined bits are initialized
138
+ * to zero and may be used in the future.
139
+ *
140
+ * PD_HAS_FREE_LINES is set if there are any not-LP_USED line pointers before
141
+ * pd_lower. This should be considered a hint rather than the truth, since
142
+ * changes to it are not WAL-logged.
143
+ */
144
+ #define PD_HAS_FREE_LINES 0x0001 /* are there any unused line pointers? */
145
+
146
+ #define PD_VALID_FLAG_BITS 0x0001 /* OR of all valid pd_flags bits */
147
+
132
148
/*
133
149
* Page layout version number 0 is for pre-7.3 Postgres releases.
134
150
* Releases 7.3 and 7.4 use 1, denoting a new HeapTupleHeader layout.
135
151
* Release 8.0 uses 2; it changed the HeapTupleHeader layout again.
136
152
* Release 8.1 uses 3; it redefined HeapTupleHeader infomask bits.
137
- * Release 8.3 uses 4; it changed the HeapTupleHeader layout again.
153
+ * Release 8.3 uses 4; it changed the HeapTupleHeader layout again, and
154
+ * added the pd_flags field (by stealing some bits from pd_tli).
138
155
*/
139
156
#define PG_PAGE_LAYOUT_VERSION 4
140
157
@@ -299,15 +316,27 @@ typedef PageHeaderData *PageHeader;
299
316
((((PageHeader) (page))->pd_lower - SizeOfPageHeaderData) \
300
317
/ sizeof(ItemIdData)))
301
318
319
+ /*
320
+ * Additional macros for access to page headers
321
+ */
302
322
#define PageGetLSN (page ) \
303
323
(((PageHeader) (page))->pd_lsn)
304
324
#define PageSetLSN (page , lsn ) \
305
325
(((PageHeader) (page))->pd_lsn = (lsn))
306
326
327
+ /* NOTE: only the 16 least significant bits are stored */
307
328
#define PageGetTLI (page ) \
308
329
(((PageHeader) (page))->pd_tli)
309
330
#define PageSetTLI (page , tli ) \
310
- (((PageHeader) (page))->pd_tli = (tli))
331
+ (((PageHeader) (page))->pd_tli = (uint16) (tli))
332
+
333
+ #define PageHasFreeLinePointers (page ) \
334
+ (((PageHeader) (page))->pd_flags & PD_HAS_FREE_LINES)
335
+ #define PageSetHasFreeLinePointers (page ) \
336
+ (((PageHeader) (page))->pd_flags |= PD_HAS_FREE_LINES)
337
+ #define PageClearHasFreeLinePointers (page ) \
338
+ (((PageHeader) (page))->pd_flags &= ~PD_HAS_FREE_LINES)
339
+
311
340
312
341
/* ----------------------------------------------------------------
313
342
* extern declarations
0 commit comments