psql and query buffer mangling - Mailing list pgsql-general

From Daniele Varrazzo
Subject psql and query buffer mangling
Date
Msg-id BANLkTi=1o8wzcUZV0xYg5F-n_FmNRPCsbQ@mail.gmail.com
Whole thread Raw
List pgsql-general
Hello,

I see psql performs some elaboration on the input query before storing
it in the query buffer: for instance variables are replaced:

    =# \set test 10
    =# select :test;
     ?column?
    ----------
           10
    (1 row)

    =# \p
    select 10;

and comments are stripped:

    duma=# select 1; -- comment
     ?column?
    ----------
            1
    (1 row)

    duma=# \p
    select 1;

Sometimes I use psql to test complex queries which are part of
programs, thus containing placeholders: roundtripping through the
editor via \e will lose the placeholders (as well as the comments)
making harder to test different values and finally to paste back the
query into the program.

Wouldn't be a better behaviour to store the unmodified input into the
query buffer and to perform the required query mangling downstream?

-- Daniele

pgsql-general by date:

Previous
From: Iain Barnett
Date:
Subject: Locale and UTF8 for template1 in 8.4.4
Next
From: Tom Lane
Date:
Subject: Re: undead index