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