From 1cfd9e88349fc259d17914ccfd4eaf7bb7f7d141 Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Wed, 7 Jan 2009 13:44:37 +0000
Subject: [PATCH] Fix executor/spi.h to follow our usual conventions for
 include files, ie, not include postgres.h nor anything else it doesn't
 directly need.  Add #includes to calling files as needed to compensate.  Per
 my proposal of yesterday.

This should be noted as a source code change in the 8.4 release notes,
since it's likely to require changes in add-on modules.
---
 contrib/spi/autoinc.c                   | 11 ++++++---
 contrib/spi/insert_username.c           | 11 ++++++---
 contrib/spi/moddatetime.c               |  8 +++---
 contrib/spi/refint.c                    |  9 ++++---
 contrib/spi/timetravel.c                | 19 +++++++-------
 contrib/tablefunc/tablefunc.c           |  3 ++-
 contrib/xml2/xpath.c                    | 12 +++++----
 contrib/xml2/xslt_proc.c                | 13 ++++++----
 doc/src/sgml/spi.sgml                   |  5 +++-
 src/backend/executor/spi.c              | 10 +++++++-
 src/backend/utils/adt/ri_triggers.c     |  7 +++++-
 src/backend/utils/adt/ruleutils.c       |  8 +++++-
 src/backend/utils/adt/tsquery_rewrite.c |  6 +++--
 src/backend/utils/adt/tsvector_op.c     |  3 ++-
 src/backend/utils/adt/xml.c             |  3 ++-
 src/include/executor/spi.h              | 33 +++----------------------
 src/pl/plperl/plperl.c                  | 10 ++++++--
 src/pl/plpgsql/src/gram.y               |  3 ++-
 src/pl/plpgsql/src/pl_exec.c            |  3 ++-
 src/pl/plpgsql/src/plpgsql.h            |  3 ++-
 src/pl/tcl/pltcl.c                      |  5 +++-
 src/test/regress/regress.c              | 19 ++++++++------
 22 files changed, 118 insertions(+), 86 deletions(-)

diff --git a/contrib/spi/autoinc.c b/contrib/spi/autoinc.c
index bc39db00c26..f5554146648 100644
--- a/contrib/spi/autoinc.c
+++ b/contrib/spi/autoinc.c
@@ -1,10 +1,13 @@
 /*
- * $PostgreSQL: pgsql/contrib/spi/autoinc.c,v 1.15 2008/05/17 01:28:22 adunstan Exp $ 
+ * $PostgreSQL: pgsql/contrib/spi/autoinc.c,v 1.16 2009/01/07 13:44:36 tgl Exp $ 
  */
+#include "postgres.h"
 
-#include "executor/spi.h"		/* this is what you need to work with SPI */
-#include "commands/trigger.h"	/* -"- and triggers */
-#include "commands/sequence.h"	/* for nextval() */
+#include "catalog/pg_type.h"
+#include "commands/sequence.h"
+#include "commands/trigger.h"
+#include "executor/spi.h"
+#include "utils/builtins.h"
 
 PG_MODULE_MAGIC;
 
diff --git a/contrib/spi/insert_username.c b/contrib/spi/insert_username.c
index 9541677ebde..377284a6133 100644
--- a/contrib/spi/insert_username.c
+++ b/contrib/spi/insert_username.c
@@ -1,15 +1,18 @@
 /*
  * insert_username.c
  * $Modified: Thu Oct 16 08:13:42 1997 by brook $
- * $PostgreSQL: pgsql/contrib/spi/insert_username.c,v 1.16 2008/03/25 22:42:42 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/spi/insert_username.c,v 1.17 2009/01/07 13:44:36 tgl Exp $
  *
  * insert user name in response to a trigger
  * usage:  insert_username (column_name)
  */
+#include "postgres.h"
 
-#include "executor/spi.h"		/* this is what you need to work with SPI */
-#include "commands/trigger.h"	/* -"- and triggers */
-#include "miscadmin.h"			/* for GetUserName() */
+#include "catalog/pg_type.h"
+#include "commands/trigger.h"
+#include "executor/spi.h"
+#include "miscadmin.h"
+#include "utils/builtins.h"
 
 PG_MODULE_MAGIC;
 
diff --git a/contrib/spi/moddatetime.c b/contrib/spi/moddatetime.c
index b4c9fe4de96..0b4d3ba3519 100644
--- a/contrib/spi/moddatetime.c
+++ b/contrib/spi/moddatetime.c
@@ -1,7 +1,7 @@
 /*
 moddatetime.c
 
-$PostgreSQL: pgsql/contrib/spi/moddatetime.c,v 1.14 2007/02/01 19:10:23 momjian Exp $
+$PostgreSQL: pgsql/contrib/spi/moddatetime.c,v 1.15 2009/01/07 13:44:36 tgl Exp $
 
 What is this?
 It is a function to be called from a trigger for the purpose of updating
@@ -13,9 +13,11 @@ not really know what I am doing.  I also had help from
 Jan Wieck <jwieck@debis.com> who told me about the timestamp_in("now") function.
 OH, me, I'm Terry Mackintosh <terry@terrym.com>
 */
+#include "postgres.h"
 
-#include "executor/spi.h"		/* this is what you need to work with SPI */
-#include "commands/trigger.h"	/* -"- and triggers */
+#include "catalog/pg_type.h"
+#include "executor/spi.h"
+#include "commands/trigger.h"
 
 PG_MODULE_MAGIC;
 
diff --git a/contrib/spi/refint.c b/contrib/spi/refint.c
index dd628e7be3e..aaef7b4977b 100644
--- a/contrib/spi/refint.c
+++ b/contrib/spi/refint.c
@@ -1,16 +1,17 @@
 /*
- * $PostgreSQL: pgsql/contrib/spi/refint.c,v 1.33 2008/05/17 01:28:22 adunstan Exp $ 
+ * $PostgreSQL: pgsql/contrib/spi/refint.c,v 1.34 2009/01/07 13:44:36 tgl Exp $ 
  *
  *
  * refint.c --	set of functions to define referential integrity
  *		constraints using general triggers.
  */
+#include "postgres.h"
 
-#include "executor/spi.h"		/* this is what you need to work with SPI */
-
-#include "commands/trigger.h"	/* -"- and triggers */
 #include <ctype.h>
 
+#include "commands/trigger.h"
+#include "executor/spi.h"
+#include "utils/builtins.h"
 
 PG_MODULE_MAGIC;
 
diff --git a/contrib/spi/timetravel.c b/contrib/spi/timetravel.c
index a0a1b22923f..a949d2d8179 100644
--- a/contrib/spi/timetravel.c
+++ b/contrib/spi/timetravel.c
@@ -1,22 +1,23 @@
 /*
- * $PostgreSQL: pgsql/contrib/spi/timetravel.c,v 1.29 2008/05/17 01:28:22 adunstan Exp $ 
+ * $PostgreSQL: pgsql/contrib/spi/timetravel.c,v 1.30 2009/01/07 13:44:36 tgl Exp $ 
  *
  *
  * timetravel.c --	function to get time travel feature
  *		using general triggers.
+ *
+ * Modified by B�JTHE Zolt�n, Hungary, mailto:urdesobt@axelero.hu
  */
+#include "postgres.h"
 
-/* Modified by B�JTHE Zolt�n, Hungary, mailto:urdesobt@axelero.hu */
+#include <ctype.h>
 
-#include "executor/spi.h"		/* this is what you need to work with SPI */
-#include "commands/trigger.h"	/* -"- and triggers */
-#include "miscadmin.h"			/* for GetPgUserName() */
+#include "catalog/pg_type.h"
+#include "commands/trigger.h"
+#include "executor/spi.h"
+#include "miscadmin.h"
+#include "utils/builtins.h"
 #include "utils/nabstime.h"
 
-#include <ctype.h>				/* tolower () */
-
-#define ABSTIMEOID	702			/* it should be in pg_type.h */
-
 PG_MODULE_MAGIC;
 
 /* AbsoluteTime currabstime(void); */
diff --git a/contrib/tablefunc/tablefunc.c b/contrib/tablefunc/tablefunc.c
index dc7924733c7..5829c841112 100644
--- a/contrib/tablefunc/tablefunc.c
+++ b/contrib/tablefunc/tablefunc.c
@@ -1,5 +1,5 @@
 /*
- * $PostgreSQL: pgsql/contrib/tablefunc/tablefunc.c,v 1.58 2009/01/01 17:23:32 momjian Exp $ 
+ * $PostgreSQL: pgsql/contrib/tablefunc/tablefunc.c,v 1.59 2009/01/07 13:44:36 tgl Exp $ 
  *
  *
  * tablefunc
@@ -34,6 +34,7 @@
 
 #include <math.h>
 
+#include "catalog/pg_type.h"
 #include "fmgr.h"
 #include "funcapi.h"
 #include "executor/spi.h"
diff --git a/contrib/xml2/xpath.c b/contrib/xml2/xpath.c
index b2f3342f737..d5244a1ce34 100644
--- a/contrib/xml2/xpath.c
+++ b/contrib/xml2/xpath.c
@@ -1,15 +1,17 @@
 /*
- * $PostgreSQL: pgsql/contrib/xml2/xpath.c,v 1.21 2008/10/29 00:00:38 tgl Exp $ 
+ * $PostgreSQL: pgsql/contrib/xml2/xpath.c,v 1.22 2009/01/07 13:44:36 tgl Exp $
  *
  * Parser interface for DOM-based parser (libxml) rather than
-   stream-based SAX-type parser */
-
+ * stream-based SAX-type parser
+ */
 #include "postgres.h"
-#include "fmgr.h"
+
 #include "executor/spi.h"
+#include "fmgr.h"
 #include "funcapi.h"
-#include "miscadmin.h"
 #include "lib/stringinfo.h"
+#include "miscadmin.h"
+#include "utils/builtins.h"
 
 /* libxml includes */
 
diff --git a/contrib/xml2/xslt_proc.c b/contrib/xml2/xslt_proc.c
index 425a9393337..4ca176ed2ec 100644
--- a/contrib/xml2/xslt_proc.c
+++ b/contrib/xml2/xslt_proc.c
@@ -1,14 +1,17 @@
 /*
- * $PostgreSQL: pgsql/contrib/xml2/xslt_proc.c,v 1.13 2008/05/17 01:28:22 adunstan Exp $ 
+ * $PostgreSQL: pgsql/contrib/xml2/xslt_proc.c,v 1.14 2009/01/07 13:44:36 tgl Exp $ 
  *
- * XSLT processing functions (requiring libxslt) */
-/* John Gray, for Torchbox 2003-04-01 */
-
+ * XSLT processing functions (requiring libxslt)
+ *
+ * John Gray, for Torchbox 2003-04-01
+ */
 #include "postgres.h"
-#include "fmgr.h"
+
 #include "executor/spi.h"
+#include "fmgr.h"
 #include "funcapi.h"
 #include "miscadmin.h"
+#include "utils/builtins.h"
 
 /* libxml includes */
 
diff --git a/doc/src/sgml/spi.sgml b/doc/src/sgml/spi.sgml
index 04cd0ca1791..9df76db0457 100644
--- a/doc/src/sgml/spi.sgml
+++ b/doc/src/sgml/spi.sgml
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/spi.sgml,v 1.62 2008/04/01 03:09:30 tgl Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/spi.sgml,v 1.63 2009/01/07 13:44:36 tgl Exp $ -->
 
 <chapter id="spi">
  <title>Server Programming Interface</title>
@@ -3617,7 +3617,10 @@ INSERT INTO a SELECT * FROM a;
   </para>
 
 <programlisting>
+#include "postgres.h"
+
 #include "executor/spi.h"
+#include "utils/builtins.h"
 
 #ifdef PG_MODULE_MAGIC
 PG_MODULE_MAGIC;
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c
index 4bc45dc17f8..5391dcb6e9b 100644
--- a/src/backend/executor/spi.c
+++ b/src/backend/executor/spi.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.204 2009/01/02 20:42:00 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.205 2009/01/07 13:44:36 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -16,12 +16,20 @@
 
 #include "access/printtup.h"
 #include "access/sysattr.h"
+#include "access/xact.h"
 #include "catalog/heap.h"
+#include "catalog/pg_type.h"
 #include "commands/trigger.h"
+#include "executor/executor.h"
 #include "executor/spi_priv.h"
+#include "tcop/pquery.h"
+#include "tcop/utility.h"
+#include "utils/builtins.h"
+#include "utils/datum.h"
 #include "utils/lsyscache.h"
 #include "utils/memutils.h"
 #include "utils/snapmgr.h"
+#include "utils/syscache.h"
 #include "utils/typcache.h"
 
 
diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c
index 97d6d6c5e39..53b9c43f081 100644
--- a/src/backend/utils/adt/ri_triggers.c
+++ b/src/backend/utils/adt/ri_triggers.c
@@ -15,7 +15,7 @@
  *
  * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.111 2009/01/01 17:23:49 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.112 2009/01/07 13:44:36 tgl Exp $
  *
  * ----------
  */
@@ -30,18 +30,23 @@
 
 #include "postgres.h"
 
+#include "access/xact.h"
 #include "catalog/pg_constraint.h"
 #include "catalog/pg_operator.h"
+#include "catalog/pg_type.h"
 #include "commands/trigger.h"
 #include "executor/spi.h"
 #include "parser/parse_coerce.h"
 #include "parser/parse_relation.h"
 #include "miscadmin.h"
 #include "utils/acl.h"
+#include "utils/builtins.h"
 #include "utils/fmgroids.h"
+#include "utils/guc.h"
 #include "utils/lsyscache.h"
 #include "utils/memutils.h"
 #include "utils/snapmgr.h"
+#include "utils/syscache.h"
 #include "utils/tqual.h"
 
 
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 43cfcb284ee..845b1bf96a2 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.294 2009/01/01 17:23:50 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.295 2009/01/07 13:44:36 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -25,9 +25,12 @@
 #include "catalog/pg_authid.h"
 #include "catalog/pg_constraint.h"
 #include "catalog/pg_depend.h"
+#include "catalog/pg_language.h"
 #include "catalog/pg_opclass.h"
 #include "catalog/pg_operator.h"
+#include "catalog/pg_proc.h"
 #include "catalog/pg_trigger.h"
+#include "catalog/pg_type.h"
 #include "commands/defrem.h"
 #include "commands/tablespace.h"
 #include "executor/spi.h"
@@ -44,9 +47,12 @@
 #include "rewrite/rewriteHandler.h"
 #include "rewrite/rewriteManip.h"
 #include "rewrite/rewriteSupport.h"
+#include "utils/array.h"
+#include "utils/builtins.h"
 #include "utils/fmgroids.h"
 #include "utils/lsyscache.h"
 #include "utils/tqual.h"
+#include "utils/syscache.h"
 #include "utils/typcache.h"
 #include "utils/xml.h"
 
diff --git a/src/backend/utils/adt/tsquery_rewrite.c b/src/backend/utils/adt/tsquery_rewrite.c
index 25d42ae2959..22db8609f3a 100644
--- a/src/backend/utils/adt/tsquery_rewrite.c
+++ b/src/backend/utils/adt/tsquery_rewrite.c
@@ -7,17 +7,19 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_rewrite.c,v 1.13 2009/01/01 17:23:50 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_rewrite.c,v 1.14 2009/01/07 13:44:36 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
 
 #include "postgres.h"
 
+#include "catalog/pg_type.h"
 #include "executor/spi.h"
+#include "miscadmin.h"
 #include "tsearch/ts_type.h"
 #include "tsearch/ts_utils.h"
-#include "miscadmin.h"
+#include "utils/builtins.h"
 
 
 static int
diff --git a/src/backend/utils/adt/tsvector_op.c b/src/backend/utils/adt/tsvector_op.c
index f63dad7a3b9..27cef9a89c7 100644
--- a/src/backend/utils/adt/tsvector_op.c
+++ b/src/backend/utils/adt/tsvector_op.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/utils/adt/tsvector_op.c,v 1.20 2009/01/01 17:23:50 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/backend/utils/adt/tsvector_op.c,v 1.21 2009/01/07 13:44:36 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -15,6 +15,7 @@
 #include "postgres.h"
 
 #include "catalog/namespace.h"
+#include "catalog/pg_type.h"
 #include "commands/trigger.h"
 #include "executor/spi.h"
 #include "funcapi.h"
diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c
index bf0bd92b2f7..fcfc05ba515 100644
--- a/src/backend/utils/adt/xml.c
+++ b/src/backend/utils/adt/xml.c
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.82 2009/01/01 17:23:50 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.83 2009/01/07 13:44:37 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -81,6 +81,7 @@
 #include "utils/datetime.h"
 #include "utils/lsyscache.h"
 #include "utils/memutils.h"
+#include "utils/syscache.h"
 #include "utils/xml.h"
 
 
diff --git a/src/include/executor/spi.h b/src/include/executor/spi.h
index 7966fe3dc1c..c28730c425b 100644
--- a/src/include/executor/spi.h
+++ b/src/include/executor/spi.h
@@ -6,44 +6,17 @@
  * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/executor/spi.h,v 1.68 2009/01/01 17:23:59 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/executor/spi.h,v 1.69 2009/01/07 13:44:37 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
 #ifndef SPI_H
 #define SPI_H
 
-/*
- * This file may be used by client modules that haven't already
- * included postgres.h
- */
-#include "postgres.h"
-
-/*
- *	Most of these are not needed by this file, but may be used by
- *	user-written code that uses SPI
- */
-#include "access/heapam.h"
-#include "access/xact.h"
-#include "catalog/pg_language.h"
-#include "catalog/pg_proc.h"
-#include "catalog/pg_type.h"
-#include "executor/execdefs.h"
-#include "executor/executor.h"
-#include "nodes/execnodes.h"
-#include "nodes/params.h"
 #include "nodes/parsenodes.h"
-#include "nodes/plannodes.h"
-#include "nodes/primnodes.h"
-#include "nodes/relation.h"
-#include "tcop/dest.h"
-#include "tcop/pquery.h"
-#include "tcop/tcopprot.h"
-#include "tcop/utility.h"
-#include "utils/builtins.h"
-#include "utils/datum.h"
 #include "utils/portal.h"
-#include "utils/syscache.h"
+#include "utils/relcache.h"
+#include "utils/snapshot.h"
 
 
 typedef struct SPITupleTable
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c
index e2df129f52b..8dcbf09a48c 100644
--- a/src/pl/plperl/plperl.c
+++ b/src/pl/plperl/plperl.c
@@ -1,7 +1,7 @@
 /**********************************************************************
  * plperl.c - perl as a procedural language for PostgreSQL
  *
- *	  $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.143 2008/12/11 07:34:09 petere Exp $
+ *	  $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.144 2009/01/07 13:44:37 tgl Exp $
  *
  **********************************************************************/
 
@@ -16,6 +16,10 @@
 #include <locale.h>
 
 /* postgreSQL stuff */
+#include "access/xact.h"
+#include "catalog/pg_language.h"
+#include "catalog/pg_proc.h"
+#include "catalog/pg_type.h"
 #include "commands/trigger.h"
 #include "executor/spi.h"
 #include "funcapi.h"
@@ -23,12 +27,14 @@
 #include "miscadmin.h"
 #include "nodes/makefuncs.h"
 #include "parser/parse_type.h"
+#include "utils/builtins.h"
 #include "utils/fmgroids.h"
 #include "utils/guc.h"
+#include "utils/hsearch.h"
 #include "utils/lsyscache.h"
 #include "utils/memutils.h"
+#include "utils/syscache.h"
 #include "utils/typcache.h"
-#include "utils/hsearch.h"
 
 /* define our text domain for translations */
 #undef TEXTDOMAIN
diff --git a/src/pl/plpgsql/src/gram.y b/src/pl/plpgsql/src/gram.y
index 71e86c9b6d3..7ae3536754d 100644
--- a/src/pl/plpgsql/src/gram.y
+++ b/src/pl/plpgsql/src/gram.y
@@ -9,13 +9,14 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.118 2009/01/01 17:24:03 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.119 2009/01/07 13:44:37 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
 
 #include "plpgsql.h"
 
+#include "catalog/pg_type.h"
 #include "parser/parser.h"
 
 
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index 4983da1b455..04eb52bdc3f 100644
--- a/src/pl/plpgsql/src/pl_exec.c
+++ b/src/pl/plpgsql/src/pl_exec.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.226 2009/01/01 17:24:03 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.227 2009/01/07 13:44:37 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -27,6 +27,7 @@
 #include "tcop/tcopprot.h"
 #include "utils/array.h"
 #include "utils/builtins.h"
+#include "utils/datum.h"
 #include "utils/lsyscache.h"
 #include "utils/memutils.h"
 #include "utils/snapmgr.h"
diff --git a/src/pl/plpgsql/src/plpgsql.h b/src/pl/plpgsql/src/plpgsql.h
index 973bc032a20..f7c8b5b04de 100644
--- a/src/pl/plpgsql/src/plpgsql.h
+++ b/src/pl/plpgsql/src/plpgsql.h
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.107 2009/01/01 17:24:04 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.108 2009/01/07 13:44:37 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -18,6 +18,7 @@
 
 #include "postgres.h"
 
+#include "access/xact.h"
 #include "fmgr.h"
 #include "miscadmin.h"
 #include "commands/trigger.h"
diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c
index f71af5c7257..3f5e32e52eb 100644
--- a/src/pl/tcl/pltcl.c
+++ b/src/pl/tcl/pltcl.c
@@ -2,7 +2,7 @@
  * pltcl.c		- PostgreSQL support for Tcl as
  *				  procedural language (PL)
  *
- *	  $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.124 2008/12/11 07:34:09 petere Exp $
+ *	  $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.125 2009/01/07 13:44:37 tgl Exp $
  *
  **********************************************************************/
 
@@ -18,8 +18,10 @@
 #define CONST84
 #endif
 
+#include "access/xact.h"
 #include "catalog/pg_language.h"
 #include "catalog/pg_proc.h"
+#include "catalog/pg_type.h"
 #include "commands/trigger.h"
 #include "executor/spi.h"
 #include "fmgr.h"
@@ -33,6 +35,7 @@
 #include "utils/syscache.h"
 #include "utils/typcache.h"
 
+
 #define HAVE_TCL_VERSION(maj,min) \
 	((TCL_MAJOR_VERSION > maj) || \
 	 (TCL_MAJOR_VERSION == maj && TCL_MINOR_VERSION >= min))
diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c
index c5ea947f84e..ffbe4e37b83 100644
--- a/src/test/regress/regress.c
+++ b/src/test/regress/regress.c
@@ -1,15 +1,22 @@
 /*
- * $PostgreSQL: pgsql/src/test/regress/regress.c,v 1.71 2008/03/25 22:42:46 tgl Exp $
+ * $PostgreSQL: pgsql/src/test/regress/regress.c,v 1.72 2009/01/07 13:44:37 tgl Exp $
  */
 
 #include "postgres.h"
 
-#include <float.h>				/* faked on sunos */
+#include <float.h>
+#include <math.h>
 
 #include "access/transam.h"
-#include "utils/geo_decls.h"	/* includes <math.h> */
-#include "executor/executor.h"	/* For GetAttributeByName */
-#include "commands/sequence.h"	/* for nextval() */
+#include "access/xact.h"
+#include "catalog/pg_type.h"
+#include "commands/sequence.h"
+#include "commands/trigger.h"
+#include "executor/executor.h"
+#include "executor/spi.h"
+#include "utils/builtins.h"
+#include "utils/geo_decls.h"
+
 
 #define P_MAXDIG 12
 #define LDELIM			'('
@@ -325,8 +332,6 @@ oldstyle_length(int n, text *t)
 	return n + len;
 }
 
-#include "executor/spi.h"		/* this is what you need to work with SPI */
-#include "commands/trigger.h"	/* -"- and triggers */
 
 static TransactionId fd17b_xid = InvalidTransactionId;
 static TransactionId fd17a_xid = InvalidTransactionId;
-- 
GitLab