When running scripts against Postgres with the psql
client, errors will accumulate by default. This is good from the perspective of resiliency, but may not always be desirable behavior, especially with a long-running script.
Fortunately there is a switch that can be set to fail on the first error.
Using the -v
option, set the ON_ERROR_STOP
variable as follows:
$ psql -d superstore -v ON_ERROR_STOP=1 -f setup.sql
Now the script will halt on the first error encountered.