pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: jgd@well.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #6715: 9.2b2 psql \ir does not understand leading ../
Date: Wed, 04 Jul 2012 02:41:46 -0400
Message-ID: <9781.1341384106@sss.pgh.pa.us> (raw)
In-Reply-To: <E1SmFkY-0003pD-NX@wrigleys.postgresql.org>
References: <E1SmFkY-0003pD-NX@wrigleys.postgresql.org>

jgd@well.com writes:
> When I do
> \ir ../bar.sql
> I get the bar.sql file in the CWD.

AFAICS, it works fine when \ir is used interactively.  However,
you seem to be using it from a script:

> $ psql -aX greg -f foo.sql

and then indeed it does not work so well.  psql is trying to evaluate
the \ir relative to the script file's location, using this code:

            snprintf(relpath, MAXPGPATH, "%s", pset.inputfile);
            get_parent_directory(relpath);
            join_path_components(relpath, relpath, filename);
            canonicalize_path(relpath);

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.

			regards, tom lane



view thread (5+ messages)  latest in thread

Message-ID: <9781.1341384106@sss.pgh.pa.us>
Permalink:  ../9781.1341384106@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/9781.1341384106@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, jgd@well.com
  Subject: Re: BUG #6715: 9.2b2 psql \ir does not understand leading ../
  In-Reply-To: <9781.1341384106@sss.pgh.pa.us>
  References: <E1SmFkY-0003pD-NX@wrigleys.postgresql.org> <9781.1341384106@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