diff options
Diffstat (limited to 'src/bin/psql')
-rw-r--r-- | src/bin/psql/command.c | 9 | ||||
-rw-r--r-- | src/bin/psql/help.c | 7 | ||||
-rw-r--r-- | src/bin/psql/tab-complete.c | 2 |
3 files changed, 11 insertions, 7 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 66e1aec011a..c0a7a5566eb 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -319,7 +319,8 @@ exec_command(const char *cmd, status = exec_command_ef_ev(scan_state, active_branch, query_buf, true); else if (strcmp(cmd, "ev") == 0) status = exec_command_ef_ev(scan_state, active_branch, query_buf, false); - else if (strcmp(cmd, "echo") == 0 || strcmp(cmd, "qecho") == 0) + else if (strcmp(cmd, "echo") == 0 || strcmp(cmd, "qecho") == 0 || + strcmp(cmd, "warn") == 0) status = exec_command_echo(scan_state, active_branch, cmd); else if (strcmp(cmd, "elif") == 0) status = exec_command_elif(scan_state, cstack, query_buf); @@ -1114,7 +1115,7 @@ exec_command_ef_ev(PsqlScanState scan_state, bool active_branch, } /* - * \echo and \qecho -- echo arguments to stdout or query output + * \echo, \qecho, and \warn -- echo arguments to stdout, query output, or stderr */ static backslashResult exec_command_echo(PsqlScanState scan_state, bool active_branch, const char *cmd) @@ -1129,13 +1130,15 @@ exec_command_echo(PsqlScanState scan_state, bool active_branch, const char *cmd) if (strcmp(cmd, "qecho") == 0) fout = pset.queryFout; + else if (strcmp(cmd, "warn") == 0) + fout = stderr; else fout = stdout; while ((value = psql_scan_slash_option(scan_state, OT_NORMAL, "ed, false))) { - if (!quoted && strcmp(value, "-n") == 0) + if (first && !no_newline && !quoted && strcmp(value, "-n") == 0) no_newline = true; else { diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c index 5fb1baadc57..d9b982d3a0b 100644 --- a/src/bin/psql/help.c +++ b/src/bin/psql/help.c @@ -169,7 +169,7 @@ slashUsage(unsigned short int pager) * Use "psql --help=commands | wc" to count correctly. It's okay to count * the USE_READLINE line even in builds without that. */ - output = PageOutput(127, pager ? &(pset.popt.topt) : NULL); + output = PageOutput(128, pager ? &(pset.popt.topt) : NULL); fprintf(output, _("General\n")); fprintf(output, _(" \\copyright show PostgreSQL usage and distribution terms\n")); @@ -206,11 +206,12 @@ slashUsage(unsigned short int pager) fprintf(output, _("Input/Output\n")); fprintf(output, _(" \\copy ... perform SQL COPY with data stream to the client host\n")); - fprintf(output, _(" \\echo [STRING] write string to standard output\n")); + fprintf(output, _(" \\echo [-n] [STRING] write string to standard output (-n for no newline)\n")); fprintf(output, _(" \\i FILE execute commands from file\n")); fprintf(output, _(" \\ir FILE as \\i, but relative to location of current script\n")); fprintf(output, _(" \\o [FILE] send all query results to file or |pipe\n")); - fprintf(output, _(" \\qecho [STRING] write string to query output stream (see \\o)\n")); + fprintf(output, _(" \\qecho [-n] [STRING] write string to \\o output stream (-n for no newline)\n")); + fprintf(output, _(" \\warn [-n] [STRING] write string to standard error (-n for no newline)\n")); fprintf(output, "\n"); fprintf(output, _("Conditional\n")); diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 12355348c95..9009b05e122 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -1438,7 +1438,7 @@ psql_completion(const char *text, int start, int end) "\\t", "\\T", "\\timing", "\\unset", "\\x", - "\\w", "\\watch", + "\\w", "\\warn", "\\watch", "\\z", "\\!", "\\?", NULL |