aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/executor/execSRF.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/backend/executor/execSRF.c b/src/backend/executor/execSRF.c
index 8aec3b549bd..545b6c19dac 100644
--- a/src/backend/executor/execSRF.c
+++ b/src/backend/executor/execSRF.c
@@ -353,11 +353,21 @@ ExecMakeTableFunctionResult(SetExprState *setexpr,
*/
if (rsinfo.isDone != ExprMultipleResult)
break;
+
+ /*
+ * Check that set-returning functions were properly declared.
+ * (Note: for historical reasons, we don't complain if a non-SRF
+ * returns ExprEndResult; that's treated as returning NULL.)
+ */
+ if (!returnsSet)
+ ereport(ERROR,
+ (errcode(ERRCODE_E_R_I_E_SRF_PROTOCOL_VIOLATED),
+ errmsg("table-function protocol for value-per-call mode was not followed")));
}
else if (rsinfo.returnMode == SFRM_Materialize)
{
/* check we're on the same page as the function author */
- if (!first_time || rsinfo.isDone != ExprSingleResult)
+ if (!first_time || rsinfo.isDone != ExprSingleResult || !returnsSet)
ereport(ERROR,
(errcode(ERRCODE_E_R_I_E_SRF_PROTOCOL_VIOLATED),
errmsg("table-function protocol for materialize mode was not followed")));