refactor: extract shared utility sources into src/bin/common/ - #1136
Merged
Conversation
Move 16 .c/.h pairs out of src/bin/pg_autoctl/ into the new
src/bin/common/ directory and compile them into libpgaf_common.a,
a static archive linked by pg_autoctl (and, in a future PR, pgaftest).
New files
src/bin/common/Makefile — builds libpgaf_common.a standalone
src/bin/common/Makefile.common — shared build variables included by
both pg_autoctl/Makefile and the
upcoming pgaftest/Makefile; auto-
detects macOS gettext via brew
Moved files (pg_autoctl → common, superset variants kept)
debian, env_utils, file_utils, ini_file, ini_implementation,
ipaddr, lock_utils, parsing, pgctl, pgsetup, pgsql, pgtuning,
pidfile, signals, string_utils, system_utils
Notable content changes in the common/ copies:
pgsql.c/h — adds pgsql_alter_role_password() used by the upcoming
--autoctl-node-password feature
pgctl.c — adds --checkpoint=fast for pg_basebackup; fixes
intToString dangling-pointer use
pgsetup.c — minor style / brace fixes from citus_indent
signals.c — idem
ipaddr.c — idem
ini_file.c — idem
src/bin/Makefile updated to build common/ before pg_autoctl.
src/bin/pg_autoctl/Makefile updated to include Makefile.common and
link $(COMMON_LIB) instead of compiling the moved sources directly.
This was referenced Jul 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Move 16 .c/.h utility pairs out of
src/bin/pg_autoctl/into a newsrc/bin/common/directory, compiled into a static archivelibpgaf_common.alinked bypg_autoctl(and a futurepgaftestbinary).
Motivation
The upcoming
pgaftesttest runner needs the same pgsql, pgsetup,pgctl, parsing, ipaddr, and related utilities. Rather than copying
them, they live in one place and both binaries link the same archive.
Changes
New files
src/bin/common/Makefile— buildslibpgaf_common.astandalonesrc/bin/common/Makefile.common— shared build variables includedby both
pg_autoctl/Makefileand the upcomingpgaftest/Makefile;auto-detects macOS gettext path via
brew --prefix gettextMoved files (pg_autoctl/ → common/)
debian,env_utils,file_utils,ini_file,ini_implementation,ipaddr,lock_utils,parsing,pgctl,pgsetup,pgsql,pgtuning,pidfile,signals,string_utils,system_utilsNotable content improvements in the common/ copies
pgsql.c/hpgsql_alter_role_password()for the upcoming--autoctl-node-passwordfeaturepgctl.c--checkpoint=fastforpg_basebackup; fixesintToStringdangling-pointer usepgsetup.c,signals.c,ipaddr.c,ini_file.ccitus_indentUpdated Makefiles
src/bin/Makefile— addscommontarget as a prerequisite forpg_autoctlsrc/bin/pg_autoctl/Makefile— includesMakefile.commonand links$(COMMON_LIB)instead of compiling the moved sources directlyTesting
make -C src/bin/)docker run --rm -v $(pwd):/repo -w /repo citus/stylechecker:no-py citus_indent --check