pg_upgrade: Move live_check variable to user_opts.
Nathan Bossart <nathan@postgresql.org>
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
Files
| Path | Change | +/− |
|---|---|---|
| src/bin/pg_upgrade/check.c | modified | +15 −15 |
| src/bin/pg_upgrade/controldata.c | modified | +2 −1 |
| src/bin/pg_upgrade/info.c | modified | +5 −7 |
| src/bin/pg_upgrade/option.c | modified | +2 −2 |
| src/bin/pg_upgrade/pg_upgrade.c | modified | +10 −11 |
| src/bin/pg_upgrade/pg_upgrade.h | modified | +7 −6 |
Discussion
- optimizing pg_upgrade's once-in-each-database steps 37 messages · 2024-05-16 → 2024-09-16