Index: src/backend/commands/tablespace.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/commands/tablespace.c,v
retrieving revision 1.77
diff -c -c -r1.77 tablespace.c
*** src/backend/commands/tablespace.c	18 Jul 2010 04:47:46 -0000	1.77
--- src/backend/commands/tablespace.c	18 Jul 2010 05:17:23 -0000
***************
*** 1355,1368 ****
  	/* Backup blocks are not used in tblspc records */
  	Assert(!(record->xl_info & XLR_BKP_BLOCK_MASK));
  
! 	if (info == XLOG_TBLSPC_CREATE)
! 	{
! 		xl_tblspc_create_rec *xlrec = (xl_tblspc_create_rec *) XLogRecGetData(record);
! 		char	   *location = xlrec->ts_path;
! 
! 		create_tablespace_directories(location, xlrec->ts_id);
! 	}
! 	else if (info == XLOG_TBLSPC_DROP)
  	{
  		xl_tblspc_drop_rec *xlrec = (xl_tblspc_drop_rec *) XLogRecGetData(record);
  
--- 1355,1365 ----
  	/* Backup blocks are not used in tblspc records */
  	Assert(!(record->xl_info & XLR_BKP_BLOCK_MASK));
  
! 	/*
! 	 *	If we are creating a tablespace during recovery, it is unclear
! 	 *	what state it is in, so potentially remove it before creating it.
! 	 */
! 	if (info == XLOG_TBLSPC_DROP || info == XLOG_TBLSPC_CREATE)
  	{
  		xl_tblspc_drop_rec *xlrec = (xl_tblspc_drop_rec *) XLogRecGetData(record);
  
***************
*** 1395,1400 ****
--- 1392,1407 ----
  	}
  	else
  		elog(PANIC, "tblspc_redo: unknown op code %u", info);
+ 
+ 	/* Now create the tablespace we perhaps just removed. */
+ 	if (info == XLOG_TBLSPC_CREATE)
+ 	{
+ 		xl_tblspc_create_rec *xlrec = (xl_tblspc_create_rec *) XLogRecGetData(record);
+ 		char	   *location = xlrec->ts_path;
+ 
+ 		create_tablespace_directories(location, xlrec->ts_id);
+ 	}
+ 
  }
  
  void
