@@ -287,7 +287,8 @@ ExecParallelSetupTupleQueues(ParallelContext *pcxt, bool reinitialize)
287287if (!reinitialize )
288288tqueuespace =
289289shm_toc_allocate (pcxt -> toc ,
290- PARALLEL_TUPLE_QUEUE_SIZE * pcxt -> nworkers );
290+ mul_size (PARALLEL_TUPLE_QUEUE_SIZE ,
291+ pcxt -> nworkers ));
291292else
292293tqueuespace = shm_toc_lookup (pcxt -> toc ,PARALLEL_KEY_TUPLE_QUEUE );
293294
@@ -296,7 +297,8 @@ ExecParallelSetupTupleQueues(ParallelContext *pcxt, bool reinitialize)
296297{
297298shm_mq * mq ;
298299
299- mq = shm_mq_create (tqueuespace + i * PARALLEL_TUPLE_QUEUE_SIZE ,
300+ mq = shm_mq_create (tqueuespace +
301+ ((Size )i )* PARALLEL_TUPLE_QUEUE_SIZE ,
300302 (Size )PARALLEL_TUPLE_QUEUE_SIZE );
301303
302304shm_mq_set_receiver (mq ,MyProc );
@@ -380,12 +382,12 @@ ExecInitParallelPlan(PlanState *planstate, EState *estate, int nworkers)
380382 * looking at pgBufferUsage, so do it unconditionally.
381383 */
382384shm_toc_estimate_chunk (& pcxt -> estimator ,
383- sizeof (BufferUsage )* pcxt -> nworkers );
385+ mul_size ( sizeof (BufferUsage ), pcxt -> nworkers ) );
384386shm_toc_estimate_keys (& pcxt -> estimator ,1 );
385387
386388/* Estimate space for tuple queues. */
387389shm_toc_estimate_chunk (& pcxt -> estimator ,
388- PARALLEL_TUPLE_QUEUE_SIZE * pcxt -> nworkers );
390+ mul_size ( PARALLEL_TUPLE_QUEUE_SIZE , pcxt -> nworkers ) );
389391shm_toc_estimate_keys (& pcxt -> estimator ,1 );
390392
391393/*
@@ -404,7 +406,9 @@ ExecInitParallelPlan(PlanState *planstate, EState *estate, int nworkers)
404406sizeof (int )* e .nnodes ;
405407instrumentation_len = MAXALIGN (instrumentation_len );
406408instrument_offset = instrumentation_len ;
407- instrumentation_len += sizeof (Instrumentation )* e .nnodes * nworkers ;
409+ instrumentation_len +=
410+ mul_size (sizeof (Instrumentation ),
411+ mul_size (e .nnodes ,nworkers ));
408412shm_toc_estimate_chunk (& pcxt -> estimator ,instrumentation_len );
409413shm_toc_estimate_keys (& pcxt -> estimator ,1 );
410414}
@@ -432,7 +436,7 @@ ExecInitParallelPlan(PlanState *planstate, EState *estate, int nworkers)
432436
433437/* Allocate space for each worker's BufferUsage; no need to initialize. */
434438bufusage_space = shm_toc_allocate (pcxt -> toc ,
435- sizeof (BufferUsage )* pcxt -> nworkers );
439+ mul_size ( sizeof (BufferUsage ), pcxt -> nworkers ) );
436440shm_toc_insert (pcxt -> toc ,PARALLEL_KEY_BUFFER_USAGE ,bufusage_space );
437441pei -> buffer_usage = bufusage_space ;
438442
@@ -511,7 +515,7 @@ ExecParallelRetrieveInstrumentation(PlanState *planstate,
511515InstrAggNode (planstate -> instrument ,& instrument [n ]);
512516
513517/* Also store the per-worker detail. */
514- ibytes = instrumentation -> num_workers * sizeof (Instrumentation );
518+ ibytes = mul_size ( instrumentation -> num_workers , sizeof (Instrumentation ) );
515519planstate -> worker_instrument =
516520palloc (ibytes + offsetof(WorkerInstrumentation ,instrument ));
517521planstate -> worker_instrument -> num_workers = instrumentation -> num_workers ;