On Sat, 2021-11-27 at 18:30 -0500, Tom Lane wrote: > Trying to gather together the various issues mentioned on this thread, > I see: > > * Initial input lines that are blank (whitespace, maybe including a > comment) are merged into the next command's history entry; but since > said lines don't give rise to any text sent to the server, there's > not really any reason why they couldn't be treated as text to be > emitted to the history file immediately. This is what Greg originally > set out to change. After my experiments mentioned above, I'm quite > doubtful that his patch is correct in detail (I'm afraid that it > probably emits stuff too soon in some cases), but it could likely be > fixed if we could just get agreement that a change of that sort is OK.
For me, it is just a mild annoyance to have unrelated comments preceding the query be part of the query's history file entry. If that is difficult to improve, I can live with it the way it is. > * It's not great that dash-dash comments aren't included in what we > send to the server. However, changing that is a lot trickier than > it looks. I think we want to continue suppressing comments that > precede the query proper. Including comments that are within the > query text (ahead of the trailing semi) is not so hard, but comments > following the semicolon look too much like comments-ahead-of-the- > next-query. Perhaps that issue should be left for another day ... > although it does feel like it interacts with the first point. If we treat double-dash comments differently from /* */ ones, that is indeed odd. I personally haven't been bothered by it, though. > * Misbehavior of M-# was also mentioned. Does anyone object to > the draft patch I posted for that? No, I think that is a clear improvement. There was one other problem mentioned in the original mail, and that seems to be the most serious one to me: > psql psql (14.1) Type "help" for help. test=> \set HISTCONTROL ignorespace test=> -- line that starts with space test=> SELECT 42; ?column? ══════════ 42 (1 row) Now that query is not added to the history file at all. Yours, Laurenz Albe