From 9b46abb7c47de8aa408a8c83666fd67c5447eb85 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 31 Oct 2008 19:37:56 +0000 Subject: 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. --- src/backend/tcop/dest.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/backend/tcop/dest.c') diff --git a/src/backend/tcop/dest.c b/src/backend/tcop/dest.c index d5b420b1c86..e687c52f803 100644 --- a/src/backend/tcop/dest.c +++ b/src/backend/tcop/dest.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/tcop/dest.c,v 1.72 2008/01/01 19:45:52 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/tcop/dest.c,v 1.73 2008/10/31 19:37:56 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -32,6 +32,7 @@ #include "access/xact.h" #include "commands/copy.h" #include "executor/executor.h" +#include "executor/functions.h" #include "executor/tstoreReceiver.h" #include "libpq/libpq.h" #include "libpq/pqformat.h" @@ -132,6 +133,9 @@ CreateDestReceiver(CommandDest dest, Portal portal) case DestCopyOut: return CreateCopyDestReceiver(); + + case DestSQLFunction: + return CreateSQLFunctionDestReceiver(); } /* should never get here */ @@ -158,6 +162,7 @@ EndCommand(const char *commandTag, CommandDest dest) case DestTuplestore: case DestIntoRel: case DestCopyOut: + case DestSQLFunction: break; } } @@ -198,6 +203,7 @@ NullCommand(CommandDest dest) case DestTuplestore: case DestIntoRel: case DestCopyOut: + case DestSQLFunction: break; } } @@ -240,6 +246,7 @@ ReadyForQuery(CommandDest dest) case DestTuplestore: case DestIntoRel: case DestCopyOut: + case DestSQLFunction: break; } } -- cgit v1.2.3