summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2006-01-06 00:15:58 +0000
committerTom Lane2006-01-06 00:15:58 +0000
commit9395f4911ae577aed180667e26fcba05ec699cad (patch)
tree5bbbe50ca66ef693a925ca120496d6e7eabbfa51
parentcf3c9c14c3337c1e411b926c556ab5e0d0143b65 (diff)
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.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/backend/access/heap/hio.c b/src/backend/access/heap/hio.c
index 440c94bf56b..4e59d59f3ed 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.58.2.1 2005/11/22 18:23:04 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/heap/hio.c,v 1.58.2.2 2006/01/06 00:15:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -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))