Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 165C992B8E9 for ; Thu, 5 Jul 2012 15:43:13 -0300 (ADT) Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Smr1C-0000kl-IB for pgsql-bugs@postgresql.org; Thu, 05 Jul 2012 18:43:12 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id q65Igvj4018465; Thu, 5 Jul 2012 14:42:57 -0400 (EDT) From: Tom Lane To: Josh Kupershmidt cc: jgd@well.com, pgsql-bugs@postgresql.org Subject: Re: BUG #6715: 9.2b2 psql \ir does not understand leading ../ In-reply-to: References: <9781.1341384106@sss.pgh.pa.us> Comments: In-reply-to Josh Kupershmidt message dated "Wed, 04 Jul 2012 10:19:27 -0700" Date: Thu, 05 Jul 2012 14:42:57 -0400 Message-ID: <18464.1341513777@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201207/32 X-Sequence-Number: 33508 Josh Kupershmidt writes: > On Tue, Jul 3, 2012 at 11:41 PM, Tom Lane 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