Re: PSQL commands: \quit_if, \quit_unless

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: PSQL commands: \quit_if, \quit_unless
Дата
Msg-id 27762.1480367262@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: PSQL commands: \quit_if, \quit_unless  (Corey Huinker <corey.huinker@gmail.com>)
Ответы Re: PSQL commands: \quit_if, \quit_unless
Re: PSQL commands: \quit_if, \quit_unless
Список pgsql-hackers
Corey Huinker <corey.huinker@gmail.com> writes:
> On Mon, Nov 28, 2016 at 2:03 PM, Fabien COELHO <coelho@cri.ensmp.fr> wrote:
>> I'm wondering if an simplistic interpreted \if \elsif/\else \fi would make
>> more sense:

> The problem is that \if \elsif \else \fi is anything but simplistic, and
> would be a vastly bigger change. Detecting nested if-thens, detecting
> un-matched if-thens, etc.

Yes, but...  We've generally refrained from inventing any control flow
metacommands for psql, and TBH this does *not* seem like the place to
start.  If we take this patch we are very likely to find that it doesn't
fit in at all whenever someone does show up with a proposal for control
flow features.

If we had an agreed-on sketch for what that feature set would look like,
I wouldn't necessarily object to implementing commands like these first.
But as it stands I think we'd be painting ourselves into a corner.
There's no reason to assume a-priori that this patch creates either naming
conventions or semantics (e.g. what is suitable as a boolean expression)
that we'd be happy with in a larger context.

As far as the original problem goes, I wonder whether what you really
want isn't a \quit command that lets you specify psql's exit code.
I'm not quite seeing how this proposal advances the problem of
communicating between psql and shell portions of a script; but I can
see how returning 0 (ok) vs 1 (error) vs 2 (some special case) would
help with that.
        regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Corey Huinker
Дата:
Сообщение: Re: PSQL commands: \quit_if, \quit_unless
Следующее
От: Petr Jelinek
Дата:
Сообщение: Re: Logical Replication WIP