Re: pg_dump crash on identity sequence with not loaded attributes
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Artur Zakirov <zaartur@gmail.com>
Cc: Peter Eisentraut <peter@eisentraut.org>,
PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Date: 2024-12-10T21:15:16Z
Lists: pgsql-bugs
Attachments
- fix-pg_dump-identity-sequence.patch (text/x-diff) patch
Artur Zakirov <zaartur@gmail.com> writes:
> I think it will still be necessary to negate DUMP_COMPONENT_DEFINITION
> from seqinfo->dobj.dump because we shouldn't dump statements like ...
> ALTER COLUMN ... ADD GENERATED ..., if the table's definition isn't
> dumped.
Yeah. After chewing on this for awhile, I think the cleanest solution
is say that b965f2617 was just wrong, and we should revert it in
favor of adopting this logic:
if (seqinfo->is_identity_sequence)
seqinfo->dobj.dump = owning_tab->dobj.dump;
else
seqinfo->dobj.dump |= owning_tab->dobj.dump;
That is, for an identity sequence we should dump the exact same
properties as for its owning table. This basically rejects the
notion that a table can be inside an extension while its identity
sequence is not (or vice versa), which is the same position we
take for indexes, rules, etc. However, for non-identity owned
sequences (i.e. serials) keep the same behavior as before.
The large comment block just below here (added by f9e439b1c)
carefully describes the behavior that was wanted for non-identity
sequences, and I don't think we need to break that.
The attached patch also gets rid of the dubious coding in
getPublicationNamespaces. We might get push-back on that ignoring
schemas belonging to extensions, but if so I'd prefer to see the
behavior coded in a more transparent fashion.
regards, tom lane
Commits
-
Fix possible crash in pg_dump with identity sequences.
- c7f3c414fded 14.16 landed
- b6df2d6e5d83 13.19 landed
- ad950ea98e54 17.3 landed
- 7b8cb9cd6a76 18.0 landed
- 782cc1aa3d15 16.7 landed
- 6978129b4e95 15.11 landed
-
Do not dump identity sequences with excluded parent table
- b965f2617184 12.0 cited