Skip to content

Commit d2202a6

Browse files
committed
Don't elide blank lines when accumulating psql command history.
This can change the meaning of queries, if the blank line happens to occur in the middle of a quoted literal, as per complaint from Tomas Vondra. Back-patch to all supported branches.
1 parent 003fae7 commit d2202a6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/bin/psql/input.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ void
8686
pg_append_history(const char *s, PQExpBuffer history_buf)
8787
{
8888
#ifdef USE_READLINE
89-
if (useHistory && s && s[0])
89+
if (useHistory && s)
9090
{
9191
appendPQExpBufferStr(history_buf, s);
92-
if (s[strlen(s) - 1] != '\n')
92+
if (!s[0] || s[strlen(s) - 1] != '\n')
9393
appendPQExpBufferChar(history_buf, '\n');
9494
}
9595
#endif

0 commit comments

Comments
 (0)