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 1kai04-0001l8-RX for pgsql-bugs@arkaria.postgresql.org; Thu, 05 Nov 2020 16:20: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 1kai03-0001I3-M8 for pgsql-bugs@arkaria.postgresql.org; Thu, 05 Nov 2020 16:20:35 +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 1kai03-0001Hq-GU for pgsql-bugs@lists.postgresql.org; Thu, 05 Nov 2020 16:20:35 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kai01-0007cp-5V for pgsql-bugs@lists.postgresql.org; Thu, 05 Nov 2020 16:20:35 +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 0A5GKTVP1477410; Thu, 5 Nov 2020 11:20:29 -0500 From: Tom Lane To: Alvaro Herrera cc: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16703: pg-dump fails to process recursive view definition In-reply-to: <1473888.1604590908@sss.pgh.pa.us> References: <16703-e348f58aab3cf6cc@postgresql.org> <1438431.1604588428@sss.pgh.pa.us> <1473888.1604590908@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Thu, 05 Nov 2020 10:41:48 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1477408.1604593229.1@sss.pgh.pa.us> Date: Thu, 05 Nov 2020 11:20:29 -0500 Message-ID: <1477409.1604593229@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Further news: I thought to myself "let's leave a self-referential view behind in the final regression test state, so we can actually exercise pg_dump/pg_upgrade with one". It turns out that that's not gonna work, at least not right away. pg_dump dumps the view all right, but it dumps CREATE VIEW "public"."self_referential_view" AS SELECT "self_referential_view"."key", "self_referential_view"."data" FROM "public"."self_referential_view"; which of course fails to load, complaining "relation "public.self_referential_view" does not exist". I'm not particularly desperate to do anything about that. It's important that pg_dump not fail on such a view, so you don't have a risk that your backups didn't work at all. But if you have to do some finagling to restore it, that's less critical. Also, this has been the situation all along and there have been no complaints. One could imagine getting pg_dump to handle this by treating the self-reference as a circular reference and then doing what it does to break reference loops with views. I experimented briefly with that, but it's a bigger can of worms than it seems; pg_dump_sort.c does not seem to have quite enough info to tell whether references are explicit self-references or not. regards, tom lane