File tree 1 file changed +7
-6
lines changed
1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 7
7
* Portions Copyright (c) 1996-2003, 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.57 2003/12/11 21:21:55 tgl Exp $
10
+ * $PostgreSQL: pgsql/src/include/storage/bufpage.h,v 1.58 2004/06/05 17:42:46 tgl Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -283,13 +283,14 @@ typedef PageHeaderData *PageHeader;
283
283
* Since offset numbers are 1-based, this is also the number
284
284
* of items on the page.
285
285
*
286
- * NOTE: to ensure sane behavior if the page is not initialized
287
- * (pd_lower == 0), cast the unsigned values to int before dividing.
288
- * That way we get -1 or so, not a huge positive number.. .
286
+ * NOTE: if the page is not initialized (pd_lower == 0), we must
287
+ * return zero to ensure sane behavior. Accept double evaluation
288
+ * of the argument so that we can ensure this .
289
289
*/
290
290
#define PageGetMaxOffsetNumber (page ) \
291
- (((int) (((PageHeader) (page))->pd_lower - SizeOfPageHeaderData)) \
292
- / ((int) sizeof(ItemIdData)))
291
+ (((PageHeader) (page))->pd_lower <= SizeOfPageHeaderData ? 0 : \
292
+ ((((PageHeader) (page))->pd_lower - SizeOfPageHeaderData) \
293
+ / sizeof(ItemIdData)))
293
294
294
295
#define PageGetLSN (page ) \
295
296
(((PageHeader) (page))->pd_lsn)
You can’t perform that action at this time.
0 commit comments