Re: Avoid a possible overflow (src/backend/utils/sort/logtape.c)

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Peter Geoghegan <pg@bowt.ie>
Cc: Ranier Vilela <ranier.vf@gmail.com>, Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2023-08-25T01:18:48Z
Lists: pgsql-hackers
On Thu, Aug 24, 2023 at 05:33:15PM -0700, Peter Geoghegan wrote:
> I am in favor of fixing the problem. I don't quite recall what it was
> that made the discussion stall last time around.

I think that you mean this one:
https://www.postgresql.org/message-id/CAH2-WznCscXnWmnj=STC0aSa7QG+BRedDnZsP=Jo_R9GUZvUrg@mail.gmail.com

Still that looks entirely different to me.  Here we have a problem
where the number of free blocks stored may cause an overflow in the
internal routine retrieving a free block, but your other thread
is about long being not enough on Windows.  I surely agree that
there's an argument for improving this interface and remove its use of
long in the long-term but that would not be backpatched.  I also don't
see why we cannot do the change proposed here until then, and it's
backpatchable.

There is a second thread related to logtape.c here, but that's still
different:
https://www.postgresql.org/message-id/flat/CAH2-Wzn5PCBLUrrds%3DhD439LtWP%2BPD7ekRTd%3D8LdtqJ%2BKO5D1Q%40mail.gmail.com
--
Michael

Commits

  1. Avoid possible overflow with ltsGetFreeBlock() in logtape.c