#include "postgres.h"
+#include <limits.h>
+
#include "access/gin_private.h"
#include "utils/datum.h"
#include "utils/memutils.h"
*/
if (eo->count >= eo->maxcount)
{
+ if (eo->maxcount > INT_MAX)
+ ereport(ERROR,
+ (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
+ errmsg("posting list is too long"),
+ errhint("Reduce maintenance_work_mem")));
+
accum->allocatedMemory -= GetMemoryChunkSpace(eo->list);
eo->maxcount *= 2;
eo->list = (ItemPointerData *)
- repalloc(eo->list, sizeof(ItemPointerData) * eo->maxcount);
+ repalloc_huge(eo->list, sizeof(ItemPointerData) * eo->maxcount);
accum->allocatedMemory += GetMemoryChunkSpace(eo->list);
}
*/
if (GinPageGetOpaque(page)->rightlink == InvalidBlockNumber ||
(GinPageHasFullRow(page) &&
- (accum.allocatedMemory >= maintenance_work_mem * 1024L)))
+ (accum.allocatedMemory >= (Size)maintenance_work_mem * 1024L)))
{
ItemPointerData *list;
uint32 nlist;
&htup->t_self);
/* If we've maxed out our available memory, dump everything to the index */
- if (buildstate->accum.allocatedMemory >= maintenance_work_mem * 1024L)
+ if (buildstate->accum.allocatedMemory >= (Size)maintenance_work_mem * 1024L)
{
ItemPointerData *list;
Datum key;