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 1kagke-0007D9-G4 for pgsql-bugs@arkaria.postgresql.org; Thu, 05 Nov 2020 15:00:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kagkc-0004lt-Mf for pgsql-bugs@arkaria.postgresql.org; Thu, 05 Nov 2020 15:00:34 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kagkc-0004lm-Gr for pgsql-bugs@lists.postgresql.org; Thu, 05 Nov 2020 15:00:34 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kagka-0003ES-B0 for pgsql-bugs@lists.postgresql.org; Thu, 05 Nov 2020 15:00:33 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 0A5F0SSd1438432; Thu, 5 Nov 2020 10:00:28 -0500 From: Tom Lane To: exclusion@gmail.com cc: pgsql-bugs@lists.postgresql.org, Alvaro Herrera Subject: Re: BUG #16703: pg-dump fails to process recursive view definition In-reply-to: <16703-e348f58aab3cf6cc@postgresql.org> References: <16703-e348f58aab3cf6cc@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Thu, 05 Nov 2020 12:00:01 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1438430.1604588428.1@sss.pgh.pa.us> Date: Thu, 05 Nov 2020 10:00:28 -0500 Message-ID: <1438431.1604588428@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form writes: > The following recursive views (borrowed from regress/sql/lock.sql, see > "detecting infinite recursions in view definitions"): > CREATE VIEW lock_view2(a) AS SELECT NULL::integer; > CREATE VIEW lock_view3 AS SELECT * from lock_view2; > CREATE OR REPLACE VIEW lock_view2 AS SELECT * from lock_view3; > can be created successfully, but make a subsequent pg_dump fail: > pg_dump: error: query failed: ERROR: infinite recursion detected in rules > for relation "lock_view2" > pg_dump: error: query was: LOCK TABLE public.lock_view2 IN ACCESS SHARE > MODE > The offending commit is 64fc3e03. Yeah, not surprising. It seems like the least painful solution might be to teach LockTableRecurse to detect recursion and just not recurse into a view it's already locked. (BTW, I wonder if we shouldn't have a stack depth check there, too.) regards, tom lane