pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: Anastasia Lubennikova <a.lubennikova@postgrespro.ru>
Cc: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: Masahiko Sawada <masahiko.sawada@2ndquadrant.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Dumping/restoring fails on inherited generated column
Date: Wed, 03 Feb 2021 10:31:38 -0500
Message-ID: <3906769.1612366298@sss.pgh.pa.us> (raw)
In-Reply-To: <2903e1ce-0765-cbeb-dd58-8fab7f6596a3@2ndquadrant.com>
References: <15830.1575468847@sss.pgh.pa.us>
	<fd559544-274c-f514-d8bf-358d2c539455@2ndquadrant.com>
	<31905.1575491779@sss.pgh.pa.us>
	<d6ebcc2e-3e6f-6915-6616-70ef665aed66@2ndquadrant.com>
	<24369.1580758361@sss.pgh.pa.us>
	<b1c831dd-d520-5e7f-0304-0eeed39c9996@2ndquadrant.com>
	<CA+fd4k4cHKUmEyHiPHx0QL3T-DXAP8O1CP-hUvo1WX6RwNC=tA@mail.gmail.com>
	<3f272982-0e0d-17a1-3fb6-fedc74197676@2ndquadrant.com>
	<c9848634-76c1-3c21-fc19-f1b7eebb640f@2ndquadrant.com>
	<3169466.1594841366@sss.pgh.pa.us>
	<CA+fd4k4fck6xzsF8mPWeVSZFBLtiA2cQxrPqBaYcoZGc+hZ=JQ@mail.gmail.com>
	<CA+fd4k6pLzrZDQsdsxcS06AwGRf1DgwOw84sFq9oXNw+83nB1g@mail.gmail.com>
	<e87e2efe-c820-c0d3-f7a0-0789beb78ff1@2ndquadrant.com>
	<CAD21AoCfgYKJo3cEhoUr4cKWxmSxi_gdHQDmOJ5XKC-dDc4yBw@mail.gmail.com>
	<e8e3f666-9050-1029-42cf-d0ecfdb8902e@2ndquadrant.com>
	<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>

Peter Eisentraut <peter.eisentraut@2ndquadrant.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





view thread (37+ messages)  latest in thread

Message-ID: <3906769.1612366298@sss.pgh.pa.us>
Permalink:  ../3906769.1612366298@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3906769.1612366298@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, peter.eisentraut@2ndquadrant.com, a.lubennikova@postgrespro.ru, sawada.mshk@gmail.com, masahiko.sawada@2ndquadrant.com
  Subject: Re: Dumping/restoring fails on inherited generated column
  In-Reply-To: <3906769.1612366298@sss.pgh.pa.us>
  References: <15830.1575468847@sss.pgh.pa.us> <fd559544-274c-f514-d8bf-358d2c539455@2ndquadrant.com> <31905.1575491779@sss.pgh.pa.us> <d6ebcc2e-3e6f-6915-6616-70ef665aed66@2ndquadrant.com> <24369.1580758361@sss.pgh.pa.us> <b1c831dd-d520-5e7f-0304-0eeed39c9996@2ndquadrant.com> <CA+fd4k4cHKUmEyHiPHx0QL3T-DXAP8O1CP-hUvo1WX6RwNC=tA@mail.gmail.com> <3f272982-0e0d-17a1-3fb6-fedc74197676@2ndquadrant.com> <c9848634-76c1-3c21-fc19-f1b7eebb640f@2ndquadrant.com> <3169466.1594841366@sss.pgh.pa.us> <CA+fd4k4fck6xzsF8mPWeVSZFBLtiA2cQxrPqBaYcoZGc+hZ=JQ@mail.gmail.com> <CA+fd4k6pLzrZDQsdsxcS06AwGRf1DgwOw84sFq9oXNw+83nB1g@mail.gmail.com> <e87e2efe-c820-c0d3-f7a0-0789beb78ff1@2ndquadrant.com> <CAD21AoCfgYKJo3cEhoUr4cKWxmSxi_gdHQDmOJ5XKC-dDc4yBw@mail.gmail.com> <e8e3f666-9050-1029-42cf-d0ecfdb8902e@2ndquadrant.com> <0f57d5e9-4112-1ba8-64d8-c02062c1e95d@postgrespro.ru> <41888c80-e5bd-f9e5-75dc-fb377113168c@2ndquadrant.com> <2808494.1611938475@sss.pgh.pa.us> <3906769.1612366298@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox