Re: Big script execution - Mailing list pgsql-general

From Laurenz Albe
Subject Re: Big script execution
Date
Msg-id a167ec10588c4936c85327e1aa92b3d479cf5fa1.camel@cybertec.at
Whole thread Raw
In response to Big script execution  (Igor Korot <ikorot01@gmail.com>)
Responses Re: Big script execution
List pgsql-general
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



pgsql-general by date:

Previous
From: Achilleas Mantzios - cloud
Date:
Subject: Re: exclusion constraint question
Next
From: Igor Korot
Date:
Subject: Re: Big script execution