pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix overflow handling in plpgsql's integer FOR loops.
Date: Sat, 17 Mar 2018 19:38:41 +0000
Message-ID: <E1exHf7-0000lk-MP@gemulon.postgresql.org> (raw)

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
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/04c76acab46fe3ea1c630868fbf53cd12146e3cd

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



view thread (6+ messages)

Message-ID: <E1exHf7-0000lk-MP@gemulon.postgresql.org>
Permalink:  ../E1exHf7-0000lk-MP@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1exHf7-0000lk-MP@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Fix overflow handling in plpgsql's integer FOR loops.
  In-Reply-To: <E1exHf7-0000lk-MP@gemulon.postgresql.org>
  References: <E1exHf7-0000lk-MP@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox