|
45 | 45 | * Portions Copyright (c) 1994, Regents of the University of California
|
46 | 46 | *
|
47 | 47 | * IDENTIFICATION
|
48 |
| - * $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.126 2004/12/31 21:59:45 pgsql Exp $ |
| 48 | + * $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.127 2005/01/27 23:42:18 tgl Exp $ |
49 | 49 | *
|
50 | 50 | *-------------------------------------------------------------------------
|
51 | 51 | */
|
|
55 | 55 | #include"access/heapam.h"
|
56 | 56 | #include"catalog/pg_aggregate.h"
|
57 | 57 | #include"catalog/pg_operator.h"
|
| 58 | +#include"catalog/pg_proc.h" |
58 | 59 | #include"executor/executor.h"
|
59 | 60 | #include"executor/nodeAgg.h"
|
60 | 61 | #include"miscadmin.h"
|
@@ -1260,6 +1261,35 @@ ExecInitAgg(Agg *node, EState *estate)
|
1260 | 1261 | peraggstate->transfn_oid=transfn_oid=aggform->aggtransfn;
|
1261 | 1262 | peraggstate->finalfn_oid=finalfn_oid=aggform->aggfinalfn;
|
1262 | 1263 |
|
| 1264 | +/* Check that aggregate owner has permission to call component fns */ |
| 1265 | +{ |
| 1266 | +HeapTupleprocTuple; |
| 1267 | +AclIdaggOwner; |
| 1268 | + |
| 1269 | +procTuple=SearchSysCache(PROCOID, |
| 1270 | +ObjectIdGetDatum(aggref->aggfnoid), |
| 1271 | +0,0,0); |
| 1272 | +if (!HeapTupleIsValid(procTuple)) |
| 1273 | +elog(ERROR,"cache lookup failed for function %u", |
| 1274 | +aggref->aggfnoid); |
| 1275 | +aggOwner= ((Form_pg_proc)GETSTRUCT(procTuple))->proowner; |
| 1276 | +ReleaseSysCache(procTuple); |
| 1277 | + |
| 1278 | +aclresult=pg_proc_aclcheck(transfn_oid,aggOwner, |
| 1279 | +ACL_EXECUTE); |
| 1280 | +if (aclresult!=ACLCHECK_OK) |
| 1281 | +aclcheck_error(aclresult,ACL_KIND_PROC, |
| 1282 | +get_func_name(transfn_oid)); |
| 1283 | +if (OidIsValid(finalfn_oid)) |
| 1284 | +{ |
| 1285 | +aclresult=pg_proc_aclcheck(finalfn_oid,aggOwner, |
| 1286 | +ACL_EXECUTE); |
| 1287 | +if (aclresult!=ACLCHECK_OK) |
| 1288 | +aclcheck_error(aclresult,ACL_KIND_PROC, |
| 1289 | +get_func_name(finalfn_oid)); |
| 1290 | +} |
| 1291 | +} |
| 1292 | + |
1263 | 1293 | /* resolve actual type of transition state, if polymorphic */
|
1264 | 1294 | aggtranstype=aggform->aggtranstype;
|
1265 | 1295 | if (aggtranstype==ANYARRAYOID||aggtranstype==ANYELEMENTOID)
|
|