pgsql: Fix two off-by-one errors in bufmgr.c. - Mailing list pgsql-committers

From Andres Freund
Subject pgsql: Fix two off-by-one errors in bufmgr.c.
Date
Msg-id E1ZPY5o-0000N3-MW@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix two off-by-one errors in bufmgr.c.

In 4b4b680c I passed a buffer index number (starting from 0) instead of
a proper Buffer id (which start from 1 for shared buffers) in two
places.

This wasn't noticed so far as one of those locations isn't compiled at
all (PrintPinnedBufs) and the other one (InvalidBuffer) requires a
unlikely, but possible, set of circumstances to trigger a symptom.

To reduce the likelihood of such incidents a bit also convert existing
open coded mappings from buffer descriptors to buffer ids with
BufferDescriptorGetBuffer().

Author: Qingqing Zhou
Reported-By: Qingqing Zhou
Discussion: CAJjS0u2ai9ooUisKtkV8cuVUtEkMTsbK8c7juNAjv8K11zeCQg@mail.gmail.com
Backpatch: 9.5 where the private ref count infrastructure was introduced

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/d25fbf9f3ecffb5c80a9201a6310e74da24556a4

Modified Files
--------------
src/backend/storage/buffer/bufmgr.c |   36 ++++++++++++++++++-----------------
1 file changed, 19 insertions(+), 17 deletions(-)


pgsql-committers by date:

Previous
From: Andres Freund
Date:
Subject: pgsql: Handle PQresultErrorField(PG_DIAG_SQLSTATE) returning NULL in st
Next
From: Andres Freund
Date:
Subject: pgsql: Remove duplicated assignment in pg_create_physical_replication_s