summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-10-31 19:37:56 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-10-31 19:37:56 +0000
commit9b46abb7c47de8aa408a8c83666fd67c5447eb85 (patch)
tree034991f27008de03ff71f505431b10a1b2ae5e5e /src/include
parentcd97f98844b5640b1cdc701c691c962155dce3b4 (diff)
downloadpostgresql-9b46abb7c47de8aa408a8c83666fd67c5447eb85.tar.gz
Allow SQL-language functions to return the output of an INSERT/UPDATE/DELETE
RETURNING clause, not just a SELECT as formerly. A side effect of this patch is that when a set-returning SQL function is used in a FROM clause, performance is improved because the output is collected into a tuplestore within the function, rather than using the less efficient value-per-call mechanism.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/executor/functions.h5
-rw-r--r--src/include/nodes/execnodes.h8
-rw-r--r--src/include/tcop/dest.h5
3 files changed, 12 insertions, 6 deletions
diff --git a/src/include/executor/functions.h b/src/include/executor/functions.h
index b5451ad43b..61f782d18d 100644
--- a/src/include/executor/functions.h
+++ b/src/include/executor/functions.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/executor/functions.h,v 1.31 2008/03/18 22:04:14 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/executor/functions.h,v 1.32 2008/10/31 19:37:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -15,6 +15,7 @@
#define FUNCTIONS_H
#include "nodes/execnodes.h"
+#include "tcop/dest.h"
extern Datum fmgr_sql(PG_FUNCTION_ARGS);
@@ -24,4 +25,6 @@ extern bool check_sql_fn_retval(Oid func_id, Oid rettype,
bool insertRelabels,
JunkFilter **junkFilter);
+extern DestReceiver *CreateSQLFunctionDestReceiver(void);
+
#endif /* FUNCTIONS_H */
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 8164de6a08..3fe16bd098 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/execnodes.h,v 1.193 2008/10/29 00:00:39 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/execnodes.h,v 1.194 2008/10/31 19:37:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -151,13 +151,15 @@ typedef enum
/*
* Return modes for functions returning sets. Note values must be chosen
* as separate bits so that a bitmask can be formed to indicate supported
- * modes.
+ * modes. SFRM_Materialize_Random and SFRM_Materialize_Preferred are
+ * auxiliary flags about SFRM_Materialize mode, rather than separate modes.
*/
typedef enum
{
SFRM_ValuePerCall = 0x01, /* one value returned per call */
SFRM_Materialize = 0x02, /* result set instantiated in Tuplestore */
- SFRM_Materialize_Random = 0x04 /* Tuplestore needs randomAccess */
+ SFRM_Materialize_Random = 0x04, /* Tuplestore needs randomAccess */
+ SFRM_Materialize_Preferred = 0x08 /* caller prefers Tuplestore */
} SetFunctionReturnMode;
/*
diff --git a/src/include/tcop/dest.h b/src/include/tcop/dest.h
index 7484b84f76..5522f78c68 100644
--- a/src/include/tcop/dest.h
+++ b/src/include/tcop/dest.h
@@ -54,7 +54,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/tcop/dest.h,v 1.54 2008/01/01 19:45:59 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/tcop/dest.h,v 1.55 2008/10/31 19:37:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -86,7 +86,8 @@ typedef enum
DestSPI, /* results sent to SPI manager */
DestTuplestore, /* results sent to Tuplestore */
DestIntoRel, /* results sent to relation (SELECT INTO) */
- DestCopyOut /* results sent to COPY TO code */
+ DestCopyOut, /* results sent to COPY TO code */
+ DestSQLFunction /* results sent to SQL-language func mgr */
} CommandDest;
/* ----------------