proposal: using PQexecParams in psql (using variables as real params) - Mailing list pgsql-hackers

From Pavel Stehule
Subject proposal: using PQexecParams in psql (using variables as real params)
Date
Msg-id 162867790911151401u605fd4b4v6e0a2db42876f2eb@mail.gmail.com
Whole thread Raw
Responses Re: proposal: using PQexecParams in psql (using variables as real params)
List pgsql-hackers
Hello

I propose to add possibility to use psql variables as real query
parameters. The goal of this proposal is simplification of creating
psql based commands. Current using of psql variables based on
substitution has large area of using, but has some risks. a) there are
possible sql injection, b) we have to have to do some special (not too
much readable quoting) - see Bruce's book, psql chapter.

I checked, so this doesn't need much work. Attachment contains a prototype.

[pavel@nemesis ~]$ echo "select upper(:message)" | psql -r -v
message="Pavel's cat" postgres
    upper
─────────────
 PAVEL'S CAT
(1 row)

[pavel@nemesis ~]$ psql -v message="Pavel's cat" postgres
psql (8.5devel)
Type "help" for help.

postgres=# \pexec
Separately passing parameters is on.
postgres=# select upper(:message);
    upper
─────────────
 PAVEL'S CAT
(1 row)

This small feature simplify integration psql to shell environment.

comments, notes??

Regards
Pavel Stehule

Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: patch - Report the schema along table name in a referential failure error message
Next
From: Tom Lane
Date:
Subject: Re: [COMMITTERS] pgsql: /home/peter/commit-msg