Re: [HACKERS] PSQL return coder

2013-10-15 Thread James Sewell
I was avoiding ON_ERROR_STOP because I was using ON_ERROR_ROLLBACK, but have just realised that if I encase my SQL in a transaction then rollback will still happen. Perfect! James Sewell, PostgreSQL Team Lead / Solutions Architect __ Level 2, 50 Queen St, M

Re: [HACKERS] PSQL return coder

2013-10-10 Thread Merlin Moncure
On Thu, Oct 10, 2013 at 1:52 AM, Tom Lane wrote: > James Sewell writes: >> My question is in a rollback scenario is it possible to get PSQL to return >> a non 0 exit status? > > Maybe you could use -c instead of -f? > > $ psql -c 'select 1; select 1/0' regression > ERROR: division by zero > $ ec

Re: [HACKERS] PSQL return coder

2013-10-09 Thread Tom Lane
James Sewell writes: > My question is in a rollback scenario is it possible to get PSQL to return > a non 0 exit status? Maybe you could use -c instead of -f? $ psql -c 'select 1; select 1/0' regression ERROR: division by zero $ echo $? 1 You won't need explicit BEGIN/END because this is alrea

Re: [HACKERS] PSQL return coder

2013-10-09 Thread Pavel Stehule
Hello 2013/10/10 James Sewell > Hello, > > I am using PSQL to run SQL from a file with the -f flag as follows: > > BEGIN > SQL > SQL > ... > END > > This gives me rollback on error and a nicer output than -1. This works > fine. > > My question is in a rollback scenario is it possible to get PSQ

[HACKERS] PSQL return coder

2013-10-09 Thread James Sewell
Hello, I am using PSQL to run SQL from a file with the -f flag as follows: BEGIN SQL SQL ... END This gives me rollback on error and a nicer output than -1. This works fine. My question is in a rollback scenario is it possible to get PSQL to return a non 0 exit status? Cheers,a James -- J