From: | bt22nakamorit <bt22nakamorit(at)oss(dot)nttdata(dot)com> |
---|---|
To: | Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com> |
Cc: | Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Make ON_ERROR_STOP stop on shell script failure |
Date: | 2022-09-30 07:54:06 |
Message-ID: | d87e16e15d5498f0eb62fc23d4397fd6@oss.nttdata.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
2022-09-21 11:45 に Fujii Masao wrote:
> 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,
I agree that some applications may depend on the behavior of previous
ON_ERROR_STOP.
I created a patch that implements off, on, shell, and all option for
ON_ERROR_STOP.
I also edited the code for \g, \o, \w, and \set in addition to \! to
return exit status of shell commands for ON_ERROR_STOP.
There were discussions regarding the error messages for when shell
command fails.
I have found that \copy already handles exit status of shell commands
when it executes one, so I copied the messages from there.
More specifically, I referred to """bool do_copy(const char *args)""" in
src/bin/psql/copy.c
Any feedback would be very much appreciated.
Tatsu
Attachment | Content-Type | Size |
---|---|---|
stop_error2.patch | text/x-diff | 8.8 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Benjamin Coutu | 2022-09-30 08:00:31 | Re: disfavoring unparameterized nested loops |
Previous Message | vignesh C | 2022-09-30 07:47:13 | Re: Support logical replication of DDLs |