Move some code from src/bin/scripts to src/fe_utils to permit reuse.
authorRobert Haas <rhaas@postgresql.org>
Fri, 5 Feb 2021 18:33:38 +0000 (13:33 -0500)
committerRobert Haas <rhaas@postgresql.org>
Fri, 5 Feb 2021 18:33:38 +0000 (13:33 -0500)
commite955bd4b6c2bcdbd253837f6cf4c7520b98e69d4
treebc8e70ed9fbe9bee458299dc6f76b20311185cf7
parentc444472af5c202067a9ecb0ff8df7370fb1ea8f4
Move some code from src/bin/scripts to src/fe_utils to permit reuse.

The parallel slots infrastructure (which implements client-side
multiplexing of server connections doing similar things, not
threading or multiple processes or anything like that) are moved from
src/bin/scripts/scripts_parallel.c to src/fe_utils/parallel_slot.c.

The functions consumeQueryResult() and processQueryResult() which were
previously part of src/bin/scripts/common.c are now moved into that
file as well, becoming static helper functions. This might need to be
changed in the future, but currently they're not used for anything
else.

Some other functions from src/bin/scripts/common.c are moved to to
src/fe_utils and are split up among several files.  connectDatabase(),
connectMaintenanceDatabase(), and disconnectDatabase() are moved to
connect_utils.c.  executeQuery(), executeCommand(), and
executeMaintenanceCommand() are move to query_utils.c.
handle_help_version_opts() is moved to option_utils.c.

Mark Dilger, reviewed by me. The larger patch series of which this is
a part has also had review from Peter Geoghegan, Andres Freund, Álvaro
Herrera, Michael Paquier, and Amul Sul, but I don't know whether any
of them have reviewed this bit specifically.

Discussion: http://postgr.es/m/12ED3DA8-25F0-4B68-937D-D907CFBF08E7@enterprisedb.com
Discussion: http://postgr.es/m/5F743835-3399-419C-8324-2D424237E999@enterprisedb.com
Discussion: http://postgr.es/m/70655DF3-33CE-4527-9A4D-DDEB582B6BA0@enterprisedb.com
22 files changed:
src/bin/scripts/Makefile
src/bin/scripts/clusterdb.c
src/bin/scripts/common.c
src/bin/scripts/common.h
src/bin/scripts/createdb.c
src/bin/scripts/createuser.c
src/bin/scripts/dropdb.c
src/bin/scripts/dropuser.c
src/bin/scripts/nls.mk
src/bin/scripts/pg_isready.c
src/bin/scripts/reindexdb.c
src/bin/scripts/vacuumdb.c
src/fe_utils/Makefile
src/fe_utils/connect_utils.c [new file with mode: 0644]
src/fe_utils/option_utils.c [new file with mode: 0644]
src/fe_utils/parallel_slot.c [moved from src/bin/scripts/scripts_parallel.c with 80% similarity]
src/fe_utils/query_utils.c [new file with mode: 0644]
src/include/fe_utils/connect_utils.h [new file with mode: 0644]
src/include/fe_utils/option_utils.h [new file with mode: 0644]
src/include/fe_utils/parallel_slot.h [moved from src/bin/scripts/scripts_parallel.h with 82% similarity]
src/include/fe_utils/query_utils.h [new file with mode: 0644]
src/tools/msvc/Mkvcbuild.pm