public inbox for [email protected]  
help / color / mirror / Atom feed
From: Laurenz Albe <[email protected]>
To: Igor Korot <[email protected]>
To: pgsql-generallists.postgresql.org <[email protected]>
Subject: Re: Big script execution
Date: Mon, 10 Mar 2025 17:31:51 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <CA+FnnTx2Q=C-hUEBU08GMmfa0AGPt=XETnOW6G+=MyjrVmb7+Q@mail.gmail.com>
References: <CA+FnnTx2Q=C-hUEBU08GMmfa0AGPt=XETnOW6G+=MyjrVmb7+Q@mail.gmail.com>

On Mon, 2025-03-10 at 16:42 -0500, Igor Korot wrote:
> I am trying to execute a huge script (~40K lines) that will populate
> my database.
> 
> The script starts with "BEGIN TRANSACTION" and will end
> with "COMMIT".
> 
> however I'd like to rollback if there is an error encounter.
> 
> When I execute it from the Terminal I do use
> 
> -v ON_ERROR_STOP=1
> 
> but I'd like to rolback the transaction so it starts a fresh every time.
> 
> Is there some kind of
> 
> ON ERROR ROLLBACK
> 
> command I can put inside the script?

That happens automatically: if you are running the whole script in a
single transaction, any error will make the whole transaction roll back.

Yours,
Laurenz Albe






view thread (5+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Big script execution
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox