Re: [PATCH] pg_dump: Restore extension config table data before user objects during pg_upgrade

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, Jimmy Angelakos <jimmy(dot)angelakos(at)pgedge(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCH] pg_dump: Restore extension config table data before user objects during pg_upgrade
Date: 2026-09-17 15:39:18
Message-ID: 7f982335-781c-46a5-ae1c-fd6978ecc4fd@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 14.09.26 17:45, Matthias van de Meent wrote:
>> + /*
>> + * For binary upgrade (DO_EXTENSION_DATA), don't apply
>> + * the filter condition - we need ALL data since the
>> + * extension won't populate built-in data in binary
>> + * upgrade mode.
>> + */
> What does this comment mean? In a binary upgrade mode, we don't
> filter table data because we're transfering the whole table-on-disk --
> we never look at the contents of tables, only the RelFileLocator.
> Adding more conditionals here is very confusing; I don't see any other
> place where we do this.
>
> Note that in a binary upgrade, CREATE EXTENSION doesn't actually run
> the extension's SQL install scripts -- it copies the objects from the
> old cluster's catalogs into the new cluster's catalogs, and re-links
> the dependent catalog objects to the extension object; see the comment
> in pg_dump.c's dumpExtension(), starting at line 11916 (current HEAD @
> 34fcd735f1).

I think this change, meaning

- if (strlen(extconditionarray[j]) > 0)
+ if (strlen(extconditionarray[j]) > 0 && !dopt->binary_upgrade)

might be an independent bug fix, but it's not a bug you'd normally hit.

You can reproduce this straightforwardly by making an extension with a
configuration table and some filter with some "built-in" configuration
rows, and then dumping it with pg_dump --binary-upgrade. Since in
binary upgrade mode, CREATE EXTENSION doesn't actually run the
extension's SQL install scripts, the "built-in" configuration rows won't
be created, and only the "user-created" rows. By skipping the filter in
binary upgrade mode, as proposed by the patch, you'll get both built-in
and user-created rows dumped correctly.

But pg_upgrade runs pg_dump with --binary-upgrade --no-data, so it
doesn't dump any configuration table rows either way. So this normal
course of action is not affected by this problem.

But I think this change could still be useful to make pg_dump's behavior
internally consistent. This might be helpful to make future changes or
alternative uses more robust.

Alternatively, we could prohibit combinations of --binary-upgrade with
options that result in dumping data (no option, --data-only, etc.).

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-09-17 15:41:07 Re: ERROR: too late to create a new PlaceHolderInfo
Previous Message Nikolay Samokhvalov 2026-09-17 15:34:55 Re: [PG19][PATCH] Make postgres_fdw statistics import atomic