pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Josh Kupershmidt <schmiddy@gmail.com>
Cc: jgd@well.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #6715: 9.2b2 psql \ir does not understand leading ../
Date: Thu, 05 Jul 2012 14:42:57 -0400
Message-ID: <18464.1341513777@sss.pgh.pa.us> (raw)
In-Reply-To: <CAK3UJRF8cMdRJOES4EdhFwD5cuaK8NLjg09+G5ectoF6jLG4gg@mail.gmail.com>
References: <E1SmFkY-0003pD-NX@wrigleys.postgresql.org>
	<9781.1341384106@sss.pgh.pa.us>
	<CAK3UJRF8cMdRJOES4EdhFwD5cuaK8NLjg09+G5ectoF6jLG4gg@mail.gmail.com>

Josh Kupershmidt <schmiddy@gmail.com> writes:
> On Tue, Jul 3, 2012 at 11:41 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> The get_parent_directory() call reduces "foo.sql" to an empty string,
>> which seems a tad bogus --- wouldn't "." be better?  But in any case,
>> join_path_components() thinks it can process a "../" prefix of the
>> tail argument by stripping a directory name from the head argument,
>> and there's nothing there to strip.  So IMO join_path_components()
>> is flat-out broken when applied to a non-absolute head path.
>> Not sure about what a useful solution would be.

> I may not have time to look at this today, but I think this behavior
> worked fine in the last version[1] of Gurjeet's \ir patch which I
> reviewed, which had different behavior for pathname normalization than
> what got committed.
> [1] http://archives.postgresql.org/message-id/BANLkTi=eW_nUH9195=9uPqF7Treg4UH7-g@mail.gmail.com

[ looks at that... ]  Well, I can certainly see why Robert got rid of
that kluge in favor of using the path-manipulation functions we already
have.  It looks like most of the existing uses of join_path_components
are using absolute paths (eg, the result of getcwd), which probably
explains why we've not previously noticed that it's not working
correctly in such cases.

On reflection I think that what we need to do is fix it so that it only
strips "../" from the tail string when there is a directory name
available to be stripped from the head string.  Otherwise just stop
trimming.

			regards, tom lane



view thread (5+ messages)  latest in thread

Message-ID: <18464.1341513777@sss.pgh.pa.us>
Permalink:  ../18464.1341513777@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/18464.1341513777@sss.pgh.pa.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, schmiddy@gmail.com, jgd@well.com
  Subject: Re: BUG #6715: 9.2b2 psql \ir does not understand leading ../
  In-Reply-To: <18464.1341513777@sss.pgh.pa.us>
  References: <E1SmFkY-0003pD-NX@wrigleys.postgresql.org> <9781.1341384106@sss.pgh.pa.us> <CAK3UJRF8cMdRJOES4EdhFwD5cuaK8NLjg09+G5ectoF6jLG4gg@mail.gmail.com> <18464.1341513777@sss.pgh.pa.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