Split up guc.c for better build speed and ease of maintenance.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 13 Sep 2022 15:05:07 +0000 (11:05 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 13 Sep 2022 15:11:45 +0000 (11:11 -0400)
commit0a20ff54f5e66158930d5328f89f087d4e9ab400
tree061094ad7638e0d0be3fe007f29ed31710a75cec
parent257eb57b50f7c65467bfc2f4d579622fa13f3370
Split up guc.c for better build speed and ease of maintenance.

guc.c has grown to be one of our largest .c files, making it
a bottleneck for compilation.  It's also acquired a bunch of
knowledge that'd be better kept elsewhere, because of our not
very good habit of putting variable-specific check hooks here.
Hence, split it up along these lines:

* guc.c itself retains just the core GUC housekeeping mechanisms.
* New file guc_funcs.c contains the SET/SHOW interfaces and some
  SQL-accessible functions for GUC manipulation.
* New file guc_tables.c contains the data arrays that define the
  built-in GUC variables, along with some already-exported constant
  tables.
* GUC check/assign/show hook functions are moved to the variable's
  home module, whenever that's clearly identifiable.  A few hard-
  to-classify hooks ended up in commands/variable.c, which was
  already a home for miscellaneous GUC hook functions.

To avoid cluttering a lot more header files with #include "guc.h",
I also invented a new header file utils/guc_hooks.h and put all
the GUC hook functions' declarations there, regardless of their
originating module.  That allowed removal of #include "guc.h"
from some existing headers.  The fallout from that (hopefully
all caught here) demonstrates clearly why such inclusions are
best minimized: there are a lot of files that, for example,
were getting array.h at two or more levels of remove, despite
not having any connection at all to GUCs in themselves.

There is some very minor code beautification here, such as
renaming a couple of inconsistently-named hook functions
and improving some comments.  But mostly this just moves
code from point A to point B and deals with the ensuing
needs for #include adjustments and exporting a few functions
that previously weren't exported.

Patch by me, per a suggestion from Andres Freund; thanks also
to Michael Paquier for the idea to invent guc_funcs.c.

Discussion: https://postgr.es/m/587607.1662836699@sss.pgh.pa.us
59 files changed:
contrib/amcheck/verify_nbtree.c
contrib/ltree/_ltree_gist.c
contrib/ltree/_ltree_op.c
contrib/ltree/lquery_op.c
contrib/ltree/ltree_gist.c
contrib/pg_surgery/heap_surgery.c
contrib/pg_trgm/trgm_op.c
src/backend/access/brin/brin.c
src/backend/access/table/tableamapi.c
src/backend/access/transam/xlog.c
src/backend/access/transam/xlogprefetcher.c
src/backend/access/transam/xlogrecovery.c
src/backend/backup/basebackup.c
src/backend/catalog/aclchk.c
src/backend/catalog/namespace.c
src/backend/catalog/pg_parameter_acl.c
src/backend/commands/cluster.c
src/backend/commands/indexcmds.c
src/backend/commands/tablespace.c
src/backend/commands/trigger.c
src/backend/commands/variable.c
src/backend/libpq/pqcomm.c
src/backend/partitioning/partbounds.c
src/backend/port/sysv_shmem.c
src/backend/port/win32_shmem.c
src/backend/postmaster/autovacuum.c
src/backend/replication/repl_gram.y
src/backend/replication/repl_scanner.l
src/backend/replication/syncrep.c
src/backend/replication/syncrep_gram.y
src/backend/replication/syncrep_scanner.l
src/backend/storage/buffer/localbuf.c
src/backend/storage/ipc/ipci.c
src/backend/storage/lmgr/predicate.c
src/backend/tcop/postgres.c
src/backend/tsearch/dict.c
src/backend/utils/adt/pg_locale.c
src/backend/utils/adt/selfuncs.c
src/backend/utils/adt/varchar.c
src/backend/utils/adt/varlena.c
src/backend/utils/cache/ts_cache.c
src/backend/utils/error/elog.c
src/backend/utils/init/postinit.c
src/backend/utils/misc/Makefile
src/backend/utils/misc/guc.c
src/backend/utils/misc/guc_funcs.c [new file with mode: 0644]
src/backend/utils/misc/guc_tables.c [new file with mode: 0644]
src/include/access/tableam.h
src/include/access/xlog.h
src/include/commands/variable.h [deleted file]
src/include/replication/syncrep.h
src/include/tcop/tcopprot.h
src/include/tsearch/ts_cache.h
src/include/utils/elog.h
src/include/utils/guc.h
src/include/utils/guc_hooks.h [new file with mode: 0644]
src/include/utils/guc_tables.h
src/include/utils/pg_locale.h
src/test/regress/regress.c