pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedWe have to close the cursor or rollback the transaction in case of failure?
2+ messages / 2 participants
[nested] [flat]
* We have to close the cursor or rollback the transaction in case of failure?
@ 2019-12-05 10:00 M Tarkeshwar Rao <m.tarkeshwar.rao@ericsson.com>
2019-12-05 15:05 ` Re: We have to close the cursor or rollback the transaction in case of failure? Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 2+ messages in thread
From: M Tarkeshwar Rao @ 2019-12-05 10:00 UTC (permalink / raw)
To: pgsql-general
Hi all,
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?
postgres[10709]: [6-1] < 2019-10-29 11:24:22.550 CET > ERROR: canceling statement due to conflict with recovery
postgres[10709]: [6-2] < 2019-10-29 11:24:22.550 CET > DETAIL: User query might have needed to see row versions that must be removed.
postgres[10709]: [6-3] < 2019-10-29 11:24:22.550 CET > STATEMENT: FETCH 1000 IN mycursor_3461662464_1572368715367985819
postgres[10709]: [7-1] < 2019-10-29 11:24:22.550 CET > ERROR: current transaction is aborted, commands ignored until end of transaction block
postgres[10709]: [7-2] < 2019-10-29 11:24:22.550 CET > STATEMENT: CLOSE mycursor_3461662464_1572368715367985819
O
Regards
Tarkeshwar
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: We have to close the cursor or rollback the transaction in case of failure?
2019-12-05 10:00 We have to close the cursor or rollback the transaction in case of failure? M Tarkeshwar Rao <m.tarkeshwar.rao@ericsson.com>
@ 2019-12-05 15:05 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 2019-12-05 15:05 UTC (permalink / raw)
To: M Tarkeshwar Rao <m.tarkeshwar.rao@ericsson.com>; +Cc: pgsql-general
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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2019-12-05 15:05 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-12-05 10:00 We have to close the cursor or rollback the transaction in case of failure? M Tarkeshwar Rao <m.tarkeshwar.rao@ericsson.com>
2019-12-05 15:05 ` Tom Lane <tgl@sss.pgh.pa.us>
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