Commit ff4fd4bf authored by Robert Haas's avatar Robert Haas

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.
parent 04da3232
...@@ -95,10 +95,10 @@ void ...@@ -95,10 +95,10 @@ void
pg_append_history(const char *s, PQExpBuffer history_buf) pg_append_history(const char *s, PQExpBuffer history_buf)
{ {
#ifdef USE_READLINE #ifdef USE_READLINE
if (useHistory && s && s[0]) if (useHistory && s)
{ {
appendPQExpBufferStr(history_buf, s); appendPQExpBufferStr(history_buf, s);
if (s[strlen(s) - 1] != '\n') if (!s[0] || s[strlen(s) - 1] != '\n')
appendPQExpBufferChar(history_buf, '\n'); appendPQExpBufferChar(history_buf, '\n');
} }
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment