</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>-b</></term>
+ <term><option>--echo-errors</></term>
+ <listitem>
+ <para>
+ Print failed SQL commands to standard error output. This is
+ equivalent to setting the variable <varname>ECHO</varname> to
+ <literal>errors</literal>.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term><option>-c <replaceable class="parameter">command</replaceable></></term>
<term><option>--command=<replaceable class="parameter">command</replaceable></></term>
<literal>queries</literal>,
<application>psql</application> merely prints all queries as
they are sent to the server. The switch for this is
- <option>-e</option>.
+ <option>-e</option>. If set to <literal>errors</literal> then only
+ failed queries are displayed on standard error output. The switch
+ for this is <option>-b</option>.
</para>
</listitem>
</varlistentry>
printf(_("\nInput and output options:\n"));
printf(_(" -a, --echo-all echo all input from script\n"));
+ printf(_(" -b, --echo-errors echo failed commands\n"));
printf(_(" -e, --echo-queries echo commands sent to server\n"));
printf(_(" -E, --echo-hidden display queries that internal commands generate\n"));
printf(_(" -L, --log-file=FILENAME send session log to file\n"));
{"command", required_argument, NULL, 'c'},
{"dbname", required_argument, NULL, 'd'},
{"echo-queries", no_argument, NULL, 'e'},
+ {"echo-errors", no_argument, NULL, 'b'},
{"echo-hidden", no_argument, NULL, 'E'},
{"file", required_argument, NULL, 'f'},
{"field-separator", required_argument, NULL, 'F'},
memset(options, 0, sizeof *options);
- while ((c = getopt_long(argc, argv, "aAc:d:eEf:F:h:HlL:no:p:P:qR:sStT:U:v:VwWxXz?01",
+ while ((c = getopt_long(argc, argv, "aAbc:d:eEf:F:h:HlL:no:p:P:qR:sStT:U:v:VwWxXz?01",
long_options, &optindex)) != -1)
{
switch (c)
case 'A':
pset.popt.topt.format = PRINT_UNALIGNED;
break;
+ case 'b':
+ SetVariable(pset.vars, "ECHO", "errors");
+ break;
case 'c':
options->action_string = pg_strdup(optarg);
if (optarg[0] == '\\')
pset.echo = PSQL_ECHO_NONE;
else if (strcmp(newval, "queries") == 0)
pset.echo = PSQL_ECHO_QUERIES;
+ else if (strcmp(newval, "errors") == 0)
+ pset.echo = PSQL_ECHO_ERRORS;
else if (strcmp(newval, "all") == 0)
pset.echo = PSQL_ECHO_ALL;
else