* 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"
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. */
*/
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();