Re: ReadRecentBuffer() is broken for local buffer

Heikki Linnakangas <hlinnaka@iki.fi>

From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Thomas Munro <thomas.munro@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2022-07-25T06:10:45Z
Lists: pgsql-hackers
On 25/07/2022 00:35, Thomas Munro wrote:
> On Mon, Jul 25, 2022 at 6:22 AM Heikki Linnakangas <hlinnaka@iki.fi> wrote:
>> ReadRecentBuffer() doesn't work for local buffers, i.e. for temp tables.
>> The bug is pretty clear if you look at the code:
> 
> -        bufHdr = GetBufferDescriptor(-recent_buffer - 1);
> +        int            b = -recent_buffer - 1;
> +
> +        bufHdr = GetLocalBufferDescriptor(b);
> 
> Ugh, right.  Obviously this code path is not reached currently.  I
> added the local path for completeness but I didn't think of the idea
> of testing it the way you suggested, hence thinko escaped into the
> wild.  That way of testing seems good and the patch indeed fixes the
> problem.

Pushed, thanks for the reviews.

- Heikki



Commits

  1. Fix ReadRecentBuffer for local buffers.