Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dBN5o-0007g4-96 for pgsql-bugs@arkaria.postgresql.org; Thu, 18 May 2017 15:11:56 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dBN5n-0005jM-7M for pgsql-bugs@arkaria.postgresql.org; Thu, 18 May 2017 15:11:55 +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 1dBN5m-0005gQ-DM for pgsql-bugs@postgresql.org; Thu, 18 May 2017 15:11:54 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dBN5j-0007NY-FD for pgsql-bugs@postgresql.org; Thu, 18 May 2017 15:11:53 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v4IFBnS5021219; Thu, 18 May 2017 11:11:49 -0400 From: Tom Lane To: kwan.lim@gmail.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #14659: "ERROR: could not open relation with OID" when creating table from SELECT with large row In-reply-to: <20170518142443.29045.69550@wrigleys.postgresql.org> References: <20170518142443.29045.69550@wrigleys.postgresql.org> Comments: In-reply-to kwan.lim@gmail.com message dated "Thu, 18 May 2017 14:24:43 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <21217.1495120309.1@sss.pgh.pa.us> Date: Thu, 18 May 2017 11:11:49 -0400 Message-ID: <21218.1495120309@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org kwan.lim@gmail.com writes: > We have a UDF that creates a temporary table from a SELECT statement then > returns the result and drops the table. > For certain cases where it appears that there are large strings in some > columns the UDF fails with: "ERROR: could not open relation with OID" What seems to be happening is that if the strings are large enough to be toasted, then the data returned out of the function with RETURN QUERY contains toast pointers referencing the temp table's toast table. If you drop the temp table then those pointers will fail upon use. In this particular example there's an obvious workaround: lose the final DROP TABLE. The function's initial "DROP IF EXISTS" will serve just fine. It seems like what we'd have to do to fix this is to detoast datums that are going into the returned tuplestore. That's pretty annoying from a performance standpoint, but I don't see any good alternative. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs