Thread: Is it really such a great idea for spi.h to include the world?

Is it really such a great idea for spi.h to include the world?

From
Tom Lane
Date:
executor/spi.h includes far more than it needs, starting with postgres.h
which as a general rule we don't expect any other header file to
include.  I think the argument for this was to keep things simple for
SPI-using loadable modules, but I doubt that it's really improving their
lives much.  A quick look through the existing files that include spi.h
shows that most of them have to include a pile of other stuff anyway.

I propose changing spi.h to follow the same include-only-what-you-must
rule as every other backend header file.  Thoughts?
        regards, tom lane


Re: Is it really such a great idea for spi.h to include the world?

From
Bruce Momjian
Date:
Tom Lane wrote:
> executor/spi.h includes far more than it needs, starting with postgres.h
> which as a general rule we don't expect any other header file to
> include.  I think the argument for this was to keep things simple for
> SPI-using loadable modules, but I doubt that it's really improving their
> lives much.  A quick look through the existing files that include spi.h
> shows that most of them have to include a pile of other stuff anyway.
> 
> I propose changing spi.h to follow the same include-only-what-you-must
> rule as every other backend header file.  Thoughts?

I don't think we ever cleaned out spi.h in the past because we were
worried about 3rd party code using it (I am fine with a cleanup).

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + If your life is a hard drive, Christ can be your backup. +


Re: Is it really such a great idea for spi.h to include the world?

From
Alvaro Herrera
Date:
Bruce Momjian wrote:
> Tom Lane wrote:
> > executor/spi.h includes far more than it needs, starting with postgres.h
> > which as a general rule we don't expect any other header file to
> > include.  I think the argument for this was to keep things simple for
> > SPI-using loadable modules, but I doubt that it's really improving their
> > lives much.  A quick look through the existing files that include spi.h
> > shows that most of them have to include a pile of other stuff anyway.
> > 
> > I propose changing spi.h to follow the same include-only-what-you-must
> > rule as every other backend header file.  Thoughts?
> 
> I don't think we ever cleaned out spi.h in the past because we were
> worried about 3rd party code using it (I am fine with a cleanup).

I've wondered about spi.h lately too while looking at header cleanup,
and I agree with the proposed solution.  The worst that can happen is
that somebody needs to add extra includes in their programs in order for
them to compile with 8.4.  We do enough other changes that this one is
really minor.  Better late than never anyway.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


Re: Is it really such a great idea for spi.h to include the world?

From
Tom Lane
Date:
Alvaro Herrera <alvherre@commandprompt.com> writes:
> Bruce Momjian wrote:
>> Tom Lane wrote:
>>> I propose changing spi.h to follow the same include-only-what-you-must
>>> rule as every other backend header file.  Thoughts?
>> 
>> I don't think we ever cleaned out spi.h in the past because we were
>> worried about 3rd party code using it (I am fine with a cleanup).

> I've wondered about spi.h lately too while looking at header cleanup,
> and I agree with the proposed solution.  The worst that can happen is
> that somebody needs to add extra includes in their programs in order for
> them to compile with 8.4.  We do enough other changes that this one is
> really minor.  Better late than never anyway.

Okay, I'll do a trial patch and we can see exactly how much has to be
added (at least among core and contrib) before deciding for sure.
        regards, tom lane


Re: Is it really such a great idea for spi.h to include the world?

From
Tom Lane
Date:
I wrote:
> Okay, I'll do a trial patch and we can see exactly how much has to be
> added (at least among core and contrib) before deciding for sure.

This compiles and passes regression tests.  It looks like the main
things there might be an argument for adding back to spi.h would be
pg_type.h and builtins.h, as a very large proportion of the files
using spi.h had to have those added.  Comments?

            regards, tom lane


Index: contrib/spi/autoinc.c
===================================================================
RCS file: /cvsroot/pgsql/contrib/spi/autoinc.c,v
retrieving revision 1.15
diff -c -r1.15 autoinc.c
*** contrib/spi/autoinc.c    17 May 2008 01:28:22 -0000    1.15
--- contrib/spi/autoinc.c    6 Jan 2009 20:38:28 -0000
***************
*** 1,10 ****
  /*
   * $PostgreSQL: pgsql/contrib/spi/autoinc.c,v 1.15 2008/05/17 01:28:22 adunstan Exp $
   */

! #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() */

  PG_MODULE_MAGIC;

--- 1,13 ----
  /*
   * $PostgreSQL: pgsql/contrib/spi/autoinc.c,v 1.15 2008/05/17 01:28:22 adunstan Exp $
   */
+ #include "postgres.h"

! #include "catalog/pg_type.h"
! #include "commands/sequence.h"
! #include "commands/trigger.h"
! #include "executor/spi.h"
! #include "utils/builtins.h"

  PG_MODULE_MAGIC;

Index: contrib/spi/insert_username.c
===================================================================
RCS file: /cvsroot/pgsql/contrib/spi/insert_username.c,v
retrieving revision 1.16
diff -c -r1.16 insert_username.c
*** contrib/spi/insert_username.c    25 Mar 2008 22:42:42 -0000    1.16
--- contrib/spi/insert_username.c    6 Jan 2009 20:38:28 -0000
***************
*** 6,15 ****
   * insert user name in response to a trigger
   * usage:  insert_username (column_name)
   */

! #include "executor/spi.h"        /* this is what you need to work with SPI */
! #include "commands/trigger.h"    /* -"- and triggers */
! #include "miscadmin.h"            /* for GetUserName() */

  PG_MODULE_MAGIC;

--- 6,18 ----
   * insert user name in response to a trigger
   * usage:  insert_username (column_name)
   */
+ #include "postgres.h"

! #include "catalog/pg_type.h"
! #include "commands/trigger.h"
! #include "executor/spi.h"
! #include "miscadmin.h"
! #include "utils/builtins.h"

  PG_MODULE_MAGIC;

Index: contrib/spi/moddatetime.c
===================================================================
RCS file: /cvsroot/pgsql/contrib/spi/moddatetime.c,v
retrieving revision 1.14
diff -c -r1.14 moddatetime.c
*** contrib/spi/moddatetime.c    1 Feb 2007 19:10:23 -0000    1.14
--- contrib/spi/moddatetime.c    6 Jan 2009 20:38:28 -0000
***************
*** 13,21 ****
  Jan Wieck <jwieck@debis.com> who told me about the timestamp_in("now") function.
  OH, me, I'm Terry Mackintosh <terry@terrym.com>
  */

! #include "executor/spi.h"        /* this is what you need to work with SPI */
! #include "commands/trigger.h"    /* -"- and triggers */

  PG_MODULE_MAGIC;

--- 13,23 ----
  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 "catalog/pg_type.h"
! #include "executor/spi.h"
! #include "commands/trigger.h"

  PG_MODULE_MAGIC;

Index: contrib/spi/refint.c
===================================================================
RCS file: /cvsroot/pgsql/contrib/spi/refint.c,v
retrieving revision 1.33
diff -c -r1.33 refint.c
*** contrib/spi/refint.c    17 May 2008 01:28:22 -0000    1.33
--- contrib/spi/refint.c    6 Jan 2009 20:38:28 -0000
***************
*** 5,16 ****
   * refint.c --    set of functions to define referential integrity
   *        constraints using general triggers.
   */

- #include "executor/spi.h"        /* this is what you need to work with SPI */
-
- #include "commands/trigger.h"    /* -"- and triggers */
  #include <ctype.h>


  PG_MODULE_MAGIC;

--- 5,17 ----
   * refint.c --    set of functions to define referential integrity
   *        constraints using general triggers.
   */
+ #include "postgres.h"

  #include <ctype.h>

+ #include "commands/trigger.h"
+ #include "executor/spi.h"
+ #include "utils/builtins.h"

  PG_MODULE_MAGIC;

Index: contrib/spi/timetravel.c
===================================================================
RCS file: /cvsroot/pgsql/contrib/spi/timetravel.c,v
retrieving revision 1.29
diff -c -r1.29 timetravel.c
*** contrib/spi/timetravel.c    17 May 2008 01:28:22 -0000    1.29
--- contrib/spi/timetravel.c    6 Jan 2009 20:38:28 -0000
***************
*** 4,22 ****
   *
   * timetravel.c --    function to get time travel feature
   *        using general triggers.
   */

! /* Modified by BÖJTHE Zoltán, Hungary, mailto:urdesobt@axelero.hu */

! #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 "utils/nabstime.h"

- #include <ctype.h>                /* tolower () */
-
- #define ABSTIMEOID    702            /* it should be in pg_type.h */
-
  PG_MODULE_MAGIC;

  /* AbsoluteTime currabstime(void); */
--- 4,23 ----
   *
   * 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"

! #include <ctype.h>

! #include "catalog/pg_type.h"
! #include "commands/trigger.h"
! #include "executor/spi.h"
! #include "miscadmin.h"
! #include "utils/builtins.h"
  #include "utils/nabstime.h"

  PG_MODULE_MAGIC;

  /* AbsoluteTime currabstime(void); */
Index: contrib/tablefunc/tablefunc.c
===================================================================
RCS file: /cvsroot/pgsql/contrib/tablefunc/tablefunc.c,v
retrieving revision 1.58
diff -c -r1.58 tablefunc.c
*** contrib/tablefunc/tablefunc.c    1 Jan 2009 17:23:32 -0000    1.58
--- contrib/tablefunc/tablefunc.c    6 Jan 2009 20:38:28 -0000
***************
*** 34,39 ****
--- 34,40 ----

  #include <math.h>

+ #include "catalog/pg_type.h"
  #include "fmgr.h"
  #include "funcapi.h"
  #include "executor/spi.h"
Index: contrib/xml2/xpath.c
===================================================================
RCS file: /cvsroot/pgsql/contrib/xml2/xpath.c,v
retrieving revision 1.21
diff -c -r1.21 xpath.c
*** contrib/xml2/xpath.c    29 Oct 2008 00:00:38 -0000    1.21
--- contrib/xml2/xpath.c    6 Jan 2009 20:38:29 -0000
***************
*** 1,15 ****
  /*
!  * $PostgreSQL: pgsql/contrib/xml2/xpath.c,v 1.21 2008/10/29 00:00:38 tgl Exp $
   *
   * Parser interface for DOM-based parser (libxml) rather than
!    stream-based SAX-type parser */
!
  #include "postgres.h"
! #include "fmgr.h"
  #include "executor/spi.h"
  #include "funcapi.h"
- #include "miscadmin.h"
  #include "lib/stringinfo.h"

  /* libxml includes */

--- 1,17 ----
  /*
!  * $PostgreSQL: pgsql/contrib/xml2/xpath.c,v 1.21 2008/10/29 00:00:38 tgl Exp $
   *
   * Parser interface for DOM-based parser (libxml) rather than
!  * stream-based SAX-type parser
!  */
  #include "postgres.h"
!
  #include "executor/spi.h"
+ #include "fmgr.h"
  #include "funcapi.h"
  #include "lib/stringinfo.h"
+ #include "miscadmin.h"
+ #include "utils/builtins.h"

  /* libxml includes */

Index: contrib/xml2/xslt_proc.c
===================================================================
RCS file: /cvsroot/pgsql/contrib/xml2/xslt_proc.c,v
retrieving revision 1.13
diff -c -r1.13 xslt_proc.c
*** contrib/xml2/xslt_proc.c    17 May 2008 01:28:22 -0000    1.13
--- contrib/xml2/xslt_proc.c    6 Jan 2009 20:38:29 -0000
***************
*** 1,14 ****
  /*
   * $PostgreSQL: pgsql/contrib/xml2/xslt_proc.c,v 1.13 2008/05/17 01:28:22 adunstan Exp $
   *
!  * XSLT processing functions (requiring libxslt) */
! /* John Gray, for Torchbox 2003-04-01 */
!
  #include "postgres.h"
! #include "fmgr.h"
  #include "executor/spi.h"
  #include "funcapi.h"
  #include "miscadmin.h"

  /* libxml includes */

--- 1,17 ----
  /*
   * $PostgreSQL: pgsql/contrib/xml2/xslt_proc.c,v 1.13 2008/05/17 01:28:22 adunstan Exp $
   *
!  * XSLT processing functions (requiring libxslt)
!  *
!  * John Gray, for Torchbox 2003-04-01
!  */
  #include "postgres.h"
!
  #include "executor/spi.h"
+ #include "fmgr.h"
  #include "funcapi.h"
  #include "miscadmin.h"
+ #include "utils/builtins.h"

  /* libxml includes */

Index: doc/src/sgml/spi.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/spi.sgml,v
retrieving revision 1.62
diff -c -r1.62 spi.sgml
*** doc/src/sgml/spi.sgml    1 Apr 2008 03:09:30 -0000    1.62
--- doc/src/sgml/spi.sgml    6 Jan 2009 20:38:29 -0000
***************
*** 3617,3623 ****
--- 3617,3626 ----
    </para>

  <programlisting>
+ #include "postgres.h"
+
  #include "executor/spi.h"
+ #include "utils/builtins.h"

  #ifdef PG_MODULE_MAGIC
  PG_MODULE_MAGIC;
Index: src/backend/executor/spi.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/executor/spi.c,v
retrieving revision 1.204
diff -c -r1.204 spi.c
*** src/backend/executor/spi.c    2 Jan 2009 20:42:00 -0000    1.204
--- src/backend/executor/spi.c    6 Jan 2009 20:38:29 -0000
***************
*** 16,27 ****
--- 16,35 ----

  #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"


Index: src/backend/utils/adt/ri_triggers.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v
retrieving revision 1.111
diff -c -r1.111 ri_triggers.c
*** src/backend/utils/adt/ri_triggers.c    1 Jan 2009 17:23:49 -0000    1.111
--- src/backend/utils/adt/ri_triggers.c    6 Jan 2009 20:38:29 -0000
***************
*** 30,47 ****
--- 30,52 ----

  #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"


Index: src/backend/utils/adt/ruleutils.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v
retrieving revision 1.294
diff -c -r1.294 ruleutils.c
*** src/backend/utils/adt/ruleutils.c    1 Jan 2009 17:23:50 -0000    1.294
--- src/backend/utils/adt/ruleutils.c    6 Jan 2009 20:38:29 -0000
***************
*** 25,33 ****
--- 25,36 ----
  #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,52 ****
--- 47,58 ----
  #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"

Index: src/backend/utils/adt/tsquery_rewrite.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/utils/adt/tsquery_rewrite.c,v
retrieving revision 1.13
diff -c -r1.13 tsquery_rewrite.c
*** src/backend/utils/adt/tsquery_rewrite.c    1 Jan 2009 17:23:50 -0000    1.13
--- src/backend/utils/adt/tsquery_rewrite.c    6 Jan 2009 20:38:29 -0000
***************
*** 14,23 ****

  #include "postgres.h"

  #include "executor/spi.h"
  #include "tsearch/ts_type.h"
  #include "tsearch/ts_utils.h"
! #include "miscadmin.h"


  static int
--- 14,25 ----

  #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 "utils/builtins.h"


  static int
Index: src/backend/utils/adt/tsvector_op.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/utils/adt/tsvector_op.c,v
retrieving revision 1.20
diff -c -r1.20 tsvector_op.c
*** src/backend/utils/adt/tsvector_op.c    1 Jan 2009 17:23:50 -0000    1.20
--- src/backend/utils/adt/tsvector_op.c    6 Jan 2009 20:38:29 -0000
***************
*** 15,20 ****
--- 15,21 ----
  #include "postgres.h"

  #include "catalog/namespace.h"
+ #include "catalog/pg_type.h"
  #include "commands/trigger.h"
  #include "executor/spi.h"
  #include "funcapi.h"
Index: src/backend/utils/adt/xml.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/utils/adt/xml.c,v
retrieving revision 1.82
diff -c -r1.82 xml.c
*** src/backend/utils/adt/xml.c    1 Jan 2009 17:23:50 -0000    1.82
--- src/backend/utils/adt/xml.c    6 Jan 2009 20:38:29 -0000
***************
*** 81,86 ****
--- 81,87 ----
  #include "utils/datetime.h"
  #include "utils/lsyscache.h"
  #include "utils/memutils.h"
+ #include "utils/syscache.h"
  #include "utils/xml.h"


Index: src/include/executor/spi.h
===================================================================
RCS file: /cvsroot/pgsql/src/include/executor/spi.h,v
retrieving revision 1.68
diff -c -r1.68 spi.h
*** src/include/executor/spi.h    1 Jan 2009 17:23:59 -0000    1.68
--- src/include/executor/spi.h    6 Jan 2009 20:38:29 -0000
***************
*** 13,49 ****
  #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"


  typedef struct SPITupleTable
--- 13,22 ----
  #ifndef SPI_H
  #define SPI_H

  #include "nodes/parsenodes.h"
  #include "utils/portal.h"
! #include "utils/relcache.h"
! #include "utils/snapshot.h"


  typedef struct SPITupleTable
Index: src/pl/plperl/plperl.c
===================================================================
RCS file: /cvsroot/pgsql/src/pl/plperl/plperl.c,v
retrieving revision 1.143
diff -c -r1.143 plperl.c
*** src/pl/plperl/plperl.c    11 Dec 2008 07:34:09 -0000    1.143
--- src/pl/plperl/plperl.c    6 Jan 2009 20:38:29 -0000
***************
*** 16,21 ****
--- 16,25 ----
  #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,34 ****
  #include "miscadmin.h"
  #include "nodes/makefuncs.h"
  #include "parser/parse_type.h"
  #include "utils/fmgroids.h"
  #include "utils/guc.h"
  #include "utils/lsyscache.h"
  #include "utils/memutils.h"
  #include "utils/typcache.h"
- #include "utils/hsearch.h"

  /* define our text domain for translations */
  #undef TEXTDOMAIN
--- 27,40 ----
  #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"

  /* define our text domain for translations */
  #undef TEXTDOMAIN
Index: src/pl/plpgsql/src/gram.y
===================================================================
RCS file: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v
retrieving revision 1.118
diff -c -r1.118 gram.y
*** src/pl/plpgsql/src/gram.y    1 Jan 2009 17:24:03 -0000    1.118
--- src/pl/plpgsql/src/gram.y    6 Jan 2009 20:38:30 -0000
***************
*** 16,21 ****
--- 16,22 ----

  #include "plpgsql.h"

+ #include "catalog/pg_type.h"
  #include "parser/parser.h"


Index: src/pl/plpgsql/src/pl_exec.c
===================================================================
RCS file: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v
retrieving revision 1.226
diff -c -r1.226 pl_exec.c
*** src/pl/plpgsql/src/pl_exec.c    1 Jan 2009 17:24:03 -0000    1.226
--- src/pl/plpgsql/src/pl_exec.c    6 Jan 2009 20:38:30 -0000
***************
*** 27,32 ****
--- 27,33 ----
  #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"
Index: src/pl/plpgsql/src/plpgsql.h
===================================================================
RCS file: /cvsroot/pgsql/src/pl/plpgsql/src/plpgsql.h,v
retrieving revision 1.107
diff -c -r1.107 plpgsql.h
*** src/pl/plpgsql/src/plpgsql.h    1 Jan 2009 17:24:04 -0000    1.107
--- src/pl/plpgsql/src/plpgsql.h    6 Jan 2009 20:38:30 -0000
***************
*** 18,23 ****
--- 18,24 ----

  #include "postgres.h"

+ #include "access/xact.h"
  #include "fmgr.h"
  #include "miscadmin.h"
  #include "commands/trigger.h"
Index: src/pl/tcl/pltcl.c
===================================================================
RCS file: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v
retrieving revision 1.124
diff -c -r1.124 pltcl.c
*** src/pl/tcl/pltcl.c    11 Dec 2008 07:34:09 -0000    1.124
--- src/pl/tcl/pltcl.c    6 Jan 2009 20:38:30 -0000
***************
*** 18,25 ****
--- 18,27 ----
  #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,38 ****
--- 35,41 ----
  #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))
Index: src/test/regress/regress.c
===================================================================
RCS file: /cvsroot/pgsql/src/test/regress/regress.c,v
retrieving revision 1.71
diff -c -r1.71 regress.c
*** src/test/regress/regress.c    25 Mar 2008 22:42:46 -0000    1.71
--- src/test/regress/regress.c    6 Jan 2009 20:38:30 -0000
***************
*** 4,15 ****

  #include "postgres.h"

! #include <float.h>                /* faked on sunos */

  #include "access/transam.h"
! #include "utils/geo_decls.h"    /* includes <math.h> */
! #include "executor/executor.h"    /* For GetAttributeByName */
! #include "commands/sequence.h"    /* for nextval() */

  #define P_MAXDIG 12
  #define LDELIM            '('
--- 4,22 ----

  #include "postgres.h"

! #include <float.h>
! #include <math.h>

  #include "access/transam.h"
! #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,332 ****
      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;
--- 332,337 ----

Re: Is it really such a great idea for spi.h to include the world?

From
Alvaro Herrera
Date:
Tom Lane wrote:
> I wrote:
> > Okay, I'll do a trial patch and we can see exactly how much has to be
> > added (at least among core and contrib) before deciding for sure.
> 
> This compiles and passes regression tests.  It looks like the main
> things there might be an argument for adding back to spi.h would be
> pg_type.h and builtins.h, as a very large proportion of the files
> using spi.h had to have those added.  Comments?

They are both very lean, so no objections.  I guess that the pg_type.h
inclusion is needed due to the predefined type OIDs, and it makes me
wonder whether it would be useful to have them in a separate header.
Not enough concern for the idea to even make it to Bruce's open items
mailbox ...

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


Re: Is it really such a great idea for spi.h to include the world?

From
Tom Lane
Date:
Alvaro Herrera <alvherre@commandprompt.com> writes:
> They are both very lean, so no objections.  I guess that the pg_type.h
> inclusion is needed due to the predefined type OIDs, and it makes me
> wonder whether it would be useful to have them in a separate header.
> Not enough concern for the idea to even make it to Bruce's open items
> mailbox ...

After the header refactoring Zdenek did last year, there's not much
reason to not just #include pg_type.h --- so I'd just as soon keep
those macros together with the associated DATA lines.
        regards, tom lane