Re: psql: Allow editing query results with \gedit

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Christoph Berg <myon(at)debian(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: psql: Allow editing query results with \gedit
Date: 2024-05-17 13:51:50
Message-ID: CA+TgmoYgyUvbsbqTpp6FvHqpuE9sRsYbVtqQyirt975yc84gCw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, May 17, 2024 at 9:24 AM Christoph Berg <myon(at)debian(dot)org> wrote:
> Tom> The stated complaint was "it's too hard to build UPDATE commands",
> Tom> which I can sympathize with.
>
> ... which this would perfectly address - it's building the commands.
>
> The editor will have a bit more clutter (the UPDATE SET WHERE
> boilerplate), and the fields are somewhat out of order (the key at the
> end), but SQL commands are what people understand, and there is
> absolutely no ambiguity on what is going to be executed since the
> commands are exactly what is leaving the editor.

A point to consider is that the user can also do this in the query
itself, if desired. It'd just be a matter of assembling the query
string with appropriate calls to quote_literal() and quote_ident(),
which is not actually all that hard and I suspect many of us have done
that at one point or another. And then you know that you'll get the
right set of key columns and update the right table (as opposed to,
say, a view over the right table, or the wrong one out of several
tables that you joined).

Now you might say, well, that's not terribly convenient, which is
probably true, but this might be a case of -- convenient, reliable,
works with arbitrary queries -- pick two. I don't know. I wouldn't be
all that surprised if there's something clever and useful we could do
in this area, but I sure don't know what it is.

--
Robert Haas
EDB: http://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Joe Conway 2024-05-17 13:54:08 Re: commitfest.postgresql.org is no longer fit for purpose
Previous Message Christoph Berg 2024-05-17 13:42:52 Re: psql JSON output format