Re: open item: tablespace handing in pg_dump/pg_restore

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Reini Urban <rurban(at)x-ray(dot)at>
Cc: PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: open item: tablespace handing in pg_dump/pg_restore
Date: 2004-10-04 19:01:12
Message-ID: 200410041901.i94J1CG18426@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-cygwin pgsql-hackers pgsql-hackers-win32


I am confused. CVS has in port.h:

#if defined(WIN32) || defined(__CYGWIN__)
/*
* Win32 doesn't have reliable rename/unlink during concurrent access,
* and we need special code to do symlinks.
*/
extern int pgrename(const char *from, const char *to);
extern int pgunlink(const char *path);
extern int pgsymlink(const char *oldpath, const char *newpath);
...
#define rename(from, to) pgrename(from, to)
#define unlink(path) pgunlink(path)
#define symlink(oldpath, newpath) pgsymlink(oldpath, newpath)

so you should already be calling the junction code on Cygwin.

---------------------------------------------------------------------------

Reini Urban wrote:
> Tom Lane schrieb:
> > Gavin Sherry <swm(at)linuxworld(dot)com(dot)au> writes:
> >>I though this may have been the problem. configure.in defines HAVE_SYMLINK
> >>to 1 if we are win32. It seems that for Reini's case we are setting our
> >>template (and PORTNAME) to win32 when I suspect it should be cygwin.
> >>Anyone got any ideas?
> >
> > What are the prospects of making the junction code work under cygwin?
>
> Somethink like the attached patch is easier.
> Just replace symlink() for dirs with link() #ifdef __CYGWIN__
>
> just wait a sec until the tests run through...
> (completely fresh build)
> --
> Reini Urban
> http://xarch.tu-graz.ac.at/home/rurban/

> Index: tablespace.c
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/backend/commands/tablespace.c,v
> retrieving revision 1.11
> diff -u -b -r1.11 tablespace.c
> --- tablespace.c 30 Aug 2004 02:54:38 -0000 1.11
> +++ tablespace.c 4 Oct 2004 18:37:13 -0000
> @@ -349,7 +349,11 @@
> linkloc = (char *) palloc(strlen(DataDir) + 11 + 10 + 1);
> sprintf(linkloc, "%s/pg_tblspc/%u", DataDir, tablespaceoid);
>
> +#ifdef __CYGWIN__
> + if (link(location, linkloc) < 0)
> +#else
> if (symlink(location, linkloc) < 0)
> +#endif
> ereport(ERROR,
> (errcode_for_file_access(),
> errmsg("could not create symbolic link \"%s\": %m",
> @@ -976,7 +980,11 @@
> linkloc = (char *) palloc(strlen(DataDir) + 11 + 10 + 1);
> sprintf(linkloc, "%s/pg_tblspc/%u", DataDir, xlrec->ts_id);
>
> +#ifdef __CYGWIN__
> + if (link(location, linkloc) < 0)
> +#else
> if (symlink(location, linkloc) < 0)
> +#endif
> {
> if (errno != EEXIST)
> ereport(ERROR,

>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-cygwin by date

  From Date Subject
Next Message Wayne Phillips 2004-10-04 19:14:23 on w2k or xp?
Previous Message Reini Urban 2004-10-04 18:40:55 Re: open item: tablespace handing in pg_dump/pg_restore

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2004-10-04 19:10:24 Re: SQL-Invoked Procedures for 8.1
Previous Message Jim C. Nasby 2004-10-04 18:55:21 Re: SQL-Invoked Procedures for 8.1

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Reini Urban 2004-10-04 19:20:57 Re: open item: tablespace handing in pg_dump/pg_restore
Previous Message Reini Urban 2004-10-04 18:40:55 Re: open item: tablespace handing in pg_dump/pg_restore