Somebody seems to have thought they could get away without checking for
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 11 Jun 2009 16:14:18 +0000 (16:14 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 11 Jun 2009 16:14:18 +0000 (16:14 +0000)
rsinfo->expectedDesc == NULL in deflist_to_tuplestore(), but that doesn't
look very safe to me.  Noted in passing while studying problem report
from Greg Davidson.

src/backend/foreign/foreign.c

index 981cd10b1ce70aa1df80f34886f70d9f823a6bbd..13174a5959831eafbe50563fd3762def44f4d29c 100644 (file)
@@ -279,7 +279,8 @@ deflist_to_tuplestore(ReturnSetInfo *rsinfo, List *options)
                ereport(ERROR,
                                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                                 errmsg("set-valued function called in context that cannot accept a set")));
-       if (!(rsinfo->allowedModes & SFRM_Materialize))
+       if (!(rsinfo->allowedModes & SFRM_Materialize) ||
+               rsinfo->expectedDesc == NULL)
                ereport(ERROR,
                                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                                 errmsg("materialize mode required, but it is not allowed in this context")));