Skip to content

Commit

Permalink
Refactor planner's header files.
Browse files Browse the repository at this point in the history
Create a new header optimizer/optimizer.h, which exposes just the
planner functions that can be used "at arm's length", without need
to access Paths or the other planner-internal data structures defined
in nodes/relation.h.  This is intended to provide the whole planner
API seen by most of the rest of the system; although FDWs still need
to use additional stuff, and more thought is also needed about just
what selfuncs.c should rely on.

The main point of doing this now is to limit the amount of new
#include baggage that will be needed by "planner support functions",
which I expect to introduce later, and which will be in relevant
datatype modules rather than anywhere near the planner.

This commit just moves relevant declarations into optimizer.h from
other header files (a couple of which go away because everything
got moved), and adjusts #include lists to match.  There's further
cleanup that could be done if we want to decide that some stuff
being exposed by optimizer.h doesn't belong in the planner at all,
but I'll leave that for another day.

Discussion: https://postgr.es/m/[email protected]
  • Loading branch information
tglsfdc committed Jan 29, 2019
1 parent a1b8c41 commit f09346a
Show file tree
Hide file tree
Showing 91 changed files with 278 additions and 303 deletions.
1 change: 0 additions & 1 deletion contrib/bloom/blcost.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "postgres.h"

#include "fmgr.h"
#include "optimizer/cost.h"
#include "utils/selfuncs.h"

#include "bloom.h"
Expand Down
3 changes: 1 addition & 2 deletions contrib/file_fdw/file_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@
#include "foreign/foreign.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "optimizer/cost.h"
#include "optimizer/optimizer.h"
#include "optimizer/pathnode.h"
#include "optimizer/planmain.h"
#include "optimizer/restrictinfo.h"
#include "optimizer/var.h"
#include "utils/memutils.h"
#include "utils/rel.h"
#include "utils/sampling.h"
Expand Down
3 changes: 1 addition & 2 deletions contrib/postgres_fdw/deparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "nodes/plannodes.h"
#include "optimizer/clauses.h"
#include "optimizer/optimizer.h"
#include "optimizer/prep.h"
#include "optimizer/tlist.h"
#include "optimizer/var.h"
#include "parser/parsetree.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
Expand Down
2 changes: 1 addition & 1 deletion contrib/postgres_fdw/postgres_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
#include "nodes/nodeFuncs.h"
#include "optimizer/cost.h"
#include "optimizer/clauses.h"
#include "optimizer/optimizer.h"
#include "optimizer/pathnode.h"
#include "optimizer/paths.h"
#include "optimizer/planmain.h"
#include "optimizer/restrictinfo.h"
#include "optimizer/var.h"
#include "optimizer/tlist.h"
#include "parser/parsetree.h"
#include "utils/builtins.h"
Expand Down
3 changes: 1 addition & 2 deletions contrib/tsm_system_rows/tsm_system_rows.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
#include "access/tsmapi.h"
#include "catalog/pg_type.h"
#include "miscadmin.h"
#include "optimizer/clauses.h"
#include "optimizer/cost.h"
#include "optimizer/optimizer.h"
#include "utils/sampling.h"

PG_MODULE_MAGIC;
Expand Down
3 changes: 1 addition & 2 deletions contrib/tsm_system_time/tsm_system_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
#include "access/tsmapi.h"
#include "catalog/pg_type.h"
#include "miscadmin.h"
#include "optimizer/clauses.h"
#include "optimizer/cost.h"
#include "optimizer/optimizer.h"
#include "utils/sampling.h"
#include "utils/spccache.h"

Expand Down
2 changes: 1 addition & 1 deletion src/backend/access/gist/gistbuild.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "access/xloginsert.h"
#include "catalog/index.h"
#include "miscadmin.h"
#include "optimizer/cost.h"
#include "optimizer/optimizer.h"
#include "storage/bufmgr.h"
#include "storage/smgr.h"
#include "utils/memutils.h"
Expand Down
4 changes: 0 additions & 4 deletions src/backend/access/spgist/spgutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "access/transam.h"
#include "access/xact.h"
#include "catalog/pg_amop.h"
#include "optimizer/paths.h"
#include "storage/bufmgr.h"
#include "storage/indexfsm.h"
#include "storage/lmgr.h"
Expand All @@ -32,9 +31,6 @@
#include "utils/lsyscache.h"
#include "utils/syscache.h"

extern Expr *spgcanorderbyop(IndexOptInfo *index,
PathKey *pathkey, int pathkeyno,
Expr *orderby_clause, int *indexcol_p);

/*
* SP-GiST handler function: return IndexAmRoutine with access method parameters
Expand Down
3 changes: 1 addition & 2 deletions src/backend/access/tablesample/bernoulli.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
#include "access/hash.h"
#include "access/tsmapi.h"
#include "catalog/pg_type.h"
#include "optimizer/clauses.h"
#include "optimizer/cost.h"
#include "optimizer/optimizer.h"
#include "utils/builtins.h"


Expand Down
3 changes: 1 addition & 2 deletions src/backend/access/tablesample/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
#include "access/relscan.h"
#include "access/tsmapi.h"
#include "catalog/pg_type.h"
#include "optimizer/clauses.h"
#include "optimizer/cost.h"
#include "optimizer/optimizer.h"
#include "utils/builtins.h"


Expand Down
2 changes: 1 addition & 1 deletion src/backend/access/transam/parallel.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "libpq/pqformat.h"
#include "libpq/pqmq.h"
#include "miscadmin.h"
#include "optimizer/planmain.h"
#include "optimizer/optimizer.h"
#include "pgstat.h"
#include "storage/ipc.h"
#include "storage/sinval.h"
Expand Down
4 changes: 1 addition & 3 deletions src/backend/catalog/heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@
#include "executor/executor.h"
#include "miscadmin.h"
#include "nodes/nodeFuncs.h"
#include "optimizer/clauses.h"
#include "optimizer/var.h"
#include "optimizer/planner.h"
#include "optimizer/optimizer.h"
#include "parser/parse_coerce.h"
#include "parser/parse_collate.h"
#include "parser/parse_expr.h"
Expand Down
3 changes: 1 addition & 2 deletions src/backend/catalog/index.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "optimizer/clauses.h"
#include "optimizer/planner.h"
#include "optimizer/optimizer.h"
#include "parser/parser.h"
#include "rewrite/rewriteManip.h"
#include "storage/bufmgr.h"
Expand Down
4 changes: 1 addition & 3 deletions src/backend/catalog/partition.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
#include "catalog/pg_inherits.h"
#include "catalog/pg_partitioned_table.h"
#include "nodes/makefuncs.h"
#include "optimizer/clauses.h"
#include "optimizer/prep.h"
#include "optimizer/var.h"
#include "optimizer/optimizer.h"
#include "partitioning/partbounds.h"
#include "rewrite/rewriteManip.h"
#include "utils/fmgroids.h"
Expand Down
2 changes: 1 addition & 1 deletion src/backend/commands/cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "commands/tablecmds.h"
#include "commands/vacuum.h"
#include "miscadmin.h"
#include "optimizer/planner.h"
#include "optimizer/optimizer.h"
#include "storage/bufmgr.h"
#include "storage/lmgr.h"
#include "storage/predicate.h"
Expand Down
4 changes: 1 addition & 3 deletions src/backend/commands/copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@
#include "libpq/pqformat.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "optimizer/clauses.h"
#include "optimizer/planner.h"
#include "optimizer/prep.h"
#include "optimizer/optimizer.h"
#include "nodes/makefuncs.h"
#include "parser/parse_coerce.h"
#include "parser/parse_collate.h"
Expand Down
2 changes: 0 additions & 2 deletions src/backend/commands/explain.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#include "nodes/extensible.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "optimizer/clauses.h"
#include "optimizer/planmain.h"
#include "parser/parsetree.h"
#include "rewrite/rewriteHandler.h"
#include "storage/bufmgr.h"
Expand Down
3 changes: 1 addition & 2 deletions src/backend/commands/functioncmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@
#include "executor/executor.h"
#include "funcapi.h"
#include "miscadmin.h"
#include "optimizer/clauses.h"
#include "optimizer/var.h"
#include "optimizer/optimizer.h"
#include "parser/parse_coerce.h"
#include "parser/parse_collate.h"
#include "parser/parse_expr.h"
Expand Down
4 changes: 1 addition & 3 deletions src/backend/commands/indexcmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "optimizer/clauses.h"
#include "optimizer/planner.h"
#include "optimizer/var.h"
#include "optimizer/optimizer.h"
#include "parser/parse_coerce.h"
#include "parser/parse_func.h"
#include "parser/parse_oper.h"
Expand Down
6 changes: 1 addition & 5 deletions src/backend/commands/tablecmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "nodes/parsenodes.h"
#include "optimizer/clauses.h"
#include "optimizer/planner.h"
#include "optimizer/predtest.h"
#include "optimizer/prep.h"
#include "optimizer/var.h"
#include "optimizer/optimizer.h"
#include "parser/parse_clause.h"
#include "parser/parse_coerce.h"
#include "parser/parse_collate.h"
Expand Down
3 changes: 1 addition & 2 deletions src/backend/commands/trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
#include "miscadmin.h"
#include "nodes/bitmapset.h"
#include "nodes/makefuncs.h"
#include "optimizer/clauses.h"
#include "optimizer/var.h"
#include "optimizer/optimizer.h"
#include "parser/parse_clause.h"
#include "parser/parse_collate.h"
#include "parser/parse_func.h"
Expand Down
2 changes: 1 addition & 1 deletion src/backend/commands/typecmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
#include "executor/executor.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "optimizer/var.h"
#include "optimizer/optimizer.h"
#include "parser/parse_coerce.h"
#include "parser/parse_collate.h"
#include "parser/parse_expr.h"
Expand Down
3 changes: 1 addition & 2 deletions src/backend/executor/execExpr.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "optimizer/clauses.h"
#include "optimizer/planner.h"
#include "optimizer/optimizer.h"
#include "pgstat.h"
#include "utils/builtins.h"
#include "utils/datum.h"
Expand Down
1 change: 0 additions & 1 deletion src/backend/executor/execMain.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
#include "jit/jit.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "optimizer/clauses.h"
#include "parser/parsetree.h"
#include "rewrite/rewriteManip.h"
#include "storage/bufmgr.h"
Expand Down
2 changes: 0 additions & 2 deletions src/backend/executor/execParallel.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
#include "executor/tqueue.h"
#include "jit/jit.h"
#include "nodes/nodeFuncs.h"
#include "optimizer/planmain.h"
#include "optimizer/planner.h"
#include "storage/spin.h"
#include "tcop/tcopprot.h"
#include "utils/datum.h"
Expand Down
3 changes: 1 addition & 2 deletions src/backend/executor/nodeAgg.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,7 @@
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "optimizer/clauses.h"
#include "optimizer/tlist.h"
#include "optimizer/optimizer.h"
#include "parser/parse_agg.h"
#include "parser/parse_coerce.h"
#include "utils/acl.h"
Expand Down
2 changes: 1 addition & 1 deletion src/backend/executor/nodeGather.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "executor/nodeSubplan.h"
#include "executor/tqueue.h"
#include "miscadmin.h"
#include "optimizer/planmain.h"
#include "optimizer/optimizer.h"
#include "pgstat.h"
#include "utils/memutils.h"
#include "utils/rel.h"
Expand Down
2 changes: 1 addition & 1 deletion src/backend/executor/nodeGatherMerge.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "executor/tqueue.h"
#include "lib/binaryheap.h"
#include "miscadmin.h"
#include "optimizer/planmain.h"
#include "optimizer/optimizer.h"
#include "utils/memutils.h"
#include "utils/rel.h"

Expand Down
1 change: 0 additions & 1 deletion src/backend/executor/nodeIndexscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include "lib/pairingheap.h"
#include "miscadmin.h"
#include "nodes/nodeFuncs.h"
#include "optimizer/clauses.h"
#include "utils/array.h"
#include "utils/datum.h"
#include "utils/lsyscache.h"
Expand Down
2 changes: 1 addition & 1 deletion src/backend/executor/nodeWindowAgg.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include "executor/nodeWindowAgg.h"
#include "miscadmin.h"
#include "nodes/nodeFuncs.h"
#include "optimizer/clauses.h"
#include "optimizer/optimizer.h"
#include "parser/parse_agg.h"
#include "parser/parse_coerce.h"
#include "utils/acl.h"
Expand Down
1 change: 0 additions & 1 deletion src/backend/jit/llvm/llvmjit_expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "optimizer/planner.h"
#include "parser/parse_coerce.h"
#include "parser/parsetree.h"
#include "pgstat.h"
Expand Down
2 changes: 1 addition & 1 deletion src/backend/optimizer/path/allpaths.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
#include "optimizer/cost.h"
#include "optimizer/geqo.h"
#include "optimizer/inherit.h"
#include "optimizer/optimizer.h"
#include "optimizer/pathnode.h"
#include "optimizer/paths.h"
#include "optimizer/plancat.h"
#include "optimizer/planner.h"
#include "optimizer/restrictinfo.h"
#include "optimizer/tlist.h"
#include "optimizer/var.h"
#include "parser/parse_clause.h"
#include "parser/parsetree.h"
#include "partitioning/partprune.h"
Expand Down
1 change: 1 addition & 0 deletions src/backend/optimizer/path/clausesel.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "nodes/nodeFuncs.h"
#include "optimizer/clauses.h"
#include "optimizer/cost.h"
#include "optimizer/optimizer.h"
#include "optimizer/pathnode.h"
#include "optimizer/plancat.h"
#include "utils/fmgroids.h"
Expand Down
1 change: 1 addition & 0 deletions src/backend/optimizer/path/costsize.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
#include "nodes/nodeFuncs.h"
#include "optimizer/clauses.h"
#include "optimizer/cost.h"
#include "optimizer/optimizer.h"
#include "optimizer/pathnode.h"
#include "optimizer/paths.h"
#include "optimizer/placeholder.h"
Expand Down
2 changes: 1 addition & 1 deletion src/backend/optimizer/path/equivclass.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
#include "nodes/nodeFuncs.h"
#include "optimizer/appendinfo.h"
#include "optimizer/clauses.h"
#include "optimizer/optimizer.h"
#include "optimizer/pathnode.h"
#include "optimizer/paths.h"
#include "optimizer/planmain.h"
#include "optimizer/restrictinfo.h"
#include "optimizer/var.h"
#include "utils/lsyscache.h"


Expand Down
3 changes: 1 addition & 2 deletions src/backend/optimizer/path/indxpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@
#include "nodes/nodeFuncs.h"
#include "optimizer/clauses.h"
#include "optimizer/cost.h"
#include "optimizer/optimizer.h"
#include "optimizer/pathnode.h"
#include "optimizer/paths.h"
#include "optimizer/predtest.h"
#include "optimizer/prep.h"
#include "optimizer/restrictinfo.h"
#include "optimizer/var.h"
#include "utils/builtins.h"
#include "utils/bytea.h"
#include "utils/lsyscache.h"
Expand Down
3 changes: 1 addition & 2 deletions src/backend/optimizer/path/pathkeys.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "nodes/plannodes.h"
#include "optimizer/clauses.h"
#include "optimizer/optimizer.h"
#include "optimizer/pathnode.h"
#include "optimizer/paths.h"
#include "optimizer/tlist.h"
#include "utils/lsyscache.h"


Expand Down
2 changes: 1 addition & 1 deletion src/backend/optimizer/path/tidpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
#include "catalog/pg_type.h"
#include "nodes/nodeFuncs.h"
#include "optimizer/clauses.h"
#include "optimizer/optimizer.h"
#include "optimizer/pathnode.h"
#include "optimizer/paths.h"
#include "optimizer/restrictinfo.h"
#include "optimizer/var.h"


/*
Expand Down
Loading

0 comments on commit f09346a

Please sign in to comment.