Skip to content

Commit 2d0475e

Browse files
committed
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.
1 parent 304160c commit 2d0475e

File tree

1 file changed

+10
-3
lines changed
  • src/backend/access/heap

1 file changed

+10
-3
lines changed

src/backend/access/heap/hio.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/heap/hio.c,v 1.59 2005/11/22 18:17:06 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/heap/hio.c,v 1.60 2006/01/06 00:15:50 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -281,10 +281,17 @@ RelationGetBufferForTuple(Relation relation, Size len,
281281
UnlockRelationForExtension(relation, ExclusiveLock);
282282

283283
/*
284-
* We need to initialize the empty new page.
284+
* We need to initialize the empty new page. Double-check that it really
285+
* is empty (this should never happen, but if it does we don't want to
286+
* risk wiping out valid data).
285287
*/
286288
pageHeader = (Page) BufferGetPage(buffer);
287-
Assert(PageIsNew((PageHeader) pageHeader));
289+
290+
if (!PageIsNew((PageHeader) pageHeader))
291+
elog(ERROR, "page %u of relation \"%s\" should be empty but is not",
292+
BufferGetBlockNumber(buffer),
293+
RelationGetRelationName(relation));
294+
288295
PageInit(pageHeader, BufferGetPageSize(buffer), 0);
289296

290297
if (len > PageGetFreeSpace(pageHeader))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy