Feature proposal for psql

Поиск
Список
Период
Сортировка
От Denis Gantsev
Тема Feature proposal for psql
Дата
Msg-id CAPsvASuWxEuqW-x73_x4-Mgj7i3P9LgHRcn4UQpxUriBVqguqA@mail.gmail.com
обсуждение исходный текст
Ответы Re: Feature proposal for psql  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
Hello
I have a working proposal for a small feature, which I would describe in one sentence as
"named parametrized queries".
Basically it allows to save something like this in a file:

--psql:MyQuery1
SELECT 42 FROM @0
WHERE true
--psql:end

--psql:MyQuery2
/* updates stuff... */
UPDATE stuff SET ..
--psql:end

Then, from inside psql, I can invoke the query by its name, and pass an (or many) argument(s).
For example, invoking it like so:
db=# \nq MyQuery1 blabla
Would substitute literally the "@0"  with "blabla" and send it to the backend.

I am aware that saving queries is already possible with variables (:var), and saved variables can be sourced from .psqlrc file.
However, I think passing arguments in bash style is kinda nicer, because I don't need to set any variables beforehand. Also this would allow to have a clean and valid SQL (well kinda, if no placeholders "@" is used) and comments.
I have also added autocompletion.

Should I send the diff to the mailing list, or maybe it's not something useful?

Regards
Denis

В списке pgsql-novice по дате отправления:

Предыдущее
От: Laurenz Albe
Дата:
Сообщение: Re: New Data Type Implementation
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Feature proposal for psql