From: Tom Lane <tgl@sss.pgh.pa.us>
To: M Tarkeshwar Rao <m.tarkeshwar.rao@ericsson.com>
Cc: 'pgsql-general@postgresql.org' <pgsql-general@postgresql.org>
Subject: Re: We have to close the cursor or rollback the transaction in case of failure?
Date: Thu, 05 Dec 2019 10:05:11 -0500
Message-ID: <13187.1575558311@sss.pgh.pa.us> (raw)
In-Reply-To: <VI1PR0701MB27183BDF1E22EA50E87206B3AE5C0@VI1PR0701MB2718.eurprd07.prod.outlook.com>
References: <VI1PR0701MB27183BDF1E22EA50E87206B3AE5C0@VI1PR0701MB2718.eurprd07.prod.outlook.com>
M Tarkeshwar Rao <m.tarkeshwar.rao@ericsson.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
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, m.tarkeshwar.rao@ericsson.com
Subject: Re: We have to close the cursor or rollback the transaction in case of failure?
In-Reply-To: <13187.1575558311@sss.pgh.pa.us>
References: <VI1PR0701MB27183BDF1E22EA50E87206B3AE5C0@VI1PR0701MB2718.eurprd07.prod.outlook.com> <13187.1575558311@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox