aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/tcop/fastpath.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/backend/tcop/fastpath.c b/src/backend/tcop/fastpath.c
index 9207d76981a..515f12b4898 100644
--- a/src/backend/tcop/fastpath.c
+++ b/src/backend/tcop/fastpath.c
@@ -200,7 +200,6 @@ fetch_fp_info(Oid func_id, struct fp_info *fip)
HeapTuple func_htp;
Form_pg_proc pp;
- Assert(OidIsValid(func_id));
Assert(fip != NULL);
/*
@@ -214,8 +213,6 @@ fetch_fp_info(Oid func_id, struct fp_info *fip)
MemSet(fip, 0, sizeof(struct fp_info));
fip->funcid = InvalidOid;
- fmgr_info(func_id, &fip->flinfo);
-
func_htp = SearchSysCache1(PROCOID, ObjectIdGetDatum(func_id));
if (!HeapTupleIsValid(func_htp))
ereport(ERROR,
@@ -223,6 +220,13 @@ fetch_fp_info(Oid func_id, struct fp_info *fip)
errmsg("function with OID %u does not exist", func_id)));
pp = (Form_pg_proc) GETSTRUCT(func_htp);
+ /* reject pg_proc entries that are unsafe to call via fastpath */
+ if (pp->proisagg || pp->proiswindow || pp->proretset)
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot call function %s via fastpath interface",
+ NameStr(pp->proname))));
+
/* watch out for catalog entries with more than FUNC_MAX_ARGS args */
if (pp->pronargs > FUNC_MAX_ARGS)
elog(ERROR, "function %s has more than %d arguments",
@@ -235,6 +239,8 @@ fetch_fp_info(Oid func_id, struct fp_info *fip)
ReleaseSysCache(func_htp);
+ fmgr_info(func_id, &fip->flinfo);
+
/*
* This must be last!
*/