Обсуждение: pgsql: Fix overflow handling in plpgsql's integer FOR loops.

Поиск
Список
Период
Сортировка

pgsql: Fix overflow handling in plpgsql's integer FOR loops.

От
Tom Lane
Дата:
Fix overflow handling in plpgsql's integer FOR loops.

The test to exit the loop if the integer control value would overflow
an int32 turns out not to work on some ICC versions, as it's dependent
on the assumption that the compiler will execute the code as written
rather than "optimize" it.  ICC lacks any equivalent of gcc's -fwrapv
switch, so it was optimizing on the assumption of no integer overflow,
and that breaks this.  Rewrite into a form that in fact does not
do any overflowing computations.

Per Tomas Vondra and buildfarm member fulmar.  It's been like this
for a long time, although it was not till we added a regression test
case covering the behavior (in commit dd2243f2a) that the problem
became apparent.  Back-patch to all supported versions.

Discussion: https://postgr.es/m/50562fdc-0876-9843-c883-15b8566c7511@2ndquadrant.com

Branch
------
REL9_5_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/b3fade55cba65f551fd7315ceedbca930248a525

Modified Files
--------------
src/pl/plpgsql/src/pl_exec.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)