pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix logic buglets in pg_dump's flagInhAttrs().
Date: Tue, 28 Feb 2023 23:06:49 +0000
Message-ID: <E1pX93Z-001En8-2e@gemulon.postgresql.org> (raw)

Fix logic buglets in pg_dump's flagInhAttrs().

As it stands, flagInhAttrs() can make changes in table properties that
change decisions made at other tables during other iterations of its
loop.  This is a pretty bad idea, since we visit the tables in OID
order which is not necessarily related to inheritance relationships.
So far as I can tell, the consequences are just cosmetic: we might
dump DEFAULT or GENERATED expressions that we don't really need to
because they match properties of the parent.  Nonetheless, it's buggy,
and somebody might someday add functionality here that fails less
benignly when the traversal order varies.

One issue is that when we decide we needn't dump a particular
GENERATED expression, we physically unlink the struct for it,
so that it will now look like the table has no such expression,
causing the wrong choice to be made at any child visited later.
We can improve that by instead clearing the dobj.dump flag,
and taking care to check that flag when it comes time to dump
the expression or not.

The other problem is that if we decide we need to fake up a DEFAULT
NULL clause to override a default that would otherwise get inherited,
we modify the data structure in the reverse fashion, creating an
attrdefs entry where there hadn't been one.  It's harder to avoid
doing that, but since the backend won't report a plain "DEFAULT NULL"
property we can modify the code to recognize ones we just added.

Add some commentary to perhaps forestall future mistakes of the
same ilk.

Since the effects of this seem only cosmetic, no back-patch.

Discussion: https://postgr.es/m/1506298.1676323579@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/128dd9f9eca0b633b51ffcd5b0f798fbc48ec4c0

Modified Files
--------------
src/bin/pg_dump/common.c  | 29 +++++++++++++++++++++++------
src/bin/pg_dump/pg_dump.c | 10 ++++++----
2 files changed, 29 insertions(+), 10 deletions(-)



Message-ID: <E1pX93Z-001En8-2e@gemulon.postgresql.org>
Permalink:  ../E1pX93Z-001En8-2e@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1pX93Z-001En8-2e@gemulon.postgresql.org

 · 

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-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Fix logic buglets in pg_dump's flagInhAttrs().
  In-Reply-To: <E1pX93Z-001En8-2e@gemulon.postgresql.org>
  References: <E1pX93Z-001En8-2e@gemulon.postgresql.org>

* 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