diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index bdfb67cd9a1..b92a1ea02b3 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -53,8 +53,8 @@ PostgreSQL documentation - Print all input lines to standard output as they are read. This is more - useful for script processing than interactive mode. This is + Print all nonempty input lines to standard output as they are read. + (This does not apply to lines read interactively.) This is equivalent to setting the variable ECHO to all. @@ -2863,14 +2863,14 @@ bar ECHO - If set to all, all lines - entered from the keyboard or from a script are written to the standard output - before they are parsed or executed. To select this behavior on program + If set to all, all nonempty input lines are printed + to standard output as they are read. (This does not apply to lines + read interactively.) To select this behavior on program start-up, use the switch . If set to queries, - psql merely prints all queries as - they are sent to the server. The switch for this is - . If set to errors then only + psql prints each query to standard output + as it is sent to the server. The switch for this is + . If set to errors, then only failed queries are displayed on standard error output. The switch for this is . If unset, or if set to none (or any other value than those above) then diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c index d2267640abe..b6cef94272c 100644 --- a/src/bin/psql/mainloop.c +++ b/src/bin/psql/mainloop.c @@ -187,7 +187,7 @@ MainLoop(FILE *source) break; } - /* nothing left on line? then ignore */ + /* no further processing of empty lines, unless within a literal */ if (line[0] == '\0' && !psql_scan_in_quote(scan_state)) { free(line); @@ -211,10 +211,12 @@ MainLoop(FILE *source) continue; } - /* echo back if flag is set */ + /* echo back if flag is set, unless interactive */ if (pset.echo == PSQL_ECHO_ALL && !pset.cur_cmd_interactive) + { puts(line); - fflush(stdout); + fflush(stdout); + } /* insert newlines into query buffer between source lines */ if (query_buf->len > 0)