mirror of
https://github.com/postgres/postgres.git
synced 2025-08-25 20:23:07 +03:00
Repair possible failure to update hint bits back to disk, per
http://archives.postgresql.org/pgsql-hackers/2004-10/msg00464.php. This fix is intended to be permanent: it moves the responsibility for calling SetBufferCommitInfoNeedsSave() into the tqual.c routines, eliminating the requirement for callers to test whether t_infomask changed. Also, tighten validity checking on buffer IDs in bufmgr.c --- several routines were paranoid about out-of-range shared buffer numbers but not about out-of-range local ones, which seems a tad pointless.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/storage/bufmgr.h,v 1.86 2004/08/29 05:06:58 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/storage/bufmgr.h,v 1.87 2004/10/15 22:40:25 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -51,13 +51,14 @@ extern int32 *LocalRefCount;
|
||||
* These routines are beaten on quite heavily, hence the macroization.
|
||||
*/
|
||||
|
||||
#define BAD_BUFFER_ID(bid) ((bid) < 1 || (bid) > NBuffers)
|
||||
|
||||
/*
|
||||
* BufferIsValid
|
||||
* True iff the given buffer number is valid (either as a shared
|
||||
* or local buffer).
|
||||
*
|
||||
* This is not quite the inverse of the BufferIsInvalid() macro, since this
|
||||
* adds sanity rangechecks on the buffer number.
|
||||
*
|
||||
* Note: For a long time this was defined the same as BufferIsPinned,
|
||||
* that is it would say False if you didn't hold a pin on the buffer.
|
||||
* I believe this was bogus and served only to mask logic errors.
|
||||
@@ -66,10 +67,9 @@ extern int32 *LocalRefCount;
|
||||
*/
|
||||
#define BufferIsValid(bufnum) \
|
||||
( \
|
||||
BufferIsLocal(bufnum) ? \
|
||||
((bufnum) >= -NLocBuffer) \
|
||||
: \
|
||||
(! BAD_BUFFER_ID(bufnum)) \
|
||||
(bufnum) != InvalidBuffer && \
|
||||
(bufnum) >= -NLocBuffer && \
|
||||
(bufnum) <= NBuffers \
|
||||
)
|
||||
|
||||
/*
|
||||
@@ -81,15 +81,13 @@ extern int32 *LocalRefCount;
|
||||
*/
|
||||
#define BufferIsPinned(bufnum) \
|
||||
( \
|
||||
BufferIsLocal(bufnum) ? \
|
||||
((bufnum) >= -NLocBuffer && LocalRefCount[-(bufnum) - 1] > 0) \
|
||||
!BufferIsValid(bufnum) ? \
|
||||
false \
|
||||
: \
|
||||
( \
|
||||
BAD_BUFFER_ID(bufnum) ? \
|
||||
false \
|
||||
BufferIsLocal(bufnum) ? \
|
||||
(LocalRefCount[-(bufnum) - 1] > 0) \
|
||||
: \
|
||||
(PrivateRefCount[(bufnum) - 1] > 0) \
|
||||
) \
|
||||
)
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user