break out of write loop when psql fails

fixes hanging in --create-functions
add setup option to ignore SQL errors

needed when restoring partial backups