3131 *
3232 *
3333 * IDENTIFICATION
34- * $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.66 2006/02/11 23:31:34 tgl Exp $
34+ * $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.67 2006/03/04 19:09:09 tgl Exp $
3535 *
3636 *-------------------------------------------------------------------------
3737 */
4848#include "storage/freespace.h"
4949#include "storage/smgr.h"
5050#include "utils/lsyscache.h"
51+ #include "utils/memutils.h"
5152#include "utils/pg_rusage.h"
5253
5354
@@ -957,6 +958,7 @@ lazy_space_alloc(LVRelStats *vacrelstats, BlockNumber relblocks)
957958
958959 maxtuples = (maintenance_work_mem * 1024L ) / sizeof (ItemPointerData );
959960 maxtuples = Min (maxtuples , INT_MAX );
961+ maxtuples = Min (maxtuples , MaxAllocSize / sizeof (ItemPointerData ));
960962 /* stay sane if small maintenance_work_mem */
961963 maxtuples = Max (maxtuples , MaxHeapTuplesPerPage );
962964
@@ -966,6 +968,7 @@ lazy_space_alloc(LVRelStats *vacrelstats, BlockNumber relblocks)
966968 palloc (maxtuples * sizeof (ItemPointerData ));
967969
968970 maxpages = MaxFSMPages ;
971+ maxpages = Min (maxpages , MaxAllocSize / sizeof (PageFreeSpaceInfo ));
969972 /* No need to allocate more pages than the relation has blocks */
970973 if (relblocks < (BlockNumber ) maxpages )
971974 maxpages = (int ) relblocks ;
0 commit comments