pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Inoue, Hiroshi <h-inoue@dream.email.ne.jp>
To: Matej Mihelič <Matej.Mihelic@neosys.si>
Cc: pgsql-odbc@postgresql.org <pgsql-odbc@postgresql.org>
Subject: Re: Q: Is there a way to force psqlODBC with enabled UseDeclareFetch to commit statements and avoid nesting transactions (savepoints)?
Date: Tue, 29 Aug 2017 08:05:41 +0900
Message-ID: <34ea555b-e098-dbe8-2774-4d2389f15bc9@dream.email.ne.jp> (raw)
In-Reply-To: <2dc8921cc299459eb8bcc91bab1ae37b@neosys.si>
References: <2dc8921cc299459eb8bcc91bab1ae37b@neosys.si>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-odbc>

Hi,

On 2017/08/25 16:45, Matej Mihelič wrote:
> Q: Is there a way to force psqlODBC with enabled UseDeclareFetch to commit statements and avoid nesting transactions (savepoints)?
>
> Since generated cursors are declared WITH HOLD they would survive COMMIT, and I assume, release resources on the server. I know that this would not be appropriate for all statements!
>
> I am trying to determine if there is a combination of statement attributes or some other settings that would make the ODBC driver operate in such fashion. I was hoping there is some combination of (statement) settings that would tell the driver that we are sending a forward only, read only, statement.

Normal? read only and forward only cursors are closed automatically when 
reached EOF.
Cursors are closed when statements are closed via SQLCloseCursor() or 
SQLFreeStmt(.., SQL_CLOSE).

Do you want another option that cursors are closed at transaction end?

regards,
Hiroshi Inoue


>   My hope is that this would allow the driver to avoid keeping the transaction open and prevent the application from staying "idle in transaction" until all cursors are fetched completely.
>
> What I'd like to achieve is an equivalent of the following "psql" script:
> BEGIN;
> declare cur1 NO SCROLL CURSOR WITH HOLD FOR SELECT * FROM pg_type;
> FETCH FORWARD 5 FROM cur1;
> COMMIT;
> BEGIN;
> declare cur2 NO SCROLL CURSOR WITH HOLD FOR SELECT * FROM pg_roles;
> FETCH FORWARD 5 FROM cur2;
> COMMIT;
>
> FETCH FORWARD 5 FROM cur1;
> FETCH FORWARD 5 FROM cur2;
> close cur1;
> close cur2;
>
> Perhaps my assumption, as I am coming from a different DB environment, that releasing transactions in such cases would free significant resources, is not really worth the effort on PostgreSQL. The other issue that I am thinking of is the fact that these sessions will be terminated on "idle_in_transaction_session_timeout" and rollback the outer transaction and all consequently, all nested savepoints.
>
> I would really appreciate a comment from someone more knowledgeable about these two assumptions. I am still in my initial strides with PG.
>
> -- Regards, Matej.


-- 
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc



view thread (4+ messages)  latest in thread

Message-ID: <34ea555b-e098-dbe8-2774-4d2389f15bc9@dream.email.ne.jp>
Permalink:  ../34ea555b-e098-dbe8-2774-4d2389f15bc9@dream.email.ne.jp/
Also on:    postgresql.org/message-id/34ea555b-e098-dbe8-2774-4d2389f15bc9@dream.email.ne.jp

 · 

reply

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-odbc@postgresql.org
  Cc: h-inoue@dream.email.ne.jp, Matej.Mihelic@neosys.si
  Subject: Re: Q: Is there a way to force psqlODBC with enabled UseDeclareFetch to commit statements and avoid nesting transactions (savepoints)?
  In-Reply-To: <34ea555b-e098-dbe8-2774-4d2389f15bc9@dream.email.ne.jp>
  References: <2dc8921cc299459eb8bcc91bab1ae37b@neosys.si> <34ea555b-e098-dbe8-2774-4d2389f15bc9@dream.email.ne.jp>

* 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