Restore check_mut_excl_opts, usage in pg_restore and pg_dumpall - Mailing list pgsql-hackers

From Mahendra Singh Thalor
Subject Restore check_mut_excl_opts, usage in pg_restore and pg_dumpall
Date
Msg-id CAKYtNAo-xsBzDQm6bUO_RPPmRkBKFUgnkU0HPhGaeGJHMBx1dA@mail.gmail.com
Whole thread
Responses Re: Restore check_mut_excl_opts, usage in pg_restore and pg_dumpall
List pgsql-hackers
Hi,

Commit 7ca548f23a6 reverted pg_dumpall's non-text output format support
per Noah Misch's post-commit review. That revert was scoped carefully to
remove only the feature itself, but its commit message notes one piece of
unavoidable collateral damage:

  Because the feature restructured pg_dumpall.c and pg_restore.c (pg_restore's
  main() was split into restore_one_database() plus a dispatcher) and
  interleaved its option checks with the conflicting-option refactor in the
  same regions, the cosmetic check_mut_excl_opts() reflow of those two files'
  option blocks is inseparable from the feature and comes out with it; the
  behavior is unchanged.

In other words, pg_restore.c and pg_dumpall.c both went back to their old,
ad hoc pairwise "if (a && b) pg_fatal(...)" style option-conflict checks,
even though converting them to use the shared check_mut_excl_opts() helper
(added by b2898baaf7e, and already used by pg_dump.c) is a purely mechanical,
behavior-preserving cleanup with no dependency on the reverted feature's
design.

Attached are two small, independent patches that redo that conversion on
top of current master:

  0001 - pg_restore.c: converts its *-only / --no-* / --statistics /
         --clean / --single-transaction conflict checks to
         check_mut_excl_opts().

  0002 - pg_dumpall.c: same conversion for --exclude-database, the *-only
         options, their --no-* counterparts, --statistics, and --clean.
         Also tracks -s/--schema-only locally (schema_only), which
         pg_dumpall previously just passed through to pg_dump without
         recording, since check_mut_excl_opts() needs it. Updates the
         expected error text in the TAP tests to match
         check_mut_excl_opts()'s "options X and Y cannot be used together"
         wording, and adds coverage for a couple of option pairs that
         previously had no dedicated test.

Both patches preserve the exact pre-existing error-message wording and
option-reporting order for every combination that already had test
coverage; I verified this with the full src/bin/pg_dump TAP suite
(make check), which passes cleanly with both patches applied.

They're independent of each other and can be applied/reviewed in either
order or separately.

I think we can commit those into v19 and master. Please review and let
me know feedback.

-- 
Thanks and Regards
Mahendra Singh Thalor
EnterpriseDB: http://www.enterprisedb.com

Attachment

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: [Proposal] Adding callback support for custom statistics kinds
Next
From: Daniel Gustafsson
Date:
Subject: Re: Grab bag of smaller OpenSSL fixups