Cleanup error handling in PostgreSQL