Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd4545dc

Browse files
committed
Complain if a function-in-FROM returns a set when it shouldn't.
Throw a "function protocol violation" error if a function in FROMtries to return a set though it wasn't marked proretset. Althoughsuch cases work at the moment, it doesn't seem like something wewant to guarantee will keep working. Besides, there are othernegative consequences of not setting the proretset flag, such aspotentially bad plans.No back-patch, since if there is any third-party code violatingthis expectation, people wouldn't appreciate us breaking it ina minor release.Discussion:https://postgr.es/m/1636062.1615141782@sss.pgh.pa.us
1 parentfed10d4 commitd4545dc

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

‎src/backend/executor/execSRF.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,21 @@ ExecMakeTableFunctionResult(SetExprState *setexpr,
353353
*/
354354
if (rsinfo.isDone!=ExprMultipleResult)
355355
break;
356+
357+
/*
358+
* Check that set-returning functions were properly declared.
359+
* (Note: for historical reasons, we don't complain if a non-SRF
360+
* returns ExprEndResult; that's treated as returning NULL.)
361+
*/
362+
if (!returnsSet)
363+
ereport(ERROR,
364+
(errcode(ERRCODE_E_R_I_E_SRF_PROTOCOL_VIOLATED),
365+
errmsg("table-function protocol for value-per-call mode was not followed")));
356366
}
357367
elseif (rsinfo.returnMode==SFRM_Materialize)
358368
{
359369
/* check we're on the same page as the function author */
360-
if (!first_time||rsinfo.isDone!=ExprSingleResult)
370+
if (!first_time||rsinfo.isDone!=ExprSingleResult|| !returnsSet)
361371
ereport(ERROR,
362372
(errcode(ERRCODE_E_R_I_E_SRF_PROTOCOL_VIOLATED),
363373
errmsg("table-function protocol for materialize mode was not followed")));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp