On 2019-12-04 21:36, Tom Lane wrote:
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?

Right. New patch using that approach attached. (Could use more extensive comments.)

--
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From eeeab95adcaa298851abd3fd44d8646510e7aed2 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Mon, 3 Feb 2020 19:56:34 +0100
Subject: [PATCH v2] Fix dumping of inherited generated columns

---
 src/bin/pg_dump/pg_dump.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 33e58fa287..c9938323b1 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -8492,6 +8492,13 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int 
numTables)
                                if (tbinfo->attisdropped[adnum - 1])
                                        continue;
 
+                               /*
+                                * ignore generated columns on child tables 
unless they have a
+                                * local definition
+                                */
+                               if (tbinfo->attgenerated[adnum - 1] && 
!tbinfo->attislocal[adnum - 1])
+                                       continue;
+
                                attrdefs[j].dobj.objType = DO_ATTRDEF;
                                attrdefs[j].dobj.catId.tableoid = 
atooid(PQgetvalue(res, j, 0));
                                attrdefs[j].dobj.catId.oid = 
atooid(PQgetvalue(res, j, 1));
-- 
2.25.0

Reply via email to