diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-07-13 20:45:47 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-07-13 20:45:47 +0000 |
commit | 9d035f425452279041c52e01cf83b2a27e121b5c (patch) | |
tree | d521a3bdb9ca231ed49e09a48259a45b519f6d1c /src/include/access/htup.h | |
parent | 45efb09a01e93d20ccb5671703649d9f87f744de (diff) |
Clean up the use of some page-header-access macros: principally, use
SizeOfPageHeaderData instead of sizeof(PageHeaderData) in places where that
makes the code clearer, and avoid casting between Page and PageHeader where
possible. Zdenek Kotala, with some additional cleanup by Heikki Linnakangas.
I did not apply the parts of the proposed patch that would have resulted in
slightly changing the on-disk format of hash indexes; it seems to me that's
not a win as long as there's any chance of having in-place upgrade for 8.4.
Diffstat (limited to 'src/include/access/htup.h')
-rw-r--r-- | src/include/access/htup.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/include/access/htup.h b/src/include/access/htup.h index 7a77d438933..8bfdf26697e 100644 --- a/src/include/access/htup.h +++ b/src/include/access/htup.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/htup.h,v 1.99 2008/05/12 00:00:53 alvherre Exp $ + * $PostgreSQL: pgsql/src/include/access/htup.h,v 1.100 2008/07/13 20:45:47 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -362,12 +362,12 @@ do { \ * other stuff that has to be on a disk page. Since heap pages use no * "special space", there's no deduction for that. * - * NOTE: we do not need to count an ItemId for the tuple because - * sizeof(PageHeaderData) includes the first ItemId on the page. But beware - * of assuming that, say, you can fit 2 tuples of size MaxHeapTupleSize/2 - * on the same page. + * NOTE: we allow for the ItemId that must point to the tuple, ensuring that + * an otherwise-empty page can indeed hold a tuple of this size. Because + * ItemIds and tuples have different alignment requirements, don't assume that + * you can, say, fit 2 tuples of size MaxHeapTupleSize/2 on the same page. */ -#define MaxHeapTupleSize (BLCKSZ - MAXALIGN(sizeof(PageHeaderData))) +#define MaxHeapTupleSize (BLCKSZ - MAXALIGN(SizeOfPageHeaderData + sizeof(ItemIdData))) /* * MaxHeapTuplesPerPage is an upper bound on the number of tuples that can @@ -381,7 +381,7 @@ do { \ * require increases in the size of work arrays. */ #define MaxHeapTuplesPerPage \ - ((int) ((BLCKSZ - offsetof(PageHeaderData, pd_linp)) / \ + ((int) ((BLCKSZ - SizeOfPageHeaderData) / \ (MAXALIGN(offsetof(HeapTupleHeaderData, t_bits)) + sizeof(ItemIdData)))) /* |