Re: psql: Allow editing query results with \gedit

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: psql: Allow editing query results with \gedit
Дата
Msg-id CAFj8pRBG6owfU04w_6wPXd+m8z_0BHpoP+vhSHgVkSkQTtaLAg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: psql: Allow editing query results with \gedit  ("David G. Johnston" <david.g.johnston@gmail.com>)
Ответы Re: psql: Allow editing query results with \gedit  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers


po 22. 1. 2024 v 17:34 odesílatel David G. Johnston <david.g.johnston@gmail.com> napsal:
On Mon, Jan 22, 2024 at 8:06 AM Christoph Berg <myon@debian.org> wrote:
Assuming a SELECT statement reading from a single table, it is quite an
effort to transform that statement to an UPDATE statement on that table,
perhaps to fix a typo that the user has spotted in the query result.


Building off the other comments, I'd suggest trying to get rid of the intermediate JSOn format and also just focus on a single row at any given time.

For an update the first argument to the metacommand could be the unique key value present in the previous result.  The resultant UPDATE would just put that into the where clause and every other column in the result would be a SET clause column with the thing being set the current value, ready to be edited.

DELETE would be similar but without the need for a SET clause.

INSERT can produce a template INSERT (cols) VALUES ... command with some smarts regarding auto incrementing keys and placeholder values.

David J.

Can you imagine using it?  I like psql, I like term applications, my first database was FoxPro, but for dataeditation I am almost sure so I don't want to use psql.

I can imagine enhancing the current \gexec command because it is executed directly without possibility to edit. I see valuable some special clause "edit"

like

\gexec_edit or \gexec(edit) or \gexec edit

This is like current gexec but with possibility to edit the result in editor and with possibility to finish without saving.

Then we can introduce SQL functions UpdateTemplate(cols text[], rowvalue), InsertTemplate, ...

and then you can write

SELECT UpdateTemplace(ARRAY['a','b','c'],  foo) FROM foo WHERE id IN (1,2) \gexec_with_edit

But still looks strange to me - like we try reintroduce of necessity sed or awk to SQL and psql

I would have forms like FoxPro, I would have a grid like FoxPro, but not in psql, and I would not develop it :-)




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

Предыдущее
От: Arne Roland
Дата:
Сообщение: Re: Permute underscore separated components of columns before fuzzy matching
Следующее
От: vignesh C
Дата:
Сообщение: Commitfest 2024-01 third week update