pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <bruce@momjian.us>
To: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: arnaud.listes@codata.eu, PG-General Mailing List <pgsql-general@postgresql.org>
Cc: PostgreSQL-documentation <pgsql-docs@postgresql.org>
Subject: Re: [GENERAL] pg_upgrade --link on Windows
Date: Tue, 13 Jun 2017 16:07:48 -0400
Message-ID: <20170613200748.GB13879@momjian.us> (raw)
In-Reply-To: <0405d125-929b-ab4a-b7be-d49c09e7c056@aklaver.com>
References: <8da3dbd9-7daf-5589-0cc8-0eede930a492@codata.eu>
	<20170609140724.GB21215@momjian.us>
	<a892509c-0eb4-42a4-1370-6cb0ac3bc1c3@codata.eu>
	<0405d125-929b-ab4a-b7be-d49c09e7c056@aklaver.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-docs>

On Fri, Jun  9, 2017 at 07:55:55AM -0700, Adrian Klaver wrote:
> On 06/09/2017 07:39 AM, Arnaud L. wrote:
> >See this page for more details :
> >http://cects.com/overview-to-understanding-hard-links-junction-points-and-symbolic-links-in-windows/
> >
> >
> >Under "Hard Link (Linking for individual files)" :
> >"If the target is deleted, its content is still available through the hard
> >link"
> >
> >Junction Point (Directory Hard Link):
> >"If the target is moved, renamed or deleted, the Junction Point still
> >exists, but points to a non-existing directory"
> >
> >BUT, when I try to "pg_upgrade --link --check" with old-data-dir and
> >new-data-dir on different volumes, I get an error saying that both
> >directories must be on the same volume if --link is used.
> >So maybe pg_upgrade uses hard-links (i.e. to files), and only the
> >documentation is wrong by calling them junctions (i.e. soft links to
> >files) ?
> 
> Looks that way. In file.c in ~/src/bin/pg_upgrade I see:
> 
> #ifdef WIN32
>  300 /* implementation of pg_link_file() on Windows */
>  301 static int
>  302 win32_pghardlink(const char *src, const char *dst)
>  303 {
>  304     /*
>  305      * CreateHardLinkA returns zero for failure
>  306      * http://msdn.microsoft.com/en-us/library/aa363860(VS.85).aspx
>  307      */
>  308     if (CreateHardLinkA(dst, src, NULL) == 0)
>  309     {
>  310         _dosmaperr(GetLastError());
>  311         return -1;
>  312     }
>  313     else
>  314         return 0;
>  315 }
>  316 #endif

[docs list added]

I apologize for not being smarter on this thread.  When I helped with
the Windows port, I was told Windows didn't have hard links for use by
tablespace directories, so I got it into my head that Windows didn't
have hard links.  Therefore, when I was writing the docs, I called them
junction points.

Looking back to Postgres 9.0 where pg_upgrade was added to the tree, I
see that the code even at that time used hard links on Windows.  I have
created the attached patch which I will apply to all current Postgres
versions to fix this error.

Thanks for the report and the research.  :-)

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +

-- 
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs

Attachments:

junction.diff (text/x-diff, 767B) download diff --git a/doc/src/sgml/ref/pgupgrade.sgml b/doc/src/sgml/ref/pgupgrade.sgml new file mode 100644 index bf58a0a..4e27112 *** a/doc/src/sgml/ref/pgupgrade.sgml --- b/doc/src/sgml/ref/pgupgrade.sgml *************** *** 123,129 **** <term><option>-k</option></term> <term><option>--link</option></term> <listitem><para>use hard links instead of copying files to the new ! cluster (use junction points on Windows)</para></listitem> </varlistentry> <varlistentry> --- 123,129 ---- <term><option>-k</option></term> <term><option>--link</option></term> <listitem><para>use hard links instead of copying files to the new ! cluster</para></listitem> </varlistentry> <varlistentry>

view thread (14+ messages)  latest in thread

Message-ID: <20170613200748.GB13879@momjian.us>
Permalink:  ../20170613200748.GB13879@momjian.us/
Also on:    postgresql.org/message-id/20170613200748.GB13879@momjian.us

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: bruce@momjian.us, adrian.klaver@aklaver.com, pgsql-general@postgresql.org
  Subject: Re: [GENERAL] pg_upgrade --link on Windows
  In-Reply-To: <20170613200748.GB13879@momjian.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox