From: Robert Haas Date: Wed, 16 Nov 2011 01:34:47 +0000 (-0500) Subject: Don't elide blank lines when accumulating psql command history. X-Git-Tag: REL9_0_6~17 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=90bbeb195deed468decbd03af713512a990c1938;p=postgresql 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. --- diff --git a/src/bin/psql/input.c b/src/bin/psql/input.c index d28fe9c0ba..56aa1bf702 100644 --- a/src/bin/psql/input.c +++ b/src/bin/psql/input.c @@ -95,10 +95,10 @@ void pg_append_history(const char *s, PQExpBuffer history_buf) { #ifdef USE_READLINE - if (useHistory && s && s[0]) + if (useHistory && s) { appendPQExpBufferStr(history_buf, s); - if (s[strlen(s) - 1] != '\n') + if (!s[0] || s[strlen(s) - 1] != '\n') appendPQExpBufferChar(history_buf, '\n'); } #endif