diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2006-01-06 00:16:09 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2006-01-06 00:16:09 +0000 |
commit | a2dca8e9e3deaf8812e5c38f837fc3fa2162d7cf (patch) | |
tree | c043258fae3aba28caea483316ec15aef1832744 | |
parent | 718d3232af9cee59c7e0a0452cc7d02935c557ea (diff) | |
download | postgresql-a2dca8e9e3deaf8812e5c38f837fc3fa2162d7cf.tar.gz postgresql-a2dca8e9e3deaf8812e5c38f837fc3fa2162d7cf.zip |
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.
-rw-r--r-- | src/backend/access/heap/hio.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/backend/access/heap/hio.c b/src/backend/access/heap/hio.c index 46c2fd31e04..5189ce12d70 100644 --- a/src/backend/access/heap/hio.c +++ b/src/backend/access/heap/hio.c @@ -8,7 +8,7 @@ * * * 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); /* - * 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)) |