Re: pg_dump crash on identity sequence with not loaded attributes

Artur Zakirov <zaartur@gmail.com>

From: Artur Zakirov <zaartur@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Date: 2024-12-10T15:21:33Z
Lists: pgsql-bugs

Attachments

On Mon, 9 Dec 2024 at 22:51, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Artur Zakirov <zaartur@gmail.com> writes:
> > pg_dump crashes when a table is added into an extension and its
> > identity sequence isn't.
>
> Yup, reproduced here.

Thank you for looking into this. It seems that the original code was
introduced by the commit which fixed a similar crash:
https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=b965f2617184032687037547204e1db1c1e1a56c

>         /*
>          * Only dump identity sequences if we're going to dump the table that
>          * it belongs to.
>          */
> -       if (owning_tab->dobj.dump == DUMP_COMPONENT_NONE &&
> +       if ((owning_tab->dobj.dump & DUMP_COMPONENT_DEFINITION) &&
>             seqinfo->is_identity_sequence)
>         {
>             seqinfo->dobj.dump = DUMP_COMPONENT_NONE;

I think it is necessary to use negation in this condition. The patch
is attached. I checked the new patch and it works as expected.

--
Kind regards,
Artur

Commits

  1. Fix possible crash in pg_dump with identity sequences.

  2. Do not dump identity sequences with excluded parent table