@@ -92,7 +92,7 @@ setup_dynamic_shared_memory(int64 queue_size, int nworkers,
92
92
{
93
93
shm_toc_estimator e ;
94
94
int i ;
95
- uint64 segsize ;
95
+ Size segsize ;
96
96
dsm_segment * seg ;
97
97
shm_toc * toc ;
98
98
test_shm_mq_header * hdr ;
@@ -101,8 +101,12 @@ setup_dynamic_shared_memory(int64 queue_size, int nworkers,
101
101
if (queue_size < 0 || ((uint64 ) queue_size ) < shm_mq_minimum_size )
102
102
ereport (ERROR ,
103
103
(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" )));
106
110
107
111
/*
108
112
* Estimate how much shared memory we need.
@@ -116,7 +120,7 @@ setup_dynamic_shared_memory(int64 queue_size, int nworkers,
116
120
shm_toc_initialize_estimator (& e );
117
121
shm_toc_estimate_chunk (& e , sizeof (test_shm_mq_header ));
118
122
for (i = 0 ; i <= nworkers ; ++ i )
119
- shm_toc_estimate_chunk (& e , queue_size );
123
+ shm_toc_estimate_chunk (& e , ( Size ) queue_size );
120
124
shm_toc_estimate_keys (& e , 2 + nworkers );
121
125
segsize = shm_toc_estimate (& e );
122
126
@@ -138,7 +142,8 @@ setup_dynamic_shared_memory(int64 queue_size, int nworkers,
138
142
{
139
143
shm_mq * mq ;
140
144
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 );
142
147
shm_toc_insert (toc , i + 1 , mq );
143
148
144
149
if (i == 0 )
0 commit comments