diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/access/hash.h | 10 | ||||
-rw-r--r-- | src/include/access/htup.h | 14 | ||||
-rw-r--r-- | src/include/access/itup.h | 4 | ||||
-rw-r--r-- | src/include/access/nbtree.h | 7 | ||||
-rw-r--r-- | src/include/access/tuptoaster.h | 8 |
5 files changed, 19 insertions, 24 deletions
diff --git a/src/include/access/hash.h b/src/include/access/hash.h index 4d8cd79e9a8..0dab2b6ae91 100644 --- a/src/include/access/hash.h +++ b/src/include/access/hash.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/hash.h,v 1.88 2008/06/19 00:46:05 alvherre Exp $ + * $PostgreSQL: pgsql/src/include/access/hash.h,v 1.89 2008/07/13 20:45:47 tgl Exp $ * * NOTES * modeled after Margo Seltzer's hash implementation for unix. @@ -166,10 +166,10 @@ typedef HashMetaPageData *HashMetaPage; * Maximum size of a hash index item (it's okay to have only one per page) */ #define HashMaxItemSize(page) \ - (PageGetPageSize(page) - \ - sizeof(PageHeaderData) - \ - MAXALIGN(sizeof(HashPageOpaqueData)) - \ - sizeof(ItemIdData)) + MAXALIGN_DOWN(PageGetPageSize(page) - \ + SizeOfPageHeaderData - \ + sizeof(ItemIdData) - \ + MAXALIGN(sizeof(HashPageOpaqueData))) #define HASH_MIN_FILLFACTOR 10 #define HASH_DEFAULT_FILLFACTOR 75 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)))) /* diff --git a/src/include/access/itup.h b/src/include/access/itup.h index eb637b81ea4..ae53accde7c 100644 --- a/src/include/access/itup.h +++ b/src/include/access/itup.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/itup.h,v 1.49 2008/01/01 19:45:56 momjian Exp $ + * $PostgreSQL: pgsql/src/include/access/itup.h,v 1.50 2008/07/13 20:45:47 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -134,7 +134,7 @@ typedef IndexAttributeBitMapData *IndexAttributeBitMap; * must be maxaligned, and it must have an associated item pointer. */ #define MaxIndexTuplesPerPage \ - ((int) ((BLCKSZ - offsetof(PageHeaderData, pd_linp)) / \ + ((int) ((BLCKSZ - SizeOfPageHeaderData) / \ (MAXALIGN(sizeof(IndexTupleData) + 1) + sizeof(ItemIdData)))) diff --git a/src/include/access/nbtree.h b/src/include/access/nbtree.h index 9b0e8d0cf77..e0bc10c0642 100644 --- a/src/include/access/nbtree.h +++ b/src/include/access/nbtree.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/nbtree.h,v 1.120 2008/06/19 00:46:06 alvherre Exp $ + * $PostgreSQL: pgsql/src/include/access/nbtree.h,v 1.121 2008/07/13 20:45:47 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -113,13 +113,10 @@ typedef struct BTMetaPageData * * We actually need to be able to fit three items on every page, * so restrict any one item to 1/3 the per-page available space. - * - * Note: sizeof(PageHeaderData) includes the first ItemId, but we have - * to allow for 2 more, as well as the end-of-page special space. */ #define BTMaxItemSize(page) \ MAXALIGN_DOWN((PageGetPageSize(page) - \ - MAXALIGN(sizeof(PageHeaderData) + 2*sizeof(ItemIdData)) - \ + MAXALIGN(SizeOfPageHeaderData + 3*sizeof(ItemIdData)) - \ MAXALIGN(sizeof(BTPageOpaqueData))) / 3) /* diff --git a/src/include/access/tuptoaster.h b/src/include/access/tuptoaster.h index 7d1ba7d2f82..a87aee62dfc 100644 --- a/src/include/access/tuptoaster.h +++ b/src/include/access/tuptoaster.h @@ -6,7 +6,7 @@ * * Copyright (c) 2000-2008, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/include/access/tuptoaster.h,v 1.40 2008/06/19 00:46:06 alvherre Exp $ + * $PostgreSQL: pgsql/src/include/access/tuptoaster.h,v 1.41 2008/07/13 20:45:47 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -46,10 +46,9 @@ */ #define TOAST_TUPLES_PER_PAGE 4 -/* Note: sizeof(PageHeaderData) includes the first ItemId on the page */ #define TOAST_TUPLE_THRESHOLD \ MAXALIGN_DOWN((BLCKSZ - \ - MAXALIGN(sizeof(PageHeaderData) + (TOAST_TUPLES_PER_PAGE-1) * sizeof(ItemIdData))) \ + MAXALIGN(SizeOfPageHeaderData + TOAST_TUPLES_PER_PAGE * sizeof(ItemIdData))) \ / TOAST_TUPLES_PER_PAGE) #define TOAST_TUPLE_TARGET TOAST_TUPLE_THRESHOLD @@ -73,10 +72,9 @@ */ #define EXTERN_TUPLES_PER_PAGE 4 /* tweak only this */ -/* Note: sizeof(PageHeaderData) includes the first ItemId on the page */ #define EXTERN_TUPLE_MAX_SIZE \ MAXALIGN_DOWN((BLCKSZ - \ - MAXALIGN(sizeof(PageHeaderData) + (EXTERN_TUPLES_PER_PAGE-1) * sizeof(ItemIdData))) \ + MAXALIGN(SizeOfPageHeaderData + EXTERN_TUPLES_PER_PAGE * sizeof(ItemIdData))) \ / EXTERN_TUPLES_PER_PAGE) #define TOAST_MAX_CHUNK_SIZE \ |