summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2009-04-07 18:11:04 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2009-04-07 18:11:04 +0000
commit0e7d4c02892dc02e08e7810c9949e2afd15a04ad (patch)
tree346f15cea50e5e813f1fb838cb87fcabd4aeb3b0
parent6a42ab4eb8dc0b192f61671890bd34d495426f96 (diff)
Fix contrib/pg_freespacemap's underestimate of the number of pages it
could find in the FSM. Per report from Dimitri Fontaine and Andrew Gierth. (Affects only 8.2 and 8.3 since HEAD no longer has MaxFSMPages at all.)
-rw-r--r--contrib/pg_freespacemap/pg_freespacemap.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/contrib/pg_freespacemap/pg_freespacemap.c b/contrib/pg_freespacemap/pg_freespacemap.c
index cfe5cb0268c..e4475c1ffc1 100644
--- a/contrib/pg_freespacemap/pg_freespacemap.c
+++ b/contrib/pg_freespacemap/pg_freespacemap.c
@@ -3,7 +3,7 @@
* pg_freespacemap.c
* display some contents of the free space relation and page maps.
*
- * $PostgreSQL: pgsql/contrib/pg_freespacemap/pg_freespacemap.c,v 1.9 2006/10/19 18:32:46 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/pg_freespacemap/pg_freespacemap.c,v 1.9.2.1 2009/04/07 18:11:04 tgl Exp $
*-------------------------------------------------------------------------
*/
#include "postgres.h"
@@ -94,6 +94,7 @@ pg_freespacemap_pages(PG_FUNCTION_ARGS)
if (SRF_IS_FIRSTCALL())
{
int i;
+ int nchunks; /* Size of freespace.c's arena. */
int numPages; /* Max possible no. of pages in map. */
int nPages; /* Mapped pages for a relation. */
@@ -102,7 +103,10 @@ pg_freespacemap_pages(PG_FUNCTION_ARGS)
*/
FreeSpaceMap = GetFreeSpaceMap();
- numPages = MaxFSMPages;
+ /* this must match calculation in InitFreeSpaceMap(): */
+ nchunks = (MaxFSMPages - 1) / CHUNKPAGES + 1;
+ /* Worst case (lots of indexes) could have this many pages: */
+ numPages = nchunks * INDEXCHUNKPAGES;
funcctx = SRF_FIRSTCALL_INIT();