diff -rpcd a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c *** a/src/backend/commands/tablespace.c 2013-10-04 13:17:03.000000000 +0900 --- b/src/backend/commands/tablespace.c 2013-10-31 21:17:39.508000000 +0900 *************** create_tablespace_directories(const char *** 544,549 **** --- 544,550 ---- char *linkloc = palloc(OIDCHARS + OIDCHARS + 1); char *location_with_version_dir = palloc(strlen(location) + 1 + strlen(TABLESPACE_VERSION_DIRECTORY) + 1); + struct stat st; sprintf(linkloc, "pg_tblspc/%u", tablespaceoid); sprintf(location_with_version_dir, "%s/%s", location, *************** create_tablespace_directories(const char *** 606,618 **** } /* Remove old symlink in recovery, in case it points to the wrong place */ if (InRecovery) { ! if (unlink(linkloc) < 0 && errno != ENOENT) ! ereport(ERROR, ! (errcode_for_file_access(), ! errmsg("could not remove symbolic link \"%s\": %m", ! linkloc))); } /* --- 607,631 ---- } /* Remove old symlink in recovery, in case it points to the wrong place */ + /* On Windows, lstat() reports junction points as directories */ if (InRecovery) { ! if (lstat(linkloc, &st) == 0 && S_ISDIR(st.st_mode)) ! { ! if (rmdir(linkloc) < 0) ! ereport(ERROR, ! (errcode_for_file_access(), ! errmsg("could not remove directory \"%s\": %m", ! linkloc))); ! } ! else ! { ! if (unlink(linkloc) < 0 && errno != ENOENT) ! ereport(ERROR, ! (errcode_for_file_access(), ! errmsg("could not remove symbolic link \"%s\": %m", ! linkloc))); ! } } /*