aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2006-03-04 19:09:09 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2006-03-04 19:09:09 +0000
commit20bdc71369014f4cb1cf04fafbf99862cfbe2504 (patch)
tree4d3a6f6c00d182a3dfeae9cca8c0202d2b20f352
parent80cadb303ce035a291a1b7441adb59073a9529c0 (diff)
downloadpostgresql-20bdc71369014f4cb1cf04fafbf99862cfbe2504.tar.gz
postgresql-20bdc71369014f4cb1cf04fafbf99862cfbe2504.zip
Prevent lazy_space_alloc from making requests that exceed MaxAllocSize,
per report from Stefan Kaltenbrunner.
-rw-r--r--src/backend/commands/vacuumlazy.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c
index 2c1ba517638..5fc251d6c4b 100644
--- a/src/backend/commands/vacuumlazy.c
+++ b/src/backend/commands/vacuumlazy.c
@@ -31,7 +31,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.66 2006/02/11 23:31:34 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.67 2006/03/04 19:09:09 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -48,6 +48,7 @@
#include "storage/freespace.h"
#include "storage/smgr.h"
#include "utils/lsyscache.h"
+#include "utils/memutils.h"
#include "utils/pg_rusage.h"
@@ -957,6 +958,7 @@ lazy_space_alloc(LVRelStats *vacrelstats, BlockNumber relblocks)
maxtuples = (maintenance_work_mem * 1024L) / sizeof(ItemPointerData);
maxtuples = Min(maxtuples, INT_MAX);
+ maxtuples = Min(maxtuples, MaxAllocSize / sizeof(ItemPointerData));
/* stay sane if small maintenance_work_mem */
maxtuples = Max(maxtuples, MaxHeapTuplesPerPage);
@@ -966,6 +968,7 @@ lazy_space_alloc(LVRelStats *vacrelstats, BlockNumber relblocks)
palloc(maxtuples * sizeof(ItemPointerData));
maxpages = MaxFSMPages;
+ maxpages = Min(maxpages, MaxAllocSize / sizeof(PageFreeSpaceInfo));
/* No need to allocate more pages than the relation has blocks */
if (relblocks < (BlockNumber) maxpages)
maxpages = (int) relblocks;