Index: src/backend/commands/dbcommands.c
===================================================================
RCS file: /home/cvsmirror/pgsql/src/backend/commands/dbcommands.c,v
retrieving revision 1.145
diff -c -r1.145 dbcommands.c
*** src/backend/commands/dbcommands.c	17 Oct 2004 20:47:20 -0000	1.145
--- src/backend/commands/dbcommands.c	27 Oct 2004 23:48:10 -0000
***************
*** 32,37 ****
--- 32,38 ----
  #include "commands/tablespace.h"
  #include "mb/pg_wchar.h"
  #include "miscadmin.h"
+ #include "postmaster/bgwriter.h"
  #include "storage/fd.h"
  #include "storage/freespace.h"
  #include "storage/sinval.h"
***************
*** 625,630 ****
--- 626,639 ----
  	FreeSpaceMapForgetDatabase(db_id);
  
  	/*
+ 	 * On Windows, force a checkpoint so that the bgwriter doesn't hold any
+ 	 * open files, which would cause rmdir() to fail.
+ 	 */
+ #ifdef WIN32
+ 	RequestCheckpoint(true);
+ #endif
+ 
+ 	/*
  	 * Remove all tablespace subdirs belonging to the database.
  	 */
  	remove_dbtablespaces(db_id);
Index: src/backend/postmaster/bgwriter.c
===================================================================
RCS file: /home/cvsmirror/pgsql/src/backend/postmaster/bgwriter.c,v
retrieving revision 1.9
diff -c -r1.9 bgwriter.c
*** src/backend/postmaster/bgwriter.c	12 Oct 2004 21:54:40 -0000	1.9
--- src/backend/postmaster/bgwriter.c	27 Oct 2004 23:05:10 -0000
***************
*** 347,352 ****
--- 347,361 ----
  			CreateCheckPoint(false, force_checkpoint);
  
  			/*
+ 			 * After any checkpoint, close all smgr files.	This is so we
+ 			 * won't hang onto smgr references to deleted files
+ 			 * indefinitely. (It is safe to do this because this process
+ 			 * does not have a relcache, and so no dangling references
+ 			 * could remain.)
+ 			 */
+ 			smgrcloseall();
+ 
+ 			/*
  			 * Indicate checkpoint completion to any waiting backends.
  			 */
  			BgWriterShmem->ckpt_done = BgWriterShmem->ckpt_started;
***************
*** 359,373 ****
  			 */
  			last_checkpoint_time = now;
  
- 			/*
- 			 * After any checkpoint, close all smgr files.	This is so we
- 			 * won't hang onto smgr references to deleted files
- 			 * indefinitely. (It is safe to do this because this process
- 			 * does not have a relcache, and so no dangling references
- 			 * could remain.)
- 			 */
- 			smgrcloseall();
- 
  			/* Nap for configured time before rechecking */
  			n = 1;
  		}
--- 368,373 ----
