Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQ460-00082y-Oz for pgsql-general@arkaria.postgresql.org; Wed, 10 Apr 2013 23:06:28 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UQ45z-0000nl-Eh for pgsql-general@arkaria.postgresql.org; Wed, 10 Apr 2013 23:06:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQ45x-0000lz-CU for pgsql-general@postgresql.org; Wed, 10 Apr 2013 23:06:25 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQ45t-0008U8-Ce for pgsql-general@postgresql.org; Wed, 10 Apr 2013 23:06:24 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id r3AN6Cg4013082; Wed, 10 Apr 2013 19:06:12 -0400 (EDT) From: Tom Lane To: Andres Freund cc: Joshua Berry , PostgreSQL - General Subject: Re: Segmentation fault with core dump In-reply-to: <12385.1365633318@sss.pgh.pa.us> References: <20130410214929.GA7547@awork2.anarazel.de> <20130410222233.GB7547@awork2.anarazel.de> <12385.1365633318@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Wed, 10 Apr 2013 18:35:18 -0400" Date: Wed, 10 Apr 2013 19:06:12 -0400 Message-ID: <13081.1365635172@sss.pgh.pa.us> X-Pg-Spam-Score: -4.3 (----) 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 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. regards, tom lane -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general