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

Commit4d225ba

Browse files
committed
Disallow calling anything but plain functions via the fastpath API.
Reject aggregates, window functions, and procedures. Aggregatesfailed anyway, though with a somewhat obscure error message.Window functions would hit an Assert or null-pointer dereference.Procedures seemed to work as long as you didn't try to dotransaction control, but (a) transaction control is sort of thepoint of a procedure, and (b) it's not entirely clear that nobugs lurk in that path. Given the lack of testing of this area,it seems safest to be conservative in what we support.Also reject proretset functions, as the fastpath protocol can'tsupport returning a set.Also remove an easily-triggered assertion that the given OIDisn't 0; the subsequent lookups can handle that case themselves.Per report from Theodor-Arsenij Larionov-Trichkin.Back-patch to all supported branches. (The procedure angleonly applies in v11+, of course.)Discussion:https://postgr.es/m/2039442.1615317309@sss.pgh.pa.us
1 parentbbcfee0 commit4d225ba

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

‎src/backend/tcop/fastpath.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ fetch_fp_info(Oid func_id, struct fp_info *fip)
198198
HeapTuplefunc_htp;
199199
Form_pg_procpp;
200200

201-
Assert(OidIsValid(func_id));
202201
Assert(fip!=NULL);
203202

204203
/*
@@ -212,15 +211,20 @@ fetch_fp_info(Oid func_id, struct fp_info *fip)
212211
MemSet(fip,0,sizeof(structfp_info));
213212
fip->funcid=InvalidOid;
214213

215-
fmgr_info(func_id,&fip->flinfo);
216-
217214
func_htp=SearchSysCache1(PROCOID,ObjectIdGetDatum(func_id));
218215
if (!HeapTupleIsValid(func_htp))
219216
ereport(ERROR,
220217
(errcode(ERRCODE_UNDEFINED_FUNCTION),
221218
errmsg("function with OID %u does not exist",func_id)));
222219
pp= (Form_pg_proc)GETSTRUCT(func_htp);
223220

221+
/* reject pg_proc entries that are unsafe to call via fastpath */
222+
if (pp->prokind!=PROKIND_FUNCTION||pp->proretset)
223+
ereport(ERROR,
224+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
225+
errmsg("cannot call function %s via fastpath interface",
226+
NameStr(pp->proname))));
227+
224228
/* watch out for catalog entries with more than FUNC_MAX_ARGS args */
225229
if (pp->pronargs>FUNC_MAX_ARGS)
226230
elog(ERROR,"function %s has more than %d arguments",
@@ -233,6 +237,8 @@ fetch_fp_info(Oid func_id, struct fp_info *fip)
233237

234238
ReleaseSysCache(func_htp);
235239

240+
fmgr_info(func_id,&fip->flinfo);
241+
236242
/*
237243
* This must be last!
238244
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp