Re: We have to close the cursor or rollback the transaction in case of failure?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: M Tarkeshwar Rao <m(dot)tarkeshwar(dot)rao(at)ericsson(dot)com>
Cc: "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: We have to close the cursor or rollback the transaction in case of failure?
Date: 2019-12-05 15:05:11
Message-ID: 13187.1575558311@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

M Tarkeshwar Rao <m(dot)tarkeshwar(dot)rao(at)ericsson(dot)com> writes:
> I am using cursors to fetch the data from table using C++. Initially were errors as highlighted as "current transaction isaborted" in /var/logs during full vacuum.
> We are little bit confused in failure handling. In case of any failure of following function.
> PQexec(connection, myFetchSql)
> We have to close the cursor or rollback the transaction?

Once the transaction has had an error, you have to issue ROLLBACK
before you can do anything else. That will automatically close
any cursors opened in the current transaction. There's no point
in issuing an explicit CLOSE (and indeed, if you try, it'll just
produce the same "current transaction is aborted" error).

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Melvin Davidson 2019-12-05 15:58:51 Re: Schema Copy
Previous Message Zwettler Markus (OIZ) 2019-12-05 15:04:55 AW: archiving question