Thanks for testing!

On Wed, 2021-03-03 at 00:07 +0000, Jacob Champion wrote:
> On Wed, 2020-12-16 at 10:45 +0100, Laurenz Albe wrote:
> 
> > I consider this a bug fix, but one that shouldn't be backpatched.
> > Re-executing the previous query if the editor is quit is
> > annoying at least and dangerous at worst.
> 
> I like that this patch also clears the query buffer in the error case.
> (For example, if I save the file but then decide I want to cancel
> execution, the only choice is to issue an abortive :cq from Vim. The
> current master-branch behavior is to just dump me back onto a
> continuation prompt, and I have to manually \r the buffer. With this
> patch, I'm returned to an initial prompt with a clear buffer. Very
> nice.)
> 
> Some unexpected behavior I saw when testing this patch: occasionally I
> would perform a bare \e, save the temporary file, and quit, only to
> find that nothing was executed. What's happening is, I'm saving the
> file too quickly, and the timestamp check (which has only second
> precision) is failing! This isn't a problem in practice for the
> explicit-filename case, because you probably didn't create the file
> within the last second, but the temporary files are always zero seconds
> old by definition. I could see this tripping up some people.

That is because psql compares the file modification time before and
after the edit, and the "st_mtime" in "struct stat" has a precision of
seconds.  Some operating systems and file provide a finer granularity,
but for example PostgreSQL's _pgstat64 that is used on Windows doesn't.

This is no new behavior, and I think this is rare enough that we don't
have to bother.  I had to define a vim macro to :wq the file fast
enough to reproduce your observation...

Yours,
Laurenz Albe



Reply via email to