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

Commitb3fade5

Browse files
committed
Fix overflow handling in plpgsql's integer FOR loops.
The test to exit the loop if the integer control value would overflowan int32 turns out not to work on some ICC versions, as it's dependenton the assumption that the compiler will execute the code as writtenrather than "optimize" it. ICC lacks any equivalent of gcc's -fwrapvswitch, so it was optimizing on the assumption of no integer overflow,and that breaks this. Rewrite into a form that in fact does notdo any overflowing computations.Per Tomas Vondra and buildfarm member fulmar. It's been like thisfor a long time, although it was not till we added a regression testcase covering the behavior (in commitdd2243f) that the problembecame apparent. Back-patch to all supported versions.Discussion:https://postgr.es/m/50562fdc-0876-9843-c883-15b8566c7511@2ndquadrant.com
1 parent7de7ddb commitb3fade5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎src/pl/plpgsql/src/pl_exec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2118,13 +2118,13 @@ exec_stmt_fori(PLpgSQL_execstate *estate, PLpgSQL_stmt_fori *stmt)
21182118
*/
21192119
if (stmt->reverse)
21202120
{
2121-
if ((int32) (loop_value-step_value)>loop_value)
2121+
if (loop_value< (PG_INT32_MIN+step_value))
21222122
break;
21232123
loop_value-=step_value;
21242124
}
21252125
else
21262126
{
2127-
if ((int32) (loop_value+step_value)<loop_value)
2127+
if (loop_value> (PG_INT32_MAX-step_value))
21282128
break;
21292129
loop_value+=step_value;
21302130
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp