Skip to content

Commit 5e01aa7

Browse files
committed
Fixups for Win32 symlinks.
1 parent 9b3caeb commit 5e01aa7

File tree

4 files changed

+28
-7
lines changed

4 files changed

+28
-7
lines changed

configure

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12060,7 +12060,13 @@ LIBOBJS="$LIBOBJS copydir.$ac_objext"
1206012060
LIBOBJS="$LIBOBJS gettimeofday.$ac_objext"
1206112061
LIBOBJS="$LIBOBJS kill.$ac_objext"
1206212062
LIBOBJS="$LIBOBJS open.$ac_objext"
12063-
LIBOBJS="$LIBOBJS rand.$ac_objext" ;;
12063+
LIBOBJS="$LIBOBJS rand.$ac_objext"
12064+
12065+
cat >>confdefs.h <<\_ACEOF
12066+
#define HAVE_SYMLINK 1
12067+
_ACEOF
12068+
12069+
;;
1206412070
esac
1206512071

1206612072
if test "$with_readline" = yes; then

configure.in

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $PostgreSQL: pgsql/configure.in,v 1.371 2004/08/04 21:33:35 tgl Exp $
2+
dnl $PostgreSQL: pgsql/configure.in,v 1.372 2004/08/08 01:31:09 momjian Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -908,7 +908,10 @@ AC_LIBOBJ(copydir)
908908
AC_LIBOBJ(gettimeofday)
909909
AC_LIBOBJ(kill)
910910
AC_LIBOBJ(open)
911-
AC_LIBOBJ(rand) ;;
911+
AC_LIBOBJ(rand)
912+
AC_DEFINE([HAVE_SYMLINK], 1,
913+
[Define to 1 if you have the `symlink' function.])
914+
;;
912915
esac
913916

914917
if test "$with_readline" = yes; then

src/backend/commands/tablespace.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
*
4646
*
4747
* IDENTIFICATION
48-
* $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.7 2004/08/01 20:30:48 tgl Exp $
48+
* $PostgreSQL: pgsql/src/backend/commands/tablespace.c,v 1.8 2004/08/08 01:31:11 momjian Exp $
4949
*
5050
*-------------------------------------------------------------------------
5151
*/
@@ -482,11 +482,20 @@ DropTableSpace(DropTableSpaceStmt *stmt)
482482
errmsg("could not unlink file \"%s\": %m",
483483
subfile)));
484484

485+
#ifndef WIN32
485486
if (unlink(location) < 0)
486487
ereport(ERROR,
487488
(errcode_for_file_access(),
488489
errmsg("could not unlink symbolic link \"%s\": %m",
489490
location)));
491+
#else
492+
/* The junction is a directory, not a file */
493+
if (rmdir(location) < 0)
494+
ereport(ERROR,
495+
(errcode_for_file_access(),
496+
errmsg("could not remove junction dir \"%s\": %m",
497+
location)));
498+
#endif
490499

491500
pfree(subfile);
492501
pfree(location);

src/port/dirmod.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Win32 (NT, Win2k, XP). replace() doesn't work on Win95/98/Me.
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/port/dirmod.c,v 1.14 2004/08/07 21:48:09 momjian Exp $
13+
* $PostgreSQL: pgsql/src/port/dirmod.c,v 1.15 2004/08/08 01:31:15 momjian Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -153,9 +153,9 @@ pgsymlink(const char *oldpath, const char *newpath)
153153
{
154154
HANDLE dirhandle;
155155
DWORD len;
156-
char *p = nativeTarget;
157156
char buffer[MAX_PATH*sizeof(WCHAR) + sizeof(REPARSE_JUNCTION_DATA_BUFFER)];
158157
char nativeTarget[MAX_PATH];
158+
char *p = nativeTarget;
159159
REPARSE_JUNCTION_DATA_BUFFER *reparseBuf = (REPARSE_JUNCTION_DATA_BUFFER*)buffer;
160160

161161
CreateDirectory(newpath, 0);
@@ -203,9 +203,12 @@ pgsymlink(const char *oldpath, const char *newpath)
203203
NULL, GetLastError(),
204204
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
205205
(LPSTR)&msg, 0, NULL );
206+
#ifdef FRONTEND
207+
fprintf(stderr, "Error setting junction for %s: %s", nativeTarget, msg);
208+
#else
206209
ereport(ERROR, (errcode_for_file_access(),
207210
errmsg("Error setting junction for %s: %s", nativeTarget, msg)));
208-
211+
#endif
209212
LocalFree(msg);
210213

211214
CloseHandle(dirhandle);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy