1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-18 12:22:09 +03:00

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.
This commit is contained in:
Tom Lane
2006-01-06 00:16:09 +00:00
parent 718d3232af
commit a2dca8e9e3

View File

@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/heap/hio.c,v 1.54.4.1 2005/05/07 21:32:52 tgl Exp $ * $PostgreSQL: pgsql/src/backend/access/heap/hio.c,v 1.54.4.2 2006/01/06 00:16:09 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@@ -268,10 +268,17 @@ RelationGetBufferForTuple(Relation relation, Size len,
UnlockPage(relation, 0, ExclusiveLock); UnlockPage(relation, 0, 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); 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); PageInit(pageHeader, BufferGetPageSize(buffer), 0);
if (len > PageGetFreeSpace(pageHeader)) if (len > PageGetFreeSpace(pageHeader))