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 1l7K88-0002bd-Ma for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Feb 2021 15:31:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l7K87-0006WG-LC for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Feb 2021 15:31:43 +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 1l7K87-0006W9-EM for pgsql-hackers@lists.postgresql.org; Wed, 03 Feb 2021 15:31:43 +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 1l7K85-0005C7-Ed for pgsql-hackers@lists.postgresql.org; Wed, 03 Feb 2021 15:31:43 +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 113FVcHo3906770; Wed, 3 Feb 2021 10:31:38 -0500 From: Tom Lane To: Peter Eisentraut cc: Anastasia Lubennikova , Masahiko Sawada , Masahiko Sawada , PostgreSQL Hackers Subject: Re: Dumping/restoring fails on inherited generated column In-reply-to: <2903e1ce-0765-cbeb-dd58-8fab7f6596a3@2ndquadrant.com> References: <15830.1575468847@sss.pgh.pa.us> <31905.1575491779@sss.pgh.pa.us> <24369.1580758361@sss.pgh.pa.us> <3f272982-0e0d-17a1-3fb6-fedc74197676@2ndquadrant.com> <3169466.1594841366@sss.pgh.pa.us> <0f57d5e9-4112-1ba8-64d8-c02062c1e95d@postgrespro.ru> <41888c80-e5bd-f9e5-75dc-fb377113168c@2ndquadrant.com> <2808494.1611938475@sss.pgh.pa.us> <2903e1ce-0765-cbeb-dd58-8fab7f6596a3@! 2ndquadrant.com> Comments: In-reply-to Peter Eisentraut message dated "Wed, 03 Feb 2021 16:24:12 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3906768.1612366298.1@sss.pgh.pa.us> Date: Wed, 03 Feb 2021 10:31:38 -0500 Message-ID: <3906769.1612366298@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Peter Eisentraut writes: > On 2021-01-29 17:41, Tom Lane wrote: >> However ... this doesn't solve all the cases noted in this thread. >> In the first example I gave at [1], >> d3=# create table parent (f1 int default 2); >> CREATE TABLE >> d3=# create table child (f1 int default 3) inherits(parent); >> NOTICE: merging column "f1" with inherited definition >> CREATE TABLE >> d3=# create table child2() inherits(parent); >> CREATE TABLE >> d3=# alter table child2 alter column f1 set default 42; >> ALTER TABLE >> >> pg_dump still fails to restore child2.f1's non-inherited default. > I can't tell what the problem is in this example. I tried with PG11, > 12, and master, and the schema dump comes out with those same four > commands and they restore correctly AFAICT. Oh! Trying it now, I see that the child2 default does get restored as a "separate default" object: ALTER TABLE ONLY public.child2 ALTER COLUMN f1 SET DEFAULT 42; This is a bit weird, because you'd think it would be handled the same as the other child's default, but it isn't; that one comes out as CREATE TABLE public.child ( f1 integer DEFAULT 3 ) INHERITS (public.parent); while child2 looks like CREATE TABLE public.child2 ( ) INHERITS (public.parent); I now suspect that I'd seen this dump of "child2" and missed the later ALTER. So no bug here, just pilot error. Sorry for the noise. regards, tom lane