postgres.git / summary / log / commit / refs
commit d2202a6987362abc99dad9bb9e72530609642101
Author: Robert Haas <rhaas@postgresql.org>
Date: Wed Nov 16 01:34:47 2011 +0000
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.
src/bin/psql/input.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/bin/psql/input.c b/src/bin/psql/input.c
index c7ef77d8cb1..ed2b4292a1e 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
[parent: 003fae7ab472]