Re: Restore check_mut_excl_opts, usage in pg_restore and pg_dumpall

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Mahendra Singh Thalor <mahi6run(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>, nathan(at)postgresql(dot)org
Subject: Re: Restore check_mut_excl_opts, usage in pg_restore and pg_dumpall
Date: 2026-07-25 14:03:57
Message-ID: CAHGQGwE0k2AmbScwO8bymahiQtYvWrt6xS_tZNsUCJgC07x-YQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jul 20, 2026 at 7:12 PM Mahendra Singh Thalor
<mahi6run(at)gmail(dot)com> wrote:
> Here, I am attaching 3 patches for the review.

Thanks for updating the patches!

+ check_mut_excl_opts(opts->cparams.dbname, "-d/--dbname",
+ opts->filename, "-f/--file");
...
+ /* --dbname and --restrict-key are incompatible */
+ check_mut_excl_opts(opts->cparams.dbname, "-d/--dbname",
+ opts->restrict_key, "--restrict-key");

opts->cparams.dbname, opts->filename, and opts->restrict_key are pointers.
Passing them to check_mut_excl_opts() and reading them back as int is
undefined behavior. Shouldn't these calls instead be written as:

check_mut_excl_opts(opts->cparams.dbname != NULL, "-d/--dbname",
opts->filename != NULL, "-f/--file");

check_mut_excl_opts(opts->cparams.dbname != NULL, "-d/--dbname",
opts->restrict_key != NULL, "--restrict-key");

I'm wondering about backpatching. Patch 0003 fixes undefined behavior
introduced by check_mut_excl_opts(), so it seems appropriate to
backpatch it to v19. Patches 0001 and 0002 are mostly refactoring,
but they restore the v19-era cleanup that was lost when the pg_dumpall
non-text-format support was reverted, so backpatching those to v19 also
seems OK to me. Thoughts?

If we commit these, I think it would make sense to merge them into
a single commit.

Regards,

--
Fujii Masao

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-07-25 16:46:34 Re: remove_useless_joins vs. bug #19560
Previous Message Andreas Karlsson 2026-07-25 11:56:29 Re: Add cleanup parsing contexts for pg_hba and pg_ident files