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

Commit2efcd50

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 parentee4ba01 commit2efcd50

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
@@ -121,7 +121,6 @@ fetch_fp_info(Oid func_id, struct fp_info *fip)
121121
HeapTuplefunc_htp;
122122
Form_pg_procpp;
123123

124-
Assert(OidIsValid(func_id));
125124
Assert(fip!=NULL);
126125

127126
/*
@@ -135,15 +134,20 @@ fetch_fp_info(Oid func_id, struct fp_info *fip)
135134
MemSet(fip,0,sizeof(structfp_info));
136135
fip->funcid=InvalidOid;
137136

138-
fmgr_info(func_id,&fip->flinfo);
139-
140137
func_htp=SearchSysCache1(PROCOID,ObjectIdGetDatum(func_id));
141138
if (!HeapTupleIsValid(func_htp))
142139
ereport(ERROR,
143140
(errcode(ERRCODE_UNDEFINED_FUNCTION),
144141
errmsg("function with OID %u does not exist",func_id)));
145142
pp= (Form_pg_proc)GETSTRUCT(func_htp);
146143

144+
/* reject pg_proc entries that are unsafe to call via fastpath */
145+
if (pp->prokind!=PROKIND_FUNCTION||pp->proretset)
146+
ereport(ERROR,
147+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
148+
errmsg("cannot call function %s via fastpath interface",
149+
NameStr(pp->proname))));
150+
147151
/* watch out for catalog entries with more than FUNC_MAX_ARGS args */
148152
if (pp->pronargs>FUNC_MAX_ARGS)
149153
elog(ERROR,"function %s has more than %d arguments",
@@ -156,6 +160,8 @@ fetch_fp_info(Oid func_id, struct fp_info *fip)
156160

157161
ReleaseSysCache(func_htp);
158162

163+
fmgr_info(func_id,&fip->flinfo);
164+
159165
/*
160166
* This must be last!
161167
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp