Confusing behavior of psql's \e

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Confusing behavior of psql's \e
Date: 2020-12-01 03:38:35
Message-ID: 0ba3f2a658bac6546d9934ab6ba63a805d46a49b.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

If you quit the editor without saving, the current query buffer
or the last executed SQL statement get run.

This can be annoying and disruptive, and it requires you to
empty the file and save it if you don't want to execute anything.

But when editing a script, it is a clear POLA violation:

test=> \! cat q.sql
SELECT 99;

test=> SELECT 42;
?column?
----------
42
(1 row)

test=> \e q.sql
[quit the editor without saving]
?column?
----------
42
(1 row)

This is pretty bad: you either have to re-run the previous statement
or you have to empty your script file. Both are unappealing.

I have been annoyed about this myself, and I have heard other prople
complain about it, so I propose to clear the query buffer if the
editor exits without modifying the file.

This behavior is much more intuitive for me.

Yours,
Laurenz Albe

Attachment Content-Type Size
0001-Discard-query-buffer-if-editor-is-quit-in-e.patch text/x-patch 1.7 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhihong Yu 2020-12-01 03:49:34 Re: runtime error copying oids field
Previous Message Craig Ringer 2020-12-01 03:33:15 Re: Printing backtrace of postgres processes