Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1icbNv-0005dw-O5 for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Dec 2019 20:36:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1icbNu-0007Ku-6D for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Dec 2019 20:36:30 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1icbNt-0007Kn-QH for pgsql-hackers@lists.postgresql.org; Wed, 04 Dec 2019 20:36:29 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1icbNn-000456-3s for pgsql-hackers@lists.postgresql.org; Wed, 04 Dec 2019 20:36:28 +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 xB4KaJl1031906; Wed, 4 Dec 2019 15:36:19 -0500 From: Tom Lane To: Peter Eisentraut cc: pgsql-hackers@lists.postgresql.org Subject: Re: Dumping/restoring fails on inherited generated column In-reply-to: References: <15830.1575468847@sss.pgh.pa.us> Comments: In-reply-to Peter Eisentraut message dated "Wed, 04 Dec 2019 21:17:21 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <31904.1575491779.1@sss.pgh.pa.us> Date: Wed, 04 Dec 2019 15:36:19 -0500 Message-ID: <31905.1575491779@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Peter Eisentraut writes: > On 2019-12-04 15:14, Tom Lane wrote: >> It looks like gtest1_1 inherits column "b" from gtest1, so possibly >> pg_dump is just confused about the combination of inheritance and >> generated columns. > Yeah, there was some stuff about the "separate" dumping of defaults that > I apparently forgot to address. The attached patch fixes it. I'll see > about adding a test case for it, too. I don't think this is right. It will probably misbehave if the "generated" expression has any interesting dependencies: 1. You didn't duplicate the behavior of the existing separate=false case, where it adds a dependency to try to force the default's dependencies to exist before the table is created. 2. If that dependency turns out to create a dependency loop, the later code will break the loop by setting separate=true anyway. Then what? I also find it improbable that overriding the !shouldPrintColumn test is really the right thing. That test is what distinguishes the is-a-parent-table from the is-a-child-table cases, and the core of the issue here seems to be that we need to treat those differently. I wonder if the right fix is to not generate a DO_ATTRDEF object at all for generated columns in child tables. Am I right in guessing that we propagate generated-ness to child tables automatically? regards, tom lane