Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfd0cdeb

Browse files
Maksim MilyutinMaksim Milyutin
Maksim Milyutin
authored and
Maksim Milyutin
committed
Replace multiplication ops on multiple additions
1 parente710bbf commitfd0cdeb

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

‎range.sql

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ DECLARE
9191
v_rows_countINTEGER;
9292
v_maxp_start_value%TYPE;
9393
v_cur_valuep_start_value%TYPE := p_start_value;
94+
p_end_valuep_start_value%TYPE;
9495
iINTEGER;
9596

9697
BEGIN
@@ -132,12 +133,19 @@ BEGIN
132133
* and specifies partition count as 0 then do not check boundaries
133134
*/
134135
IF p_count!=0 THEN
136+
/* compute right bound of partitioning through additions*/
137+
p_end_value := p_start_value;
138+
FOR iIN1..p_count
139+
LOOP
140+
p_end_value := p_end_value+ p_interval;
141+
END LOOP;
142+
135143
/* Check boundaries*/
136144
EXECUTE format('SELECT @extschema@.check_boundaries(''%s'',''%s'',''%s'',''%s''::%s)',
137145
parent_relid,
138146
p_attribute,
139147
p_start_value,
140-
p_start_value+ p_interval* p_count,
148+
p_end_value,
141149
pg_typeof(p_start_value));
142150
END IF;
143151

@@ -190,6 +198,7 @@ DECLARE
190198
v_rows_countINTEGER;
191199
v_maxp_start_value%TYPE;
192200
v_cur_valuep_start_value%TYPE := p_start_value;
201+
p_end_valuep_start_value%TYPE;
193202
iINTEGER;
194203

195204
BEGIN
@@ -235,11 +244,18 @@ BEGIN
235244
* and specifies partition count as 0 then do not check boundaries
236245
*/
237246
IF p_count!=0 THEN
247+
/* compute right bound of partitioning through additions*/
248+
p_end_value := p_start_value;
249+
FOR iIN1..p_count
250+
LOOP
251+
p_end_value := p_end_value+ p_interval;
252+
END LOOP;
253+
238254
/* check boundaries*/
239255
PERFORM @extschema@.check_boundaries(parent_relid,
240256
p_attribute,
241257
p_start_value,
242-
p_start_value+ p_interval* p_count);
258+
p_end_value);
243259
END IF;
244260

245261
/* Create sequence for child partitions names*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp