From: | Josh Kupershmidt <schmiddy(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Cc: | Robert Haas <robertmhaas(at)gmail(dot)com>, Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com> |
Subject: | psql \ir filename normalization |
Date: | 2011-11-15 23:54:30 |
Message-ID: | CAK3UJRGTZv_rVLpEQ1oJ9Bfo3UTRRb=J=X90bvhUYBjVrs01oQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi all,
Commit c7f23494c1103f87bcf1ef7cbfcd626e73edb337 editorialized a bit on
Gurjeet Singh's patch to implement \ir for psql, particularly in
process_file(). Unfortunately, it looks like it broke the common case
of loading a .SQL file in psql's working directory. Consider the
following test case:
mkdir -p /tmp/psql_test/subdir/
mkdir -p /tmp/psql_test/path2/
echo "SELECT 'hello 1';" > /tmp/psql_test/hello.sql
echo "SELECT 'hello from parent';" > /tmp/psql_test/hello_parent.sql
echo "SELECT 'hello from absolute path';" >
/tmp/psql_test/path2/absolute_path.sql
echo -e "SELECT 'hello 2';\n\ir ../hello_parent.sql\n\ir
/tmp/psql_test/path2/absolute_path.sql" >
/tmp/psql_test/subdir/hello2.sql
echo -e "\ir hello.sql\n\ir subdir/hello2.sql" > /tmp/psql_test/load.sql
If you try to load in "load.sql" from any working directory other than
/tmp/psql_test/ , you should correctly see four output statements.
However, if you:
cd /tmp/psql_test/ && psql test -f load.sql
You will get:
psql:load.sql:1: /hello.sql: No such file or directory
psql:load.sql:2: /subdir/hello2.sql: No such file or directory
Attached is a patch which fixes this, by recycling the bit of
Gurjeet's code which used "last_slash". (I have a feeling there's a
simpler way to fix it which avoids the last_slash complications.)
Josh
Attachment | Content-Type | Size |
---|---|---|
psql_fix_ir.v2.diff | application/octet-stream | 1.5 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2011-11-15 23:57:51 | Re: ISN was: Core Extensions relocation |
Previous Message | Peter Geoghegan | 2011-11-15 23:44:09 | Re: ISN was: Core Extensions relocation |