Re: Make ON_ERROR_STOP stop on shell script failure

From: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
To: Greg Stark <stark(at)mit(dot)edu>, Andreas 'ads' Scherbaum <ads(at)pgug(dot)de>
Cc: Matheus Alcantara <mths(dot)dev(at)pm(dot)me>, bt22nakamorit <bt22nakamorit(at)oss(dot)nttdata(dot)com>, Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, 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: 2023-03-24 15:07:42
Message-ID: 8e940fb8-0e16-0e6f-c4be-e5920b49fd23@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 20.03.23 19:31, Greg Stark wrote:
> So I took a look at this patch. The conflict is with 2fe3bdbd691
> committed by Peter Eisentraut which added error checks for pipes.
> Afaics the behaviour is now for pipe commands returning non-zero to
> cause an error*always* regardless of the setting of ON_ERROR_STOP.
>
> I'm not entirely sure that's sensible actually. If you write to a pipe
> that ends in grep and it happens to produce no matching rows you may
> actually be quite surprised when that causes your script to fail...

The only thing that that patch changed in psql was the \w command, and
AFAICT, ON_ERROR_STOP is still respected:

$ cat test.sql
\w |foo

$ psql -f test.sql
sh: foo: command not found
psql:test.sql:1: error: |foo: command not found
$ echo $?
0

$ psql -f test.sql -v ON_ERROR_STOP=1
sh: foo: command not found
psql:test.sql:1: error: |foo: command not found
$ echo $?
3

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2023-03-24 15:13:52 pgsql: amcheck: Fix verify_heapam for tuples where xmin or xmax is 0.
Previous Message Kumar, Sachin 2023-03-24 15:04:01 RE: Initial Schema Sync for Logical Replication