Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmT6K-0005p4-PN for pgsql-odbc@arkaria.postgresql.org; Mon, 28 Aug 2017 23:05:48 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dmT6J-0006wG-GE for pgsql-odbc@arkaria.postgresql.org; Mon, 28 Aug 2017 23:05:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dmT6J-0006w6-4D for pgsql-odbc@postgresql.org; Mon, 28 Aug 2017 23:05:47 +0000 Received: from mail02.asahi-net.or.jp ([202.224.55.14]) by magus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmT6F-0008Dv-J6 for pgsql-odbc@postgresql.org; Mon, 28 Aug 2017 23:05:46 +0000 Received: from [192.168.1.5] (aa029213.dynamic.ppp.asahi-net.or.jp [110.5.29.213]) (Authenticated sender: GQ9H-INUE) by mail02.asahi-net.or.jp (Postfix) with ESMTPA id D18504CBB4; Tue, 29 Aug 2017 08:05:38 +0900 (JST) Subject: Re: Q: Is there a way to force psqlODBC with enabled UseDeclareFetch to commit statements and avoid nesting transactions (savepoints)? To: =?UTF-8?Q?Matej_Miheli=c4=8d?= References: <2dc8921cc299459eb8bcc91bab1ae37b@neosys.si> From: "Inoue, Hiroshi" Cc: "pgsql-odbc@postgresql.org" Message-ID: <34ea555b-e098-dbe8-2774-4d2389f15bc9@dream.email.ne.jp> Date: Tue, 29 Aug 2017 08:05:41 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <2dc8921cc299459eb8bcc91bab1ae37b@neosys.si> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-odbc Precedence: bulk Sender: pgsql-odbc-owner@postgresql.org 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