From: M <sitrash@email.com>
To: pgsql-bugs@postgresql.org
Subject: BUG #6301: extra space in psql variable expansion
Date: Fri, 18 Nov 2011 18:12:37 GMT
Message-ID: <201111181812.pAIICbGk056384@wwwmaster.postgresql.org> (raw)
The following bug has been logged online:
Bug reference: 6301
Logged by: M
Email address: sitrash@email.com
PostgreSQL version: 8.4.9
Operating system: Linux
Description: extra space in psql variable expansion
Details:
First of all, thank you for supporting a very useful product!
When psql expands a :variable into a string it appends a space to the
expansion string. For example:
psql (8.4.9)
Type "help" for help.
testdb=> \set my_home /home/crazy
testdb=> \echo :my_home/my-script.sql
/home/crazy /my-script.sql
Note the space between /home/crazy and /my-script.sql in the line above,
while there's no space after /home/crazy two lines above where my_home
variable is initialized.
This prevents use of a variable for storing the directory name where a
script to be sourced resides, as in
\i :my_dir/my-script.sql
because the expanded string contains a space between the expansion of
:my_dir and the following /my-script.sql.
I believe psql should expand the string :my_dir/my-script.sql into
/home/crazy/my-script.sql (note the lack of space between crazy and the
following / character).
No popular scripting language I'm aware of appends the space character to an
expanded variable, so psql's behavior is rather unusual. E.g.
${HOME}/my-script.sql expands into /home/crazy/my-script.sql in a Unix shell
script.
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: sitrash@email.com
Subject: Re: BUG #6301: extra space in psql variable expansion
In-Reply-To: <201111181812.pAIICbGk056384@wwwmaster.postgresql.org>
References: <201111181812.pAIICbGk056384@wwwmaster.postgresql.org>
* 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