diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-10-15 22:40:29 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-10-15 22:40:29 +0000 |
commit | 9ffc8ed58b55cb3925bb95cc184583fcb9772013 (patch) | |
tree | 9039f51525070c611a86f03a2e85a13b24005ac3 /src/include/storage/bufmgr.h | |
parent | db9e2fd0a9144707055ed382f184f5a9c11aafff (diff) |
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.
Diffstat (limited to 'src/include/storage/bufmgr.h')
-rw-r--r-- | src/include/storage/bufmgr.h | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h index cb8feda8bdf..04bc09e22c6 100644 --- a/src/include/storage/bufmgr.h +++ b/src/include/storage/bufmgr.h @@ -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) \ - ) \ ) /* |