pgsql: Don't include heapam.h from others headers. - Mailing list pgsql-committers

From Andres Freund
Subject pgsql: Don't include heapam.h from others headers.
Date
Msg-id E1gjCba-0001CD-5V@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Don't include heapam.h from others headers.

heapam.h previously was included in a number of widely used
headers (e.g. execnodes.h, indirectly in executor.h, ...). That's
problematic on its own, as heapam.h contains a lot of low-level
details that don't need to be exposed that widely, but becomes more
problematic with the upcoming introduction of pluggable table storage
- it seems inappropriate for heapam.h to be included that widely
afterwards.

heapam.h was largely only included in other headers to get the
HeapScanDesc typedef (which was defined in heapam.h, even though
HeapScanDescData is defined in relscan.h). The better solution here
seems to be to just use the underlying struct (forward declared where
necessary). Similar for BulkInsertState.

Another problem was that LockTupleMode was used in executor.h - parts
of the file tried to cope without heapam.h, but due to the fact that
it indirectly included it, several subsequent violations of that goal
were not not noticed. We could just reuse the approach of declaring
parameters as int, but it seems nicer to move LockTupleMode to
lockoptions.h - that's not a perfect location, but also doesn't seem
bad.

As a number of files relied on implicitly included heapam.h, a
significant number of files grew an explicit include. It's quite
probably that a few external projects will need to do the same.

Author: Andres Freund
Reviewed-By: Alvaro Herrera
Discussion: https://postgr.es/m/20190114000701.y4ttcb74jpskkcfb@alap3.anarazel.de

Branch
------
master

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

Modified Files
--------------
contrib/amcheck/verify_nbtree.c             |  1 +
contrib/dblink/dblink.c                     |  1 +
contrib/file_fdw/file_fdw.c                 |  1 +
contrib/pageinspect/btreefuncs.c            |  1 +
contrib/pageinspect/heapfuncs.c             |  1 +
contrib/pageinspect/rawpage.c               |  1 +
contrib/pg_freespacemap/pg_freespacemap.c   |  1 +
contrib/pg_visibility/pg_visibility.c       |  1 +
contrib/pgrowlocks/pgrowlocks.c             |  1 +
contrib/pgstattuple/pgstatapprox.c          |  1 +
contrib/pgstattuple/pgstattuple.c           |  1 +
contrib/postgres_fdw/postgres_fdw.c         |  1 +
contrib/tsm_system_rows/tsm_system_rows.c   |  1 +
contrib/tsm_system_time/tsm_system_time.c   |  1 +
src/backend/access/brin/brin.c              |  1 +
src/backend/access/common/indextuple.c      |  2 +-
src/backend/access/index/genam.c            |  1 +
src/backend/access/index/indexam.c          |  1 +
src/backend/access/nbtree/nbtsort.c         |  1 +
src/backend/access/tablesample/system.c     |  1 +
src/backend/bootstrap/bootstrap.c           |  1 +
src/backend/catalog/dependency.c            |  1 +
src/backend/catalog/heap.c                  |  1 +
src/backend/catalog/index.c                 |  1 +
src/backend/catalog/indexing.c              |  1 +
src/backend/catalog/objectaddress.c         |  1 +
src/backend/catalog/pg_proc.c               |  1 +
src/backend/catalog/toasting.c              |  1 +
src/backend/commands/alter.c                |  1 +
src/backend/commands/analyze.c              |  1 +
src/backend/commands/cluster.c              |  1 +
src/backend/commands/constraint.c           |  1 +
src/backend/commands/createas.c             |  1 +
src/backend/commands/event_trigger.c        |  1 +
src/backend/commands/extension.c            |  1 +
src/backend/commands/indexcmds.c            |  1 +
src/backend/commands/matview.c              |  1 +
src/backend/commands/sequence.c             |  1 +
src/backend/commands/statscmds.c            |  1 +
src/backend/commands/typecmds.c             |  1 +
src/backend/executor/execMain.c             | 11 +++--------
src/backend/executor/execPartition.c        |  1 +
src/backend/executor/execReplication.c      |  1 +
src/backend/executor/execUtils.c            |  1 +
src/backend/executor/nodeBitmapHeapscan.c   |  1 +
src/backend/executor/nodeLockRows.c         |  1 +
src/backend/executor/nodeModifyTable.c      |  1 +
src/backend/executor/nodeSamplescan.c       |  1 +
src/backend/executor/nodeSeqscan.c          |  1 +
src/backend/executor/nodeTidscan.c          |  1 +
src/backend/optimizer/plan/planner.c        |  1 +
src/backend/parser/parse_relation.c         |  1 +
src/backend/parser/parse_utilcmd.c          |  1 +
src/backend/partitioning/partbounds.c       |  1 +
src/backend/replication/logical/tablesync.c |  1 +
src/backend/replication/logical/worker.c    |  1 +
src/backend/rewrite/rewriteHandler.c        |  1 +
src/backend/utils/adt/misc.c                |  1 +
src/backend/utils/adt/ri_triggers.c         |  1 +
src/backend/utils/adt/ruleutils.c           |  1 +
src/backend/utils/adt/selfuncs.c            |  1 +
src/backend/utils/adt/xml.c                 |  1 +
src/backend/utils/cache/relcache.c          |  1 +
src/backend/utils/fmgr/funcapi.c            |  1 +
src/include/access/heapam.h                 | 15 ---------------
src/include/access/hio.h                    |  3 +--
src/include/access/relscan.h                |  5 ++---
src/include/catalog/index.h                 |  4 ++--
src/include/executor/executor.h             |  7 ++++---
src/include/nodes/execnodes.h               |  3 +--
src/include/nodes/lockoptions.h             | 15 +++++++++++++++
71 files changed, 91 insertions(+), 36 deletions(-)


pgsql-committers by date:

Previous
From: Michael Paquier
Date:
Subject: pgsql: Fix typo in documentation
Next
From: Andres Freund
Date:
Subject: pgsql: Don't include genam.h from execnodes.h and relscan.h anymore.