Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQbuI-0003r6-BL for pgsql-general@arkaria.postgresql.org; Fri, 12 Apr 2013 11:12:38 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UQbuH-0000zN-Q2 for pgsql-general@arkaria.postgresql.org; Fri, 12 Apr 2013 11:12:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQbuG-0000zG-Rb for pgsql-general@postgresql.org; Fri, 12 Apr 2013 11:12:36 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQbuC-00066H-PX for pgsql-general@postgresql.org; Fri, 12 Apr 2013 11:12:36 +0000 Received: from intern.anarazel.de (p5DDC5104.dip.t-dialin.net [93.220.81.4]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id 61540520004; Fri, 12 Apr 2013 13:12:32 +0200 (CEST) Date: Fri, 12 Apr 2013 13:12:31 +0200 From: Andres Freund To: Tom Lane Cc: Joshua Berry , PostgreSQL - General Subject: Re: Segmentation fault with core dump Message-ID: <20130412111231.GC5766@alap2.anarazel.de> References: <20130410214929.GA7547@awork2.anarazel.de> <20130410222233.GB7547@awork2.anarazel.de> <12385.1365633318@sss.pgh.pa.us> <13081.1365635172@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <13081.1365635172@sss.pgh.pa.us> X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org On 2013-04-10 19:06:12 -0400, Tom Lane wrote: > I wrote: > > (Wanders away wondering just how much the regression tests exercise > > holdable cursors.) > > And the answer is they're not testing this code path at all, because if > you do > DECLARE c CURSOR WITH HOLD FOR ... > FETCH ALL FROM c; > then the second query executes with a portal (and resource owner) > created to execute the FETCH command, not directly on the held portal. > > After a little bit of thought I'm not sure it's even possible to > reproduce this problem with libpq, because it doesn't expose any way to > issue a bare protocol Execute command against a pre-existing portal. > (I had thought psqlOBC went through libpq, but maybe it's playing some > games here.) > > Anyway, I'm thinking the appropriate fix might be like this > > - CurrentResourceOwner = portal->resowner; > + if (portal->resowner) > + CurrentResourceOwner = portal->resowner; > > in several places in pquery.c; that is, keep using > TopTransactionResourceOwner if the portal doesn't have its own. > > A more general but probably much more invasive solution would be to fake > up an intermediate portal when pulling data from a held portal, to > more closely approximate the explicit-FETCH case. We could also allocate a new resowner for the duration of that transaction. That would get reassigned to the transactions resowner in PreCommit_Portals (after a slight change there). That actually seems simple enough? Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general