| From: | Peter Smith <smithpb2250(at)gmail(dot)com> |
|---|---|
| To: | Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> |
| Cc: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, shveta malik <shveta(dot)malik(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, shveta malik <shvetamalik(at)gmail(dot)com> |
| Subject: | Re: pg_dump --exclude-table loses FOR ALL TABLES EXCEPT publications |
| Date: | 2026-11-25 01:59:46 |
| Message-ID: | CAHut+PurF9qikGDdRdKasX7zc8ppZ9s+x7cQxNShBKO326YN2Q@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Fri, Nov 6, 2026 at 7:09 PM Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> wrote:
>
> > "When -t is specified, pg_dump makes no attempt to dump any other
> > database objects that the selected table(s) might depend upon.
>
> That note is actually my problem: because it documents the opposite
> case: it says that when we exclude some tables, we do not dump any
> other database object depending on it. That the quoted limitation is
> for -e, -n, -t, while the issue I reported is about -N, -T and
> --exclude-table-and-children.
>
> And also note the inconsistency: with -e, -n and -t, we do what is
> documented, resulting in a consistent restore that produces no errors
> and no publications.
> With the other options, it is the opposite: we dump publications that
> depend on excluded database objects. Consequently, the restore ends
> without the publication and prints errors.
>
> So while I am also leaning towards simply documenting this, as I think
> the current behavior is better than the alternative, we are
> documenting an inconsistency. (And that's also the reason why I think
> it is important to document this)
>
> The comment for selectDumpablePublicationObject is also similarly incorrect:
>
> A publication can have schemas and tables which have schemas, but those are
> ignored in decision making, because publications are only dumped when we are
> dumping everything.
>
> When we exclude some tables, we clearly do not dump everything, but we
> still dump publications.
>
> As I wrote earlier, I think that keeping the current behavior is
> correct: there's a reasonable chance that the user restores the
> missing excluded table before the main dump, in which case we want to
> have these publications there for completeness, excluding them would
> be the wrong choice.
>
> > OTOH, if others think that will be
> > helpful, I won't mind adding it.
>
> So I think expanding the note about this, and adjusting the code
> comment would be an improvement, see attached patch. But if everyone
> else disagrees, I am also fine with leaving it as-is.
Oh, I found that the "Note" I quoted in my last post [1] was from the
old PG18 docs, but it was later removed/consolidated [1] in the PG19
docs.
~~~
About your patch:
+ <para>
+ When tables are excluded with <option>-N</option>, <option>-T</option>
+ or <option>--exclude-table-and-children</option>, publications that
+ depend on them are still dumped in full, and restoring those
+ publications fails if the excluded tables do not exist.
+ </para>
I agree it's better to say something like this up front rather than
let `pg_restore` fail without warning. It doesn't change anything, but
at least it's more like an "I told you so".
Perhaps the wording also needs to mention schemas
- "When schemas or tables are excluded..."
- "... fails when the expected schemas or tables do not exist."
For example, you can set this up to fail even when there are no tables at all:
test_pub=# create schema sc1;
CREATE SCHEMA
test_pub=# create publication pub4 for tables in schema sc1;
CREATE PUBLICATION
then:
pg_dump -N 'sc1' test_pub
or, even simpler:
pg_dump -N 'public' test_pub
======
[1] https://www.postgresql.org/message-id/CAHut%2BPvJECaGVE_Vt%2BOq4XR286NSLO3TWaRe6X3OJ2Ac4jm%3D0Q%40mail.gmail.com
[2] https://www.postgresql.org/message-id/E1vnLEB-000xHY-06%40gemulon.postgresql.org
Kind Regards,
Peter Smith.
Fujitsu Australia
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Chao Li | 2026-11-25 02:02:22 | Fix leftover data handling and simplify read conditions in copy_read_data() |
| Previous Message | Manu | 2026-11-25 01:42:32 | Re: pgsql: Don't trust NOT NULL on virtual generated columns of partitioned |