From 6929a1e6ad623d182a4aa7567af8a14c4afa3ae8 Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Tue, 12 Nov 2002 15:26:30 +0000
Subject: [PATCH] Improve comment: add note that grotty special case in
 mdread() is required by hash index implementation.

---
 src/backend/storage/smgr/md.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
index 25051a9799c..f8f82048f34 100644
--- a/src/backend/storage/smgr/md.c
+++ b/src/backend/storage/smgr/md.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.92 2002/08/06 02:36:34 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.93 2002/11/12 15:26:30 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -434,8 +434,12 @@ mdread(Relation reln, BlockNumber blocknum, char *buffer)
 	if ((nbytes = FileRead(v->mdfd_vfd, buffer, BLCKSZ)) != BLCKSZ)
 	{
 		/*
-		 * If we are at EOF, return zeroes without complaining. (XXX Is
-		 * this still necessary/a good idea??)
+		 * If we are at or past EOF, return zeroes without complaining.
+		 * Also substitute zeroes if we found a partial block at EOF.
+		 *
+		 * XXX this is really ugly, bad design.  However the current
+		 * implementation of hash indexes requires it, because hash index
+		 * pages are initialized out-of-order.
 		 */
 		if (nbytes == 0 ||
 			(nbytes > 0 && mdnblocks(reln) == blocknum))
-- 
GitLab