diff --git a/configure b/configure
index 750696056483426b20cf52e931a0bdc0f03fd43e..a9356bcc860166a6a5703292d77e932b3581a36b 100755
--- a/configure
+++ b/configure
@@ -12060,7 +12060,13 @@ LIBOBJS="$LIBOBJS copydir.$ac_objext"
 LIBOBJS="$LIBOBJS gettimeofday.$ac_objext"
 LIBOBJS="$LIBOBJS kill.$ac_objext"
 LIBOBJS="$LIBOBJS open.$ac_objext"
-LIBOBJS="$LIBOBJS rand.$ac_objext" ;;
+LIBOBJS="$LIBOBJS rand.$ac_objext"
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_SYMLINK 1
+_ACEOF
+
+;;
 esac
 
 if test "$with_readline" = yes; then
diff --git a/configure.in b/configure.in
index 5a27f6cc75a6d110008c063ff137046fe47b2fd8..cf12ce64937ea3d261e84e198fa57b2fb358a21c 100644
--- a/configure.in
+++ b/configure.in
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-dnl $PostgreSQL: pgsql/configure.in,v 1.371 2004/08/04 21:33:35 tgl Exp $
+dnl $PostgreSQL: pgsql/configure.in,v 1.372 2004/08/08 01:31:09 momjian Exp $
 dnl
 dnl Developers, please strive to achieve this order:
 dnl
@@ -908,7 +908,10 @@ AC_LIBOBJ(copydir)
 AC_LIBOBJ(gettimeofday)
 AC_LIBOBJ(kill)
 AC_LIBOBJ(open)
-AC_LIBOBJ(rand) ;;
+AC_LIBOBJ(rand)
+AC_DEFINE([HAVE_SYMLINK], 1,
+          [Define to 1 if you have the `symlink' function.])
+;;
 esac
 
 if test "$with_readline" = yes; then
diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c
index 1a9e69dc12398cd4d7ad7acd4fd9610a23a1dc12..05a13315a1f444af1aef16aee6f4f09e727868e8 100644
--- a/src/backend/commands/tablespace.c
+++ b/src/backend/commands/tablespace.c
@@ -45,7 +45,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.7 2004/08/01 20:30:48 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.8 2004/08/08 01:31:11 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -482,11 +482,20 @@ DropTableSpace(DropTableSpaceStmt *stmt)
 				 errmsg("could not unlink file \"%s\": %m",
 						subfile)));
 
+#ifndef WIN32
 	if (unlink(location) < 0)
 		ereport(ERROR,
 				(errcode_for_file_access(),
 				 errmsg("could not unlink symbolic link \"%s\": %m",
 						location)));
+#else
+	/* The junction is a directory, not a file */
+	if (rmdir(location) < 0)
+		ereport(ERROR,
+				(errcode_for_file_access(),
+				 errmsg("could not remove junction dir \"%s\": %m",
+				 		location)));
+#endif
 
 	pfree(subfile);
 	pfree(location);
diff --git a/src/port/dirmod.c b/src/port/dirmod.c
index 3010127c4c2215dfc2e4cdbd621550f2ca948f47..1ff57a26883f03cf5ed9696e25c82bc1ce1c75a8 100644
--- a/src/port/dirmod.c
+++ b/src/port/dirmod.c
@@ -10,7 +10,7 @@
  *	Win32 (NT, Win2k, XP).	replace() doesn't work on Win95/98/Me.
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/port/dirmod.c,v 1.14 2004/08/07 21:48:09 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/port/dirmod.c,v 1.15 2004/08/08 01:31:15 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -153,9 +153,9 @@ pgsymlink(const char *oldpath, const char *newpath)
 {
 	HANDLE dirhandle;
 	DWORD len;
-	char *p = nativeTarget;
 	char buffer[MAX_PATH*sizeof(WCHAR) + sizeof(REPARSE_JUNCTION_DATA_BUFFER)];
 	char nativeTarget[MAX_PATH];
+	char *p = nativeTarget;
 	REPARSE_JUNCTION_DATA_BUFFER *reparseBuf = (REPARSE_JUNCTION_DATA_BUFFER*)buffer;
     
 	CreateDirectory(newpath, 0);
@@ -203,9 +203,12 @@ pgsymlink(const char *oldpath, const char *newpath)
 					  NULL, GetLastError(), 
 					  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
 					  (LPSTR)&msg, 0, NULL );
+#ifdef FRONTEND
+		fprintf(stderr, "Error setting junction for %s: %s", nativeTarget, msg);
+#else
 		ereport(ERROR, (errcode_for_file_access(),
 			errmsg("Error setting junction for %s: %s", nativeTarget, msg)));
-	    
+#endif
 		LocalFree(msg);
 	    
 		CloseHandle(dirhandle);