Confusing behavior of psql's \e - Mailing list pgsql-hackers

From Laurenz Albe
Subject Confusing behavior of psql's \e
Date
Msg-id 0ba3f2a658bac6546d9934ab6ba63a805d46a49b.camel@cybertec.at
Whole thread Raw
Responses Re: Confusing behavior of psql's \e
List 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

pgsql-hackers by date:

Previous
From: Craig Ringer
Date:
Subject: Re: Printing backtrace of postgres processes
Next
From: Zhihong Yu
Date:
Subject: Re: runtime error copying oids field