[PATCH v4] Add \warn to psql

From: David Fetter <david(at)fetter(dot)org>
To: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
Cc: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: [PATCH v4] Add \warn to psql
Date: 2019-04-28 14:58:13
Message-ID: 20190428145813.GO28936@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Apr 27, 2019 at 10:09:27PM +0200, Fabien COELHO wrote:
>
> Hello David,
>
> About v3. Applies, compiles, global & local make check are ok. doc gen ok.
>
> > > I'd put the commands in alphabetical order (echo, qecho, warn) instead of
> > > e/w/q in the condition.
> >
> > Done.
>
> Cannot see it:
>
> + else if (strcmp(cmd, "echo") == 0 || strcmp(cmd, "warn") == 0 || strcmp(cmd, "qecho") == 0)

My mistake. I didn't think the order in which they were compared
mattered much, but it makes sense on further reflection to keep things
tidy in the code.

> > > The -n trick does not appear in the help lines, ISTM that it could fit, so
> > > maybe it could be added, possibly something like:
> > >
> > > \echo [-n] [TEXT] write string to stdout, possibly without trailing newline
> > >
> > > and same for \warn and \qecho?
> >
> > Makes sense, but I put it there just for \echo to keep lines short.
>
> I think that putting together the 3 echo variants help makes sense, but
> maybe someone will object about breaking the abc order.

Here's the alphabetical version.

> > > > How might we test this portably?
> > >
> > > Hmmm... TAP tests are expected to be portable. Attached a simple POC, which
> > > could be extended to test many more things which are currently out of
> > > coverage (src/bin/psql stuff is covered around 40% only).
> >
> > Thanks for putting this together. I've added this test, and agree that
> > increasing coverage is important for another patch.
>
> Yep.

Speaking of which, I'd like to see about getting your patch against
Testlib.pm in so more tests of psql can also go in. It's not a new
feature /per se/, and it doesn't break any current scripts, so I'd
make the argument that it's OK for them to go in and possibly even be
back-patched.

Best,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

Attachment Content-Type Size
v4-0001-Add-warn-to-psql.patch text/x-diff 7.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Fetter 2019-04-28 15:07:16 [PATCH v1] Add a way to supply stdin to TAP tests
Previous Message Michael Paquier 2019-04-28 14:05:32 Re: clean up docs for v12