Index: src/backend/executor/spi.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/executor/spi.c,v retrieving revision 1.131 diff -u -r1.131 spi.c --- src/backend/executor/spi.c 13 Oct 2004 01:25:10 -0000 1.131 +++ src/backend/executor/spi.c 13 Aug 2005 19:50:40 -0000 @@ -70,6 +70,12 @@ */ if (_SPI_curid != _SPI_connected) return SPI_ERROR_CONNECT; + + /* You can't actually execute queries if there is no current + * snapshot, so return an error straightaway. eg User defined type + * input functions */ + if (SerializableSnapshot == NULL) + return SPI_ERROR_CONNECT; if (_SPI_stack == NULL) { Index: doc/src/sgml/spi.sgml =================================================================== RCS file: /projects/cvsroot/pgsql/doc/src/sgml/spi.sgml,v retrieving revision 1.42 diff -u -r1.42 spi.sgml --- doc/src/sgml/spi.sgml 29 Jul 2005 13:00:03 -0000 1.42 +++ doc/src/sgml/spi.sgml 13 Aug 2005 19:50:40 -0000 @@ -106,6 +106,13 @@ SPI_finish are forbidden. (But see SPI_push and SPI_pop.) + + + SPI_connect will also fail if there is no current + snapshot. This generally only happens in implicitly called functions such + as type input functions. + +