summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2011-11-15 20:34:47 -0500
committerRobert Haas <rhaas@postgresql.org>2011-11-15 20:36:32 -0500
commitd2202a6987362abc99dad9bb9e72530609642101 (patch)
tree7c731457962f332dacbc854d619d953f21f9ac0a
parent003fae7ab4723b542fad657e8387401710650c61 (diff)
downloadpostgresql-d2202a6987362abc99dad9bb9e72530609642101.tar.gz
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.
-rw-r--r--src/bin/psql/input.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/bin/psql/input.c b/src/bin/psql/input.c
index c7ef77d8cb..ed2b4292a1 100644
--- a/src/bin/psql/input.c
+++ b/src/bin/psql/input.c
@@ -86,10 +86,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