Re: pg_restore - generated column - not populating

From: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Santosh Udupi <email(at)hitha(dot)net>
Cc: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: pg_restore - generated column - not populating
Date: 2021-04-26 13:40:53
Message-ID: a9d2893c-bb4a-aadf-c02d-535e752ab2b7@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-general

On 24.02.21 02:03, Tom Lane wrote:
> [ redirecting to pgsql-bugs ]
>
> Santosh Udupi <email(at)hitha(dot)net> writes:
>> Here is my table structure.
>
> Indeed, this looks pretty busted, both in v13 and HEAD. It seems that
> pg_dump is not coping well with GENERATED columns attached to a
> partition parent table. I made the attached script with a bit of
> sample data, loaded it into an empty database, and dumped it.
> The dump is evidently assuming that ALTER TABLE ATTACH PARTITION
> is going to cause the generated-ness of the columns to propagate
> to the children, but it doesn't. There also seems to be considerable
> confusion about which columns of the child tables should be included
> in the dumped data.
>
> I suspect this example is revealing bugs in both the backend
> (ATTACH PARTITION ought to take care of this, no?) and pg_dump
> (the backend can't be blamed for pg_dump's choices of columns
> to dump). Peter?

The backend side of this would be fixed by the proposed
<https://www.postgresql.org/message-id/ac35da1c-e746-ea19-bfc3-84819a4e907d%40enterprisedb.com>
(it's the same code for ALTER TABLE ... INHERIT and ATTACH PARTITION).

The pg_dump side can apparently be fixed by adding

diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c
index 1a261a5545..c210883ca3 100644
--- a/src/bin/pg_dump/common.c
+++ b/src/bin/pg_dump/common.c
@@ -585,7 +585,7 @@ flagInhAttrs(DumpOptions *dopt, TableInfo *tblinfo,
int numTables)
}

/* Remove generation expression from child */
- if (foundGenerated && !dopt->binary_upgrade)
+ if (foundGenerated && !dopt->binary_upgrade &&
!tbinfo->ispartition)
tbinfo->attrdefs[j] = NULL;
}
}

Looks like this was accidentally broken by the last minor release's
fixes in this area.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2021-04-26 16:31:16 Re: BUG #16939: Plural interval for negative singular
Previous Message Mihir Pandya 2021-04-26 13:06:26 Re: BUG #16984: any version i install it says database cluster initialization failed

Browse pgsql-general by date

  From Date Subject
Next Message Ron 2021-04-26 13:43:20 Re: Invalid byte sequence when importing Oracle BLOB
Previous Message Malik Rumi 2021-04-26 13:17:01 Re: impact of version upgrade on fts