Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 2BDC6F07918 for ; Wed, 27 Jun 2012 00:51:28 -0300 (ADT) Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SjjHr-0007oo-Ff for pgsql-bugs@postgresql.org; Wed, 27 Jun 2012 03:51:27 +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 q5R3pEu0020286; Tue, 26 Jun 2012 23:51:14 -0400 (EDT) From: Tom Lane To: lifeair@gmail.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #6707: ERROR: could not open relation with OID In-reply-to: References: Comments: In-reply-to lifeair@gmail.com message dated "Tue, 26 Jun 2012 15:39:20 -0000" Date: Tue, 26 Jun 2012 23:51:14 -0400 Message-ID: <20285.1340769074@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201206/221 X-Sequence-Number: 33448 lifeair@gmail.com writes: > CREATE OR REPLACE FUNCTION test() RETURNS integer AS > $BODY$ > DECLARE > _r RECORD; > BEGIN > CREATE TEMP TABLE test(id int); > _r := ROW(NULL)::test; > _r:=NULL; > DROP TABLE test CASCADE; > RETURN 1; > END; > $BODY$ > LANGUAGE plpgsql VOLATILE > COST 100; Hmm. The problem with this is that the DROP TABLE invalidates test's rowtype, so on a second call the already-compiled "ROW(NULL)::test" expression refers to a type that no longer exists. We could fix that by adding datatypes to the set of objects that are tracked to determine when a cached plan must be invalidated, but I'm more than a bit hesitant to expend the extra cycles for this, given the lack of previous complaints and the large number of datatypes that are mentioned in most plans. Perhaps it would be good enough to only track types that must be rowtypes (ie, are mentioned in RowExpr or ConvertRowtypeExpr)? regards, tom lane