On 1/17/17 3:07 PM, Tom Lane wrote:
> Alternatively ... is there a specific reason why you chose to make
> builtins.h the key inclusion file for this change, rather than having
> callers include fmgrprotos.h directly?  It seems like the stuff remaining
> in builtins.h is just a laundry list of random utility functions.
> Maybe dispersing those to other headers is the thing to do.

Here is a patch that moves two blocks from builtins.h into separate
header files.  That avoids having to include nodes/pg_list.h and
utils/sortsupport.h.

The remaining inclusion of nodes/nodes.h is for the oidparse() function.
 I think that could be moved out of oid.c and put somewhere near parser/
or objectaddress.c.  But the practical savings from avoiding nodes.h is
probably near zero, so I haven't done anything about that here.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>From a4f700198f19ce5a09cde8d58870187ea0e05012 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pete...@gmx.net>
Date: Wed, 18 Jan 2017 12:00:00 -0500
Subject: [PATCH] Move some things from builtins.h to new header files

This avoids that builtins.h has to include additional header files.
---
 contrib/bloom/blvalidate.c                     |  1 +
 contrib/citext/citext.c                        |  1 +
 contrib/dblink/dblink.c                        |  1 +
 contrib/fuzzystrmatch/fuzzystrmatch.c          |  1 +
 contrib/pageinspect/btreefuncs.c               |  1 +
 contrib/pageinspect/rawpage.c                  |  1 +
 contrib/pgrowlocks/pgrowlocks.c                |  1 +
 contrib/pgstattuple/pgstatindex.c              |  1 +
 contrib/pgstattuple/pgstattuple.c              |  1 +
 contrib/postgres_fdw/option.c                  |  1 +
 contrib/tsearch2/tsearch2.c                    |  1 +
 contrib/unaccent/unaccent.c                    |  1 +
 src/backend/access/brin/brin_validate.c        |  1 +
 src/backend/access/gin/ginvalidate.c           |  1 +
 src/backend/access/gist/gistvalidate.c         |  1 +
 src/backend/access/hash/hashvalidate.c         |  1 +
 src/backend/access/nbtree/nbtvalidate.c        |  1 +
 src/backend/access/spgist/spgtextproc.c        |  1 +
 src/backend/access/spgist/spgvalidate.c        |  1 +
 src/backend/catalog/namespace.c                |  1 +
 src/backend/catalog/objectaddress.c            |  1 +
 src/backend/catalog/pg_proc.c                  |  1 +
 src/backend/commands/extension.c               |  1 +
 src/backend/commands/indexcmds.c               |  1 +
 src/backend/commands/sequence.c                |  1 +
 src/backend/commands/tablespace.c              |  1 +
 src/backend/commands/variable.c                |  1 +
 src/backend/parser/parse_relation.c            |  1 +
 src/backend/postmaster/postmaster.c            |  1 +
 src/backend/replication/logical/logicalfuncs.c |  1 +
 src/backend/tsearch/dict_thesaurus.c           |  1 +
 src/backend/tsearch/wparser.c                  |  1 +
 src/backend/utils/adt/acl.c                    |  1 +
 src/backend/utils/adt/jsonb_gin.c              |  1 +
 src/backend/utils/adt/jsonb_util.c             |  1 +
 src/backend/utils/adt/regexp.c                 |  1 +
 src/backend/utils/adt/regproc.c                |  2 ++
 src/backend/utils/adt/ruleutils.c              |  1 +
 src/backend/utils/adt/selfuncs.c               |  1 +
 src/backend/utils/adt/tid.c                    |  1 +
 src/backend/utils/adt/tsvector_op.c            |  1 +
 src/backend/utils/adt/varchar.c                |  1 +
 src/backend/utils/adt/varlena.c                |  1 +
 src/backend/utils/cache/ts_cache.c             |  1 +
 src/backend/utils/fmgr/funcapi.c               |  1 +
 src/backend/utils/init/miscinit.c              |  1 +
 src/backend/utils/misc/guc.c                   |  1 +
 src/backend/utils/misc/rls.c                   |  1 +
 src/include/utils/builtins.h                   | 33 +----------------------
 src/include/utils/regproc.h                    | 28 +++++++++++++++++++
 src/include/utils/varlena.h                    | 37 ++++++++++++++++++++++++++
 src/pl/plpgsql/src/pl_comp.c                   |  1 +
 src/pl/plpgsql/src/pl_handler.c                |  1 +
 53 files changed, 117 insertions(+), 32 deletions(-)
 create mode 100644 src/include/utils/regproc.h
 create mode 100644 src/include/utils/varlena.h

diff --git a/contrib/bloom/blvalidate.c b/contrib/bloom/blvalidate.c
index ab8b848b49..cb75d23199 100644
--- a/contrib/bloom/blvalidate.c
+++ b/contrib/bloom/blvalidate.c
@@ -21,6 +21,7 @@
 #include "catalog/pg_type.h"
 #include "utils/builtins.h"
 #include "utils/lsyscache.h"
+#include "utils/regproc.h"
 #include "utils/syscache.h"
 
 #include "bloom.h"
diff --git a/contrib/citext/citext.c b/contrib/citext/citext.c
index 1174b70aa7..04f604b15f 100644
--- a/contrib/citext/citext.c
+++ b/contrib/citext/citext.c
@@ -7,6 +7,7 @@
 #include "catalog/pg_collation.h"
 #include "utils/builtins.h"
 #include "utils/formatting.h"
+#include "utils/varlena.h"
 
 #ifdef PG_MODULE_MAGIC
 PG_MODULE_MAGIC;
diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c
index e288e6f1c7..ac43c458cb 100644
--- a/contrib/dblink/dblink.c
+++ b/contrib/dblink/dblink.c
@@ -59,6 +59,7 @@
 #include "utils/memutils.h"
 #include "utils/rel.h"
 #include "utils/tqual.h"
+#include "utils/varlena.h"
 
 #include "dblink.h"
 
diff --git a/contrib/fuzzystrmatch/fuzzystrmatch.c b/contrib/fuzzystrmatch/fuzzystrmatch.c
index 09d78de596..bd36fc57dc 100644
--- a/contrib/fuzzystrmatch/fuzzystrmatch.c
+++ b/contrib/fuzzystrmatch/fuzzystrmatch.c
@@ -42,6 +42,7 @@
 
 #include "mb/pg_wchar.h"
 #include "utils/builtins.h"
+#include "utils/varlena.h"
 
 PG_MODULE_MAGIC;
 
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index 4983bbbbaf..3f09d5f0a4 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -34,6 +34,7 @@
 #include "miscadmin.h"
 #include "utils/builtins.h"
 #include "utils/rel.h"
+#include "utils/varlena.h"
 
 
 PG_FUNCTION_INFO_V1(bt_metap);
diff --git a/contrib/pageinspect/rawpage.c b/contrib/pageinspect/rawpage.c
index 0043ee18ed..a2ac078d40 100644
--- a/contrib/pageinspect/rawpage.c
+++ b/contrib/pageinspect/rawpage.c
@@ -25,6 +25,7 @@
 #include "utils/builtins.h"
 #include "utils/pg_lsn.h"
 #include "utils/rel.h"
+#include "utils/varlena.h"
 
 PG_MODULE_MAGIC;
 
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index e20e7f83de..4d49610641 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -37,6 +37,7 @@
 #include "utils/rel.h"
 #include "utils/snapmgr.h"
 #include "utils/tqual.h"
+#include "utils/varlena.h"
 
 PG_MODULE_MAGIC;
 
diff --git a/contrib/pgstattuple/pgstatindex.c b/contrib/pgstattuple/pgstatindex.c
index d9a722ac6b..b40669250a 100644
--- a/contrib/pgstattuple/pgstatindex.c
+++ b/contrib/pgstattuple/pgstatindex.c
@@ -38,6 +38,7 @@
 #include "storage/bufmgr.h"
 #include "utils/builtins.h"
 #include "utils/rel.h"
+#include "utils/varlena.h"
 
 
 /*
diff --git a/contrib/pgstattuple/pgstattuple.c b/contrib/pgstattuple/pgstattuple.c
index f48c85d6a2..06a1992bb1 100644
--- a/contrib/pgstattuple/pgstattuple.c
+++ b/contrib/pgstattuple/pgstattuple.c
@@ -36,6 +36,7 @@
 #include "storage/lmgr.h"
 #include "utils/builtins.h"
 #include "utils/tqual.h"
+#include "utils/varlena.h"
 
 PG_MODULE_MAGIC;
 
diff --git a/contrib/postgres_fdw/option.c b/contrib/postgres_fdw/option.c
index 552b33340f..e24db569ea 100644
--- a/contrib/postgres_fdw/option.c
+++ b/contrib/postgres_fdw/option.c
@@ -21,6 +21,7 @@
 #include "commands/defrem.h"
 #include "commands/extension.h"
 #include "utils/builtins.h"
+#include "utils/varlena.h"
 
 
 /*
diff --git a/contrib/tsearch2/tsearch2.c b/contrib/tsearch2/tsearch2.c
index b43dacbed3..16772a2b92 100644
--- a/contrib/tsearch2/tsearch2.c
+++ b/contrib/tsearch2/tsearch2.c
@@ -19,6 +19,7 @@
 #include "tsearch/ts_utils.h"
 #include "utils/builtins.h"
 #include "utils/guc.h"
+#include "utils/regproc.h"
 #include "utils/syscache.h"
 
 PG_MODULE_MAGIC;
diff --git a/contrib/unaccent/unaccent.c b/contrib/unaccent/unaccent.c
index 843c873f57..542e7267be 100644
--- a/contrib/unaccent/unaccent.c
+++ b/contrib/unaccent/unaccent.c
@@ -20,6 +20,7 @@
 #include "tsearch/ts_locale.h"
 #include "tsearch/ts_public.h"
 #include "utils/builtins.h"
+#include "utils/regproc.h"
 
 PG_MODULE_MAGIC;
 
diff --git a/src/backend/access/brin/brin_validate.c b/src/backend/access/brin/brin_validate.c
index 616a8d1541..dc23e00e89 100644
--- a/src/backend/access/brin/brin_validate.c
+++ b/src/backend/access/brin/brin_validate.c
@@ -23,6 +23,7 @@
 #include "catalog/pg_type.h"
 #include "utils/builtins.h"
 #include "utils/syscache.h"
+#include "utils/regproc.h"
 
 
 /*
diff --git a/src/backend/access/gin/ginvalidate.c b/src/backend/access/gin/ginvalidate.c
index 1727b00b13..0d2847456e 100644
--- a/src/backend/access/gin/ginvalidate.c
+++ b/src/backend/access/gin/ginvalidate.c
@@ -24,6 +24,7 @@
 #include "utils/builtins.h"
 #include "utils/lsyscache.h"
 #include "utils/syscache.h"
+#include "utils/regproc.h"
 
 
 /*
diff --git a/src/backend/access/gist/gistvalidate.c b/src/backend/access/gist/gistvalidate.c
index 7c0fac9470..585c92be26 100644
--- a/src/backend/access/gist/gistvalidate.c
+++ b/src/backend/access/gist/gistvalidate.c
@@ -23,6 +23,7 @@
 #include "catalog/pg_type.h"
 #include "utils/builtins.h"
 #include "utils/lsyscache.h"
+#include "utils/regproc.h"
 #include "utils/syscache.h"
 
 
diff --git a/src/backend/access/hash/hashvalidate.c b/src/backend/access/hash/hashvalidate.c
index 880fcd51fc..f914c015bd 100644
--- a/src/backend/access/hash/hashvalidate.c
+++ b/src/backend/access/hash/hashvalidate.c
@@ -25,6 +25,7 @@
 #include "parser/parse_coerce.h"
 #include "utils/builtins.h"
 #include "utils/fmgroids.h"
+#include "utils/regproc.h"
 #include "utils/syscache.h"
 
 
diff --git a/src/backend/access/nbtree/nbtvalidate.c b/src/backend/access/nbtree/nbtvalidate.c
index 7b443f216a..88e33f54cd 100644
--- a/src/backend/access/nbtree/nbtvalidate.c
+++ b/src/backend/access/nbtree/nbtvalidate.c
@@ -22,6 +22,7 @@
 #include "catalog/pg_opfamily.h"
 #include "catalog/pg_type.h"
 #include "utils/builtins.h"
+#include "utils/regproc.h"
 #include "utils/syscache.h"
 
 
diff --git a/src/backend/access/spgist/spgtextproc.c b/src/backend/access/spgist/spgtextproc.c
index bc6981358c..86788549a5 100644
--- a/src/backend/access/spgist/spgtextproc.c
+++ b/src/backend/access/spgist/spgtextproc.c
@@ -45,6 +45,7 @@
 #include "utils/builtins.h"
 #include "utils/datum.h"
 #include "utils/pg_locale.h"
+#include "utils/varlena.h"
 
 
 /*
diff --git a/src/backend/access/spgist/spgvalidate.c b/src/backend/access/spgist/spgvalidate.c
index 9e0f8cef27..1bc5bce72e 100644
--- a/src/backend/access/spgist/spgvalidate.c
+++ b/src/backend/access/spgist/spgvalidate.c
@@ -22,6 +22,7 @@
 #include "catalog/pg_opfamily.h"
 #include "catalog/pg_type.h"
 #include "utils/builtins.h"
+#include "utils/regproc.h"
 #include "utils/syscache.h"
 
 
diff --git a/src/backend/catalog/namespace.c b/src/backend/catalog/namespace.c
index 77e9777a23..a38da3047f 100644
--- a/src/backend/catalog/namespace.c
+++ b/src/backend/catalog/namespace.c
@@ -56,6 +56,7 @@
 #include "utils/lsyscache.h"
 #include "utils/memutils.h"
 #include "utils/syscache.h"
+#include "utils/varlena.h"
 
 
 /*
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index 2b1808b0f9..ca03e977c8 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -78,6 +78,7 @@
 #include "utils/fmgroids.h"
 #include "utils/lsyscache.h"
 #include "utils/memutils.h"
+#include "utils/regproc.h"
 #include "utils/syscache.h"
 #include "utils/tqual.h"
 
diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c
index 05d91fa859..7ae192a407 100644
--- a/src/backend/catalog/pg_proc.c
+++ b/src/backend/catalog/pg_proc.c
@@ -37,6 +37,7 @@
 #include "utils/acl.h"
 #include "utils/builtins.h"
 #include "utils/lsyscache.h"
+#include "utils/regproc.h"
 #include "utils/rel.h"
 #include "utils/syscache.h"
 
diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c
index 967b52a133..554fdc46b4 100644
--- a/src/backend/commands/extension.c
+++ b/src/backend/commands/extension.c
@@ -59,6 +59,7 @@
 #include "utils/rel.h"
 #include "utils/snapmgr.h"
 #include "utils/tqual.h"
+#include "utils/varlena.h"
 
 
 /* Globally visible state variables */
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index b6fa5a01d3..ed6136c153 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -51,6 +51,7 @@
 #include "utils/inval.h"
 #include "utils/lsyscache.h"
 #include "utils/memutils.h"
+#include "utils/regproc.h"
 #include "utils/snapmgr.h"
 #include "utils/syscache.h"
 #include "utils/tqual.h"
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index 2de46c270e..36f1249ee5 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -41,6 +41,7 @@
 #include "utils/lsyscache.h"
 #include "utils/resowner.h"
 #include "utils/syscache.h"
+#include "utils/varlena.h"
 
 
 /*
diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c
index 2da13be9e4..651e1b303a 100644
--- a/src/backend/commands/tablespace.c
+++ b/src/backend/commands/tablespace.c
@@ -82,6 +82,7 @@
 #include "utils/memutils.h"
 #include "utils/rel.h"
 #include "utils/tqual.h"
+#include "utils/varlena.h"
 
 
 /* GUC variables */
diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c
index 62d56b84bc..15dbaf3fd2 100644
--- a/src/backend/commands/variable.c
+++ b/src/backend/commands/variable.c
@@ -30,6 +30,7 @@
 #include "utils/syscache.h"
 #include "utils/snapmgr.h"
 #include "utils/timestamp.h"
+#include "utils/varlena.h"
 #include "mb/pg_wchar.h"
 
 /*
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c
index 1d2440b9a7..e693c316e3 100644
--- a/src/backend/parser/parse_relation.c
+++ b/src/backend/parser/parse_relation.c
@@ -31,6 +31,7 @@
 #include "utils/lsyscache.h"
 #include "utils/rel.h"
 #include "utils/syscache.h"
+#include "utils/varlena.h"
 
 
 #define MAX_FUZZY_DISTANCE				3
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 5be30b0ee1..330de04960 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -126,6 +126,7 @@
 #include "utils/memutils.h"
 #include "utils/ps_status.h"
 #include "utils/timeout.h"
+#include "utils/varlena.h"
 
 #ifdef EXEC_BACKEND
 #include "storage/spin.h"
diff --git a/src/backend/replication/logical/logicalfuncs.c b/src/backend/replication/logical/logicalfuncs.c
index d16d6da56e..41c50005d7 100644
--- a/src/backend/replication/logical/logicalfuncs.c
+++ b/src/backend/replication/logical/logicalfuncs.c
@@ -37,6 +37,7 @@
 #include "utils/inval.h"
 #include "utils/memutils.h"
 #include "utils/pg_lsn.h"
+#include "utils/regproc.h"
 #include "utils/resowner.h"
 #include "utils/lsyscache.h"
 
diff --git a/src/backend/tsearch/dict_thesaurus.c b/src/backend/tsearch/dict_thesaurus.c
index c3f3d3fbed..ee23fcfac8 100644
--- a/src/backend/tsearch/dict_thesaurus.c
+++ b/src/backend/tsearch/dict_thesaurus.c
@@ -19,6 +19,7 @@
 #include "tsearch/ts_locale.h"
 #include "tsearch/ts_utils.h"
 #include "utils/builtins.h"
+#include "utils/regproc.h"
 
 
 /*
diff --git a/src/backend/tsearch/wparser.c b/src/backend/tsearch/wparser.c
index 9a20cace05..8ca1c62713 100644
--- a/src/backend/tsearch/wparser.c
+++ b/src/backend/tsearch/wparser.c
@@ -20,6 +20,7 @@
 #include "tsearch/ts_cache.h"
 #include "tsearch/ts_utils.h"
 #include "utils/builtins.h"
+#include "utils/varlena.h"
 
 
 /******sql-level interface******/
diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c
index 56a69764c4..96ac1dfefd 100644
--- a/src/backend/utils/adt/acl.c
+++ b/src/backend/utils/adt/acl.c
@@ -36,6 +36,7 @@
 #include "utils/lsyscache.h"
 #include "utils/memutils.h"
 #include "utils/syscache.h"
+#include "utils/varlena.h"
 
 
 typedef struct
diff --git a/src/backend/utils/adt/jsonb_gin.c b/src/backend/utils/adt/jsonb_gin.c
index d60d9cac06..16ee6a22d3 100644
--- a/src/backend/utils/adt/jsonb_gin.c
+++ b/src/backend/utils/adt/jsonb_gin.c
@@ -20,6 +20,7 @@
 #include "catalog/pg_type.h"
 #include "utils/builtins.h"
 #include "utils/jsonb.h"
+#include "utils/varlena.h"
 
 typedef struct PathHashStack
 {
diff --git a/src/backend/utils/adt/jsonb_util.c b/src/backend/utils/adt/jsonb_util.c
index 05fddb07d3..11a1395038 100644
--- a/src/backend/utils/adt/jsonb_util.c
+++ b/src/backend/utils/adt/jsonb_util.c
@@ -19,6 +19,7 @@
 #include "utils/builtins.h"
 #include "utils/jsonb.h"
 #include "utils/memutils.h"
+#include "utils/varlena.h"
 
 /*
  * Maximum number of elements in an array (or key/value pairs in an object).
diff --git a/src/backend/utils/adt/regexp.c b/src/backend/utils/adt/regexp.c
index 1f02102111..3a1647bc52 100644
--- a/src/backend/utils/adt/regexp.c
+++ b/src/backend/utils/adt/regexp.c
@@ -35,6 +35,7 @@
 #include "regex/regex.h"
 #include "utils/array.h"
 #include "utils/builtins.h"
+#include "utils/varlena.h"
 
 #define PG_GETARG_TEXT_PP_IF_EXISTS(_n) \
 	(PG_NARGS() > (_n) ? PG_GETARG_TEXT_PP(_n) : NULL)
diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c
index 1f4b1ae79e..fa920c0d8c 100644
--- a/src/backend/utils/adt/regproc.c
+++ b/src/backend/utils/adt/regproc.c
@@ -41,6 +41,8 @@
 #include "utils/syscache.h"
 #include "utils/tqual.h"
 #include "utils/acl.h"
+#include "utils/regproc.h"
+#include "utils/varlena.h"
 
 static char *format_operator_internal(Oid operator_oid, bool force_qualify);
 static char *format_procedure_internal(Oid procedure_oid, bool force_qualify);
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index e1ea067c47..745e009d26 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -67,6 +67,7 @@
 #include "utils/syscache.h"
 #include "utils/tqual.h"
 #include "utils/typcache.h"
+#include "utils/varlena.h"
 #include "utils/xml.h"
 
 
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index 301dffa1c8..fa32e9eabe 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -141,6 +141,7 @@
 #include "utils/timestamp.h"
 #include "utils/tqual.h"
 #include "utils/typcache.h"
+#include "utils/varlena.h"
 
 
 /* Hooks for plugins to get control when we ask for stats */
diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c
index aa7e5e5242..a3b372f22a 100644
--- a/src/backend/utils/adt/tid.c
+++ b/src/backend/utils/adt/tid.c
@@ -32,6 +32,7 @@
 #include "utils/rel.h"
 #include "utils/snapmgr.h"
 #include "utils/tqual.h"
+#include "utils/varlena.h"
 
 
 #define DatumGetItemPointer(X)	 ((ItemPointer) DatumGetPointer(X))
diff --git a/src/backend/utils/adt/tsvector_op.c b/src/backend/utils/adt/tsvector_op.c
index c143c3fbf5..f05f913cff 100644
--- a/src/backend/utils/adt/tsvector_op.c
+++ b/src/backend/utils/adt/tsvector_op.c
@@ -27,6 +27,7 @@
 #include "tsearch/ts_utils.h"
 #include "utils/builtins.h"
 #include "utils/lsyscache.h"
+#include "utils/regproc.h"
 #include "utils/rel.h"
 
 
diff --git a/src/backend/utils/adt/varchar.c b/src/backend/utils/adt/varchar.c
index 55ee2bb7c2..c800beb08f 100644
--- a/src/backend/utils/adt/varchar.c
+++ b/src/backend/utils/adt/varchar.c
@@ -22,6 +22,7 @@
 #include "nodes/nodeFuncs.h"
 #include "utils/array.h"
 #include "utils/builtins.h"
+#include "utils/varlena.h"
 #include "mb/pg_wchar.h"
 
 
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index d66e85aa1e..254379ade7 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -34,6 +34,7 @@
 #include "utils/memutils.h"
 #include "utils/pg_locale.h"
 #include "utils/sortsupport.h"
+#include "utils/varlena.h"
 
 
 /* GUC variable */
diff --git a/src/backend/utils/cache/ts_cache.c b/src/backend/utils/cache/ts_cache.c
index 657f6c1b7c..88e4ffb66d 100644
--- a/src/backend/utils/cache/ts_cache.c
+++ b/src/backend/utils/cache/ts_cache.c
@@ -45,6 +45,7 @@
 #include "utils/inval.h"
 #include "utils/lsyscache.h"
 #include "utils/memutils.h"
+#include "utils/regproc.h"
 #include "utils/syscache.h"
 #include "utils/tqual.h"
 
diff --git a/src/backend/utils/fmgr/funcapi.c b/src/backend/utils/fmgr/funcapi.c
index 4d8a121971..c55da54878 100644
--- a/src/backend/utils/fmgr/funcapi.c
+++ b/src/backend/utils/fmgr/funcapi.c
@@ -24,6 +24,7 @@
 #include "utils/builtins.h"
 #include "utils/lsyscache.h"
 #include "utils/memutils.h"
+#include "utils/regproc.h"
 #include "utils/rel.h"
 #include "utils/syscache.h"
 #include "utils/typcache.h"
diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c
index 07be153cc0..e984e79c60 100644
--- a/src/backend/utils/init/miscinit.c
+++ b/src/backend/utils/init/miscinit.c
@@ -48,6 +48,7 @@
 #include "utils/guc.h"
 #include "utils/memutils.h"
 #include "utils/syscache.h"
+#include "utils/varlena.h"
 
 
 #define DIRECTORY_LOCK_FILE		"postmaster.pid"
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 4e2bd4c496..0ef4c60767 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -83,6 +83,7 @@
 #include "utils/rls.h"
 #include "utils/snapmgr.h"
 #include "utils/tzparser.h"
+#include "utils/varlena.h"
 #include "utils/xml.h"
 
 #ifndef PG_KRB_SRVTAB
diff --git a/src/backend/utils/misc/rls.c b/src/backend/utils/misc/rls.c
index 70dc3d1ace..faf1599404 100644
--- a/src/backend/utils/misc/rls.c
+++ b/src/backend/utils/misc/rls.c
@@ -26,6 +26,7 @@
 #include "utils/lsyscache.h"
 #include "utils/rls.h"
 #include "utils/syscache.h"
+#include "utils/varlena.h"
 
 
 /*
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 95f5e9292b..5bdca8203d 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -16,9 +16,7 @@
 
 #include "fmgr.h"
 #include "nodes/nodes.h"
-#include "nodes/pg_list.h"
 #include "utils/fmgrprotos.h"
-#include "utils/sortsupport.h"
 
 
 /* bool.c */
@@ -74,17 +72,6 @@ extern Oid	oidparse(Node *node);
 extern char *regexp_fixed_prefix(text *text_re, bool case_insensitive,
 					Oid collation, bool *exact);
 
-/* regproc.c */
-extern List *stringToQualifiedNameList(const char *string);
-extern char *format_procedure(Oid procedure_oid);
-extern char *format_procedure_qualified(Oid procedure_oid);
-extern void format_procedure_parts(Oid operator_oid, List **objnames,
-					   List **objargs);
-extern char *format_operator(Oid operator_oid);
-extern char *format_operator_qualified(Oid operator_oid);
-extern void format_operator_parts(Oid operator_oid, List **objnames,
-					  List **objargs);
-
 /* ruleutils.c */
 extern bool quote_all_identifiers;
 extern const char *quote_identifier(const char *ident);
@@ -94,7 +81,7 @@ extern char *quote_qualified_identifier(const char *qualifier,
 /* varchar.c */
 extern int	bpchartruelen(char *s, int len);
 
-/* varlena.c */
+/* popular functions from varlena.c */
 extern text *cstring_to_text(const char *s);
 extern text *cstring_to_text_with_len(const char *s, int len);
 extern char *text_to_cstring(const text *t);
@@ -103,24 +90,6 @@ extern void text_to_cstring_buffer(const text *src, char *dst, size_t dst_len);
 #define CStringGetTextDatum(s) PointerGetDatum(cstring_to_text(s))
 #define TextDatumGetCString(d) text_to_cstring((text *) DatumGetPointer(d))
 
-extern int	varstr_cmp(char *arg1, int len1, char *arg2, int len2, Oid collid);
-extern void varstr_sortsupport(SortSupport ssup, Oid collid, bool bpchar);
-extern int varstr_levenshtein(const char *source, int slen,
-				   const char *target, int tlen,
-				   int ins_c, int del_c, int sub_c,
-				   bool trusted);
-extern int varstr_levenshtein_less_equal(const char *source, int slen,
-							  const char *target, int tlen,
-							  int ins_c, int del_c, int sub_c,
-							  int max_d, bool trusted);
-extern List *textToQualifiedNameList(text *textval);
-extern bool SplitIdentifierString(char *rawstring, char separator,
-					  List **namelist);
-extern bool SplitDirectoriesString(char *rawstring, char separator,
-					   List **namelist);
-extern text *replace_text_regexp(text *src_text, void *regexp,
-					text *replace_text, bool glob);
-
 /* xid.c */
 extern int	xidComparator(const void *arg1, const void *arg2);
 
diff --git a/src/include/utils/regproc.h b/src/include/utils/regproc.h
new file mode 100644
index 0000000000..70f47922cc
--- /dev/null
+++ b/src/include/utils/regproc.h
@@ -0,0 +1,28 @@
+/*-------------------------------------------------------------------------
+ *
+ * regproc.h
+ *    Functions for the built-in types regproc, regclass, regtype, etc.
+ *
+ * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * src/include/utils/regproc.h
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef REGPROC_H
+#define REGPROC_H
+
+#include "nodes/pg_list.h"
+
+extern List *stringToQualifiedNameList(const char *string);
+extern char *format_procedure(Oid procedure_oid);
+extern char *format_procedure_qualified(Oid procedure_oid);
+extern void format_procedure_parts(Oid operator_oid, List **objnames,
+					   List **objargs);
+extern char *format_operator(Oid operator_oid);
+extern char *format_operator_qualified(Oid operator_oid);
+extern void format_operator_parts(Oid operator_oid, List **objnames,
+					  List **objargs);
+
+#endif
diff --git a/src/include/utils/varlena.h b/src/include/utils/varlena.h
new file mode 100644
index 0000000000..b5994a1c72
--- /dev/null
+++ b/src/include/utils/varlena.h
@@ -0,0 +1,37 @@
+/*-------------------------------------------------------------------------
+ *
+ * varlena.h
+ *    Functions for the variable-length built-in types.
+ *
+ * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * src/include/utils/varlena.h
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef VARLENA_H
+#define VARLENA_H
+
+#include "nodes/pg_list.h"
+#include "utils/sortsupport.h"
+
+extern int	varstr_cmp(char *arg1, int len1, char *arg2, int len2, Oid collid);
+extern void varstr_sortsupport(SortSupport ssup, Oid collid, bool bpchar);
+extern int varstr_levenshtein(const char *source, int slen,
+				   const char *target, int tlen,
+				   int ins_c, int del_c, int sub_c,
+				   bool trusted);
+extern int varstr_levenshtein_less_equal(const char *source, int slen,
+							  const char *target, int tlen,
+							  int ins_c, int del_c, int sub_c,
+							  int max_d, bool trusted);
+extern List *textToQualifiedNameList(text *textval);
+extern bool SplitIdentifierString(char *rawstring, char separator,
+					  List **namelist);
+extern bool SplitDirectoriesString(char *rawstring, char separator,
+					   List **namelist);
+extern text *replace_text_regexp(text *src_text, void *regexp,
+					text *replace_text, bool glob);
+
+#endif
diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c
index 3c52d71fcd..b25b3f1de0 100644
--- a/src/pl/plpgsql/src/pl_comp.c
+++ b/src/pl/plpgsql/src/pl_comp.c
@@ -29,6 +29,7 @@
 #include "utils/guc.h"
 #include "utils/lsyscache.h"
 #include "utils/memutils.h"
+#include "utils/regproc.h"
 #include "utils/rel.h"
 #include "utils/syscache.h"
 
diff --git a/src/pl/plpgsql/src/pl_handler.c b/src/pl/plpgsql/src/pl_handler.c
index ca8c9cb3ce..e15be5d9ac 100644
--- a/src/pl/plpgsql/src/pl_handler.c
+++ b/src/pl/plpgsql/src/pl_handler.c
@@ -24,6 +24,7 @@
 #include "utils/guc.h"
 #include "utils/lsyscache.h"
 #include "utils/syscache.h"
+#include "utils/varlena.h"
 
 
 static bool plpgsql_extra_checks_check_hook(char **newvalue, void **extra, GucSource source);
-- 
2.11.0

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to