New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No implicit transactions for named with hold cursors outside their transaction #7

Closed
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
2 participants
@snaury
Copy link
Contributor

snaury commented Jul 9, 2013

Hi,

I noticed that currently named "with hold" cursors behave differently than client-side cursors in some aspects, which seem to be a little off:

  • When closing withhold cursor after its creating transaction is committed another transaction is implicitly started, which may unexpectedly leave connection is a long transaction
  • When fetching data outside their transactions, again, an implicit transaction is started, when it seems it's not needed. Current documentation (http://www.postgresql.org/docs/current/static/sql-declare.html) currently says that it copies rows to temporary file/memory, and it seems to me (though I'm not entirely certain) that fetch would return data as it was in a transaction where cursor was created, not how it is in another transaction.

What do you think? Should implicit transactions always be created, or is it better to fetch/close in basically autocommit mode?

snaury added some commits Jul 9, 2013

No implicit transaction on named cursor close
Also, don't start an implicit transaction when fetching with
named with hold cursor, since it already returns results
from a previously committed transaction.
@dvarrazzo

This comment has been minimized.

Copy link
Member

dvarrazzo commented Jul 9, 2013

Thank you for the observations, will think about that. I haven't designed/used the withhold cursors so I'll have to check what you say but it makes sense.

Federico is the author of the with_hold cursor: I don't think he is following a thread here. The best thing would be to explain your observations to the mailing list: Federico and others could give you better feedback than me.

@dvarrazzo

This comment has been minimized.

Copy link
Member

dvarrazzo commented Aug 21, 2014

I've added some tests and committed your patches, thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment