Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TjZIm-0005OD-B6 for pgsql-bugs@arkaria.postgresql.org; Fri, 14 Dec 2012 17:44:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TjZIl-00043t-8T for pgsql-bugs@arkaria.postgresql.org; Fri, 14 Dec 2012 17:43:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TjZIk-00043n-DT for pgsql-bugs@postgresql.org; Fri, 14 Dec 2012 17:43:58 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TjZIh-0001ii-K4 for pgsql-bugs@postgresql.org; Fri, 14 Dec 2012 17:43:58 +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 qBEHhrm9002960; Fri, 14 Dec 2012 12:43:54 -0500 (EST) From: Tom Lane To: Heikki Linnakangas , Robert Haas cc: Pg Bugs Subject: Re: Bug with temporary child of a permanent table after recovery In-reply-to: <50CB1455.3080002@vmware.com> References: <50CB1455.3080002@vmware.com> Comments: In-reply-to Heikki Linnakangas message dated "Fri, 14 Dec 2012 13:58:13 +0200" Date: Fri, 14 Dec 2012 12:43:53 -0500 Message-ID: <2959.1355507033@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 Heikki Linnakangas writes: > Spotted by accident while working on a patch: > Open psql and do: > CREATE TABLE uctest(f1 int, f2 text); > -- Create a temporary child of the permanent table > CREATE TEMP TABLE ucchild () inherits (uctest); > In another terminal: > pg_ctl stop -m immediate > pg_ctl start > psql (9.3devel) > Type "help" for help. > postgres=# SELECT * FROM uctest; > ERROR: could not open file "base/12030/t2_16392": No such file or directory > This goes back to 9.1. I believe this used to work before Robert redesigned temp relations. The underlying physical file got removed during postmaster restart, but at this point the catalog entry for the temp table is still there, and the planner is failing to disregard it as intended. The problem is that the RELATION_IS_OTHER_TEMP macro #define RELATION_IS_OTHER_TEMP(relation) \ ((relation)->rd_rel->relpersistence == RELPERSISTENCE_TEMP \ && (relation)->rd_backend != MyBackendId) is getting fooled by a chance collision of backend IDs --- that is, the failure only occurs in sessions with the same BackendId that the original table creator had. It worked before because the "is my temp table" test was based on whether the table belonged to myTempNamespace, which would be InvalidOid until the backend had started using the temp namespace --- and one of the things involved in that is to run around and clean out any leftover tables in that schema. I'm not sure where rd_backend gets set up, but maybe we can fix this by not allowing rd_backend to acquire a valid value unless we've begun using the temp namespace. 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