Re: psql: show only failed queries - Mailing list pgsql-hackers

From Fujii Masao
Subject Re: psql: show only failed queries
Date
Msg-id CAHGQGwHYynkbExq_yFud9RFoXFW6vuAeJEHNp7rPQ_D-S3=_KA@mail.gmail.com
Whole thread Raw
In response to Re: psql: show only failed queries  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: psql: show only failed queries  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-hackers
On Mon, Jun 30, 2014 at 8:33 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
>
>
>
> 2014-06-30 13:01 GMT+02:00 Abhijit Menon-Sen <ams@2ndquadrant.com>:
>
>> At 2014-06-30 12:48:30 +0200, pavel.stehule@gmail.com wrote:
>> >
>> > +      <para>
>> > +      Print a failed SQL commands to standard error output. This is
>> > +      equivalent to setting the variable <varname>ECHO</varname> to
>> > +      <literal>errors</literal>.
>>
>> No "a", just "Print failed SQL commands …".
>>
>> > -        <option>-e</option>.
>> > +        <option>-e</option>. If set to <literal>error</literal> then
>> > only
>> > +        failed queries are displayed.
>>
>> Should be "errors" here, not "error".
>>
>> >       printf(_("  -a, --echo-all           echo all input from
>> > script\n"));
>> > +     printf(_("  -b  --echo-errors        echo failed commands sent to
>> > server\n"));
>> >       printf(_("  -e, --echo-queries       echo commands sent to
>> > server\n"));
>>
>> Should have a comma after -b to match other options. Also I would remove
>> "sent to server" from the description: "echo failed commands" is fine.
>
>
> fixed

$ psql -b
bin/psql: invalid option -- 'b'
Try "psql --help" for more information.

I got this error. ISTM you forgot to add 'b' into the third argument of
getopt_long in startup.c.
        <application>psql</application> merely prints all queries as        they are sent to the server. The switch for
thisis 
-        <option>-e</option>.
+        <option>-e</option>. If set to <literal>errors</literal> then only
+        failed queries are displayed.

I think that where failed queries are output should be documented here.
Otherwise users might misunderstand they are output to standard output
like ECHO=all and queries do.

It's better to add "The switch for this is <option>-b</option>." into the doc.

+    else if (strcmp(prev2_wd, "\\set") == 0)
+    {
+        if (strcmp(prev_wd, "ECHO") == 0)
+        {
+            static const char *const my_list[] =
+            {"none", "errors", "queries", "all", NULL};
+
+            COMPLETE_WITH_LIST_CS(my_list);
+        }
+        else if (strcmp(prev_wd, "ECHO_HIDDEN") == 0)
+        {
+            static const char *const my_list[] =
+            {"noexec", "off", "on", NULL};
+
+            COMPLETE_WITH_LIST_CS(my_list);
+        }
+    }

I think that adding tab-completions of psql variables is good, but
adding those of only ECHO and ECHO_HIDDEN seems half-baked.
Probably this part should be split into separate patch.

Regards,

--
Fujii Masao



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: postgresql.auto.conf and reload
Next
From: Ashutosh Bapat
Date:
Subject: Re: Extending constraint exclusion for implied constraints/conditions