Re: Big script execution

From: Igor Korot <ikorot01(at)gmail(dot)com>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Big script execution
Date: 2025-03-10 16:35:45
Message-ID: CA+FnnTw0Q-DDusB9LVfQXYQer72Y8dZ3vxqv_1NMTqLCnH20hg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi, Laurenz,

On Mon, Mar 10, 2025, 11:31 AM Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
wrote:

> 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.
>

Will the tables also be deleted?
The CREATE TABLE statements are part of this big transaction.

Thank you.

> Yours,
> Laurenz Albe
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Christophe Pettus 2025-03-10 16:36:51 Re: Big script execution
Previous Message Laurenz Albe 2025-03-10 16:31:51 Re: Big script execution