From: Tom Lane Date: Fri, 6 Jan 2006 00:15:58 +0000 (+0000) Subject: Convert Assert checking for empty page into a regular test and elog. X-Git-Url: http://waps.l3s.uni-hannover.de/gitweb/?a=commitdiff_plain;h=46e1182f922f2aacca928578b2f3e7eaaa7abcf5;p=users%2Fbernd%2Fpostgres.git Convert Assert checking for empty page into a regular test and elog. The consequences of overwriting a non-empty page are bad enough that we should not omit this test in production builds. --- diff --git a/src/backend/access/heap/hio.c b/src/backend/access/heap/hio.c index 116dcb71d3..6481493f3a 100644 --- a/src/backend/access/heap/hio.c +++ b/src/backend/access/heap/hio.c @@ -281,10 +281,17 @@ RelationGetBufferForTuple(Relation relation, Size len, UnlockRelationForExtension(relation, ExclusiveLock); /* - * We need to initialize the empty new page. + * We need to initialize the empty new page. Double-check that it really + * is empty (this should never happen, but if it does we don't want to + * risk wiping out valid data). */ pageHeader = (Page) BufferGetPage(buffer); - Assert(PageIsNew((PageHeader) pageHeader)); + + if (!PageIsNew((PageHeader) pageHeader)) + elog(ERROR, "page %u of relation \"%s\" should be empty but is not", + BufferGetBlockNumber(buffer), + RelationGetRelationName(relation)); + PageInit(pageHeader, BufferGetPageSize(buffer), 0); if (len > PageGetFreeSpace(pageHeader))