diff --git a/configure b/configure
index 18daf4e8dc00819710d0789c3b6db9ea1f0ffe64..150c958ca09372c65b09de48027ca3c54645f8d0 100755
--- a/configure
+++ b/configure
@@ -11145,8 +11145,13 @@ ac_cv_func_fseeko=yes
 esac
 
 # Solaris has a very slow qsort in certain cases, so we replace it.
-case $host_os in
-  solaris*) LIBOBJS="$LIBOBJS qsort.$ac_objext" ;;
+case $host_os in solaris*)
+LIBOBJS="$LIBOBJS qsort.$ac_objext" ;;
+esac
+
+# Win32 can't to rename or unlink on an open file
+case $host_os in win32*)
+LIBOBJS="$LIBOBJS dirmod.$ac_objext" ;;
 esac
 
 # On HPUX 9, rint() is not in regular libm.a but in /lib/pa1.1/libm.a;
diff --git a/configure.in b/configure.in
index b0b8358972b18a6535b00a5d49d4a33455c6fd9c..9e50e487c9415e84e2fe75a81ddb81113655318c 100644
--- a/configure.in
+++ b/configure.in
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-dnl $Header: /cvsroot/pgsql/configure.in,v 1.242 2003/04/06 22:45:22 petere Exp $
+dnl $Header: /cvsroot/pgsql/configure.in,v 1.243 2003/04/22 02:18:09 momjian Exp $
 dnl
 dnl Developers, please strive to achieve this order:
 dnl
@@ -856,8 +856,13 @@ ac_cv_func_fseeko=yes
 esac
 
 # Solaris has a very slow qsort in certain cases, so we replace it.
-case $host_os in
-  solaris*) AC_LIBOBJ(qsort) ;;
+case $host_os in solaris*) 
+AC_LIBOBJ(qsort) ;;
+esac
+
+# Win32 can't to rename or unlink on an open file
+case $host_os in win32*) 
+AC_LIBOBJ(dirmod) ;;
 esac
 
 # On HPUX 9, rint() is not in regular libm.a but in /lib/pa1.1/libm.a;
diff --git a/src/include/c.h b/src/include/c.h
index 8b92a98793aac0bd42136834ef3e0afeb1625011..833312b9d6a756d30b0d7a2b4ad3ed27fd9cfdfb 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -12,7 +12,7 @@
  * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: c.h,v 1.138 2003/04/18 01:03:42 momjian Exp $
+ * $Id: c.h,v 1.139 2003/04/22 02:18:09 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -711,6 +711,17 @@ int fseeko(FILE *stream, off_t offset, int whence);
 off_t ftello(FILE *stream);
 #endif
 
+/*
+ * Win32 doesn't have reliable rename/unlink during concurrent access
+ */
+#ifdef WIN32
+int pgrename(const char *from, const char *to);
+int pgunlink(const char *path);      
+#define rename(path)		pgrename(path)
+#define unlink(from, to)	pgunlink(from, to)
+#endif
+
+  
 /* These are for things that are one way on Unix and another on NT */
 #define NULL_DEV		"/dev/null"