| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> | 
|---|---|
| To: | Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> | 
| Cc: | Anastasia Lubennikova <a(dot)lubennikova(at)postgrespro(dot)ru>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Masahiko Sawada <masahiko(dot)sawada(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> | 
| Subject: | Re: Dumping/restoring fails on inherited generated column | 
| Date: | 2021-02-03 15:31:38 | 
| Message-ID: | 3906769.1612366298@sss.pgh.pa.us | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers | 
Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Stephen Frost | 2021-02-03 15:33:57 | Re: Key management with tests | 
| Previous Message | Peter Eisentraut | 2021-02-03 15:24:12 | Re: Dumping/restoring fails on inherited generated column |