@@ -91,6 +91,7 @@ DECLARE
91
91
v_rows_countINTEGER ;
92
92
v_maxp_start_value%TYPE;
93
93
v_cur_valuep_start_value%TYPE := p_start_value;
94
+ p_end_valuep_start_value%TYPE;
94
95
iINTEGER ;
95
96
96
97
BEGIN
@@ -132,12 +133,19 @@ BEGIN
132
133
* and specifies partition count as 0 then do not check boundaries
133
134
*/
134
135
IF p_count!= 0 THEN
136
+ /* compute right bound of partitioning through additions*/
137
+ p_end_value := p_start_value;
138
+ FOR iIN 1 ..p_count
139
+ LOOP
140
+ p_end_value := p_end_value+ p_interval;
141
+ END LOOP;
142
+
135
143
/* Check boundaries*/
136
144
EXECUTE format(' SELECT @extschema@.check_boundaries(' ' %s' ' ,' ' %s' ' ,' ' %s' ' ,' ' %s' ' ::%s)' ,
137
145
parent_relid,
138
146
p_attribute,
139
147
p_start_value,
140
- p_start_value + p_interval * p_count ,
148
+ p_end_value ,
141
149
pg_typeof(p_start_value));
142
150
END IF;
143
151
@@ -190,6 +198,7 @@ DECLARE
190
198
v_rows_countINTEGER ;
191
199
v_maxp_start_value%TYPE;
192
200
v_cur_valuep_start_value%TYPE := p_start_value;
201
+ p_end_valuep_start_value%TYPE;
193
202
iINTEGER ;
194
203
195
204
BEGIN
@@ -235,11 +244,18 @@ BEGIN
235
244
* and specifies partition count as 0 then do not check boundaries
236
245
*/
237
246
IF p_count!= 0 THEN
247
+ /* compute right bound of partitioning through additions*/
248
+ p_end_value := p_start_value;
249
+ FOR iIN 1 ..p_count
250
+ LOOP
251
+ p_end_value := p_end_value+ p_interval;
252
+ END LOOP;
253
+
238
254
/* check boundaries*/
239
255
PERFORM @extschema@.check_boundaries(parent_relid,
240
256
p_attribute,
241
257
p_start_value,
242
- p_start_value + p_interval * p_count );
258
+ p_end_value );
243
259
END IF;
244
260
245
261
/* Create sequence for child partitions names*/