]> granicus.if.org Git - postgresql/commitdiff
Don't elide blank lines when accumulating psql command history.
authorRobert Haas <rhaas@postgresql.org>
Wed, 16 Nov 2011 01:34:47 +0000 (20:34 -0500)
committerRobert Haas <rhaas@postgresql.org>
Wed, 16 Nov 2011 01:36:13 +0000 (20:36 -0500)
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.

src/bin/psql/input.c

index 6628c0c30cb6974534eca3d63c241543e946f201..ec0e6e1d49bc253193b934046cc6d6dc9ff1b2fe 100644 (file)
@@ -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