Re: Fwd: psql include file using relative path

From: Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>
To: David Fetter <david(at)fetter(dot)org>
Cc: Ibrar Ahmed <ibrar(dot)ahmad(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, PGSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fwd: psql include file using relative path
Date: 2011-03-10 02:36:53
Message-ID: AANLkTimaYPn33dmUV_HWyH-=uOXa1aR2G=zkM3N+WEZK@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Mar 9, 2011 at 7:32 PM, David Fetter <david(at)fetter(dot)org> wrote:

> On Wed, Mar 09, 2011 at 07:05:19PM -0500, Gurjeet Singh wrote:
> > Good question, I hadn't thought of that either, and thinking about
> > it a bit I think we'd want to keep the current behaviour of \i and
> > provide new behaviour using a new command.
> >
> > Say when we are processing a pretty nested file after multiple \ir
> > commands, a \i <relative path file> in any of those files should
> > look for that file in psql's CWD/PWD. That is what the user expects
> > from \i command currently and I don't think it'd be desirable to
> > break that assumption.
>
> I'm not sure I understand. Stuff that worked before would still work.
>

files present:
~/1.sql
~/package/main.sql
~/package/1.sql

psql's CWD: $HOME
psql executed as: psql -f ~/package/main.sql

Now if we kept \i and \ir separate then if main.sql does

\i 1.sql

it'd read ~/1.sql, which is the current behaviour,

and

\ir 1.sql

would read ~/package/1.sql .

If we folded \ir into \i then what would you want `\i 1.sql` to do? Read
1.sql from $HOME or the one that is main.sql's sibling.

>
> Should stuff break when it has a legitimately accessible path in it
> just because that path is relative?
>

Given the above test case, I think it'd be best if we introduced a new
command for this feature.

Regards,
--
Gurjeet Singh
EnterpriseDB <http://www.enterprisedb.com/> Corporation
The Enterprise PostgreSQL <http://www.postgresql.org/> Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2011-03-10 02:40:00 Re: pgsql: Added new version of ecpg's parser generator script. This one wa
Previous Message Bruce Momjian 2011-03-10 02:21:25 Re: Sync Rep v19