BUG #6301: extra space in psql variable expansion

From: "M" <sitrash(at)email(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #6301: extra space in psql variable expansion
Date: 2011-11-18 18:12:37
Message-ID: 201111181812.pAIICbGk056384@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 6301
Logged by: M
Email address: sitrash(at)email(dot)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.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tigran Mkrtchyan 2011-11-18 19:38:34 Re: BUG #6300: duplicate key value violates unique constraint
Previous Message Tomas Vondra 2011-11-18 17:52:30 Re: BUG #6300: duplicate key value violates unique constraint