Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kEDEM-0002Gf-KV for pgsql-bugs@arkaria.postgresql.org; Fri, 04 Sep 2020 15:02:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kEDEL-0004L9-FE for pgsql-bugs@arkaria.postgresql.org; Fri, 04 Sep 2020 15:02:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kEDEL-0004L2-8L for pgsql-bugs@lists.postgresql.org; Fri, 04 Sep 2020 15:02:21 +0000 Received: from mail.dalibo.com ([212.85.157.172]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kEDEF-0004ef-04 for pgsql-bugs@lists.postgresql.org; Fri, 04 Sep 2020 15:02:20 +0000 Received: from firost (larco.ioguix.net [82.66.0.6]) by mail.dalibo.com (Postfix) with ESMTPSA id 1A218204CC; Fri, 4 Sep 2020 17:02:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dalibo.com; s=a; t=1599231734; bh=V/QZDCfDHrFJPP2sAmttvxMAABmiUeDLTgefCmaGhSI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=rD2LksQVFdUdLMdDeVslBZgBVH7CdjL543oOLes2TfpcBm/NOvm/izfG2WmGQEefD dxRtLQXcBzBAT/Xzmo7yp0ixPiSRtsN0nzZl69aib3tYHmkFXKOtEnygrP23AalyAj i9bgko0BGnYxZMnRkRvZUtK4ouzAf3kDnBbmWpP0= Date: Fri, 4 Sep 2020 17:02:13 +0200 From: Jehan-Guillaume de Rorthais To: Tom Lane Cc: pgsql-bugs@lists.postgresql.org Subject: Re: [BUG] plpgsql RETURN QUERY with toasted fields -vs- DROP/TRUNCATE Message-ID: <20200904170213.12547fb8@firost> In-Reply-To: <3568911.1598723239@sss.pgh.pa.us> References: <20200828174342.2ac34e27@firost> <3568911.1598723239@sss.pgh.pa.us> Organization: Dalibo MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sat, 29 Aug 2020 13:47:19 -0400 Tom Lane wrote: > Jehan-Guillaume de Rorthais writes: > > We discovered a bug in plpgsql. > > When using RETURN QUERY on a relation with some toasted values and when this > > relaiton is later dropped or truncated, an error is raised at the end of the > > function. > > This isn't particularly RETURN QUERY's fault; there are any number of ways > to produce the same sort of error. I reproduced it with > [...] Indeed. Thanks. > I guess we could forcibly detoast values in enough places to close all the > gaps, but the performance costs might be annoying. I think a case can > definitely be made for saying "don't do that". What do you mean? Writing in configuration to not drop a relation in a function where some past computed results depend on it? > (Another idea, perhaps, might be to detoast only in volatile functions, > reasoning that a nonvolatile one can't drop the table.) Would it be possible to detoast values iif the related relation are dropped later? Regards,