Function to do runtime relative directory mapping

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL Win32 port list <pgsql-hackers-win32(at)postgresql(dot)org>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Function to do runtime relative directory mapping
Date: 2004-05-04 17:25:36
Message-ID: 200405041725.i44HPaV24482@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-hackers-win32 pgsql-patches

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > Tom Lane wrote:
> >> I guess what you are saying is we should have a configure-time option to
> >> address configured directories via relative paths from the executable's
> >> directory, rather than absolute paths? Seems reasonable ...
>
> > Yep. In fact, why would we not use that by default?
>
> Because it'll be slower. Instead of
> /usr/local/pgsql/lib
> we'd be using something like
> /usr/local/pgsql/bin/../lib
> which is not too bad here but would get worse if the directories are not
> so close.
>
> But perhaps we can arrange for the path to be simplified down to an
> absolute form when it's constructed at backend startup? You'd need a
> routine anyway to combine the bindir path (determined by FindExec) with
> the relative path provided by configure, so maybe this routine could be
> smart about leading ../ in the configure path.

I wrote relative_path() which does the mapping from compiled src/dst to
a new path. For example:

$ tst1 /usr/local/pgsql/bin /usr/local/pgsql/lib /users/fred/pgsql/bin
/users/fred/pgsql/lib

$ tst1 /a/b/c /a/d /f/g/h
/f/d

This can be used in the backend to map from your bindir to a relative
libdir at runtime, and share too. It returns [mp]alloc'ed values, or
NULL if it can't do the tranformation.

Patch attached.

--
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

Attachment Content-Type Size
unknown_filename text/plain 3.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2004-05-04 17:33:37 Re: inconsistent owners in newly created databases?
Previous Message Bruce Momjian 2004-05-04 15:50:35 Re: The features I'm waiting for.

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Dave Page 2004-05-04 18:24:25 Re: man pages on win32
Previous Message Magnus Hagander 2004-05-04 17:12:48 Re: man pages on win32

Browse pgsql-patches by date

  From Date Subject
Next Message Andrew Dunstan 2004-05-04 18:31:27 Re: Function to do runtime relative directory
Previous Message Bruce Momjian 2004-05-04 16:05:04 Re: Run-as-admin warning for win32