@@ -92,7 +92,7 @@ setup_dynamic_shared_memory(int64 queue_size, int nworkers,
9292{
9393 shm_toc_estimator e ;
9494 int i ;
95- uint64 segsize ;
95+ Size segsize ;
9696 dsm_segment * seg ;
9797 shm_toc * toc ;
9898 test_shm_mq_header * hdr ;
@@ -101,8 +101,12 @@ setup_dynamic_shared_memory(int64 queue_size, int nworkers,
101101 if (queue_size < 0 || ((uint64 ) queue_size ) < shm_mq_minimum_size )
102102 ereport (ERROR ,
103103 (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
104- errmsg ("queue size must be at least %lu bytes" ,
105- (unsigned long ) shm_mq_minimum_size )));
104+ errmsg ("queue size must be at least %zu bytes" ,
105+ shm_mq_minimum_size )));
106+ if (queue_size != ((Size ) queue_size ))
107+ ereport (ERROR ,
108+ (errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
109+ errmsg ("queue size overflows size_t" )));
106110
107111 /*
108112 * Estimate how much shared memory we need.
@@ -116,7 +120,7 @@ setup_dynamic_shared_memory(int64 queue_size, int nworkers,
116120 shm_toc_initialize_estimator (& e );
117121 shm_toc_estimate_chunk (& e , sizeof (test_shm_mq_header ));
118122 for (i = 0 ; i <= nworkers ; ++ i )
119- shm_toc_estimate_chunk (& e , queue_size );
123+ shm_toc_estimate_chunk (& e , ( Size ) queue_size );
120124 shm_toc_estimate_keys (& e , 2 + nworkers );
121125 segsize = shm_toc_estimate (& e );
122126
@@ -138,7 +142,8 @@ setup_dynamic_shared_memory(int64 queue_size, int nworkers,
138142 {
139143 shm_mq * mq ;
140144
141- mq = shm_mq_create (shm_toc_allocate (toc , queue_size ), queue_size );
145+ mq = shm_mq_create (shm_toc_allocate (toc , (Size ) queue_size ),
146+ (Size ) queue_size );
142147 shm_toc_insert (toc , i + 1 , mq );
143148
144149 if (i == 0 )
0 commit comments