There is no need for ReadBuffer() call sites to check that the returned

buffer is valid, as ReadBuffer() will elog on error. Most of the call
sites of ReadBuffer() got this right, but this patch fixes those call
sites that did not.
This commit is contained in:
Neil Conway 2004-11-14 02:04:14 +00:00
parent 1c5125adf3
commit a236dd9536
4 changed files with 4 additions and 46 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.180 2004/10/26 16:05:02 tgl Exp $
* $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.181 2004/11/14 02:04:12 neilc Exp $
*
*
* INTERFACE ROUTINES
@ -191,8 +191,6 @@ heapgettup(Relation relation,
*buffer = ReleaseAndReadBuffer(*buffer,
relation,
ItemPointerGetBlockNumber(tid));
if (!BufferIsValid(*buffer))
elog(ERROR, "ReadBuffer failed");
LockBuffer(*buffer, BUFFER_LOCK_SHARE);
@ -226,8 +224,6 @@ heapgettup(Relation relation,
*buffer = ReleaseAndReadBuffer(*buffer,
relation,
page);
if (!BufferIsValid(*buffer))
elog(ERROR, "ReadBuffer failed");
LockBuffer(*buffer, BUFFER_LOCK_SHARE);
@ -266,8 +262,6 @@ heapgettup(Relation relation,
*buffer = ReleaseAndReadBuffer(*buffer,
relation,
page);
if (!BufferIsValid(*buffer))
elog(ERROR, "ReadBuffer failed");
LockBuffer(*buffer, BUFFER_LOCK_SHARE);
@ -360,8 +354,6 @@ heapgettup(Relation relation,
*buffer = ReleaseAndReadBuffer(*buffer,
relation,
page);
if (!BufferIsValid(*buffer))
elog(ERROR, "ReadBuffer failed");
LockBuffer(*buffer, BUFFER_LOCK_SHARE);
dp = (Page) BufferGetPage(*buffer);
@ -941,11 +933,6 @@ heap_release_fetch(Relation relation,
buffer = ReleaseAndReadBuffer(*userbuf, relation,
ItemPointerGetBlockNumber(tid));
if (!BufferIsValid(buffer))
elog(ERROR, "ReadBuffer(\"%s\", %lu) failed",
RelationGetRelationName(relation),
(unsigned long) ItemPointerGetBlockNumber(tid));
/*
* Need share lock on buffer to examine tuple commit status.
*/
@ -1049,14 +1036,7 @@ heap_get_latest_tid(Relation relation,
* get the buffer from the relation descriptor Note that this does a
* buffer pin.
*/
buffer = ReadBuffer(relation, ItemPointerGetBlockNumber(tid));
if (!BufferIsValid(buffer))
elog(ERROR, "ReadBuffer(\"%s\", %lu) failed",
RelationGetRelationName(relation),
(unsigned long) ItemPointerGetBlockNumber(tid));
LockBuffer(buffer, BUFFER_LOCK_SHARE);
/*
@ -1304,10 +1284,6 @@ heap_delete(Relation relation, ItemPointer tid,
Assert(ItemPointerIsValid(tid));
buffer = ReadBuffer(relation, ItemPointerGetBlockNumber(tid));
if (!BufferIsValid(buffer))
elog(ERROR, "ReadBuffer failed");
LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
dp = (PageHeader) BufferGetPage(buffer);
@ -1528,8 +1504,6 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
Assert(ItemPointerIsValid(otid));
buffer = ReadBuffer(relation, ItemPointerGetBlockNumber(otid));
if (!BufferIsValid(buffer))
elog(ERROR, "ReadBuffer failed");
LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
dp = (PageHeader) BufferGetPage(buffer);
@ -1863,10 +1837,6 @@ heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer,
int result;
*buffer = ReadBuffer(relation, ItemPointerGetBlockNumber(tid));
if (!BufferIsValid(*buffer))
elog(ERROR, "ReadBuffer failed");
LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE);
dp = (PageHeader) BufferGetPage(*buffer);

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.78 2004/10/26 16:05:03 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.79 2004/11/14 02:04:13 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@ -811,8 +811,6 @@ acquire_sample_rows(Relation onerel, HeapTuple *rows, int targrows,
* tuples.
*/
targbuffer = ReadBuffer(onerel, targblock);
if (!BufferIsValid(targbuffer))
elog(ERROR, "ReadBuffer failed");
LockBuffer(targbuffer, BUFFER_LOCK_SHARE);
targpage = BufferGetPage(targbuffer);
maxoffset = PageGetMaxOffsetNumber(targpage);

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/sequence.c,v 1.117 2004/09/16 16:58:28 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/sequence.c,v 1.118 2004/11/14 02:04:14 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@ -192,10 +192,6 @@ DefineSequence(CreateSeqStmt *seq)
/* Initialize first page of relation with special magic number */
buf = ReadBuffer(rel, P_NEW);
if (!BufferIsValid(buf))
elog(ERROR, "ReadBuffer failed");
Assert(BufferGetBlockNumber(buf) == 0);
page = (PageHeader) BufferGetPage(buf);
@ -850,9 +846,6 @@ read_info(SeqTable elm, Relation rel, Buffer *buf)
Form_pg_sequence seq;
*buf = ReadBuffer(rel, 0);
if (!BufferIsValid(*buf))
elog(ERROR, "ReadBuffer failed");
LockBuffer(*buf, BUFFER_LOCK_EXCLUSIVE);
page = (PageHeader) BufferGetPage(*buf);

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.174 2004/10/30 20:52:56 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.175 2004/11/14 02:04:14 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@ -1625,9 +1625,6 @@ ltrmark:;
buffer = ReadBuffer(relation, ItemPointerGetBlockNumber(tid));
if (!BufferIsValid(buffer))
elog(ERROR, "ReadBuffer failed");
dp = (PageHeader) BufferGetPage(buffer);
lp = PageGetItemId(dp, ItemPointerGetOffsetNumber(tid));