Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 5ADF19FB28A for ; Thu, 18 Jan 2007 13:42:40 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 05525-07 for ; Thu, 18 Jan 2007 13:42:18 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.171]) by postgresql.org (Postfix) with ESMTP id 91F679FA1D8 for ; Thu, 18 Jan 2007 13:42:23 -0400 (AST) Received: by ug-out-1314.google.com with SMTP id k3so232004ugf for ; Thu, 18 Jan 2007 09:42:22 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=AIWHpO8nf30X/liSMxk63LI+cmUZvmsNp9wvikhPCfEzHStw/anUw7QeoUMxDIBaUGDY/1jm4ID6mXu4IfRcLB7pKGXXIHmz+HIXBwi/XP9nYquGa4NjaQeMYEvtNAF8pQ274Xm4HG0v+M60OnlHxzeZuwY3d8JG7r2x15iTKf0= Received: by 10.82.138.6 with SMTP id l6mr304932bud.1169142142018; Thu, 18 Jan 2007 09:42:22 -0800 (PST) Received: by 10.82.170.1 with HTTP; Thu, 18 Jan 2007 09:42:21 -0800 (PST) Message-ID: <1d4e0c10701180942i60edff8bt914258ab0e1761ac@mail.gmail.com> Date: Thu, 18 Jan 2007 18:42:21 +0100 From: "Guillaume Smet" To: "Dave Cramer" , "PostgreSQL JDBC" , "Tom Lane" Subject: Re: Memory leaks using refcursors In-Reply-To: <1d4e0c10701180646p56c18dcal2cb3526bd1050e63@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1d4e0c10701171053t55e60a2epf3e395b5b97101b5@mail.gmail.com> <1d4e0c10701171422u2e9d8758ia663dd1f826f8258@mail.gmail.com> <6135.1169073075@sss.pgh.pa.us> <1d4e0c10701171527u744fd81eh6de7908599349af3@mail.gmail.com> <1d4e0c10701180057s2c2e4c85g50998c883bb470df@mail.gmail.com> <1E6DB692-8D5A-493F-9E1F-82130917EE77@postgresintl.com> <1d4e0c10701180646p56c18dcal2cb3526bd1050e63@mail.gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/118 X-Sequence-Number: 16483 Hi again, In fact, there is still a remaining problem. People who developed this application sometimes commit the transaction before closing the result set in their code. With the current driver, it's not a problem as it didn't close the cursor at all so the cursor is closed at the end of the transaction and that's all. But with this patch, we have the following case: - begin - open result set -> open the cursor - commit -> close the cursor - close the result set -> try to close the cursor -> exception and backend in an error state if autocommit is false They fixed the order of commit/close in their application but IMHO, it's a bad idea to introduce this sort of regression. A try/catch is probably not a good idea because it leaves the backend in an error state if the CLOSE query is executed in a transaction (if autocommit is false for example). Any ideas on how we can solve this problem? I can't find any way to check if a cursor is still alive without throwing an error. -- Guillaume