BUG #6301: extra space in psql variable expansion - Mailing list pgsql-bugs

From M
Subject BUG #6301: extra space in psql variable expansion
Date
Msg-id 201111181812.pAIICbGk056384@wwwmaster.postgresql.org
Whole thread Raw
Responses Re: BUG #6301: extra space in psql variable expansion  (Josh Kupershmidt <schmiddy@gmail.com>)
List pgsql-bugs
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.

pgsql-bugs by date:

Previous
From: "Tomas Vondra"
Date:
Subject: Re: BUG #6300: duplicate key value violates unique constraint
Next
From: Tigran Mkrtchyan
Date:
Subject: Re: BUG #6300: duplicate key value violates unique constraint