Re: Make ON_ERROR_STOP stop on shell script failure

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: bt22nakamorit <bt22nakamorit(at)oss(dot)nttdata(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Make ON_ERROR_STOP stop on shell script failure
Date: 2022-09-21 02:45:07
Message-ID: a56cb988-975d-e240-15d5-a7bd11ccc413@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2022/09/20 15:15, bt22nakamorit wrote:
>>>> I thought that this action is rather unexpected since, based on the
>>>> word """ON_ERROR_STOP""", ones may expect that failures of shell
>>>> scripts should halt the incoming instructions as well.
>>>> One clear solution is to let failures of shell script stop incoming
>>>> queries just like how errors of SQLs do currently. Thoughts?

+1

> I edited the documentation for ON_ERROR_STOP.
> Any other suggestions?

Thanks for the patch!
Could you add it to the next CommitFest so that we don't forget it?

We can execute the shell commands via psql in various ways
other than \! meta-command. For example,

* `command`
* \g | command
* \gx | command
* \o | command
* \w | command
* \copy ... program 'command'

ON_ERROR_STOP should handle not only \! but also all the above in the same way?

One concern about this patch is that some applications already depend on
the current behavior of ON_ERROR_STOP, i.e., psql doesn't stop even when
the shell command returns non-zero exit code. If so, we might need to
extend ON_ERROR_STOP so that it accepts the following setting values.

* off - don't stop even when either sql or shell fails (same as the current behavior)
* on or sql - stop only whensql fails (same as the current behavior)
* shell - stop only when shell fails
* all - stop when either sql or shell fails

Thought?

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message houzj.fnst@fujitsu.com 2022-09-21 02:52:41 RE: why can't a table be part of the same publication as its schema
Previous Message Bharath Rupireddy 2022-09-21 02:33:48 Re: pg_receivewal fail to streams when the partial file to write is not fully initialized present in the wal receiver directory