How to stop a Postgres script when it encounters an error?

I think the solution to add following to .psqlrc is far from perfection


there exists much more simple and convenient way – use psql with parameter:

psql -v ON_ERROR_STOP=1

better to use also -X parameter turning off .psqlrc file usage.
Works perfectly for me

p.s. the solution found in great post from Peter Eisentraut. Thank you, Peter!

Leave a Comment