Index: src/backend/storage/smgr/md.c
===================================================================
RCS file: /home/hlinnaka/pgcvsrepository/pgsql/src/backend/storage/smgr/md.c,v
retrieving revision 1.114.4.2
diff -c -r1.114.4.2 md.c
*** src/backend/storage/smgr/md.c	26 Apr 2007 23:25:30 -0000	1.114.4.2
--- src/backend/storage/smgr/md.c	20 Jul 2007 12:37:45 -0000
***************
*** 601,606 ****
--- 601,618 ----
  #endif
  
  	/*
+ 	 * Open the relation. We call mdopen before mdnblocks, because that will
+ 	 * fail if the first segment doesn't exist. That can happen in recovery,
+ 	 * if the relation was dropped after the truncate.
+ 	 */
+ 	v = mdopen(reln, InRecovery);
+ 	if (v == NULL)
+ 	{
+ 		Assert(InRecovery);
+ 		return;
+ 	}
+ 
+ 	/*
  	 * NOTE: mdnblocks makes sure we have opened all active segments, so
  	 * that truncation loop will get them all!
  	 */
***************
*** 612,619 ****
  	if (nblocks == curnblk)
  		return nblocks;			/* no work */
  
- 	v = mdopen(reln, false);
- 
  #ifndef LET_OS_MANAGE_FILESIZE
  	priorblocks = 0;
  	while (v != NULL)
--- 624,629 ----
