Index: src/backend/storage/smgr/md.c
===================================================================
RCS file: /home/hlinnaka/pgcvsrepository/pgsql/src/backend/storage/smgr/md.c,v
retrieving revision 1.128
diff -c -r1.128 md.c
*** src/backend/storage/smgr/md.c	12 Apr 2007 17:10:55 -0000	1.128
--- src/backend/storage/smgr/md.c	20 Jul 2007 12:31:42 -0000
***************
*** 717,722 ****
--- 717,734 ----
  #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 ? EXTENSION_RETURN_NULL : EXTENSION_FAIL);
+ 	if (v == NULL)
+ 	{
+ 		Assert(InRecovery);
+ 		return;
+ 	}
+ 
+ 	/*
  	 * NOTE: mdnblocks makes sure we have opened all active segments, so
  	 * that truncation loop will get them all!
  	 */
***************
*** 736,743 ****
  	if (nblocks == curnblk)
  		return;					/* no work */
  
- 	v = mdopen(reln, EXTENSION_FAIL);
- 
  #ifndef LET_OS_MANAGE_FILESIZE
  	priorblocks = 0;
  	while (v != NULL)
--- 748,753 ----
