Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 43eeaef

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 8fad10a commit 43eeaef

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
@@ -95,10 +95,10 @@ void
9595
pg_append_history(const char *s, PQExpBuffer history_buf)
9696
{
9797
#ifdef USE_READLINE
98-
if (useHistory && s && s[0])
98+
if (useHistory && s)
9999
{
100100
appendPQExpBufferStr(history_buf, s);
101-
if (s[strlen(s) - 1] != '\n')
101+
if (!s[0] || s[strlen(s) - 1] != '\n')
102102
appendPQExpBufferChar(history_buf, '\n');
103103
}
104104
#endif

0 commit comments

Comments
 (0)