[PATCH v1] Fix for bug #19773 : pg_dump differing generation expressions of inherited columns

From: Nitin Motiani <nitinmotiani(at)google(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: [PATCH v1] Fix for bug #19773 : pg_dump differing generation expressions of inherited columns
Date: 2026-10-21 18:36:44
Message-ID: CAH5HC97y7PFE6rJh8kVDUszPxGQE030nZvyHu=wZT7FBkOV3qA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

It was reported in [1] that pg_dump omits a generated column in an
inherited table when the child's expression is different from the
parent.

This seems to happen because pg_dump had special handling for
generation expressions and it only dumped them as part of create
tables. Therefore child expressions which were altered later (or in
cases where only the parent was altered) did not receive the correct
generation expressions.

I'm attaching a patch with a proposed fix. It changes getTableAttrs()
which previously used to always mark 'separate = false' for generation
expressions. That branch has been removed and now those expressions
are handled like any other column. It also changes dumpAttrDef() to
correctly dump the ALTER command with the generation expression.

It also adds an ordering constraint in dumpAttrDef() to handle
multi-level hierarchy and ALTERs in generation expressions at multiple
levels. LLM flagged this as another potential case not reported in the
original report. So the patch explicitly adds ordering to ALTER
statements by adding dependencies.

Please take a look and let me know your thoughts.

Thanks & Regards,
Nitin Motiani
Google

[1] https://www.postgresql.org/message-id/flat/19773-887c01a9fda0ec8a%40postgresql.org

Attachment Content-Type Size
v1-0001-pg_dump-Dump-differing-generation-expressions-of-.patch application/x-patch 10.0 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joel Jacobson 2026-10-21 18:56:31 Re: [PATCH] Fix leaked hash scans in pg_listening_channels()
Previous Message Manu 2026-10-21 18:30:24 Re: [PG19] Promotion hangs behind a backend blocked on a stuck client