pgsql: pg_upgrade: Move live_check variable to user_opts.

From: Nathan Bossart <nathan(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: pg_upgrade: Move live_check variable to user_opts.
Date: 2024-07-26 18:38:24
Message-ID: E1sXPpg-001LLE-Qt@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

pg_upgrade: Move live_check variable to user_opts.

At the moment, pg_upgrade stores whether it is doing a "live check"
(i.e., the user specified --check and the old server is still
running) in a local variable scoped to main(). This live_check
variable is passed to several functions. To further complicate
matters, a few call sites provide a hard-coded "false" as the
live_check argument. Specifically, this is done when calling these
functions for the new cluster, for which any live-check-only paths
won't apply.

This commit moves the live_check variable to the global user_opts
variable, which stores information about the options the user
specified on the command line. This allows us to remove the
live_check parameter from several functions. For the functions
with callers that provide a hard-coded "false" as the live_check
argument (e.g., get_control_data()), we verify the given cluster is
the old cluster before taking any live-check-only paths.

This small refactoring effort helps simplify some proposed changes
that would parallelize many of pg_upgrade's once-in-each-database
tasks using libpq's asynchronous APIs. By removing the live_check
parameter, we can more easily convert the functions to callbacks
for the new parallel system.

Reviewed-by: Daniel Gustafsson
Discussion: https://postgr.es/m/20240516211638.GA1688936%40nathanxps13

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4b56bb4ab4856070d5ea4aeafdd663d8bf96b874

Modified Files
--------------
src/bin/pg_upgrade/check.c | 30 +++++++++++++++---------------
src/bin/pg_upgrade/controldata.c | 3 ++-
src/bin/pg_upgrade/info.c | 12 +++++-------
src/bin/pg_upgrade/option.c | 4 ++--
src/bin/pg_upgrade/pg_upgrade.c | 21 ++++++++++-----------
src/bin/pg_upgrade/pg_upgrade.h | 13 +++++++------
6 files changed, 41 insertions(+), 42 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2024-07-26 18:59:53 pgsql: postgres_fdw: Fix bug in connection status check.
Previous Message Daniel Gustafsson 2024-07-26 17:17:35 pgsql: Fix building with MSVC for TLS session disabling